1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Use a 'Constant' object instead of a bit field to store the attribute data.

llvm-svn: 171221
This commit is contained in:
Bill Wendling 2012-12-29 12:29:38 +00:00
parent 7721e04b74
commit 284a1ee5ba
2 changed files with 19 additions and 8 deletions

View File

@ -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);
};
//===----------------------------------------------------------------------===//

View File

@ -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
//===----------------------------------------------------------------------===//