LValue carries a type now, so simplify the main EmitLoad/Store APIs

by removing the redundant type parameter.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133860 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
John McCall 2011-06-25 02:11:03 +00:00
Родитель 913dab2525
Коммит 545d996ec5
9 изменённых файлов: 93 добавлений и 104 удалений

Просмотреть файл

@ -359,7 +359,7 @@ CodeGenFunction::ExpandTypeFromArgs(QualType Ty, LValue LV,
if (CodeGenFunction::hasAggregateLLVMType(FT)) {
AI = ExpandTypeFromArgs(FT, LV, AI);
} else {
EmitStoreThroughLValue(RValue::get(AI), LV, FT);
EmitStoreThroughLValue(RValue::get(AI), LV);
++AI;
}
}
@ -386,7 +386,7 @@ CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV,
if (CodeGenFunction::hasAggregateLLVMType(FT)) {
ExpandTypeToArgs(FT, RValue::getAggregate(LV.getAddress()), Args);
} else {
RValue RV = EmitLoadOfLValue(LV, FT);
RValue RV = EmitLoadOfLValue(LV);
assert(RV.isScalar() &&
"Unexpected non-scalar rvalue during struct expansion.");
Args.push_back(RV.getScalarVal());
@ -1329,8 +1329,7 @@ static void emitWriteback(CodeGenFunction &CGF,
// Perform the writeback.
QualType srcAddrType = writeback.AddressType;
CGF.EmitStoreThroughLValue(RValue::get(value),
CGF.MakeAddrLValue(srcAddr, srcAddrType),
srcAddrType);
CGF.MakeAddrLValue(srcAddr, srcAddrType));
// Jump to the continuation block.
if (!provablyNonNull)
@ -1407,7 +1406,7 @@ static void emitWritebackArg(CodeGenFunction &CGF, CallArgList &args,
// Perform a copy if necessary.
if (shouldCopy) {
LValue srcLV = CGF.MakeAddrLValue(srcAddr, srcAddrType);
RValue srcRV = CGF.EmitLoadOfLValue(srcLV, srcAddrType);
RValue srcRV = CGF.EmitLoadOfLValue(srcLV);
assert(srcRV.isScalar());
llvm::Value *src = srcRV.getScalarVal();

Просмотреть файл

@ -556,7 +556,7 @@ static void EmitMemberInitializer(CodeGenFunction &CGF,
CGF.EmitExprAsInit(MemberInit->getInit(), Field, LHS, false);
} else {
RValue RHS = RValue::get(CGF.EmitScalarExpr(MemberInit->getInit()));
CGF.EmitStoreThroughLValue(RHS, LHS, FieldType);
CGF.EmitStoreThroughLValue(RHS, LHS);
}
} else if (MemberInit->getInit()->getType()->isAnyComplexType()) {
CGF.EmitComplexExprIntoAddr(MemberInit->getInit(), LHS.getAddress(),

Просмотреть файл

@ -482,7 +482,7 @@ void CodeGenFunction::EmitScalarInit(const Expr *init,
llvm::Value *value = EmitScalarExpr(init);
if (capturedByInit)
drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D));
EmitStoreThroughLValue(RValue::get(value), lvalue, lvalue.getType());
EmitStoreThroughLValue(RValue::get(value), lvalue);
return;
}
@ -579,7 +579,7 @@ void CodeGenFunction::EmitScalarInit(const Expr *init,
void CodeGenFunction::EmitScalarInit(llvm::Value *init, LValue lvalue) {
Qualifiers::ObjCLifetime lifetime = lvalue.getObjCLifetime();
if (!lifetime)
return EmitStoreThroughLValue(RValue::get(init), lvalue, lvalue.getType());
return EmitStoreThroughLValue(RValue::get(init), lvalue);
switch (lifetime) {
case Qualifiers::OCL_None:
@ -982,7 +982,7 @@ void CodeGenFunction::EmitExprAsInit(const Expr *init,
RValue rvalue = EmitReferenceBindingToExpr(init, D);
if (capturedByInit)
drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D));
EmitStoreThroughLValue(rvalue, lvalue, type);
EmitStoreThroughLValue(rvalue, lvalue);
} else if (!hasAggregateLLVMType(type)) {
EmitScalarInit(init, D, lvalue, capturedByInit);
} else if (type->isAnyComplexType()) {
@ -1163,10 +1163,11 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg,
}
// Store the initial value into the alloca.
if (doStore)
EmitStoreOfScalar(Arg, DeclPtr, Ty.isVolatileQualified(),
getContext().getDeclAlign(&D).getQuantity(), Ty,
CGM.getTBAAInfo(Ty));
if (doStore) {
LValue lv = MakeAddrLValue(DeclPtr, Ty,
getContext().getDeclAlign(&D).getQuantity());
EmitStoreOfScalar(Arg, lv);
}
}
llvm::Value *&DMEntry = LocalDeclMap[&D];

Просмотреть файл

@ -140,7 +140,7 @@ void CodeGenFunction::EmitAnyExprToMem(const Expr *E,
else {
RValue RV = RValue::get(EmitScalarExpr(E, /*Ignore*/ false));
LValue LV = MakeAddrLValue(Location, E->getType());
EmitStoreThroughLValue(RV, LV, E->getType());
EmitStoreThroughLValue(RV, LV);
}
}
@ -251,7 +251,7 @@ EmitExprForReferenceBinding(CodeGenFunction &CGF, const Expr *E,
return LV.getAddress();
// We have to load the lvalue.
RV = CGF.EmitLoadOfLValue(LV, E->getType());
RV = CGF.EmitLoadOfLValue(LV);
} else {
if (!ObjCARCReferenceLifetimeType.isNull()) {
ReferenceTemporary = CreateReferenceTemporary(CGF,
@ -395,7 +395,7 @@ EmitExprForReferenceBinding(CodeGenFunction &CGF, const Expr *E,
Object = CreateReferenceTemporary(CGF, T, InitializedDecl);
LValue TempLV = CGF.MakeAddrLValue(Object,
Adjustment.Field->getType());
CGF.EmitStoreThroughLValue(CGF.EmitLoadOfLValue(LV, T), TempLV, T);
CGF.EmitStoreThroughLValue(CGF.EmitLoadOfLValue(LV), TempLV);
break;
}
@ -780,7 +780,7 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *value, LValue lvalue) {
/// EmitLoadOfLValue - Given an expression that represents a value lvalue, this
/// method emits the address of the lvalue, then loads the result as an rvalue,
/// returning the rvalue.
RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
RValue CodeGenFunction::EmitLoadOfLValue(LValue LV) {
if (LV.isObjCWeak()) {
// load of a __weak object.
llvm::Value *AddrWeakObj = LV.getAddress();
@ -791,17 +791,10 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
return RValue::get(EmitARCLoadWeak(LV.getAddress()));
if (LV.isSimple()) {
llvm::Value *Ptr = LV.getAddress();
// Functions are l-values that don't require loading.
if (ExprType->isFunctionType())
return RValue::get(Ptr);
assert(!LV.getType()->isFunctionType());
// Everything needs a load.
return RValue::get(EmitLoadOfScalar(Ptr, LV.isVolatileQualified(),
LV.getAlignment(), ExprType,
LV.getTBAAInfo()));
return RValue::get(EmitLoadOfScalar(LV));
}
if (LV.isVectorElt()) {
@ -814,21 +807,20 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
// If this is a reference to a subset of the elements of a vector, either
// shuffle the input or extract/insert them as appropriate.
if (LV.isExtVectorElt())
return EmitLoadOfExtVectorElementLValue(LV, ExprType);
return EmitLoadOfExtVectorElementLValue(LV);
if (LV.isBitField())
return EmitLoadOfBitfieldLValue(LV, ExprType);
return EmitLoadOfBitfieldLValue(LV);
assert(LV.isPropertyRef() && "Unknown LValue type!");
return EmitLoadOfPropertyRefLValue(LV);
}
RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV,
QualType ExprType) {
RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV) {
const CGBitFieldInfo &Info = LV.getBitFieldInfo();
// Get the output type.
const llvm::Type *ResLTy = ConvertType(ExprType);
const llvm::Type *ResLTy = ConvertType(LV.getType());
unsigned ResSizeInBits = CGM.getTargetData().getTypeSizeInBits(ResLTy);
// Compute the result as an OR of all of the individual component accesses.
@ -854,7 +846,7 @@ RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV,
// Cast to the access type.
const llvm::Type *PTy = llvm::Type::getIntNPtrTy(getLLVMContext(),
AI.AccessWidth,
CGM.getContext().getTargetAddressSpace(ExprType));
CGM.getContext().getTargetAddressSpace(LV.getType()));
Ptr = Builder.CreateBitCast(Ptr, PTy);
// Perform the load.
@ -898,8 +890,7 @@ RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV,
// If this is a reference to a subset of the elements of a vector, create an
// appropriate shufflevector.
RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV,
QualType ExprType) {
RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV) {
llvm::Value *Vec = Builder.CreateLoad(LV.getExtVectorAddr(),
LV.isVolatileQualified(), "tmp");
@ -907,7 +898,7 @@ RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV,
// If the result of the expression is a non-vector type, we must be extracting
// a single element. Just codegen as an extractelement.
const VectorType *ExprVT = ExprType->getAs<VectorType>();
const VectorType *ExprVT = LV.getType()->getAs<VectorType>();
if (!ExprVT) {
unsigned InIdx = getAccessedFieldNo(0, Elts);
llvm::Value *Elt = llvm::ConstantInt::get(Int32Ty, InIdx);
@ -934,8 +925,7 @@ RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV,
/// EmitStoreThroughLValue - Store the specified rvalue into the specified
/// lvalue, where both are guaranteed to the have the same type, and that type
/// is 'Ty'.
void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
QualType Ty) {
void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst) {
if (!Dst.isSimple()) {
if (Dst.isVectorElt()) {
// Read/modify/write the vector, inserting the new element.
@ -950,10 +940,10 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
// If this is an update of extended vector elements, insert them as
// appropriate.
if (Dst.isExtVectorElt())
return EmitStoreThroughExtVectorComponentLValue(Src, Dst, Ty);
return EmitStoreThroughExtVectorComponentLValue(Src, Dst);
if (Dst.isBitField())
return EmitStoreThroughBitfieldLValue(Src, Dst, Ty);
return EmitStoreThroughBitfieldLValue(Src, Dst);
assert(Dst.isPropertyRef() && "Unknown LValue type");
return EmitStoreThroughPropertyRefLValue(Src, Dst);
@ -970,7 +960,7 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
break;
case Qualifiers::OCL_Strong:
EmitARCStoreStrong(Dst, Ty, Src.getScalarVal(), /*ignore*/ true);
EmitARCStoreStrong(Dst, Src.getScalarVal(), /*ignore*/ true);
return;
case Qualifiers::OCL_Weak:
@ -978,7 +968,8 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
return;
case Qualifiers::OCL_Autoreleasing:
Src = RValue::get(EmitObjCExtendObjectLifetime(Ty, Src.getScalarVal()));
Src = RValue::get(EmitObjCExtendObjectLifetime(Dst.getType(),
Src.getScalarVal()));
// fall into the normal path
break;
}
@ -1021,18 +1012,17 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
}
void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
QualType Ty,
llvm::Value **Result) {
const CGBitFieldInfo &Info = Dst.getBitFieldInfo();
// Get the output type.
const llvm::Type *ResLTy = ConvertTypeForMem(Ty);
const llvm::Type *ResLTy = ConvertTypeForMem(Dst.getType());
unsigned ResSizeInBits = CGM.getTargetData().getTypeSizeInBits(ResLTy);
// Get the source value, truncated to the width of the bit-field.
llvm::Value *SrcVal = Src.getScalarVal();
if (Ty->isBooleanType())
if (Dst.getType()->isBooleanType())
SrcVal = Builder.CreateIntCast(SrcVal, ResLTy, /*IsSigned=*/false);
SrcVal = Builder.CreateAnd(SrcVal, llvm::APInt::getLowBitsSet(ResSizeInBits,
@ -1127,8 +1117,7 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
}
void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
LValue Dst,
QualType Ty) {
LValue Dst) {
// This access turns into a read/modify/write of the vector. Load the input
// value now.
llvm::Value *Vec = Builder.CreateLoad(Dst.getExtVectorAddr(),
@ -1137,7 +1126,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
llvm::Value *SrcVal = Src.getScalarVal();
if (const VectorType *VTy = Ty->getAs<VectorType>()) {
if (const VectorType *VTy = Dst.getType()->getAs<VectorType>()) {
unsigned NumSrcElts = VTy->getNumElements();
unsigned NumDstElts =
cast<llvm::VectorType>(Vec->getType())->getNumElements();
@ -2247,7 +2236,7 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
RValue RV = EmitAnyExpr(E->getRHS());
LValue LV = EmitLValue(E->getLHS());
EmitStoreThroughLValue(RV, LV, E->getType());
EmitStoreThroughLValue(RV, LV);
return LV;
}

Просмотреть файл

@ -588,7 +588,7 @@ AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV) {
EmitNullInitializationToLValue(LV);
} else if (type->isReferenceType()) {
RValue RV = CGF.EmitReferenceBindingToExpr(E, /*InitializedDecl=*/0);
CGF.EmitStoreThroughLValue(RV, LV, type);
CGF.EmitStoreThroughLValue(RV, LV);
} else if (type->isAnyComplexType()) {
CGF.EmitComplexExprIntoAddr(E, LV.getAddress(), false);
} else if (CGF.hasAggregateLLVMType(type)) {
@ -597,7 +597,7 @@ AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV) {
} else if (LV.isSimple()) {
CGF.EmitScalarInit(E, /*D=*/0, LV, /*Captured=*/false);
} else {
CGF.EmitStoreThroughLValue(RValue::get(CGF.EmitScalarExpr(E)), LV, type);
CGF.EmitStoreThroughLValue(RValue::get(CGF.EmitScalarExpr(E)), LV);
}
}
@ -612,7 +612,7 @@ void AggExprEmitter::EmitNullInitializationToLValue(LValue lv) {
if (!CGF.hasAggregateLLVMType(type)) {
// For non-aggregates, we can store zero
llvm::Value *null = llvm::Constant::getNullValue(CGF.ConvertType(type));
CGF.EmitStoreThroughLValue(RValue::get(null), lv, type);
CGF.EmitStoreThroughLValue(RValue::get(null), lv);
} else {
// There's a potential optimization opportunity in combining
// memsets; that would be easy for arrays, but relatively

Просмотреть файл

@ -82,15 +82,15 @@ public:
LValue EmitLValue(const Expr *E) { return CGF.EmitLValue(E); }
LValue EmitCheckedLValue(const Expr *E) { return CGF.EmitCheckedLValue(E); }
Value *EmitLoadOfLValue(LValue LV, QualType T) {
return CGF.EmitLoadOfLValue(LV, T).getScalarVal();
Value *EmitLoadOfLValue(LValue LV) {
return CGF.EmitLoadOfLValue(LV).getScalarVal();
}
/// EmitLoadOfLValue - Given an expression with complex type that represents a
/// value l-value, this method emits the address of the l-value, then loads
/// and returns the result.
Value *EmitLoadOfLValue(const Expr *E) {
return EmitLoadOfLValue(EmitCheckedLValue(E), E->getType());
return EmitLoadOfLValue(EmitCheckedLValue(E));
}
/// EmitConversionToBool - Convert the specified expression value to a
@ -197,7 +197,7 @@ public:
Value *VisitOpaqueValueExpr(OpaqueValueExpr *E) {
if (E->isGLValue())
return EmitLoadOfLValue(CGF.getOpaqueLValueMapping(E), E->getType());
return EmitLoadOfLValue(CGF.getOpaqueLValueMapping(E));
// Otherwise, assume the mapping is the scalar directly.
return CGF.getOpaqueRValueMapping(E).getScalarVal();
@ -252,7 +252,7 @@ public:
Value *VisitObjCIsaExpr(ObjCIsaExpr *E) {
LValue LV = CGF.EmitObjCIsaExpr(E);
Value *V = CGF.EmitLoadOfLValue(LV, E->getType()).getScalarVal();
Value *V = CGF.EmitLoadOfLValue(LV).getScalarVal();
return V;
}
@ -1018,7 +1018,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
Value *V = EmitLValue(E).getAddress();
V = Builder.CreateBitCast(V,
ConvertType(CGF.getContext().getPointerType(DestTy)));
return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy), DestTy);
return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy));
}
case CK_AnyPointerToObjCPointerCast:
@ -1125,7 +1125,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
assert(CGF.getContext().hasSameUnqualifiedType(E->getType(), DestTy));
assert(E->isGLValue() && E->getObjectKind() == OK_ObjCProperty &&
"CK_GetObjCProperty for non-lvalue or non-ObjCProperty");
RValue RV = CGF.EmitLoadOfLValue(CGF.EmitLValue(E), E->getType());
RValue RV = CGF.EmitLoadOfLValue(CGF.EmitLValue(E));
return RV.getScalarVal();
}
@ -1224,7 +1224,7 @@ Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) {
Value *ScalarExprEmitter::VisitBlockDeclRefExpr(const BlockDeclRefExpr *E) {
LValue LV = CGF.EmitBlockDeclRefLValue(E);
return CGF.EmitLoadOfLValue(LV, E->getType()).getScalarVal();
return CGF.EmitLoadOfLValue(LV).getScalarVal();
}
//===----------------------------------------------------------------------===//
@ -1261,7 +1261,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
bool isInc, bool isPre) {
QualType type = E->getSubExpr()->getType();
llvm::Value *value = EmitLoadOfLValue(LV, type);
llvm::Value *value = EmitLoadOfLValue(LV);
llvm::Value *input = value;
int amount = (isInc ? 1 : -1);
@ -1375,9 +1375,9 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
// Store the updated result through the lvalue.
if (LV.isBitField())
CGF.EmitStoreThroughBitfieldLValue(RValue::get(value), LV, type, &value);
CGF.EmitStoreThroughBitfieldLValue(RValue::get(value), LV, &value);
else
CGF.EmitStoreThroughLValue(RValue::get(value), LV, type);
CGF.EmitStoreThroughLValue(RValue::get(value), LV);
// If this is a postinc, return the value read from memory, otherwise use the
// updated value.
@ -1558,8 +1558,7 @@ Value *ScalarExprEmitter::VisitUnaryReal(const UnaryOperator *E) {
// Note that we have to ask E because Op might be an l-value that
// this won't work for, e.g. an Obj-C property.
if (E->isGLValue())
return CGF.EmitLoadOfLValue(CGF.EmitLValue(E), E->getType())
.getScalarVal();
return CGF.EmitLoadOfLValue(CGF.EmitLValue(E)).getScalarVal();
// Otherwise, calculate and project.
return CGF.EmitComplexExpr(Op, false, true).first;
@ -1575,8 +1574,7 @@ Value *ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *E) {
// Note that we have to ask E because Op might be an l-value that
// this won't work for, e.g. an Obj-C property.
if (Op->isGLValue())
return CGF.EmitLoadOfLValue(CGF.EmitLValue(E), E->getType())
.getScalarVal();
return CGF.EmitLoadOfLValue(CGF.EmitLValue(E)).getScalarVal();
// Otherwise, calculate and project.
return CGF.EmitComplexExpr(Op, true, false).second;
@ -1628,7 +1626,7 @@ LValue ScalarExprEmitter::EmitCompoundAssignLValue(
OpInfo.E = E;
// Load/convert the LHS.
LValue LHSLV = EmitCheckedLValue(E->getLHS());
OpInfo.LHS = EmitLoadOfLValue(LHSLV, LHSTy);
OpInfo.LHS = EmitLoadOfLValue(LHSLV);
OpInfo.LHS = EmitScalarConversion(OpInfo.LHS, LHSTy,
E->getComputationLHSType());
@ -1643,10 +1641,9 @@ LValue ScalarExprEmitter::EmitCompoundAssignLValue(
// 'An assignment expression has the value of the left operand after the
// assignment...'.
if (LHSLV.isBitField())
CGF.EmitStoreThroughBitfieldLValue(RValue::get(Result), LHSLV, LHSTy,
&Result);
CGF.EmitStoreThroughBitfieldLValue(RValue::get(Result), LHSLV, &Result);
else
CGF.EmitStoreThroughLValue(RValue::get(Result), LHSLV, LHSTy);
CGF.EmitStoreThroughLValue(RValue::get(Result), LHSLV);
return LHSLV;
}
@ -1674,7 +1671,7 @@ Value *ScalarExprEmitter::EmitCompoundAssign(const CompoundAssignOperator *E,
return RHS;
// Otherwise, reload the value.
return EmitLoadOfLValue(LHS, E->getType());
return EmitLoadOfLValue(LHS);
}
void ScalarExprEmitter::EmitUndefinedBehaviorIntegerDivAndRemCheck(
@ -2262,10 +2259,9 @@ Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) {
// 'An assignment expression has the value of the left operand after
// the assignment...'.
if (LHS.isBitField())
CGF.EmitStoreThroughBitfieldLValue(RValue::get(RHS), LHS, E->getType(),
&RHS);
CGF.EmitStoreThroughBitfieldLValue(RValue::get(RHS), LHS, &RHS);
else
CGF.EmitStoreThroughLValue(RValue::get(RHS), LHS, E->getType());
CGF.EmitStoreThroughLValue(RValue::get(RHS), LHS);
}
// If the result is clearly ignored, return now.
@ -2285,7 +2281,7 @@ Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) {
return RHS;
// Otherwise, reload the value.
return EmitLoadOfLValue(LHS, E->getType());
return EmitLoadOfLValue(LHS);
}
Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
@ -2681,7 +2677,7 @@ LValue CodeGenFunction::EmitObjCIsaExpr(const ObjCIsaExpr *E) {
llvm::Value *Src = EmitScalarExpr(BaseExpr);
Builder.CreateStore(Src, V);
V = ScalarExprEmitter(*this).EmitLoadOfLValue(
MakeAddrLValue(V, E->getType()), E->getType());
MakeAddrLValue(V, E->getType()));
} else {
if (E->isArrow())
V = ScalarExprEmitter(*this).EmitLoadOfLValue(BaseExpr);

Просмотреть файл

@ -466,7 +466,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
}
else {
LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(),
Ivar, 0);
Ivar, 0);
QualType propType = PD->getType();
llvm::Value *value;
@ -478,7 +478,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
PD->getType()->isObjCRetainableType())
value = emitARCRetainLoadOfScalar(*this, LV, IVART);
else
value = EmitLoadOfLValue(LV, IVART).getScalarVal();
value = EmitLoadOfLValue(LV).getScalarVal();
value = Builder.CreateBitCast(value, ConvertType(propType));
}
@ -1141,7 +1141,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
// time through the loop.
if (!elementIsVariable) {
elementLValue = EmitLValue(cast<Expr>(S.getElement()));
EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue, elementType);
EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue);
} else {
EmitScalarInit(CurrentItem, elementLValue);
}
@ -1205,7 +1205,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
llvm::Value *null = llvm::Constant::getNullValue(convertedElementType);
elementLValue = EmitLValue(cast<Expr>(S.getElement()));
EmitStoreThroughLValue(RValue::get(null), elementLValue, elementType);
EmitStoreThroughLValue(RValue::get(null), elementLValue);
}
if (DI) {
@ -1566,9 +1566,10 @@ llvm::Value *CodeGenFunction::EmitARCStoreStrongCall(llvm::Value *addr,
/// Store into a strong object. Sometimes calls this:
/// call void @objc_storeStrong(i8** %addr, i8* %value)
/// Other times, breaks it down into components.
llvm::Value *CodeGenFunction::EmitARCStoreStrong(LValue dst, QualType type,
llvm::Value *CodeGenFunction::EmitARCStoreStrong(LValue dst,
llvm::Value *newValue,
bool ignored) {
QualType type = dst.getType();
bool isBlock = type->isBlockPointerType();
// Use a store barrier at -O0 unless this is a block type or the
@ -1585,15 +1586,11 @@ llvm::Value *CodeGenFunction::EmitARCStoreStrong(LValue dst, QualType type,
newValue = EmitARCRetain(type, newValue);
// Read the old value.
llvm::Value *oldValue =
EmitLoadOfScalar(dst.getAddress(), dst.isVolatileQualified(),
dst.getAlignment(), type, dst.getTBAAInfo());
llvm::Value *oldValue = EmitLoadOfScalar(dst);
// Store. We do this before the release so that any deallocs won't
// see the old value.
EmitStoreOfScalar(newValue, dst.getAddress(),
dst.isVolatileQualified(), dst.getAlignment(),
type, dst.getTBAAInfo());
EmitStoreOfScalar(newValue, dst);
// Finally, release the old value.
EmitARCRelease(oldValue, /*precise*/ false);
@ -2184,7 +2181,7 @@ static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF,
case Qualifiers::OCL_ExplicitNone:
case Qualifiers::OCL_Strong:
case Qualifiers::OCL_Autoreleasing:
return TryEmitResult(CGF.EmitLoadOfLValue(lvalue, type).getScalarVal(),
return TryEmitResult(CGF.EmitLoadOfLValue(lvalue).getScalarVal(),
false);
case Qualifiers::OCL_Weak:
@ -2279,7 +2276,7 @@ tryEmitARCRetainScalarExpr(CodeGenFunction &CGF, const Expr *e) {
// Load the object pointer and cast it to the appropriate type.
QualType exprType = e->getType();
llvm::Value *result = CGF.EmitLoadOfLValue(lv, exprType).getScalarVal();
llvm::Value *result = CGF.EmitLoadOfLValue(lv).getScalarVal();
if (resultType)
result = CGF.Builder.CreateBitCast(result, resultType);
@ -2288,8 +2285,7 @@ tryEmitARCRetainScalarExpr(CodeGenFunction &CGF, const Expr *e) {
llvm::Value *null
= llvm::ConstantPointerNull::get(
cast<llvm::PointerType>(CGF.ConvertType(exprType)));
CGF.EmitStoreOfScalar(null, lv.getAddress(), lv.isVolatileQualified(),
lv.getAlignment(), exprType);
CGF.EmitStoreOfScalar(null, lv);
return TryEmitResult(result, true);
}
@ -2430,7 +2426,7 @@ CodeGenFunction::EmitARCStoreStrong(const BinaryOperator *e,
e->getType(), lvalue.getTBAAInfo());
EmitARCRelease(oldValue, /*precise*/ false);
} else {
value = EmitARCStoreStrong(lvalue, e->getType(), value, ignored);
value = EmitARCStoreStrong(lvalue, value, ignored);
}
return std::pair<LValue,llvm::Value*>(lvalue, value);

Просмотреть файл

@ -1299,7 +1299,7 @@ CodeGenFunction::EmitAsmInputLValue(const AsmStmt &S,
llvm::Value *Arg;
if (Info.allowsRegister() || !Info.allowsMemory()) {
if (!CodeGenFunction::hasAggregateLLVMType(InputType)) {
Arg = EmitLoadOfLValue(InputValue, InputType).getScalarVal();
Arg = EmitLoadOfLValue(InputValue).getScalarVal();
} else {
const llvm::Type *Ty = ConvertType(InputType);
uint64_t Size = CGM.getTargetData().getTypeSizeInBits(Ty);
@ -1637,7 +1637,6 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
}
}
EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i],
ResultRegQualTys[i]);
EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i]);
}
}

Просмотреть файл

@ -1856,6 +1856,11 @@ public:
llvm::Value *EmitLoadOfScalar(llvm::Value *Addr, bool Volatile,
unsigned Alignment, QualType Ty,
llvm::MDNode *TBAAInfo = 0);
/// EmitLoadOfScalar - Load a scalar value from an address, taking
/// care to appropriately convert from the memory representation to
/// the LLVM value representation. The l-value must be a simple
/// l-value.
llvm::Value *EmitLoadOfScalar(LValue lvalue);
/// EmitStoreOfScalar - Store a scalar value to an address, taking
@ -1864,23 +1869,27 @@ public:
void EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr,
bool Volatile, unsigned Alignment, QualType Ty,
llvm::MDNode *TBAAInfo = 0);
/// EmitStoreOfScalar - Store a scalar value to an address, taking
/// care to appropriately convert from the memory representation to
/// the LLVM value representation. The l-value must be a simple
/// l-value.
void EmitStoreOfScalar(llvm::Value *value, LValue lvalue);
/// EmitLoadOfLValue - Given an expression that represents a value lvalue,
/// this method emits the address of the lvalue, then loads the result as an
/// rvalue, returning the rvalue.
RValue EmitLoadOfLValue(LValue V, QualType LVType);
RValue EmitLoadOfExtVectorElementLValue(LValue V, QualType LVType);
RValue EmitLoadOfBitfieldLValue(LValue LV, QualType ExprType);
RValue EmitLoadOfLValue(LValue V);
RValue EmitLoadOfExtVectorElementLValue(LValue V);
RValue EmitLoadOfBitfieldLValue(LValue LV);
RValue EmitLoadOfPropertyRefLValue(LValue LV,
ReturnValueSlot Return = ReturnValueSlot());
/// EmitStoreThroughLValue - Store the specified rvalue into the specified
/// lvalue, where both are guaranteed to the have the same type, and that type
/// is 'Ty'.
void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty);
void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst,
QualType Ty);
void EmitStoreThroughLValue(RValue Src, LValue Dst);
void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst);
void EmitStoreThroughPropertyRefLValue(RValue Src, LValue Dst);
/// EmitStoreThroughLValue - Store Src into Dst with same constraints as
@ -1889,7 +1898,7 @@ public:
/// \param Result [out] - If non-null, this will be set to a Value* for the
/// bit-field contents after the store, appropriate for use as the result of
/// an assignment to the bit-field.
void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, QualType Ty,
void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
llvm::Value **Result=0);
/// Emit an l-value for an assignment (simple or compound) of complex type.
@ -2064,8 +2073,8 @@ public:
void EmitARCMoveWeak(llvm::Value *dst, llvm::Value *src);
llvm::Value *EmitARCRetainAutorelease(QualType type, llvm::Value *value);
llvm::Value *EmitARCRetainAutoreleaseNonBlock(llvm::Value *value);
llvm::Value *EmitARCStoreStrong(LValue addr, QualType type,
llvm::Value *value, bool ignored);
llvm::Value *EmitARCStoreStrong(LValue lvalue, llvm::Value *value,
bool ignored);
llvm::Value *EmitARCStoreStrongCall(llvm::Value *addr, llvm::Value *value,
bool ignored);
llvm::Value *EmitARCRetain(QualType type, llvm::Value *value);