summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-08-21 02:39:23 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-08-21 02:39:23 +0000
commite3b8dd433cf0dd2a9e380a4351d0286302801e14 (patch)
tree6101323d8540ac05b7de5a2d34b3d2eb80a5aefc
parent42ef669d815fd9745cbd0c06e573052647cd16b3 (diff)
downloadbcm5719-llvm-e3b8dd433cf0dd2a9e380a4351d0286302801e14.tar.gz
bcm5719-llvm-e3b8dd433cf0dd2a9e380a4351d0286302801e14.zip
IRgen/CGValue: Add alignment to LValue, and use that alignment when generating lvalue load/stores.
llvm-svn: 111710
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp7
-rw-r--r--clang/lib/CodeGen/CGValue.h19
2 files changed, 15 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 1d686be19c4..f0eec037557 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -635,11 +635,9 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
// Simple scalar l-value.
//
// FIXME: We shouldn't have to use isSingleValueType here.
- //
- // FIXME: Pass alignment!
if (EltTy->isSingleValueType())
return RValue::get(EmitLoadOfScalar(Ptr, LV.isVolatileQualified(),
- /*Alignment=*/0, ExprType));
+ LV.getAlignment(), ExprType));
assert(ExprType->isFunctionType() && "Unknown scalar value");
return RValue::get(Ptr);
@@ -849,9 +847,8 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
}
assert(Src.isScalar() && "Can't emit an agg store with this method");
- // FIXME: Pass alignment.
EmitStoreOfScalar(Src.getScalarVal(), Dst.getAddress(),
- Dst.isVolatileQualified(), /*Alignment=*/0, Ty);
+ Dst.isVolatileQualified(), Dst.getAlignment(), Ty);
}
void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
diff --git a/clang/lib/CodeGen/CGValue.h b/clang/lib/CodeGen/CGValue.h
index 917a194b389..a1bd193f9e2 100644
--- a/clang/lib/CodeGen/CGValue.h
+++ b/clang/lib/CodeGen/CGValue.h
@@ -136,6 +136,9 @@ class LValue {
// 'const' is unused here
Qualifiers Quals;
+ /// The alignment to use when accessing this lvalue.
+ unsigned char Alignment;
+
// objective-c's ivar
bool Ivar:1;
@@ -154,11 +157,12 @@ class LValue {
Expr *BaseIvarExp;
private:
- void Initialize(Qualifiers Quals) {
+ void Initialize(Qualifiers Quals, unsigned Alignment = 0) {
this->Quals = Quals;
-
- // FIXME: Convenient place to set objc flags to 0. This should really be
- // done in a user-defined constructor instead.
+ this->Alignment = Alignment;
+ assert(this->Alignment == Alignment && "Alignment exceeds allowed max!");
+
+ // Initialize Objective-C flags.
this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef = false;
this->ThreadLocalRef = false;
this->BaseIvarExp = 0;
@@ -191,6 +195,8 @@ public:
unsigned getAddressSpace() const { return Quals.getAddressSpace(); }
+ unsigned getAlignment() const { return Alignment; }
+
static void SetObjCIvar(LValue& R, bool iValue) {
R.Ivar = iValue;
}
@@ -243,11 +249,12 @@ public:
return KVCRefExpr;
}
- static LValue MakeAddr(llvm::Value *V, Qualifiers Quals) {
+ static LValue MakeAddr(llvm::Value *V, Qualifiers Quals,
+ unsigned Alignment = 0) {
LValue R;
R.LVType = Simple;
R.V = V;
- R.Initialize(Quals);
+ R.Initialize(Quals, Alignment);
return R;
}
OpenPOWER on IntegriCloud