forked from OSchip/llvm-project
Use a 'Constant' object instead of a bit field to store the attribute data.
llvm-svn: 171221
This commit is contained in:
parent
4fdde84613
commit
0cd0f7f832
|
@ -21,6 +21,7 @@
|
|||
|
||||
namespace llvm {
|
||||
|
||||
class Constant;
|
||||
class LLVMContext;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -29,9 +30,9 @@ class LLVMContext;
|
|||
/// could be a single enum, a tuple, or a string. It uses a discriminated union
|
||||
/// to distinguish them.
|
||||
class AttributeImpl : public FoldingSetNode {
|
||||
uint64_t Bits; // FIXME: We will be expanding this.
|
||||
Constant *Data;
|
||||
public:
|
||||
AttributeImpl(uint64_t bits) : Bits(bits) {}
|
||||
AttributeImpl(LLVMContext &C, uint64_t data);
|
||||
|
||||
bool hasAttribute(uint64_t A) const;
|
||||
|
||||
|
@ -41,16 +42,14 @@ public:
|
|||
uint64_t getAlignment() const;
|
||||
uint64_t getStackAlignment() const;
|
||||
|
||||
uint64_t Raw() const { return Bits; } // FIXME: Remove.
|
||||
uint64_t Raw() const; // FIXME: Remove.
|
||||
|
||||
static uint64_t getAttrMask(uint64_t Val);
|
||||
|
||||
void Profile(FoldingSetNodeID &ID) const {
|
||||
Profile(ID, Bits);
|
||||
}
|
||||
static void Profile(FoldingSetNodeID &ID, uint64_t Bits) {
|
||||
ID.AddInteger(Bits);
|
||||
Profile(ID, Data);
|
||||
}
|
||||
static void Profile(FoldingSetNodeID &ID, Constant *Data);
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -53,7 +53,7 @@ Attribute Attribute::get(LLVMContext &Context, AttrBuilder &B) {
|
|||
if (!PA) {
|
||||
// If we didn't find any existing attributes of the same shape then create a
|
||||
// new one and insert it.
|
||||
PA = new AttributeImpl(B.Raw());
|
||||
PA = new AttributeImpl(Context, B.Raw());
|
||||
pImpl->AttrsSet.InsertNode(PA, InsertPoint);
|
||||
}
|
||||
|
||||
|
@ -298,6 +298,14 @@ uint64_t AttrBuilder::getStackAlignment() const {
|
|||
// AttributeImpl Definition
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data) {
|
||||
Data = ConstantInt::get(Type::getInt64Ty(C), data);
|
||||
}
|
||||
|
||||
uint64_t AttributeImpl::Raw() const {
|
||||
return cast<ConstantInt>(Data)->getZExtValue();
|
||||
}
|
||||
|
||||
uint64_t AttributeImpl::getAttrMask(uint64_t Val) {
|
||||
switch (Val) {
|
||||
case Attribute::None: return 0;
|
||||
|
@ -354,6 +362,10 @@ uint64_t AttributeImpl::getStackAlignment() const {
|
|||
return Raw() & getAttrMask(Attribute::StackAlignment);
|
||||
}
|
||||
|
||||
void AttributeImpl::Profile(FoldingSetNodeID &ID, Constant *Data) {
|
||||
ID.AddInteger(cast<ConstantInt>(Data)->getZExtValue());
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// AttributeSetImpl Definition
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
Loading…
Reference in New Issue