forked from OSchip/llvm-project
parent
211427bda9
commit
54eb4843b1
|
@ -449,89 +449,6 @@ void CodeGenFunction::EmitClassAggrMemberwiseCopy(llvm::Value *Dest,
|
|||
EmitBlock(AfterFor, true);
|
||||
}
|
||||
|
||||
/// EmitClassAggrCopyAssignment - This routine generates code to assign a class
|
||||
/// array of objects from SrcValue to DestValue. Assignment can be either a
|
||||
/// bitwise assignment or via a copy assignment operator function call.
|
||||
/// FIXME. This can be consolidated with EmitClassAggrMemberwiseCopy
|
||||
void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
|
||||
llvm::Value *Src,
|
||||
const ArrayType *Array,
|
||||
const CXXRecordDecl *BaseClassDecl,
|
||||
QualType Ty) {
|
||||
const ConstantArrayType *CA = dyn_cast<ConstantArrayType>(Array);
|
||||
assert(CA && "VLA cannot be asssigned");
|
||||
bool BitwiseAssign = BaseClassDecl->hasTrivialCopyAssignment();
|
||||
|
||||
// Create a temporary for the loop index and initialize it with 0.
|
||||
llvm::Value *IndexPtr = CreateTempAlloca(llvm::Type::getInt64Ty(VMContext),
|
||||
"loop.index");
|
||||
llvm::Value* zeroConstant =
|
||||
llvm::Constant::getNullValue(llvm::Type::getInt64Ty(VMContext));
|
||||
Builder.CreateStore(zeroConstant, IndexPtr);
|
||||
// Start the loop with a block that tests the condition.
|
||||
llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
|
||||
llvm::BasicBlock *AfterFor = createBasicBlock("for.end");
|
||||
|
||||
EmitBlock(CondBlock);
|
||||
|
||||
llvm::BasicBlock *ForBody = createBasicBlock("for.body");
|
||||
// Generate: if (loop-index < number-of-elements fall to the loop body,
|
||||
// otherwise, go to the block after the for-loop.
|
||||
uint64_t NumElements = getContext().getConstantArrayElementCount(CA);
|
||||
llvm::Value * NumElementsPtr =
|
||||
llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), NumElements);
|
||||
llvm::Value *Counter = Builder.CreateLoad(IndexPtr);
|
||||
llvm::Value *IsLess = Builder.CreateICmpULT(Counter, NumElementsPtr,
|
||||
"isless");
|
||||
// If the condition is true, execute the body.
|
||||
Builder.CreateCondBr(IsLess, ForBody, AfterFor);
|
||||
|
||||
EmitBlock(ForBody);
|
||||
llvm::BasicBlock *ContinueBlock = createBasicBlock("for.inc");
|
||||
// Inside the loop body, emit the assignment operator call on array element.
|
||||
Counter = Builder.CreateLoad(IndexPtr);
|
||||
Src = Builder.CreateInBoundsGEP(Src, Counter, "srcaddress");
|
||||
Dest = Builder.CreateInBoundsGEP(Dest, Counter, "destaddress");
|
||||
const CXXMethodDecl *MD = 0;
|
||||
if (BitwiseAssign)
|
||||
EmitAggregateCopy(Dest, Src, Ty);
|
||||
else {
|
||||
BaseClassDecl->hasConstCopyAssignment(getContext(), MD);
|
||||
assert(MD && "EmitClassAggrCopyAssignment - No user assign");
|
||||
const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
|
||||
const llvm::Type *LTy =
|
||||
CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
|
||||
FPT->isVariadic());
|
||||
llvm::Constant *Callee = CGM.GetAddrOfFunction(MD, LTy);
|
||||
|
||||
CallArgList CallArgs;
|
||||
// Push the this (Dest) ptr.
|
||||
CallArgs.push_back(std::make_pair(RValue::get(Dest),
|
||||
MD->getThisType(getContext())));
|
||||
|
||||
// Push the Src ptr.
|
||||
QualType SrcTy = MD->getParamDecl(0)->getType();
|
||||
RValue SrcValue = SrcTy->isReferenceType() ? RValue::get(Src) :
|
||||
RValue::getAggregate(Src);
|
||||
CallArgs.push_back(std::make_pair(SrcValue, SrcTy));
|
||||
EmitCall(CGM.getTypes().getFunctionInfo(CallArgs, FPT),
|
||||
Callee, ReturnValueSlot(), CallArgs, MD);
|
||||
}
|
||||
EmitBlock(ContinueBlock);
|
||||
|
||||
// Emit the increment of the loop counter.
|
||||
llvm::Value *NextVal = llvm::ConstantInt::get(Counter->getType(), 1);
|
||||
Counter = Builder.CreateLoad(IndexPtr);
|
||||
NextVal = Builder.CreateAdd(Counter, NextVal, "inc");
|
||||
Builder.CreateStore(NextVal, IndexPtr);
|
||||
|
||||
// Finally, branch back up to the condition for the next iteration.
|
||||
EmitBranch(CondBlock);
|
||||
|
||||
// Emit the fall-through block.
|
||||
EmitBlock(AfterFor, true);
|
||||
}
|
||||
|
||||
/// GetVTTParameter - Return the VTT parameter that should be passed to a
|
||||
/// base constructor/destructor with virtual bases.
|
||||
static llvm::Value *GetVTTParameter(CodeGenFunction &CGF, GlobalDecl GD) {
|
||||
|
|
|
@ -809,12 +809,6 @@ public:
|
|||
const ConstantArrayType *Array,
|
||||
const CXXRecordDecl *ClassDecl);
|
||||
|
||||
void EmitClassAggrCopyAssignment(llvm::Value *DestValue,
|
||||
llvm::Value *SrcValue,
|
||||
const ArrayType *Array,
|
||||
const CXXRecordDecl *BaseClassDecl,
|
||||
QualType Ty);
|
||||
|
||||
void EmitClassMemberwiseCopy(llvm::Value *DestValue, llvm::Value *SrcValue,
|
||||
const CXXRecordDecl *ClassDecl);
|
||||
|
||||
|
|
Loading…
Reference in New Issue