diff options
author | David Robillard <d@drobilla.net> | 2009-10-06 17:36:34 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-10-06 17:36:34 +0000 |
commit | 0659e878a30aee50969e45a119cf2b58a9f7d5c8 (patch) | |
tree | fc85b522b861cd61fb3e5a4c92f93a422736b29f /src/llvm.cpp | |
parent | 38e28c329088f0a488c7ecfc9466a287a74c4eb7 (diff) | |
download | resp-0659e878a30aee50969e45a119cf2b58a9f7d5c8.tar.gz resp-0659e878a30aee50969e45a119cf2b58a9f7d5c8.tar.bz2 resp-0659e878a30aee50969e45a119cf2b58a9f7d5c8.zip |
Move argument substitution building from LLVM backend code to generic type code.
git-svn-id: http://svn.drobilla.net/resp/tuplr@193 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/llvm.cpp')
-rw-r--r-- | src/llvm.cpp | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/src/llvm.cpp b/src/llvm.cpp index cd5314a..0f7e7d4 100644 --- a/src/llvm.cpp +++ b/src/llvm.cpp @@ -139,12 +139,10 @@ struct LLVMEngine : public Engine { } void finishFunction(CEnv& cenv, CFunction f, const AType* retT, CValue ret) { - if (retT->concrete()) { - Value* retVal = llVal(ret); - builder.CreateRet(retVal); - } else { + if (retT->concrete()) + builder.CreateRet(llVal(ret)); + else builder.CreateRetVoid(); - } /*std::cerr << "MODULE {" << endl; module->dump(); @@ -232,39 +230,15 @@ AFn::liftCall(CEnv& cenv, const AType& argsT) AType* thisType = genericType; Subst argsSubst; + // Build and apply substitution to get concrete type for this call if (!genericType->concrete()) { - // Build substitution to apply to generic type - assert(argsT.size() == prot()->size()); - const ATuple* genericProtT = gt->second->at(1)->as<const ATuple*>(); - ATuple::const_iterator g = genericProtT->begin(); - AType::const_iterator a = argsT.begin(); - for (; a != argsT.end(); ++a, ++g) { - assert(g != genericProtT->end()); - const AType* genericArgT = (*g)->to<const AType*>(); - AType* callArgT = (*a)->to<AType*>(); - assert(genericArgT); - assert(callArgT); - if (callArgT->kind == AType::EXPR) { - assert(genericArgT->kind == AType::EXPR); - assert(callArgT->size() == genericArgT->size()); - for (size_t i = 0; i < callArgT->size(); ++i) { - const AType* gT = genericArgT->at(i)->to<const AType*>(); - AType* aT = callArgT->at(i)->to<AType*>(); - if (gT && aT) - argsSubst.add(gT, aT); - } - } else { - argsSubst.add(genericArgT, callArgT); - } - } - - // Apply substitution to get concrete type for this call + argsSubst = cenv.tenv.buildSubst(genericType, argsT); thisType = argsSubst.apply(genericType)->as<AType*>(); - THROW_IF(!thisType->concrete(), loc, - string("unable to resolve concrete type for function :: ") - + thisType->str() + "\n" + this->str()); } + THROW_IF(!thisType->concrete(), loc, + string("call has non-concrete type %1%\n") + thisType->str()); + Object::pool.addRoot(thisType); if (impls.find(thisType)) return; @@ -272,9 +246,8 @@ AFn::liftCall(CEnv& cenv, const AType& argsT) ATuple* protT = thisType->at(1)->as<ATuple*>(); vector<string> argNames; - for (size_t i = 0; i < prot()->size(); ++i) { + for (size_t i = 0; i < prot()->size(); ++i) argNames.push_back(prot()->at(i)->str()); - } // Write function declaration const string name = (this->name == "") ? cenv.penv.gensymstr("_fn") : this->name; @@ -310,7 +283,6 @@ AFn::liftCall(CEnv& cenv, const AType& argsT) #endif } - #ifdef EXPLICIT_STACK_FRAMES IRBuilder<> builder = engine->builder; |