Merge branch 'master' into merge-2.062

Conflicts:
	runtime/druntime
This commit is contained in:
kai 2013-03-24 19:39:39 +01:00
commit b13f3d3164
20 changed files with 236 additions and 196 deletions

View file

@ -807,7 +807,7 @@ void buildCommandLine(std::vector<const char*>& r, const Params& p)
if (p.logTlsUse) warning("-vtls not yet supported by LDC."); if (p.logTlsUse) warning("-vtls not yet supported by LDC.");
if (p.warnings == Warnings::asErrors) r.push_back("-w"); if (p.warnings == Warnings::asErrors) r.push_back("-w");
else if (p.warnings == Warnings::informational) r.push_back("-wi"); else if (p.warnings == Warnings::informational) r.push_back("-wi");
if (p.optimize) r.push_back("-O2"); if (p.optimize) r.push_back("-O3");
if (p.noObj) r.push_back("-o-"); if (p.noObj) r.push_back("-o-");
if (p.objDir) r.push_back(concat("-od=", p.objDir)); if (p.objDir) r.push_back(concat("-od=", p.objDir));
if (p.objName) r.push_back(concat("-of=", p.objName)); if (p.objName) r.push_back(concat("-of=", p.objName));

View file

@ -93,16 +93,15 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
gIR->scope() = IRScope(failbb, okbb); gIR->scope() = IRScope(failbb, okbb);
std::vector<LLValue*> args;
// module param
LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol(); LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol();
LLType *moduleInfoType = DtoType(Module::moduleinfo->type); LLType *moduleInfoType = DtoType(Module::moduleinfo->type);
args.push_back(DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType)));
LLValue* args[] = {
// module param
DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType)),
// line param // line param
LLConstant* c = DtoConstUint(loc.linnum); DtoConstUint(loc.linnum)
args.push_back(c); };
// call // call
llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_bounds"); llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_bounds");
@ -201,10 +200,7 @@ DValue *DtoAARemove(Loc& loc, DValue* aa, DValue* key)
pkey = DtoBitCast(pkey, funcTy->getParamType(2)); pkey = DtoBitCast(pkey, funcTy->getParamType(2));
// build arg vector // build arg vector
LLSmallVector<LLValue*, 3> args; LLValue* args[] = { aaval, keyti, pkey };
args.push_back(aaval);
args.push_back(keyti);
args.push_back(pkey);
// call runtime // call runtime
LLCallSite call = gIR->CreateCallOrInvoke(func, args); LLCallSite call = gIR->CreateCallOrInvoke(func, args);

View file

@ -215,10 +215,11 @@ void DtoArrayAssign(DValue *array, DValue *value, int op)
Type *elemType = t->nextOf()->toBasetype(); Type *elemType = t->nextOf()->toBasetype();
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, op == TOKconstruct ? "_d_arrayctor" : "_d_arrayassign"); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, op == TOKconstruct ? "_d_arrayctor" : "_d_arrayassign");
LLSmallVector<LLValue*,3> args; LLValue* args[] = {
args.push_back(DtoTypeInfoOf(elemType)); DtoTypeInfoOf(elemType),
args.push_back(DtoAggrPaint(DtoSlice(value), fn->getFunctionType()->getParamType(1))); DtoAggrPaint(DtoSlice(value), fn->getFunctionType()->getParamType(1)),
args.push_back(DtoAggrPaint(DtoSlice(array), fn->getFunctionType()->getParamType(2))); DtoAggrPaint(DtoSlice(array), fn->getFunctionType()->getParamType(2))
};
LLCallSite call = gIR->CreateCallOrInvoke(fn, args, ".array"); LLCallSite call = gIR->CreateCallOrInvoke(fn, args, ".array");
call.setCallingConv(llvm::CallingConv::C); call.setCallingConv(llvm::CallingConv::C);
@ -238,11 +239,12 @@ void DtoArraySetAssign(Loc &loc, DValue *array, DValue *value, int op)
LLValue *len = DtoArrayLen(array); LLValue *len = DtoArrayLen(array);
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, op == TOKconstruct ? "_d_arraysetctor" : "_d_arraysetassign"); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, op == TOKconstruct ? "_d_arraysetctor" : "_d_arraysetassign");
LLSmallVector<LLValue*,4> args; LLValue* args[] = {
args.push_back(DtoBitCast(ptr, getVoidPtrType())); DtoBitCast(ptr, getVoidPtrType()),
args.push_back(DtoBitCast(makeLValue(loc, value), getVoidPtrType())); DtoBitCast(makeLValue(loc, value), getVoidPtrType()),
args.push_back(len); len,
args.push_back(DtoTypeInfoOf(array->type->toBasetype()->nextOf()->toBasetype())); DtoTypeInfoOf(array->type->toBasetype()->nextOf()->toBasetype())
};
LLCallSite call = gIR->CreateCallOrInvoke(fn, args, ".newptr"); LLCallSite call = gIR->CreateCallOrInvoke(fn, args, ".newptr");
call.setCallingConv(llvm::CallingConv::C); call.setCallingConv(llvm::CallingConv::C);
@ -614,6 +616,7 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname);
std::vector<LLValue*> args; std::vector<LLValue*> args;
args.reserve(ndims+2);
args.push_back(arrayTypeInfo); args.push_back(arrayTypeInfo);
args.push_back(DtoConstSize_t(ndims)); args.push_back(DtoConstSize_t(ndims));
@ -647,11 +650,11 @@ DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, LLValue* newdim)
// call runtime // call runtime
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, zeroInit ? "_d_arraysetlengthT" : "_d_arraysetlengthiT" ); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, zeroInit ? "_d_arraysetlengthT" : "_d_arraysetlengthiT" );
LLSmallVector<LLValue*,4> args; LLValue* args[] = {
args.push_back(DtoTypeInfoOf(arrayType)); DtoTypeInfoOf(arrayType),
args.push_back(newdim); newdim,
DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(2))
args.push_back(DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(2))); };
LLValue* newArray = gIR->CreateCallOrInvoke(fn, args, ".gc_mem").getInstruction(); LLValue* newArray = gIR->CreateCallOrInvoke(fn, args, ".gc_mem").getInstruction();
return getSlice(arrayType, newArray); return getSlice(arrayType, newArray);
@ -673,10 +676,11 @@ void DtoCatAssignElement(Loc& loc, Type* arrayType, DValue* array, Expression* e
DValue *expVal = exp->toElem(gIR); DValue *expVal = exp->toElem(gIR);
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arrayappendcTX"); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arrayappendcTX");
LLSmallVector<LLValue*,3> args; LLValue* args[] = {
args.push_back(DtoTypeInfoOf(arrayType)); DtoTypeInfoOf(arrayType),
args.push_back(DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(1))); DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(1)),
args.push_back(DtoConstSize_t(1)); DtoConstSize_t(1)
};
LLValue* appendedArray = gIR->CreateCallOrInvoke(fn, args, ".appendedArray").getInstruction(); LLValue* appendedArray = gIR->CreateCallOrInvoke(fn, args, ".appendedArray").getInstruction();
appendedArray = DtoAggrPaint(appendedArray, DtoType(arrayType)); appendedArray = DtoAggrPaint(appendedArray, DtoType(arrayType));
@ -772,11 +776,12 @@ DSliceValue* DtoAppendDChar(DValue* arr, Expression* exp, const char *func)
// Prepare arguments // Prepare arguments
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, func); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, func);
LLSmallVector<LLValue*,2> args; LLValue* args[] = {
// ref string x // ref string x
args.push_back(DtoBitCast(arr->getLVal(), fn->getFunctionType()->getParamType(0))); DtoBitCast(arr->getLVal(), fn->getFunctionType()->getParamType(0)),
// dchar c // dchar c
args.push_back(DtoBitCast(valueToAppend->getRVal(), fn->getFunctionType()->getParamType(1))); DtoBitCast(valueToAppend->getRVal(), fn->getFunctionType()->getParamType(1))
};
// Call function // Call function
LLValue* newArray = gIR->CreateCallOrInvoke(fn, args, ".appendedArray").getInstruction(); LLValue* newArray = gIR->CreateCallOrInvoke(fn, args, ".appendedArray").getInstruction();
@ -818,16 +823,11 @@ static LLValue* DtoArrayEqCmp_impl(Loc& loc, const char* func, DValue* l, DValue
l = DtoCastArray(loc, l, commonType); l = DtoCastArray(loc, l, commonType);
r = DtoCastArray(loc, r, commonType); r = DtoCastArray(loc, r, commonType);
LLValue* lmem;
LLValue* rmem;
LLSmallVector<LLValue*, 3> args; LLSmallVector<LLValue*, 3> args;
// get values, reinterpret cast to void[] // get values, reinterpret cast to void[]
lmem = DtoAggrPaint(l->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context()))); args.push_back(DtoAggrPaint(l->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context()))));
args.push_back(lmem); args.push_back(DtoAggrPaint(r->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context()))));
rmem = DtoAggrPaint(r->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context())));
args.push_back(rmem);
// pass array typeinfo ? // pass array typeinfo ?
if (useti) { if (useti) {
@ -896,10 +896,11 @@ LLValue* DtoArrayCastLength(LLValue* len, LLType* elemty, LLType* newelemty)
if (esz == nsz) if (esz == nsz)
return len; return len;
LLSmallVector<LLValue*, 3> args; LLValue* args[] = {
args.push_back(len); len,
args.push_back(LLConstantInt::get(DtoSize_t(), esz, false)); LLConstantInt::get(DtoSize_t(), esz, false),
args.push_back(LLConstantInt::get(DtoSize_t(), nsz, false)); LLConstantInt::get(DtoSize_t(), nsz, false)
};
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len"); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len");
return gIR->CreateCallOrInvoke(fn, args, "tmp").getInstruction(); return gIR->CreateCallOrInvoke(fn, args, "tmp").getInstruction();

View file

@ -10,6 +10,12 @@
// Parses "DMD-style" x86/x86_64 inline assembly blocks and converts them to // Parses "DMD-style" x86/x86_64 inline assembly blocks and converts them to
// GDC/LLVM inline assembler syntax. // GDC/LLVM inline assembler syntax.
// //
// This file is designed to be included twice, once with the ASM_X86_64 define
// set to get the 64 bit asm parser, and once without to get the 32 bit one.
// This is a direct result of merging two disparate but largely identical
// implementations, and should be refactored to just use a runtime parameter
// for choosing the architecture.
//
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "id.h" #include "id.h"

View file

@ -522,7 +522,6 @@ void AsmBlockStatement::toIR(IRState* p)
{ {
Logger::println("AsmBlockStatement::toIR(): %s", loc.toChars()); Logger::println("AsmBlockStatement::toIR(): %s", loc.toChars());
LOG_SCOPE; LOG_SCOPE;
Logger::println("BEGIN ASM");
// disable inlining by default // disable inlining by default
if (!p->func()->decl->allowInlining) if (!p->func()->decl->allowInlining)
@ -768,7 +767,6 @@ void AsmBlockStatement::toIR(IRState* p)
} }
p->asmBlock = NULL; p->asmBlock = NULL;
Logger::println("END ASM");
// if asm contained external branches, emit goto forwarder code // if asm contained external branches, emit goto forwarder code
if(!gotoToVal.empty()) if(!gotoToVal.empty())

View file

@ -232,8 +232,9 @@ void DtoFinalizeClass(LLValue* inst)
// get runtime function // get runtime function
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_callfinalizer"); llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_callfinalizer");
// build args // build args
LLSmallVector<LLValue*,1> arg; LLValue* arg[] = {
arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")
};
// call // call
gIR->CreateCallOrInvoke(fn, arg, ""); gIR->CreateCallOrInvoke(fn, arg, "");
} }
@ -369,8 +370,6 @@ DValue* DtoDynamicCastObject(DValue* val, Type* _to)
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_dynamic_cast"); llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_dynamic_cast");
LLFunctionType* funcTy = func->getFunctionType(); LLFunctionType* funcTy = func->getFunctionType();
std::vector<LLValue*> args;
// Object o // Object o
LLValue* obj = val->getRVal(); LLValue* obj = val->getRVal();
obj = DtoBitCast(obj, funcTy->getParamType(0)); obj = DtoBitCast(obj, funcTy->getParamType(0));
@ -434,8 +433,6 @@ DValue* DtoDynamicCastInterface(DValue* val, Type* _to)
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_interface_cast"); llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_interface_cast");
LLFunctionType* funcTy = func->getFunctionType(); LLFunctionType* funcTy = func->getFunctionType();
std::vector<LLValue*> args;
// void* p // void* p
LLValue* ptr = val->getRVal(); LLValue* ptr = val->getRVal();
ptr = DtoBitCast(ptr, funcTy->getParamType(0)); ptr = DtoBitCast(ptr, funcTy->getParamType(0));

View file

@ -23,10 +23,8 @@ llvm::StructType* DtoComplexType(Type* type)
{ {
Type* t = type->toBasetype(); Type* t = type->toBasetype();
LLType* base = DtoComplexBaseType(t); LLType* base = DtoComplexBaseType(t);
llvm::SmallVector<LLType*, 2> types; LLType* types[] = { base, base };
types.push_back(base); return llvm::StructType::get(gIR->context(), types, false);
types.push_back(base);
return llvm::StructType::get(gIR->context(), types);
} }
LLType* DtoComplexBaseType(Type* t) LLType* DtoComplexBaseType(Type* t)
@ -62,11 +60,10 @@ LLConstant* DtoConstComplex(Type* _ty, longdouble re, longdouble im)
case Tcomplex80: base = Type::tfloat80; break; case Tcomplex80: base = Type::tfloat80; break;
} }
std::vector<LLConstant*> inits; LLConstant * inits[] = { DtoConstFP(base, re), DtoConstFP(base, im) };
inits.push_back(DtoConstFP(base, re));
inits.push_back(DtoConstFP(base, im));
return llvm::ConstantStruct::get(DtoComplexType(_ty), inits); return llvm::ConstantStruct::get(DtoComplexType(_ty),
llvm::ArrayRef<LLConstant *>(inits));
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////

View file

@ -143,39 +143,28 @@ LLCallSite IRState::CreateCallOrInvoke(LLValue* Callee, const char* Name)
LLCallSite IRState::CreateCallOrInvoke(LLValue* Callee, LLValue* Arg1, const char* Name) LLCallSite IRState::CreateCallOrInvoke(LLValue* Callee, LLValue* Arg1, const char* Name)
{ {
LLSmallVector<LLValue*, 1> args; LLValue* args[] = { Arg1 };
args.push_back(Arg1);
return CreateCallOrInvoke(Callee, args, Name); return CreateCallOrInvoke(Callee, args, Name);
} }
LLCallSite IRState::CreateCallOrInvoke2(LLValue* Callee, LLValue* Arg1, LLValue* Arg2, const char* Name) LLCallSite IRState::CreateCallOrInvoke2(LLValue* Callee, LLValue* Arg1, LLValue* Arg2, const char* Name)
{ {
LLSmallVector<LLValue*, 2> args; LLValue* args[] = { Arg1, Arg2 };
args.push_back(Arg1);
args.push_back(Arg2);
return CreateCallOrInvoke(Callee, args, Name); return CreateCallOrInvoke(Callee, args, Name);
} }
LLCallSite IRState::CreateCallOrInvoke3(LLValue* Callee, LLValue* Arg1, LLValue* Arg2, LLValue* Arg3, const char* Name) LLCallSite IRState::CreateCallOrInvoke3(LLValue* Callee, LLValue* Arg1, LLValue* Arg2, LLValue* Arg3, const char* Name)
{ {
LLSmallVector<LLValue*, 3> args; LLValue* args[] = { Arg1, Arg2, Arg3 };
args.push_back(Arg1);
args.push_back(Arg2);
args.push_back(Arg3);
return CreateCallOrInvoke(Callee, args, Name); return CreateCallOrInvoke(Callee, args, Name);
} }
LLCallSite IRState::CreateCallOrInvoke4(LLValue* Callee, LLValue* Arg1, LLValue* Arg2, LLValue* Arg3, LLValue* Arg4, const char* Name) LLCallSite IRState::CreateCallOrInvoke4(LLValue* Callee, LLValue* Arg1, LLValue* Arg2, LLValue* Arg3, LLValue* Arg4, const char* Name)
{ {
LLSmallVector<LLValue*, 4> args; LLValue* args[] = { Arg1, Arg2, Arg3, Arg4 };
args.push_back(Arg1);
args.push_back(Arg2);
args.push_back(Arg3);
args.push_back(Arg4);
return CreateCallOrInvoke(Callee, args, Name); return CreateCallOrInvoke(Callee, args, Name);
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
IRBuilder<>* IRBuilderHelper::operator->() IRBuilder<>* IRBuilderHelper::operator->()

View file

@ -59,8 +59,7 @@ void DtoDeleteMemory(LLValue* ptr)
// get runtime function // get runtime function
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delmemory"); llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delmemory");
// build args // build args
LLSmallVector<LLValue*,1> arg; LLValue* arg[] = { DtoBitCast(ptr, getVoidPtrType(), ".tmp") };
arg.push_back(DtoBitCast(ptr, getVoidPtrType(), ".tmp"));
// call // call
gIR->CreateCallOrInvoke(fn, arg); gIR->CreateCallOrInvoke(fn, arg);
} }
@ -69,13 +68,14 @@ void DtoDeleteClass(LLValue* inst)
{ {
// get runtime function // get runtime function
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delclass"); llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delclass");
// build args
LLSmallVector<LLValue*,1> arg;
// druntime wants a pointer to object // druntime wants a pointer to object
LLValue *ptr = DtoRawAlloca(inst->getType(), 0, "objectPtr"); LLValue *ptr = DtoRawAlloca(inst->getType(), 0, "objectPtr");
DtoStore(inst, ptr); DtoStore(inst, ptr);
inst = ptr; inst = ptr;
arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); // build args
LLValue* arg[] = {
DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")
};
// call // call
gIR->CreateCallOrInvoke(fn, arg); gIR->CreateCallOrInvoke(fn, arg);
} }
@ -85,8 +85,9 @@ void DtoDeleteInterface(LLValue* inst)
// get runtime function // get runtime function
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delinterface"); llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delinterface");
// build args // build args
LLSmallVector<LLValue*,1> arg; LLValue* arg[] = {
arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")
};
// call // call
gIR->CreateCallOrInvoke(fn, arg); gIR->CreateCallOrInvoke(fn, arg);
} }
@ -97,9 +98,10 @@ void DtoDeleteArray(DValue* arr)
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delarray_t"); llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delarray_t");
// build args // build args
LLSmallVector<LLValue*,2> arg; LLValue* arg[] = {
arg.push_back(DtoBitCast(arr->getLVal(), fn->getFunctionType()->getParamType(0))); DtoBitCast(arr->getLVal(), fn->getFunctionType()->getParamType(0)),
arg.push_back(DtoBitCast(DtoTypeInfoOf(arr->type->nextOf()), fn->getFunctionType()->getParamType(1))); DtoBitCast(DtoTypeInfoOf(arr->type->nextOf()), fn->getFunctionType()->getParamType(1))
};
// call // call
gIR->CreateCallOrInvoke(fn, arg); gIR->CreateCallOrInvoke(fn, arg);
@ -155,12 +157,13 @@ LLValue* DtoGcMalloc(LLType* lltype, const char* name)
void DtoAssert(Module* M, Loc loc, DValue* msg) void DtoAssert(Module* M, Loc loc, DValue* msg)
{ {
std::vector<LLValue*> args;
// func // func
const char* fname = msg ? "_d_assert_msg" : "_d_assert"; const char* fname = msg ? "_d_assert_msg" : "_d_assert";
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname); llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname);
// Arguments
llvm::SmallVector<LLValue*, 3> args;
// msg param // msg param
if (msg) if (msg)
{ {
@ -182,8 +185,7 @@ void DtoAssert(Module* M, Loc loc, DValue* msg)
} }
// line param // line param
LLConstant* c = DtoConstUint(loc.linnum); args.push_back(DtoConstUint(loc.linnum));
args.push_back(c);
// call // call
gIR->CreateCallOrInvoke(fn, args); gIR->CreateCallOrInvoke(fn, args);

View file

@ -172,10 +172,11 @@ static LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo)
// provide the default initializer // provide the default initializer
LLStructType* modulerefTy = DtoModuleReferenceType(); LLStructType* modulerefTy = DtoModuleReferenceType();
std::vector<LLConstant*> mrefvalues; LLConstant* mrefvalues[] = {
mrefvalues.push_back(LLConstant::getNullValue(modulerefTy->getContainedType(0))); LLConstant::getNullValue(modulerefTy->getContainedType(0)),
mrefvalues.push_back(llvm::ConstantExpr::getBitCast(moduleinfo, modulerefTy->getContainedType(1))); llvm::ConstantExpr::getBitCast(moduleinfo, modulerefTy->getContainedType(1))
LLConstant* thismrefinit = LLConstantStruct::get(modulerefTy, mrefvalues); };
LLConstant* thismrefinit = LLConstantStruct::get(modulerefTy, llvm::ArrayRef<LLConstant*>(mrefvalues));
// create the ModuleReference node for this module // create the ModuleReference node for this module
std::string thismrefname = "_D"; std::string thismrefname = "_D";

View file

@ -47,7 +47,7 @@ static cl::opt<signed char> optimizeLevel(
cl::desc("Setting the optimization level:"), cl::desc("Setting the optimization level:"),
cl::ZeroOrMore, cl::ZeroOrMore,
cl::values( cl::values(
clEnumValN(2, "O", "Equivalent to -O2"), clEnumValN(3, "O", "Equivalent to -O3"),
clEnumValN(0, "O0", "No optimizations (default)"), clEnumValN(0, "O0", "No optimizations (default)"),
clEnumValN(1, "O1", "Simple optimizations"), clEnumValN(1, "O1", "Simple optimizations"),
clEnumValN(2, "O2", "Good optimizations"), clEnumValN(2, "O2", "Good optimizations"),

View file

@ -165,8 +165,10 @@ void RTTIBuilder::finalize(LLType* type, LLValue* value)
// set struct body // set struct body
if (st->isOpaque()) { if (st->isOpaque()) {
const int n = inits.size();
std::vector<LLType*> types; std::vector<LLType*> types;
for (int i = 0, n = inits.size(); i < n; ++i) types.reserve(n);
for (int i = 0; i < n; ++i)
types.push_back(inits[i]->getType()); types.push_back(inits[i]->getType());
st->setBody(types); st->setBody(types);
} }

View file

@ -938,7 +938,7 @@ void SwitchStatement::toIR(IRState* p)
// first sort it // first sort it
caseArray.sort(); caseArray.sort();
// iterate and add indices to cases // iterate and add indices to cases
std::vector<LLConstant*> inits(caseArray.dim); std::vector<LLConstant*> inits(caseArray.dim, 0);
for (size_t i=0; i<caseArray.dim; ++i) for (size_t i=0; i<caseArray.dim; ++i)
{ {
Case* c = static_cast<Case*>(caseArray.data[i]); Case* c = static_cast<Case*>(caseArray.data[i]);
@ -956,14 +956,10 @@ void SwitchStatement::toIR(IRState* p)
LLConstant* arrPtr = llvm::ConstantExpr::getBitCast(arr, elemPtrTy); LLConstant* arrPtr = llvm::ConstantExpr::getBitCast(arr, elemPtrTy);
// build the static table // build the static table
std::vector<LLType*> types; LLType* types[] = { DtoSize_t(), elemPtrTy };
types.push_back(DtoSize_t()); LLStructType* sTy = llvm::StructType::get(gIR->context(), types, false);
types.push_back(elemPtrTy); LLConstant* sinits[] = { DtoConstSize_t(inits.size()), arrPtr };
LLStructType* sTy = llvm::StructType::get(gIR->context(), types); switchTable = llvm::ConstantStruct::get(sTy, llvm::ArrayRef<LLConstant*>(sinits));
std::vector<LLConstant*> sinits;
sinits.push_back(DtoConstSize_t(inits.size()));
sinits.push_back(arrPtr);
switchTable = llvm::ConstantStruct::get(sTy, sinits);
} }
// condition var // condition var
@ -1609,16 +1605,15 @@ void SwitchErrorStatement::toIR(IRState* p)
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_switch_error"); llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_switch_error");
std::vector<LLValue*> args;
// module param
LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol(); LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol();
LLType *moduleInfoType = DtoType(Module::moduleinfo->type); LLType *moduleInfoType = DtoType(Module::moduleinfo->type);
args.push_back(DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType)));
LLValue* args[] = {
// module param
DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType)),
// line param // line param
LLConstant* c = DtoConstUint(loc.linnum); DtoConstUint(loc.linnum)
args.push_back(c); };
// call // call
LLCallSite call = gIR->CreateCallOrInvoke(fn, args); LLCallSite call = gIR->CreateCallOrInvoke(fn, args);

View file

@ -328,6 +328,7 @@ LLType* DtoUnpaddedStructType(Type* dty) {
Array& fields = sty->sym->fields; Array& fields = sty->sym->fields;
std::vector<LLType*> types; std::vector<LLType*> types;
types.reserve(fields.dim);
for (unsigned i = 0; i < fields.dim; i++) { for (unsigned i = 0; i < fields.dim; i++) {
VarDeclaration* vd = static_cast<VarDeclaration*>(fields.data[i]); VarDeclaration* vd = static_cast<VarDeclaration*>(fields.data[i]);

View file

@ -259,6 +259,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args,
Logger::cout() << "_arguments storage: " << *typeinfomem << '\n'; Logger::cout() << "_arguments storage: " << *typeinfomem << '\n';
std::vector<LLConstant*> vtypeinfos; std::vector<LLConstant*> vtypeinfos;
vtypeinfos.reserve(n_arguments);
for (size_t i=begin; i<n_arguments; i++) for (size_t i=begin; i<n_arguments; i++)
{ {
Expression* argexp = static_cast<Expression*>(arguments->data[i]); Expression* argexp = static_cast<Expression*>(arguments->data[i]);
@ -270,11 +271,12 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args,
typeinfomem->setInitializer(tiinits); typeinfomem->setInitializer(tiinits);
// put data in d-array // put data in d-array
std::vector<LLConstant*> pinits; LLConstant* pinits[] = {
pinits.push_back(DtoConstSize_t(vtype->getNumElements())); DtoConstSize_t(vtype->getNumElements()),
pinits.push_back(llvm::ConstantExpr::getBitCast(typeinfomem, getPtrToType(typeinfotype))); llvm::ConstantExpr::getBitCast(typeinfomem, getPtrToType(typeinfotype))
};
LLType* tiarrty = DtoType(Type::typeinfo->type->arrayOf()); LLType* tiarrty = DtoType(Type::typeinfo->type->arrayOf());
tiinits = LLConstantStruct::get(isaStruct(tiarrty), pinits); tiinits = LLConstantStruct::get(isaStruct(tiarrty), llvm::ArrayRef<LLConstant*>(pinits));
LLValue* typeinfoarrayparam = new llvm::GlobalVariable(*gIR->module, tiarrty, LLValue* typeinfoarrayparam = new llvm::GlobalVariable(*gIR->module, tiarrty,
true, llvm::GlobalValue::InternalLinkage, tiinits, "._arguments.array"); true, llvm::GlobalValue::InternalLinkage, tiinits, "._arguments.array");
@ -507,6 +509,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
size_t n = Parameter::dim(tf->parameters); size_t n = Parameter::dim(tf->parameters);
std::vector<DValue*> argvals; std::vector<DValue*> argvals;
argvals.reserve(n);
if (dfnval && dfnval->func->isArrayOp) { if (dfnval && dfnval->func->isArrayOp) {
// slightly different approach for array operators // slightly different approach for array operators
for (int i=n-1; i>=0; --i) { for (int i=n-1; i>=0; --i) {

View file

@ -84,28 +84,56 @@ static llvm::DIType dwarfBasicType(Type* type)
LLType* T = DtoType(type); LLType* T = DtoType(type);
// find encoding // find encoding
unsigned id; unsigned Encoding;
if (t->isintegral()) switch (t->ty)
{ {
if (type->isunsigned()) case Tbool:
id = DW_ATE_unsigned; Encoding = DW_ATE_boolean;
else break;
id = DW_ATE_signed; case Tchar:
} case Twchar:
else if (t->isfloating()) case Tdchar:
{ Encoding = type->isunsigned() ? DW_ATE_unsigned_char
id = DW_ATE_float; : DW_ATE_signed_char;
} break;
else case Tint8:
{ case Tint16:
llvm_unreachable("unsupported basic type for debug info"); case Tint32:
case Tint64:
case Tint128:
Encoding = DW_ATE_signed;
break;
case Tuns8:
case Tuns16:
case Tuns32:
case Tuns64:
case Tuns128:
Encoding = DW_ATE_unsigned;
break;
case Tfloat32:
case Tfloat64:
case Tfloat80:
Encoding = DW_ATE_float;
break;
case Timaginary32:
case Timaginary64:
case Timaginary80:
Encoding = DW_ATE_imaginary_float;
break;
case Tcomplex32:
case Tcomplex64:
case Tcomplex80:
Encoding = DW_ATE_complex_float;
break;
default:
llvm_unreachable("Unsupported basic type for debug info");
} }
return gIR->dibuilder.createBasicType( return gIR->dibuilder.createBasicType(
type->toChars(), // name type->toChars(), // name
getTypeBitSize(T), // size (bits) getTypeBitSize(T), // size (bits)
getABITypeAlign(T)*8, // align (bits) getABITypeAlign(T)*8, // align (bits)
id Encoding
); );
} }
@ -188,16 +216,6 @@ static llvm::DIType dwarfCompositeType(Type* type)
LLType* T = DtoType(type); LLType* T = DtoType(type);
Type* t = type->toBasetype(); Type* t = type->toBasetype();
// defaults
llvm::StringRef name;
unsigned linnum = 0;
llvm::DIFile file;
// elements
std::vector<llvm::Value*> elems;
llvm::DIType derivedFrom;
assert((t->ty == Tstruct || t->ty == Tclass) && assert((t->ty == Tstruct || t->ty == Tclass) &&
"unsupported type for dwarfCompositeType"); "unsupported type for dwarfCompositeType");
AggregateDeclaration* sd; AggregateDeclaration* sd;
@ -226,12 +244,29 @@ static llvm::DIType dwarfCompositeType(Type* type)
if (static_cast<llvm::MDNode*>(ir->diCompositeType) != 0) if (static_cast<llvm::MDNode*>(ir->diCompositeType) != 0)
return ir->diCompositeType; return ir->diCompositeType;
name = sd->toChars(); // elements
linnum = sd->loc.linnum; std::vector<llvm::Value*> elems;
file = DtoDwarfFile(sd->loc);
// defaults
llvm::StringRef name = sd->toChars();
unsigned linnum = sd->loc.linnum;
llvm::DIFile file = DtoDwarfFile(sd->loc);
llvm::DIType derivedFrom;
// set diCompositeType to handle recursive types properly // set diCompositeType to handle recursive types properly
if (!ir->diCompositeType) if (!ir->diCompositeType) {
#if LDC_LLVM_VER >= 301
unsigned tag = (t->ty == Tstruct) ? llvm::dwarf::DW_TAG_structure_type
: llvm::dwarf::DW_TAG_class_type;
ir->diCompositeType = gIR->dibuilder.createForwardDecl(tag, name,
#if LDC_LLVM_VER >= 302
llvm::DIDescriptor(file),
#endif
file, linnum);
#else
ir->diCompositeType = gIR->dibuilder.createTemporaryType(); ir->diCompositeType = gIR->dibuilder.createTemporaryType();
#endif
}
if (!ir->aggrdecl->isInterfaceDeclaration()) // plain interfaces don't have one if (!ir->aggrdecl->isInterfaceDeclaration()) // plain interfaces don't have one
{ {
@ -301,7 +336,10 @@ static llvm::DIGlobalVariable dwarfGlobalVariable(LLGlobalVariable* ll, VarDecla
assert(vd->isDataseg() || (vd->storage_class & (STCconst | STCimmutable) && vd->init)); assert(vd->isDataseg() || (vd->storage_class & (STCconst | STCimmutable) && vd->init));
return gIR->dibuilder.createGlobalVariable( return gIR->dibuilder.createGlobalVariable(
vd->toChars(), // name TODO: mangle() or toPrettyChars() instead? vd->toChars(), // name
#if LDC_LLVM_VER >= 303
vd->mangle(), // linkage name
#endif
DtoDwarfFile(vd->loc), // file DtoDwarfFile(vd->loc), // file
vd->loc.linnum, // line num vd->loc.linnum, // line num
dwarfTypeDescription_impl(vd->type, NULL), // type dwarfTypeDescription_impl(vd->type, NULL), // type
@ -328,9 +366,11 @@ static llvm::DIType dwarfArrayType(Type* type) {
llvm::DIFile file = DtoDwarfFile(Loc(gIR->dmodule, 0)); llvm::DIFile file = DtoDwarfFile(Loc(gIR->dmodule, 0));
std::vector<llvm::Value*> elems; llvm::Value* elems[] = {
elems.push_back(dwarfMemberType(0, Type::tsize_t, file, "length", 0)); dwarfMemberType(0, Type::tsize_t, file, "length", 0),
elems.push_back(dwarfMemberType(0, t->nextOf()->pointerTo(), file, "ptr", global.params.is64bit?8:4)); dwarfMemberType(0, t->nextOf()->pointerTo(), file, "ptr",
global.params.is64bit ? 8 : 4)
};
return gIR->dibuilder.createStructType return gIR->dibuilder.createStructType
( (
@ -475,17 +515,26 @@ llvm::DISubprogram DtoDwarfSubProgram(FuncDeclaration* fd)
Logger::println("D to dwarf subprogram"); Logger::println("D to dwarf subprogram");
LOG_SCOPE; LOG_SCOPE;
llvm::DICompileUnit CU(gIR->dibuilder.getCU());
assert(CU && CU.Verify() && "Compilation unit missing or corrupted");
llvm::DIFile file = DtoDwarfFile(fd->loc); llvm::DIFile file = DtoDwarfFile(fd->loc);
Type *retType = static_cast<TypeFunction*>(fd->type)->next; Type *retType = static_cast<TypeFunction*>(fd->type)->next;
// Create "dummy" subroutine type for the return type
llvm::SmallVector<llvm::Value*, 16> Elts;
Elts.push_back(dwarfTypeDescription(retType, NULL));
llvm::DIArray EltTypeArray = gIR->dibuilder.getOrCreateArray(Elts);
llvm::DIType DIFnType = gIR->dibuilder.createSubroutineType(file, EltTypeArray);
// FIXME: duplicates ? // FIXME: duplicates ?
return gIR->dibuilder.createFunction( return gIR->dibuilder.createFunction(
llvm::DICompileUnit(file), // context CU, // context
fd->toPrettyChars(), // name fd->toPrettyChars(), // name
fd->mangle(), // linkage name fd->mangle(), // linkage name
file, // file file, // file
fd->loc.linnum, // line no fd->loc.linnum, // line no
dwarfTypeDescription(retType, NULL), // type DIFnType, // type
fd->protection == PROTprivate, // is local to unit fd->protection == PROTprivate, // is local to unit
gIR->dmodule == getDefinedModule(fd), // isdefinition gIR->dmodule == getDefinedModule(fd), // isdefinition
#if LDC_LLVM_VER >= 301 #if LDC_LLVM_VER >= 301
@ -509,6 +558,12 @@ llvm::DISubprogram DtoDwarfSubProgramInternal(const char* prettyname, const char
llvm::DIFile file(DtoDwarfFile(Loc(gIR->dmodule, 0))); llvm::DIFile file(DtoDwarfFile(Loc(gIR->dmodule, 0)));
// Create "dummy" subroutine type for the return type
llvm::SmallVector<llvm::Value*, 1> Elts;
Elts.push_back(llvm::DIType(NULL));
llvm::DIArray EltTypeArray = gIR->dibuilder.getOrCreateArray(Elts);
llvm::DIType DIFnType = gIR->dibuilder.createSubroutineType(file, EltTypeArray);
// FIXME: duplicates ? // FIXME: duplicates ?
return gIR->dibuilder.createFunction( return gIR->dibuilder.createFunction(
llvm::DIDescriptor(file), // context llvm::DIDescriptor(file), // context
@ -516,7 +571,7 @@ llvm::DISubprogram DtoDwarfSubProgramInternal(const char* prettyname, const char
mangledname, // linkage name mangledname, // linkage name
file, // file file, // file
0, // line no 0, // line no
llvm::DIType(NULL), // return type. TODO: fill it up DIFnType, // return type. TODO: fill it up
true, // is local to unit true, // is local to unit
true // isdefinition true // isdefinition
#if LDC_LLVM_VER >= 301 #if LDC_LLVM_VER >= 301

View file

@ -17,27 +17,22 @@
#include "gen/irstate.h" #include "gen/irstate.h"
#include "gen/tollvm.h" #include "gen/tollvm.h"
void RegisterDwarfSymbols(llvm::Module* mod);
/** /// \brief Emit the Dwarf compile_unit global for a Module m.
* Emit the Dwarf compile_unit global for a Module m. /// \param m Module to emit as compile unit.
* @param m
*/
void DtoDwarfCompileUnit(Module* m); void DtoDwarfCompileUnit(Module* m);
/** /// \brief Emit the Dwarf subprogram global for a function declaration fd.
* Emit the Dwarf subprogram global for a function declaration fd. /// \param fd Function declaration to emit as subprogram.
* @param fd /// \returns the Dwarf subprogram global.
* @return the Dwarf subprogram global.
*/
llvm::DISubprogram DtoDwarfSubProgram(FuncDeclaration* fd); llvm::DISubprogram DtoDwarfSubProgram(FuncDeclaration* fd);
/** /// \brief Emit the Dwarf subprogram global for a internal function.
* Emit the Dwarf subprogram global for a internal function. /// This is used for generated functions like moduleinfoctors,
* This is used for generated functions like moduleinfoctors, /// module ctors/dtors and unittests.
* module ctors/dtors and unittests. /// \param prettyname The name as seen in the source.
* @return the Dwarf subprogram global. /// \param mangledname The mangled name in the object file.
*/ /// \returns the Dwarf subprogram global.
llvm::DISubprogram DtoDwarfSubProgramInternal(const char* prettyname, const char* mangledname); llvm::DISubprogram DtoDwarfSubProgramInternal(const char* prettyname, const char* mangledname);
void DtoDwarfFuncStart(FuncDeclaration* fd); void DtoDwarfFuncStart(FuncDeclaration* fd);
@ -49,20 +44,17 @@ void DtoDwarfStopPoint(unsigned ln);
void DtoDwarfValue(LLValue *val, VarDeclaration* vd); void DtoDwarfValue(LLValue *val, VarDeclaration* vd);
/** /// \brief Emits all things necessary for making debug info for a local variable vd.
* Emits all things necessary for making debug info for a local variable vd. /// \param ll LLVM Value of the variable.
* @param ll LLVM Value of the variable. /// \param vd Variable declaration to emit debug info for.
* @param vd Variable declaration to emit debug info for. /// \param addr An array of complex address operations.
*/
void DtoDwarfLocalVariable(LLValue* ll, VarDeclaration* vd, void DtoDwarfLocalVariable(LLValue* ll, VarDeclaration* vd,
llvm::ArrayRef<LLValue*> addr = llvm::ArrayRef<LLValue*>()); llvm::ArrayRef<LLValue*> addr = llvm::ArrayRef<LLValue*>());
/** /// \brief Emits all things necessary for making debug info for a global variable vd.
* Emits all things necessary for making debug info for a global variable vd. /// \param ll LLVM global variable
* @param ll /// \param vd Variable declaration to emit debug info for.
* @param vd /// \returns Created debug info
* @return
*/
llvm::DIGlobalVariable DtoDwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd); llvm::DIGlobalVariable DtoDwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd);
void DtoDwarfModuleEnd(); void DtoDwarfModuleEnd();

View file

@ -1950,9 +1950,10 @@ DValue* NewExp::toElem(IRState* p)
else else
{ {
size_t ndims = arguments->dim; size_t ndims = arguments->dim;
std::vector<DValue*> dims(ndims); std::vector<DValue*> dims;
dims.reserve(ndims);
for (size_t i=0; i<ndims; ++i) for (size_t i=0; i<ndims; ++i)
dims[i] = static_cast<Expression*>(arguments->data[i])->toElem(p); dims.push_back(static_cast<Expression*>(arguments->data[i])->toElem(p));
return DtoNewMulDimDynArray(loc, newtype, &dims[0], ndims, true); return DtoNewMulDimDynArray(loc, newtype, &dims[0], ndims, true);
} }
} }
@ -2798,11 +2799,12 @@ LLConstant* ArrayLiteralExp::toConstElem(IRState* p)
bool dyn = (bt->ty != Tsarray); bool dyn = (bt->ty != Tsarray);
// build the initializer // build the initializer
std::vector<LLConstant*> vals(elements->dim, NULL); std::vector<LLConstant*> vals;
vals.reserve(elements->dim);
for (unsigned i=0; i<elements->dim; ++i) for (unsigned i=0; i<elements->dim; ++i)
{ {
Expression* expr = static_cast<Expression*>(elements->data[i]); Expression* expr = static_cast<Expression*>(elements->data[i]);
vals[i] = expr->toConstElem(p); vals.push_back(expr->toConstElem(p));
} }
// build the constant array initialize // build the constant array initialize
@ -2974,7 +2976,7 @@ LLConstant* StructLiteralExp::toConstElem(IRState* p)
sd->codegen(Type::sir); sd->codegen(Type::sir);
// get inits // get inits
std::vector<LLConstant*> inits(sd->fields.dim, NULL); std::vector<LLConstant*> inits(sd->fields.dim, 0);
size_t nexprs = elements->dim;; size_t nexprs = elements->dim;;
Expression** exprs = (Expression**)elements->data; Expression** exprs = (Expression**)elements->data;
@ -2987,8 +2989,8 @@ LLConstant* StructLiteralExp::toConstElem(IRState* p)
std::vector<LLConstant*> values = DtoStructLiteralValues(sd, inits); std::vector<LLConstant*> values = DtoStructLiteralValues(sd, inits);
// we know those values are constants.. cast them // we know those values are constants.. cast them
std::vector<LLConstant*> constvals(values.size(), NULL); std::vector<LLConstant*> constvals(values.size(), 0);
std::vector<LLType*> types(values.size(), NULL); std::vector<LLType*> types(values.size(), 0);
for (size_t i = 0; i < values.size(); ++i) { for (size_t i = 0; i < values.size(); ++i) {
constvals[i] = llvm::cast<LLConstant>(values[i]); constvals[i] = llvm::cast<LLConstant>(values[i]);
types[i] = values[i]->getType(); types[i] = values[i]->getType();
@ -3059,6 +3061,8 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p)
{ {
std::vector<LLConstant*> keysInits, valuesInits; std::vector<LLConstant*> keysInits, valuesInits;
keysInits.reserve(keys->dim);
valuesInits.reserve(keys->dim);
for (size_t i = 0, n = keys->dim; i < n; ++i) for (size_t i = 0, n = keys->dim; i < n; ++i)
{ {
Expression* ekey = keys->tdata()[i]; Expression* ekey = keys->tdata()[i];
@ -3178,11 +3182,12 @@ DValue* TypeExp::toElem(IRState *p)
DValue* TupleExp::toElem(IRState *p) DValue* TupleExp::toElem(IRState *p)
{ {
Logger::print("TupleExp::toElem() %s\n", toChars()); Logger::print("TupleExp::toElem() %s\n", toChars());
std::vector<LLType*> types(exps->dim, NULL); std::vector<LLType*> types;
types.reserve(exps->dim);
for (size_t i = 0; i < exps->dim; i++) for (size_t i = 0; i < exps->dim; i++)
{ {
Expression *el = static_cast<Expression *>(exps->data[i]); Expression *el = static_cast<Expression *>(exps->data[i]);
types[i] = DtoTypeNotVoid(el->type); types.push_back(DtoTypeNotVoid(el->type));
} }
LLValue *val = DtoRawAlloca(LLStructType::get(gIR->context(), types),0, "tuple"); LLValue *val = DtoRawAlloca(LLStructType::get(gIR->context(), types),0, "tuple");
for (size_t i = 0; i < exps->dim; i++) for (size_t i = 0; i < exps->dim; i++)

View file

@ -492,7 +492,7 @@ LLValue* DtoGEP1(LLValue* ptr, LLValue* i0, const char* var, llvm::BasicBlock* b
LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var, llvm::BasicBlock* bb) LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var, llvm::BasicBlock* bb)
{ {
LLValue* v[2] = { i0, i1 }; LLValue* v[] = { i0, i1 };
return llvm::GetElementPtrInst::Create(ptr, v, var?var:"tmp", bb?bb:gIR->scopebb()); return llvm::GetElementPtrInst::Create(ptr, v, var?var:"tmp", bb?bb:gIR->scopebb());
} }
@ -507,7 +507,7 @@ LLValue* DtoGEPi1(LLValue* ptr, unsigned i, const char* var, llvm::BasicBlock* b
LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm::BasicBlock* bb) LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm::BasicBlock* bb)
{ {
LLValue* v[2] = { DtoConstUint(i0), DtoConstUint(i1) }; LLValue* v[] = { DtoConstUint(i0), DtoConstUint(i1) };
return llvm::GetElementPtrInst::Create(ptr, v, var?var:"tmp", bb?bb:gIR->scopebb()); return llvm::GetElementPtrInst::Create(ptr, v, var?var:"tmp", bb?bb:gIR->scopebb());
} }
@ -515,7 +515,7 @@ LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm::
LLConstant* DtoGEPi(LLConstant* ptr, unsigned i0, unsigned i1) LLConstant* DtoGEPi(LLConstant* ptr, unsigned i0, unsigned i1)
{ {
LLValue* v[2] = { DtoConstUint(i0), DtoConstUint(i1) }; LLValue* v[] = { DtoConstUint(i0), DtoConstUint(i1) };
return llvm::ConstantExpr::getGetElementPtr(ptr, v, true); return llvm::ConstantExpr::getGetElementPtr(ptr, v, true);
} }
@ -644,7 +644,7 @@ LLConstant* DtoConstFP(Type* t, longdouble value)
if(llty == LLType::getFloatTy(gIR->context()) || llty == LLType::getDoubleTy(gIR->context())) if(llty == LLType::getFloatTy(gIR->context()) || llty == LLType::getDoubleTy(gIR->context()))
return LLConstantFP::get(llty, value); return LLConstantFP::get(llty, value);
else if(llty == LLType::getX86_FP80Ty(gIR->context())) { else if(llty == LLType::getX86_FP80Ty(gIR->context())) {
uint64_t bits[] = {0, 0}; uint64_t bits[] = { 0, 0 };
bits[0] = *reinterpret_cast<uint64_t*>(&value); bits[0] = *reinterpret_cast<uint64_t*>(&value);
bits[1] = *reinterpret_cast<uint16_t*>(reinterpret_cast<uint64_t*>(&value) + 1); bits[1] = *reinterpret_cast<uint16_t*>(reinterpret_cast<uint64_t*>(&value) + 1);
#if LDC_LLVM_VER >= 303 #if LDC_LLVM_VER >= 303
@ -678,7 +678,7 @@ LLConstant* DtoConstString(const char* str)
#endif #endif
llvm::GlobalVariable* gvar = new llvm::GlobalVariable( llvm::GlobalVariable* gvar = new llvm::GlobalVariable(
*gIR->module, init->getType(), true, llvm::GlobalValue::InternalLinkage, init, ".str"); *gIR->module, init->getType(), true, llvm::GlobalValue::InternalLinkage, init, ".str");
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; LLConstant* idxs[] = { DtoConstUint(0), DtoConstUint(0) };
return DtoConstSlice( return DtoConstSlice(
DtoConstSize_t(s.size()), DtoConstSize_t(s.size()),
llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true), llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true),
@ -697,7 +697,7 @@ LLConstant* DtoConstStringPtr(const char* str, const char* section)
llvm::GlobalVariable* gvar = new llvm::GlobalVariable( llvm::GlobalVariable* gvar = new llvm::GlobalVariable(
*gIR->module, init->getType(), true, llvm::GlobalValue::InternalLinkage, init, ".str"); *gIR->module, init->getType(), true, llvm::GlobalValue::InternalLinkage, init, ".str");
if (section) gvar->setSection(section); if (section) gvar->setSection(section);
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; LLConstant* idxs[] = { DtoConstUint(0), DtoConstUint(0) };
return llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true); return llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true);
} }

@ -1 +1 @@
Subproject commit a2efaf9525894ccd0f649cc87fea269ff6263e4a Subproject commit 34f9dcf7aed758a3cce48cb77e4e77d7d877d676