summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp16
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp6
-rw-r--r--clang/lib/CodeGen/CGRecordLayout.h6
-rw-r--r--clang/lib/CodeGen/CGRecordLayoutBuilder.cpp7
-rw-r--r--clang/lib/CodeGen/CGValue.h10
5 files changed, 22 insertions, 23 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index eb848331ece..0aa4438f4f4 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -605,8 +605,9 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV,
QualType ExprType) {
- unsigned StartBit = LV.getBitFieldInfo().Start;
- unsigned BitfieldSize = LV.getBitFieldInfo().Size;
+ const CGBitFieldInfo &Info = LV.getBitFieldInfo();
+ unsigned StartBit = Info.Start;
+ unsigned BitfieldSize = Info.Size;
llvm::Value *Ptr = LV.getBitFieldAddr();
const llvm::Type *EltTy =
@@ -650,7 +651,7 @@ RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV,
}
// Sign extend if necessary.
- if (LV.isBitFieldSigned()) {
+ if (Info.IsSigned) {
llvm::Value *ExtraBits = llvm::ConstantInt::get(EltTy,
EltTySize - BitfieldSize);
Val = Builder.CreateAShr(Builder.CreateShl(Val, ExtraBits),
@@ -781,8 +782,9 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
QualType Ty,
llvm::Value **Result) {
- unsigned StartBit = Dst.getBitFieldInfo().Start;
- unsigned BitfieldSize = Dst.getBitFieldInfo().Size;
+ const CGBitFieldInfo &Info = Dst.getBitFieldInfo();
+ unsigned StartBit = Info.Start;
+ unsigned BitfieldSize = Info.Size;
llvm::Value *Ptr = Dst.getBitFieldAddr();
const llvm::Type *EltTy =
@@ -805,7 +807,7 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
"bf.reload.val");
// Sign extend if necessary.
- if (Dst.isBitFieldSigned()) {
+ if (Info.IsSigned) {
unsigned SrcTySize = CGM.getTargetData().getTypeSizeInBits(SrcTy);
llvm::Value *ExtraBits = llvm::ConstantInt::get(SrcTy,
SrcTySize - BitfieldSize);
@@ -1484,7 +1486,7 @@ LValue CodeGenFunction::EmitLValueForBitfield(llvm::Value* BaseValue,
llvm::PointerType::get(FieldTy, AS));
llvm::Value *V = Builder.CreateConstGEP1_32(BaseValue, Info.FieldNo);
- return LValue::MakeBitfield(V, Info, Field->getType()->isSignedIntegerType(),
+ return LValue::MakeBitfield(V, Info,
Field->getType().getCVRQualifiers()|CVRQualifiers);
}
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 467ad43bb25..ac8fa057a0e 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -126,12 +126,12 @@ LValue CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF,
// objects.
unsigned FieldNo = 0; // This value is unused.
CGBitFieldInfo *Info =
- new (CGF.CGM.getContext()) CGBitFieldInfo(FieldNo, BitOffset, BitFieldSize);
+ new (CGF.CGM.getContext()) CGBitFieldInfo(FieldNo, BitOffset, BitFieldSize,
+ IvarTy->isSignedIntegerType());
// FIXME: We need to set a very conservative alignment on this, or make sure
// that the runtime is doing the right thing.
- return LValue::MakeBitfield(V, *Info, IvarTy->isSignedIntegerType(),
- Quals.getCVRQualifiers());
+ return LValue::MakeBitfield(V, *Info, Quals.getCVRQualifiers());
}
///
diff --git a/clang/lib/CodeGen/CGRecordLayout.h b/clang/lib/CodeGen/CGRecordLayout.h
index 5e2abb1bb38..fd1775ea5e6 100644
--- a/clang/lib/CodeGen/CGRecordLayout.h
+++ b/clang/lib/CodeGen/CGRecordLayout.h
@@ -21,12 +21,14 @@ namespace CodeGen {
class CGBitFieldInfo {
public:
- CGBitFieldInfo(unsigned FieldNo, unsigned Start, unsigned Size)
- : FieldNo(FieldNo), Start(Start), Size(Size) {}
+ CGBitFieldInfo(unsigned FieldNo, unsigned Start, unsigned Size,
+ bool IsSigned)
+ : FieldNo(FieldNo), Start(Start), Size(Size), IsSigned(IsSigned) {}
unsigned FieldNo;
unsigned Start;
unsigned Size;
+ bool IsSigned : 1;
};
/// CGRecordLayout - This class handles struct and union layout info while
diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
index e6aa320d81a..4b9ec66e178 100644
--- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -178,10 +178,11 @@ void CGRecordLayoutBuilder::LayoutBitField(const FieldDecl *D,
const llvm::Type *Ty = Types.ConvertTypeForMemRecursive(D->getType());
uint64_t TypeSizeInBits = getTypeSizeInBytes(Ty) * 8;
+ bool IsSigned = D->getType()->isSignedIntegerType();
LLVMBitFields.push_back(LLVMBitFieldInfo(
D, CGBitFieldInfo(FieldOffset / TypeSizeInBits,
FieldOffset % TypeSizeInBits,
- FieldSize)));
+ FieldSize, IsSigned)));
AppendBytes(NumBytesToAppend);
@@ -279,8 +280,10 @@ void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) {
continue;
// Add the bit field info.
+ bool IsSigned = Field->getType()->isSignedIntegerType();
LLVMBitFields.push_back(LLVMBitFieldInfo(
- *Field, CGBitFieldInfo(0, 0, FieldSize)));
+ *Field, CGBitFieldInfo(0, 0, FieldSize,
+ IsSigned)));
} else {
LLVMFields.push_back(LLVMFieldInfo(*Field, 0));
}
diff --git a/clang/lib/CodeGen/CGValue.h b/clang/lib/CodeGen/CGValue.h
index 465ea769137..91fb714315f 100644
--- a/clang/lib/CodeGen/CGValue.h
+++ b/clang/lib/CodeGen/CGValue.h
@@ -154,9 +154,6 @@ class LValue {
// Lvalue is a global reference of an objective-c object
bool GlobalObjCRef : 1;
- /// Is the bit-field value signed.
- bool BitFieldIsSigned : 1;
-
Expr *BaseIvarExp;
private:
void SetQualifiers(Qualifiers Quals) {
@@ -231,10 +228,6 @@ public:
assert(isBitField());
return *BitFieldInfo;
}
- bool isBitFieldSigned() const {
- assert(isBitField());
- return BitFieldIsSigned;
- }
// property ref lvalue
const ObjCPropertyRefExpr *getPropertyRefExpr() const {
@@ -277,12 +270,11 @@ public:
}
static LValue MakeBitfield(llvm::Value *V, const CGBitFieldInfo &Info,
- bool IsSigned, unsigned CVR) {
+ unsigned CVR) {
LValue R;
R.LVType = BitField;
R.V = V;
R.BitFieldInfo = &Info;
- R.BitFieldIsSigned = IsSigned;
R.SetQualifiers(Qualifiers::fromCVRMask(CVR));
return R;
}
OpenPOWER on IntegriCloud