diff options
-rw-r--r-- | src/compile.cpp | 17 | ||||
-rw-r--r-- | src/llvm.cpp | 42 |
2 files changed, 1 insertions, 58 deletions
diff --git a/src/compile.cpp b/src/compile.cpp index 170c198..30a8a95 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -40,22 +40,7 @@ ASymbol::compile(CEnv& cenv) CVal AFn::compile(CEnv& cenv) { - AType* aFnT = cenv.type(this); - /*const Type* fnT = llType(aFnT); - return fnT ? static_cast<Function*>(impls.find(aFnT)) : NULL;*/ - return impls.find(aFnT); - - /*vector<const Type*> types; - types.push_back(PointerType::get(fnT, 0)); - types.push_back(PointerType::get(Type::VoidTy, 0)); - LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine()); - IRBuilder<> builder = engine->builder; - Value* tag = ConstantInt::get(Type::Int8Ty, GC::TAG_FRAME); - StructType* tupT = StructType::get(types, false); - Value* tupSize = ConstantInt::get(Type::Int32Ty, sizeof(void*) * 2); - Value* tup = builder.CreateCall2(engine->alloc, tupSize, tag, "fn"); - Value* tupPtr = builder.CreateBitCast(tup, PointerType::get(tupT, 0)); - return tupPtr;*/ + return impls.find(cenv.type(this)); } CVal diff --git a/src/llvm.cpp b/src/llvm.cpp index 34f23ca..1477917 100644 --- a/src/llvm.cpp +++ b/src/llvm.cpp @@ -259,15 +259,6 @@ LLVMEngine::compileFunction(CEnv& cenv, AFn* fn, const AType& argsT) Subst oldSubst = cenv.tsubst; cenv.tsubst = Subst::compose(cenv.tsubst, Subst::compose(argsSubst, fn->subst)); -//#define EXPLICIT_STACK_FRAMES 1 - -#ifdef EXPLICIT_STACK_FRAMES - vector<const Type*> types; - types.push_back(Type::Int8Ty); - types.push_back(Type::Int8Ty); - size_t s = 16; // stack frame size in bits -#endif - // Bind argument values in CEnv vector<Value*> args; AFn::const_iterator p = fn->prot()->begin(); @@ -277,40 +268,7 @@ LLVMEngine::compileFunction(CEnv& cenv, AFn* fn, const AType& argsT) const Type* lt = llType(t); THROW_IF(!lt, fn->loc, "untyped parameter\n"); cenv.def((*p)->as<ASymbol*>(), *p, t, &*a); -#ifdef EXPLICIT_STACK_FRAMES - types.push_back(lt); - s += std::max(lt->getPrimitiveSizeInBits(), unsigned(8)); -#endif - } - -#ifdef EXPLICIT_STACK_FRAMES - IRBuilder<> builder = engine->builder; - - // Scan out definitions - for (size_t i = 0; i < size(); ++i) { - ADef* def = at(i)->to<ADef*>(); - if (def) { - const Type* lt = llType(cenv.type(def->at(2))); - THROW_IF(!lt, loc, "untyped definition\n"); - types.push_back(lt); - s += std::max(lt->getPrimitiveSizeInBits(), unsigned(8)); - } - } - - // Create stack frame - StructType* frameT = StructType::get(types, false); - Value* tag = ConstantInt::get(Type::Int8Ty, GC::TAG_FRAME); - Value* frameSize = ConstantInt::get(Type::Int32Ty, s / 8); - Value* frame = builder.CreateCall2(engine->alloc, frameSize, tag, "frame"); - Value* framePtr = builder.CreateBitCast(frame, PointerType::get(frameT, 0)); - - // Bind parameter values in stack frame - i = 2; - for (Function::arg_iterator a = f->arg_begin(); a != f->arg_end(); ++a, ++i) { - Value* v = builder.CreateStructGEP(framePtr, i, "arg"); - builder.CreateStore(&*a, v); } -#endif // Write function body try { |