Fixed building of LDC1. Work on arrays

This commit is contained in:
Alexey Prokhin
2010-10-08 15:58:10 +04:00
parent 41a66cf437
commit eb68fc3d8c
2 changed files with 15 additions and 3 deletions

View File

@@ -470,7 +470,7 @@ DSliceValue* DtoNewDynArray(Loc& loc, Type* arrayType, DValue* dim, bool default
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname);
// call allocator
LLValue* array = gIR->CreateCallOrInvoke2(fn, arrayTypeInfo, arrayLen, ".gc_mem").getInstruction();
LLValue* newptr = gIR->CreateCallOrInvoke2(fn, arrayTypeInfo, arrayLen, ".gc_mem").getInstruction();
// cast to wanted type
const LLType* dstType = DtoType(arrayType)->getContainedType(1);
@@ -504,7 +504,12 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size
bool zeroInit = vtype->isZeroInit();
if (defaultInit && !isInitialized(vtype))
defaultInit = false;
#if DMDV2
const char* fnname = zeroInit ? "_d_newarraymT" : "_d_newarraymiT";
#else
const char* fnname = defaultInit ? (zeroInit ? "_d_newarraymT" : "_d_newarraymiT") : "_d_newarraymvT";
#endif
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname);
// build dims
@@ -520,6 +525,9 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size
// call allocator
LLValue* newptr = gIR->CreateCallOrInvoke3(fn, arrayTypeInfo, DtoConstSize_t(ndims), dimsArg, ".gc_mem").getInstruction();
#if DMDV2
return getSlice(arrayType, newptr);
#else
// cast to wanted type
const LLType* dstType = DtoType(arrayType)->getContainedType(1);
if (newptr->getType() != dstType)
@@ -530,6 +538,7 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size
assert(firstDim);
return new DSliceValue(arrayType, firstDim, newptr);
#endif
}
//////////////////////////////////////////////////////////////////////////////////////////
@@ -564,6 +573,7 @@ DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, LLValue* newdim)
LLValue* arrPtr = DtoArrayPtr(array);
args.push_back(DtoArrayLen(array));
LLValue* newptr = gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), ".gc_mem").getInstruction();
if (Logger::enabled())
Logger::cout() << "arrPtr = " << *arrPtr << '\n';

View File

@@ -309,11 +309,10 @@ static void LLVM_D_BuildRuntimeModule()
// void* _d_newarraymT(TypeInfo ti, size_t length, size_t* dims)
// void* _d_newarraymiT(TypeInfo ti, size_t length, size_t* dims)
// void* _d_newarraymvT(TypeInfo ti, size_t length, size_t* dims)
// D1: void* _d_newarraymvT(TypeInfo ti, size_t length, size_t* dims)
{
llvm::StringRef fname("_d_newarraymT");
llvm::StringRef fname2("_d_newarraymiT");
llvm::StringRef fname3("_d_newarraymvT");
std::vector<const LLType*> types;
types.push_back(typeInfoTy);
types.push_back(sizeTy);
@@ -323,8 +322,11 @@ static void LLVM_D_BuildRuntimeModule()
->setAttributes(Attr_NoAlias_3_NoCapture);
llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)
->setAttributes(Attr_NoAlias_3_NoCapture);
#if DMDV1
llvm::StringRef fname3("_d_newarraymvT");
llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M)
->setAttributes(Attr_NoAlias_3_NoCapture);
#endif
}
// D1: