summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-08-20 00:15:15 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-08-20 00:15:15 +0000
commit6147a908f6d2a67dde46328c83332b92265ab3ae (patch)
tree0968b91f0458f701bbcee690f425854ccbe1481c
parent21531fa592cd76e5d3df839ce469bea918404ac8 (diff)
ir-gen for multi-dimensional array construction. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79497 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGCXX.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index deaac7499f..b564a08501 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -374,18 +374,31 @@ 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);
// Emit the increment of the loop counter.
@@ -399,7 +412,6 @@ CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
// Emit the fall-through block.
EmitBlock(AfterFor, true);
-
}
void