IRgen: Move BitFieldIsSigned bit into CGBitFieldInfo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100513 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index eb84833..0aa4438 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -605,8 +605,9 @@
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 @@
}
// 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::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 @@
"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 @@
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/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 467ad43..ac8fa05 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -126,12 +126,12 @@
// 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/lib/CodeGen/CGRecordLayout.h b/lib/CodeGen/CGRecordLayout.h
index 5e2abb1..fd1775e 100644
--- a/lib/CodeGen/CGRecordLayout.h
+++ b/lib/CodeGen/CGRecordLayout.h
@@ -21,12 +21,14 @@
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/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp
index e6aa320..4b9ec66 100644
--- a/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -178,10 +178,11 @@
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 @@
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/lib/CodeGen/CGValue.h b/lib/CodeGen/CGValue.h
index 465ea76..91fb714 100644
--- a/lib/CodeGen/CGValue.h
+++ b/lib/CodeGen/CGValue.h
@@ -154,9 +154,6 @@
// 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 @@
assert(isBitField());
return *BitFieldInfo;
}
- bool isBitFieldSigned() const {
- assert(isBitField());
- return BitFieldIsSigned;
- }
// property ref lvalue
const ObjCPropertyRefExpr *getPropertyRefExpr() const {
@@ -277,12 +270,11 @@
}
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;
}