From f1e547a50a132afedbcd31700abb4ff79405e665 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 20 Jun 2009 18:57:15 +0000 Subject: Move alloc function to backend. git-svn-id: http://svn.drobilla.net/resp/tuplr@137 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- llvm.cpp | 21 ++++++++++++--------- tuplr.hpp | 1 - 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/llvm.cpp b/llvm.cpp index c7d9224..b40f953 100644 --- a/llvm.cpp +++ b/llvm.cpp @@ -51,10 +51,20 @@ llType(const AType* t) } struct LLVMEngine { - LLVMEngine() : module(new Module("tuplr")), engine(ExecutionEngine::create(module)) {} + LLVMEngine() + : module(new Module("tuplr")), engine(ExecutionEngine::create(module)) + { + // Host provided allocation primitive prototype + std::vector argsT(1, Type::Int32Ty); // unsigned size + argsT.push_back(Type::Int8Ty); // char tag + FunctionType* funcT = FunctionType::get(PointerType::get(Type::Int8Ty, 0), argsT, false); + alloc = Function::Create(funcT, Function::ExternalLinkage, + "tuplr_gc_allocate", module); + } Module* module; ExecutionEngine* engine; IRBuilder<> builder; + CFunction alloc; }; static LLVMEngine* @@ -82,7 +92,7 @@ struct CEnv::PImpl { }; CEnv::CEnv(PEnv& p, TEnv& t, CEngine e, ostream& os, ostream& es) - : out(os), err(es), penv(p), tenv(t), symID(0), alloc(0), _pimpl(new PImpl((LLVMEngine*)e)) + : out(os), err(es), penv(p), tenv(t), symID(0), _pimpl(new PImpl((LLVMEngine*)e)) { } @@ -520,13 +530,6 @@ newCenv(PEnv& penv, TEnv& tenv) LLVMEngine* engine = new LLVMEngine(); CEnv* cenv = new CEnv(penv, tenv, engine); - // Host provided allocation primitive prototypes - std::vector argsT(1, Type::Int32Ty); // size - argsT.push_back(Type::Int8Ty); // tag - FunctionType* funcT = FunctionType::get(PointerType::get(Type::Int8Ty, 0), argsT, false); - cenv->alloc = Function::Create(funcT, Function::ExternalLinkage, - "tuplr_gc_allocate", engine->module); - return cenv; } diff --git a/tuplr.hpp b/tuplr.hpp index 78c6918..96a1556 100644 --- a/tuplr.hpp +++ b/tuplr.hpp @@ -599,7 +599,6 @@ struct CEnv { Vals vals; unsigned symID; - CFunction alloc; Subst tsubst; map args; -- cgit v1.2.1