mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-05 13:09:10 +00:00
Add a few (as yet unused) query methods to determine if the attribute that's
stored here is of a certain kind. This is in preparation for when an Attribute object represents a single attribute, instead of a bitmask of attributes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171247 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b4912b9dcc
commit
529ec718ac
@ -34,6 +34,9 @@ class AttributeImpl : public FoldingSetNode {
|
||||
public:
|
||||
AttributeImpl(LLVMContext &C, uint64_t data);
|
||||
|
||||
bool contains(Attribute::AttrKind Kind) const;
|
||||
bool contains(StringRef Kind) const;
|
||||
|
||||
bool hasAttribute(uint64_t A) const;
|
||||
|
||||
bool hasAttributes() const;
|
||||
@ -42,6 +45,20 @@ public:
|
||||
uint64_t getAlignment() const;
|
||||
uint64_t getStackAlignment() const;
|
||||
|
||||
bool operator==(Attribute::AttrKind Kind) const {
|
||||
return contains(Kind);
|
||||
}
|
||||
bool operator!=(Attribute::AttrKind Kind) const {
|
||||
return !contains(Kind);
|
||||
}
|
||||
|
||||
bool operator==(StringRef Kind) const {
|
||||
return contains(Kind);
|
||||
}
|
||||
bool operator!=(StringRef Kind) const {
|
||||
return !contains(Kind);
|
||||
}
|
||||
|
||||
uint64_t getBitMask() const; // FIXME: Remove.
|
||||
|
||||
static uint64_t getAttrMask(uint64_t Val);
|
||||
|
@ -302,7 +302,21 @@ AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data) {
|
||||
Data = ConstantInt::get(Type::getInt64Ty(C), data);
|
||||
}
|
||||
|
||||
bool AttributeImpl::contains(Attribute::AttrKind Kind) const {
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))
|
||||
return CI->getZExtValue() == Kind;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AttributeImpl::contains(StringRef Kind) const {
|
||||
if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data))
|
||||
if (CDA->isString())
|
||||
return CDA->getAsString() == Kind;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t AttributeImpl::getBitMask() const {
|
||||
// FIXME: Remove this.
|
||||
return cast<ConstantInt>(Data)->getZExtValue();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user