[cfe-commits] r100513 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CGObjCMac.cpp CGRecordLayout.h CGRecordLayoutBuilder.cpp CGValue.h
Daniel Dunbar
daniel at zuster.org
Mon Apr 5 18:07:44 PDT 2010
Author: ddunbar
Date: Mon Apr 5 20:07:44 2010
New Revision: 100513
URL: http://llvm.org/viewvc/llvm-project?rev=100513&view=rev
Log:
IRgen: Move BitFieldIsSigned bit into CGBitFieldInfo.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGRecordLayout.h
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CGValue.h
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=100513&r1=100512&r2=100513&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Apr 5 20:07:44 2010
@@ -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);
}
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=100513&r1=100512&r2=100513&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Apr 5 20:07:44 2010
@@ -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());
}
///
Modified: cfe/trunk/lib/CodeGen/CGRecordLayout.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayout.h?rev=100513&r1=100512&r2=100513&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayout.h (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayout.h Mon Apr 5 20:07:44 2010
@@ -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
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=100513&r1=100512&r2=100513&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Mon Apr 5 20:07:44 2010
@@ -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));
}
Modified: cfe/trunk/lib/CodeGen/CGValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGValue.h?rev=100513&r1=100512&r2=100513&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGValue.h (original)
+++ cfe/trunk/lib/CodeGen/CGValue.h Mon Apr 5 20:07:44 2010
@@ -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;
}
More information about the cfe-commits
mailing list