[cfe-commits] r79497 - /cfe/trunk/lib/CodeGen/CGCXX.cpp
Fariborz Jahanian
fjahanian at apple.com
Wed Aug 19 17:15:16 PDT 2009
Author: fjahanian
Date: Wed Aug 19 19:15:15 2009
New Revision: 79497
URL: http://llvm.org/viewvc/llvm-project?rev=79497&view=rev
Log:
ir-gen for multi-dimensional array construction. WIP.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=79497&r1=79496&r2=79497&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Aug 19 19:15:15 2009
@@ -374,18 +374,31 @@
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 @@
// Emit the fall-through block.
EmitBlock(AfterFor, true);
-
}
void
More information about the cfe-commits
mailing list