mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-08 16:03:13 +01:00
[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 :/
This commit is contained in:
51
gen/aa.cpp
51
gen/aa.cpp
@@ -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 @@ static llvm::Value* to_pkey(DValue* key)
|
||||
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 @@ static llvm::Value* to_pkey(DValue* key)
|
||||
|
||||
// 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 @@ static llvm::Value* to_pkey(DValue* key)
|
||||
}
|
||||
|
||||
// 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 @@ DValue* DtoAAIndex(Type* type, DValue* aa, DValue* key)
|
||||
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 @@ DValue* DtoAAIn(Type* type, DValue* aa, DValue* key)
|
||||
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 @@ void DtoAARemove(DValue* aa, DValue* key)
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user