[cfe-commits] r56010 - in /cfe/trunk/lib/CodeGen: CGExprAgg.cpp CodeGenFunction.h
Daniel Dunbar
daniel at zuster.org
Tue Sep 9 13:49:46 PDT 2008
Author: ddunbar
Date: Tue Sep 9 15:49:46 2008
New Revision: 56010
URL: http://llvm.org/viewvc/llvm-project?rev=56010&view=rev
Log:
Move EmitAggregate{Copy,Clear} into CodeGenFunction.
- No functionality change.
Modified:
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=56010&r1=56009&r2=56010&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Tue Sep 9 15:49:46 2008
@@ -48,11 +48,6 @@
/// then loads the result into DestPtr.
void EmitAggLoadOfLValue(const Expr *E);
- void EmitAggregateCopy(llvm::Value *DestPtr, llvm::Value *SrcPtr,
- QualType EltTy);
-
- void EmitAggregateClear(llvm::Value *DestPtr, QualType Ty);
-
void EmitNonConstInit(InitListExpr *E);
//===--------------------------------------------------------------------===//
@@ -111,38 +106,6 @@
// Utilities
//===----------------------------------------------------------------------===//
-void AggExprEmitter::EmitAggregateClear(llvm::Value *DestPtr, QualType Ty) {
- assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex");
-
- CGF.EmitMemSetToZero(DestPtr, Ty);
-}
-
-void AggExprEmitter::EmitAggregateCopy(llvm::Value *DestPtr,
- llvm::Value *SrcPtr, QualType Ty) {
- assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex");
-
- // Aggregate assignment turns into llvm.memmove.
- const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
- if (DestPtr->getType() != BP)
- DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
- if (SrcPtr->getType() != BP)
- SrcPtr = Builder.CreateBitCast(SrcPtr, BP, "tmp");
-
- // Get size and alignment info for this aggregate.
- std::pair<uint64_t, unsigned> TypeInfo = CGF.getContext().getTypeInfo(Ty);
-
- // FIXME: Handle variable sized types.
- const llvm::Type *IntPtr = llvm::IntegerType::get(CGF.LLVMPointerWidth);
-
- Builder.CreateCall4(CGF.CGM.getMemMoveFn(),
- DestPtr, SrcPtr,
- // TypeInfo.first describes size in bits.
- llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
- llvm::ConstantInt::get(llvm::Type::Int32Ty,
- TypeInfo.second/8));
-}
-
-
/// EmitAggLoadOfLValue - Given an expression with aggregate type that
/// represents a value lvalue, this method emits the address of the lvalue,
/// then loads the result into DestPtr.
@@ -156,7 +119,7 @@
// FIXME: If the source is volatile, we must read from it.
return;
- EmitAggregateCopy(DestPtr, SrcPtr, E->getType());
+ CGF.EmitAggregateCopy(DestPtr, SrcPtr, E->getType());
}
//===----------------------------------------------------------------------===//
@@ -180,7 +143,7 @@
// FIXME: If the source is volatile, we must read from it.
return;
- EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
+ CGF.EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
}
void AggExprEmitter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
@@ -192,7 +155,7 @@
// FIXME: If the source is volatile, we must read from it.
return;
- EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
+ CGF.EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
}
void AggExprEmitter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
@@ -204,7 +167,7 @@
// FIXME: If the source is volatile, we must read from it.
return;
- EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
+ CGF.EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
}
void AggExprEmitter::VisitOverloadExpr(const OverloadExpr *E) {
@@ -218,7 +181,7 @@
// FIXME: If the source is volatile, we must read from it.
return;
- EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
+ CGF.EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
}
void AggExprEmitter::VisitBinComma(const BinaryOperator *E) {
@@ -261,7 +224,7 @@
return;
// If the result of the assignment is used, copy the RHS there also.
- EmitAggregateCopy(DestPtr, LHS.getAddress(), E->getType());
+ CGF.EmitAggregateCopy(DestPtr, LHS.getAddress(), E->getType());
}
}
@@ -329,7 +292,7 @@
// FIXME: volatility
Builder.CreateStore(llvm::Constant::getNullValue(EType), NextVal);
else
- EmitAggregateClear(NextVal, QType);
+ CGF.EmitAggregateClear(NextVal, QType);
}
} else
assert(false && "Invalid initializer");
@@ -469,3 +432,34 @@
AggExprEmitter(*this, DestPtr, VolatileDest).Visit(const_cast<Expr*>(E));
}
+
+void CodeGenFunction::EmitAggregateClear(llvm::Value *DestPtr, QualType Ty) {
+ assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex");
+
+ EmitMemSetToZero(DestPtr, Ty);
+}
+
+void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
+ llvm::Value *SrcPtr, QualType Ty) {
+ assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex");
+
+ // Aggregate assignment turns into llvm.memmove.
+ const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
+ if (DestPtr->getType() != BP)
+ DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
+ if (SrcPtr->getType() != BP)
+ SrcPtr = Builder.CreateBitCast(SrcPtr, BP, "tmp");
+
+ // Get size and alignment info for this aggregate.
+ std::pair<uint64_t, unsigned> TypeInfo = getContext().getTypeInfo(Ty);
+
+ // FIXME: Handle variable sized types.
+ const llvm::Type *IntPtr = llvm::IntegerType::get(LLVMPointerWidth);
+
+ Builder.CreateCall4(CGM.getMemMoveFn(),
+ DestPtr, SrcPtr,
+ // TypeInfo.first describes size in bits.
+ llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
+ llvm::ConstantInt::get(llvm::Type::Int32Ty,
+ TypeInfo.second/8));
+}
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=56010&r1=56009&r2=56010&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Sep 9 15:49:46 2008
@@ -181,6 +181,11 @@
RValue EmitAnyExprToTemp(const Expr *E, llvm::Value *AggLoc = 0,
bool isAggLocVolatile = false);
+ void EmitAggregateCopy(llvm::Value *DestPtr, llvm::Value *SrcPtr,
+ QualType EltTy);
+
+ void EmitAggregateClear(llvm::Value *DestPtr, QualType Ty);
+
/// isDummyBlock - Return true if BB is an empty basic block
/// with no predecessors.
static bool isDummyBlock(const llvm::BasicBlock *BB);
More information about the cfe-commits
mailing list