Mercurial > projects > ldc
diff gen/aa.cpp @ 213:7816aafeea3c trunk
[svn r229] Updated the object.d implementation to the latest Tango.
Fixed a bunch of the built-in typeinfos for arrays, they did not inherit TypeInfo_Array.
Applied patch to tango/text/convert/Layout.d by fvbommel, closes #47 .
Cleaned up some type code.
Replaced uses of llvm::Type with LLType (a typedef), same for Value and Constant.
Fixed a few cases where typeinfo for user structs could be emitted multiple times, seems to still be some cases of this :/
author | lindquist |
---|---|
date | Fri, 30 May 2008 19:32:04 +0200 |
parents | db9890b3fb64 |
children | 0806379a5eca |
line wrap: on
line diff
--- a/gen/aa.cpp Tue May 27 22:14:24 2008 +0200 +++ b/gen/aa.cpp Fri May 30 19:32:04 2008 +0200 @@ -13,11 +13,11 @@ // makes sure the key value lives in memory so it can be passed to the runtime functions without problems // returns the pointer -static llvm::Value* to_pkey(DValue* key) +static LLValue* to_pkey(DValue* key) { Type* keytype = key->getType(); bool needmem = !DtoIsPassedByRef(keytype); - llvm::Value* pkey; + LLValue* pkey; if (key->isIm()) { pkey = key->getRVal(); } @@ -35,7 +35,7 @@ pkey = key->getRVal(); } else { - llvm::Value* tmp = new llvm::AllocaInst(DtoType(keytype), "aatmpkeystorage", gIR->topallocapoint()); + LLValue* tmp = new llvm::AllocaInst(DtoType(keytype), "aatmpkeystorage", gIR->topallocapoint()); DVarValue* var = new DVarValue(keytype, tmp, true); DtoAssign(var, key); return tmp; @@ -43,7 +43,7 @@ // give memory if (needmem) { - llvm::Value* tmp = new llvm::AllocaInst(DtoType(keytype), "aatmpkeystorage", gIR->topallocapoint()); + LLValue* tmp = new llvm::AllocaInst(DtoType(keytype), "aatmpkeystorage", gIR->topallocapoint()); DtoStore(pkey, tmp); pkey = tmp; } @@ -52,17 +52,12 @@ } // returns the keytype typeinfo -static llvm::Value* to_keyti(DValue* key) +static LLValue* to_keyti(DValue* key) { // keyti param Type* keytype = key->getType(); keytype->getTypeInfo(NULL); - TypeInfoDeclaration* tid = keytype->getTypeInfoDeclaration(); - assert(tid); - DtoResolveDsymbol(Type::typeinfo); - DtoForceDeclareDsymbol(tid); - assert(tid->ir.irGlobal->value); - return tid->ir.irGlobal->value; + return DtoTypeInfoOf(keytype, false); } ///////////////////////////////////////////////////////////////////////////////////// @@ -77,32 +72,32 @@ const llvm::FunctionType* funcTy = func->getFunctionType(); // aa param - llvm::Value* aaval = aa->getLVal(); + LLValue* aaval = aa->getLVal(); aaval = DtoBitCast(aaval, funcTy->getParamType(0)); // keyti param - llvm::Value* keyti = to_keyti(key); + LLValue* keyti = to_keyti(key); keyti = DtoBitCast(keyti, funcTy->getParamType(1)); // valuesize param - llvm::Value* valsize = DtoConstSize_t(getABITypeSize(DtoType(type))); + LLValue* valsize = DtoConstSize_t(getABITypeSize(DtoType(type))); // pkey param - llvm::Value* pkey = to_pkey(key); + LLValue* pkey = to_pkey(key); pkey = DtoBitCast(pkey, funcTy->getParamType(3)); // build arg vector - std::vector<llvm::Value*> args; + LLSmallVector<LLValue*, 4> args; args.push_back(aaval); args.push_back(keyti); args.push_back(valsize); args.push_back(pkey); // call runtime - llvm::Value* ret = gIR->ir->CreateCall(func, args.begin(), args.end(), "aa.index"); + LLValue* ret = gIR->ir->CreateCall(func, args.begin(), args.end(), "aa.index"); // cast return value - const llvm::Type* targettype = getPtrToType(DtoType(type)); + const LLType* targettype = getPtrToType(DtoType(type)); if (ret->getType() != targettype) ret = DtoBitCast(ret, targettype); @@ -123,30 +118,30 @@ Logger::cout() << "_aaIn = " << *func << '\n'; // aa param - llvm::Value* aaval = aa->getRVal(); + LLValue* aaval = aa->getRVal(); Logger::cout() << "aaval: " << *aaval << '\n'; Logger::cout() << "totype: " << *funcTy->getParamType(0) << '\n'; aaval = DtoBitCast(aaval, funcTy->getParamType(0)); // keyti param - llvm::Value* keyti = to_keyti(key); + LLValue* keyti = to_keyti(key); keyti = DtoBitCast(keyti, funcTy->getParamType(1)); // pkey param - llvm::Value* pkey = to_pkey(key); + LLValue* pkey = to_pkey(key); pkey = DtoBitCast(pkey, funcTy->getParamType(2)); // build arg vector - std::vector<llvm::Value*> args; + LLSmallVector<LLValue*, 3> args; args.push_back(aaval); args.push_back(keyti); args.push_back(pkey); // call runtime - llvm::Value* ret = gIR->ir->CreateCall(func, args.begin(), args.end(), "aa.in"); + LLValue* ret = gIR->ir->CreateCall(func, args.begin(), args.end(), "aa.in"); // cast return value - const llvm::Type* targettype = DtoType(type); + const LLType* targettype = DtoType(type); if (ret->getType() != targettype) ret = DtoBitCast(ret, targettype); @@ -167,21 +162,21 @@ Logger::cout() << "_aaDel = " << *func << '\n'; // aa param - llvm::Value* aaval = aa->getRVal(); + LLValue* aaval = aa->getRVal(); Logger::cout() << "aaval: " << *aaval << '\n'; Logger::cout() << "totype: " << *funcTy->getParamType(0) << '\n'; aaval = DtoBitCast(aaval, funcTy->getParamType(0)); // keyti param - llvm::Value* keyti = to_keyti(key); + LLValue* keyti = to_keyti(key); keyti = DtoBitCast(keyti, funcTy->getParamType(1)); // pkey param - llvm::Value* pkey = to_pkey(key); + LLValue* pkey = to_pkey(key); pkey = DtoBitCast(pkey, funcTy->getParamType(2)); // build arg vector - std::vector<llvm::Value*> args; + LLSmallVector<LLValue*, 3> args; args.push_back(aaval); args.push_back(keyti); args.push_back(pkey);