From owner-svn-soc-all@FreeBSD.ORG Tue Jul 22 13:26:55 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 28E6D257 for ; Tue, 22 Jul 2014 13:26:55 +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 EF98125D2 for ; Tue, 22 Jul 2014 13:26:54 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6MDQs3U025656 for ; Tue, 22 Jul 2014 13:26:54 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.8/8.14.8/Submit) id s6MDQswQ025526 for svn-soc-all@FreeBSD.org; Tue, 22 Jul 2014 13:26:54 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 22 Jul 2014 13:26:54 GMT Message-Id: <201407221326.s6MDQswQ025526@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: r271237 - 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: Tue, 22 Jul 2014 13:26:55 -0000 Author: dpl Date: Tue Jul 22 13:26:54 2014 New Revision: 271237 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271237 Log: Added basic boilerplate (to be modified). 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 Tue Jul 22 08:52:49 2014 (r271236) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Tue Jul 22 13:26:54 2014 (r271237) @@ -1,5 +1,7 @@ /* JIT compilation code */ #include +#include +#include #include #include @@ -10,6 +12,13 @@ using namespace llvm; +struct funcdef { + string name; + int args; +} + +vector funcdefs = { + Module *mod; LLVMContext con; LLVMContext &c = con; @@ -33,4 +42,46 @@ } mod = ptr.get(); ptr = parseBitcodeFile(buffer.get(), c); + + + // XXX - We have to automate this. + // 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 + // inlined. + F->setLinkage(GlobalValue::PrivateLinkage); + // Add an entry basic block to this function and set it + BasicBlock *entry = BasicBlock::Create(C, "entry", F); + B.SetInsertPoint(entry); + // Cache the type of registers + regTy = Type::getInt16Ty(C); + + // Collect the function parameters + auto args = F->arg_begin(); + oldGrid = args++; + newGrid = args++; + width = args++; + height = args++; + x = args++; + y = args++; + + // Create space on the stack for the local registers + for (int i=0 ; i<10 ; i++) + { + a[i] = B.CreateAlloca(regTy); + } + // Create a space on the stack for the current value. This can be + // assigned to, and will be returned at the end. Store the value passed + // as a parameter in this. + v = B.CreateAlloca(regTy); + B.CreateStore(args++, v); + + // Create a load of pointers to the global registers. + Value *gArg = args; + for (int i=0 ; i<10 ; i++) + { + B.CreateStore(ConstantInt::get(regTy, 0), a[i]); + g[i] = B.CreateConstGEP1_32(gArg, i); + } + }