socsvn commit: r271282 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw

dpl at FreeBSD.org dpl at FreeBSD.org
Wed Jul 23 16:26:30 UTC 2014


Author: dpl
Date: Wed Jul 23 16:26:29 2014
New Revision: 271282
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271282

Log:
  Modularized the LLVM code.
  

Modified:
  soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc

Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc
==============================================================================
--- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc	Wed Jul 23 15:53:29 2014	(r271281)
+++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc	Wed Jul 23 16:26:29 2014	(r271282)
@@ -12,39 +12,39 @@
 
 using namespace llvm;
 
-struct funcdef {
-	string name;
-	int args;
-}
-
-vector<struct funcdef> funcdefs = {
-
-Module *mod;
-LLVMContext con;
-LLVMContext &c = con;
-OwningPtr<MemoryBuffer> buffer;
+class jitCompiler { 
+	private:
+		Module *mod;
+		LLVMContext con;
+		LLVMContext &c = con;
+		OwningPtr<MemoryBuffer> buffer;
+	public:
+		jitCompiler(std::string name)
+		{
+			/* We load the bc for JIT compilation */
+			error_code ec = MemoryBuffer::getFile(name, buffer);
+			if (ec) {
+				std::cerr << "Failed to open bitcode: " << ec.message() << "\n";
+				exit(EXIT_FAILURE);
+			}
+
+			ErrorOr<Module*> ptr = parseBitcodeFile(buffer.get(), con);
+			if ((ec = ptr.getError()))
+			{
+				std::cerr << "Failed to parse bitcode: " << ec.message() << "\n";
+				exit(EXIT_FAILURE);
+			}
+			mod = ptr.get();
+			ptr = parseBitcodeFile(buffer.get(), c);
+		}
+} ;
 
 extern "C" void
 ipfw_jit_init()
 {
-	/* We load the bc for JIT compilation */
-	error_code ec = MemoryBuffer::getFile("runtime.bc", buffer);
-	if (ec) {
-		std::cerr << "Failed to open runtime.bc: " << ec.message() << "\n";
-		exit(EXIT_FAILURE);
-	}
-
-	ErrorOr<Module*> ptr = parseBitcodeFile(buffer.get(), con);
-	if ((ec = ptr.getError()))
-	{
-		std::cerr << "Failed to parse runtime.bc: " << ec.message() << "\n";
-		exit(EXIT_FAILURE);
-	}
-	mod = ptr.get();
-	ptr = parseBitcodeFile(buffer.get(), c);
-
+	jitCompiler("ip_fw_rules.bc");
 
-	// XXX - We have to automate this.
+	/* XXX - We have to understand what we have to here.
 	// Get the stub (prototype) for the cell function
 	F = Mod->getFunction("cell");
 	// Set it to have private linkage, so that it can be removed after being
@@ -84,4 +84,5 @@
 		g[i] = B.CreateConstGEP1_32(gArg, i);
 	}
 
+	*/
 }


More information about the svn-soc-all mailing list