forked from OSchip/llvm-project
ir-gen for multi-dimensional array construction. WIP.
llvm-svn: 79497
This commit is contained in:
parent
eebcf574dd
commit
eeb0e57247
|
@ -374,17 +374,30 @@ CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
|
|||
EmitBlock(ForBody);
|
||||
|
||||
llvm::BasicBlock *ContinueBlock = createBasicBlock("for.inc");
|
||||
|
||||
// Inside the loop body, emit the constructor call on the array element.
|
||||
Counter = Builder.CreateLoad(IndexPtr);
|
||||
llvm::Value *Address = Builder.CreateInBoundsGEP(This, Counter, "arrayidx");
|
||||
if (const ConstantArrayType *CAT =
|
||||
dyn_cast<ConstantArrayType>(Array->getElementType())) {
|
||||
// Need to call this routine again.
|
||||
uint32_t delta = 1;
|
||||
const ConstantArrayType *CAW = CAT;
|
||||
do {
|
||||
delta *= CAW->getSize().getZExtValue();
|
||||
CAW = dyn_cast<ConstantArrayType>(CAW->getElementType());
|
||||
} while (CAW);
|
||||
// Address = This + delta*Counter
|
||||
llvm::Value *DeltaPtr =
|
||||
llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), delta);
|
||||
Counter = Builder.CreateLoad(IndexPtr);
|
||||
DeltaPtr = Builder.CreateMul(Counter, DeltaPtr, "mul");
|
||||
llvm::Value *Address =
|
||||
Builder.CreateInBoundsGEP(This, DeltaPtr, "arrayidx");
|
||||
EmitCXXAggrConstructorCall(D, CAT, Address);
|
||||
}
|
||||
else
|
||||
else {
|
||||
Counter = Builder.CreateLoad(IndexPtr);
|
||||
llvm::Value *Address = Builder.CreateInBoundsGEP(This, Counter, "arrayidx");
|
||||
EmitCXXConstructorCall(D, Ctor_Complete, Address, 0, 0);
|
||||
}
|
||||
|
||||
EmitBlock(ContinueBlock);
|
||||
|
||||
|
@ -399,7 +412,6 @@ CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
|
|||
|
||||
// Emit the fall-through block.
|
||||
EmitBlock(AfterFor, true);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue