forked from OSchip/llvm-project
IRgen: Move BitFieldIsSigned bit into CGBitFieldInfo.
llvm-svn: 100513
This commit is contained in:
parent
d45491077a
commit
196ea449ed
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
///
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue