From owner-svn-soc-all@FreeBSD.ORG Wed Jul 23 16:26:30 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2C965539 for ; Wed, 23 Jul 2014 16:26:30 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F30572F31 for ; Wed, 23 Jul 2014 16:26:29 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6NGQTTX060352 for ; Wed, 23 Jul 2014 16:26:29 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.8/8.14.8/Submit) id s6NGQTvs060225 for svn-soc-all@FreeBSD.org; Wed, 23 Jul 2014 16:26:29 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 23 Jul 2014 16:26:29 GMT Message-Id: <201407231626.s6NGQTvs060225@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271282 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jul 2014 16:26:30 -0000 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 funcdefs = { - -Module *mod; -LLVMContext con; -LLVMContext &c = con; -OwningPtr buffer; +class jitCompiler { + private: + Module *mod; + LLVMContext con; + LLVMContext &c = con; + OwningPtr 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 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 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); } + */ }