Use a 'Constant' object instead of a bit field to store the attribute data.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171221 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/VMCore/AttributeImpl.h b/lib/VMCore/AttributeImpl.h
index e27a029..3b8f818 100644
--- a/lib/VMCore/AttributeImpl.h
+++ b/lib/VMCore/AttributeImpl.h
@@ -21,6 +21,7 @@
namespace llvm {
+class Constant;
class LLVMContext;
//===----------------------------------------------------------------------===//
@@ -29,9 +30,9 @@
/// 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 @@
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);
+ Profile(ID, Data);
}
- static void Profile(FoldingSetNodeID &ID, uint64_t Bits) {
- ID.AddInteger(Bits);
- }
+ static void Profile(FoldingSetNodeID &ID, Constant *Data);
};
//===----------------------------------------------------------------------===//
diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp
index 3a59357..c85e5fe 100644
--- a/lib/VMCore/Attributes.cpp
+++ b/lib/VMCore/Attributes.cpp
@@ -53,7 +53,7 @@
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 @@
// 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 @@
return Raw() & getAttrMask(Attribute::StackAlignment);
}
+void AttributeImpl::Profile(FoldingSetNodeID &ID, Constant *Data) {
+ ID.AddInteger(cast<ConstantInt>(Data)->getZExtValue());
+}
+
//===----------------------------------------------------------------------===//
// AttributeSetImpl Definition
//===----------------------------------------------------------------------===//