mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 10:06:05 +00:00
Rename AlignAttribute to IntAttribute
Currently the only kind of integer IR attributes that we have are alignment attributes, and so the attribute kind that takes an integer parameter is called AlignAttr, but that will change (we'll soon be adding a dereferenceable attribute that also takes an integer value). Accordingly, rename AlignAttribute to IntAttribute (class names, enums, etc.). No functionality change intended. llvm-svn: 213352
This commit is contained in:
parent
3dd43fc75d
commit
e15442c8aa
@ -141,8 +141,8 @@ public:
|
|||||||
/// \brief Return true if the attribute is an Attribute::AttrKind type.
|
/// \brief Return true if the attribute is an Attribute::AttrKind type.
|
||||||
bool isEnumAttribute() const;
|
bool isEnumAttribute() const;
|
||||||
|
|
||||||
/// \brief Return true if the attribute is an alignment attribute.
|
/// \brief Return true if the attribute is an integer attribute.
|
||||||
bool isAlignAttribute() const;
|
bool isIntAttribute() const;
|
||||||
|
|
||||||
/// \brief Return true if the attribute is a string (target-dependent)
|
/// \brief Return true if the attribute is a string (target-dependent)
|
||||||
/// attribute.
|
/// attribute.
|
||||||
|
@ -683,7 +683,7 @@ std::error_code BitcodeReader::ParseAttributeGroupBlock() {
|
|||||||
return EC;
|
return EC;
|
||||||
|
|
||||||
B.addAttribute(Kind);
|
B.addAttribute(Kind);
|
||||||
} else if (Record[i] == 1) { // Align attribute
|
} else if (Record[i] == 1) { // Integer attribute
|
||||||
Attribute::AttrKind Kind;
|
Attribute::AttrKind Kind;
|
||||||
if (std::error_code EC = ParseAttrKind(Record[++i], &Kind))
|
if (std::error_code EC = ParseAttrKind(Record[++i], &Kind))
|
||||||
return EC;
|
return EC;
|
||||||
|
@ -272,7 +272,7 @@ static void WriteAttributeGroupTable(const ValueEnumerator &VE,
|
|||||||
if (Attr.isEnumAttribute()) {
|
if (Attr.isEnumAttribute()) {
|
||||||
Record.push_back(0);
|
Record.push_back(0);
|
||||||
Record.push_back(getAttrKindEncoding(Attr.getKindAsEnum()));
|
Record.push_back(getAttrKindEncoding(Attr.getKindAsEnum()));
|
||||||
} else if (Attr.isAlignAttribute()) {
|
} else if (Attr.isIntAttribute()) {
|
||||||
Record.push_back(1);
|
Record.push_back(1);
|
||||||
Record.push_back(getAttrKindEncoding(Attr.getKindAsEnum()));
|
Record.push_back(getAttrKindEncoding(Attr.getKindAsEnum()));
|
||||||
Record.push_back(Attr.getValueAsInt());
|
Record.push_back(Attr.getValueAsInt());
|
||||||
|
@ -39,7 +39,7 @@ class AttributeImpl : public FoldingSetNode {
|
|||||||
protected:
|
protected:
|
||||||
enum AttrEntryKind {
|
enum AttrEntryKind {
|
||||||
EnumAttrEntry,
|
EnumAttrEntry,
|
||||||
AlignAttrEntry,
|
IntAttrEntry,
|
||||||
StringAttrEntry
|
StringAttrEntry
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public:
|
|||||||
virtual ~AttributeImpl();
|
virtual ~AttributeImpl();
|
||||||
|
|
||||||
bool isEnumAttribute() const { return KindID == EnumAttrEntry; }
|
bool isEnumAttribute() const { return KindID == EnumAttrEntry; }
|
||||||
bool isAlignAttribute() const { return KindID == AlignAttrEntry; }
|
bool isIntAttribute() const { return KindID == IntAttrEntry; }
|
||||||
bool isStringAttribute() const { return KindID == StringAttrEntry; }
|
bool isStringAttribute() const { return KindID == StringAttrEntry; }
|
||||||
|
|
||||||
bool hasAttribute(Attribute::AttrKind A) const;
|
bool hasAttribute(Attribute::AttrKind A) const;
|
||||||
@ -67,7 +67,7 @@ public:
|
|||||||
void Profile(FoldingSetNodeID &ID) const {
|
void Profile(FoldingSetNodeID &ID) const {
|
||||||
if (isEnumAttribute())
|
if (isEnumAttribute())
|
||||||
Profile(ID, getKindAsEnum(), 0);
|
Profile(ID, getKindAsEnum(), 0);
|
||||||
else if (isAlignAttribute())
|
else if (isIntAttribute())
|
||||||
Profile(ID, getKindAsEnum(), getValueAsInt());
|
Profile(ID, getKindAsEnum(), getValueAsInt());
|
||||||
else
|
else
|
||||||
Profile(ID, getKindAsString(), getValueAsString());
|
Profile(ID, getKindAsString(), getValueAsString());
|
||||||
@ -108,19 +108,19 @@ public:
|
|||||||
Attribute::AttrKind getEnumKind() const { return Kind; }
|
Attribute::AttrKind getEnumKind() const { return Kind; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class AlignAttributeImpl : public EnumAttributeImpl {
|
class IntAttributeImpl : public EnumAttributeImpl {
|
||||||
void anchor() override;
|
void anchor() override;
|
||||||
unsigned Align;
|
uint64_t Val;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AlignAttributeImpl(Attribute::AttrKind Kind, unsigned Align)
|
IntAttributeImpl(Attribute::AttrKind Kind, uint64_t Val)
|
||||||
: EnumAttributeImpl(AlignAttrEntry, Kind), Align(Align) {
|
: EnumAttributeImpl(IntAttrEntry, Kind), Val(Val) {
|
||||||
assert(
|
assert(
|
||||||
(Kind == Attribute::Alignment || Kind == Attribute::StackAlignment) &&
|
(Kind == Attribute::Alignment || Kind == Attribute::StackAlignment) &&
|
||||||
"Wrong kind for alignment attribute!");
|
"Wrong kind for int attribute!");
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getAlignment() const { return Align; }
|
uint64_t getValue() const { return Val; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class StringAttributeImpl : public AttributeImpl {
|
class StringAttributeImpl : public AttributeImpl {
|
||||||
|
@ -47,7 +47,7 @@ Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
|
|||||||
if (!Val)
|
if (!Val)
|
||||||
PA = new EnumAttributeImpl(Kind);
|
PA = new EnumAttributeImpl(Kind);
|
||||||
else
|
else
|
||||||
PA = new AlignAttributeImpl(Kind, Val);
|
PA = new IntAttributeImpl(Kind, Val);
|
||||||
pImpl->AttrsSet.InsertNode(PA, InsertPoint);
|
pImpl->AttrsSet.InsertNode(PA, InsertPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,8 +96,8 @@ bool Attribute::isEnumAttribute() const {
|
|||||||
return pImpl && pImpl->isEnumAttribute();
|
return pImpl && pImpl->isEnumAttribute();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attribute::isAlignAttribute() const {
|
bool Attribute::isIntAttribute() const {
|
||||||
return pImpl && pImpl->isAlignAttribute();
|
return pImpl && pImpl->isIntAttribute();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attribute::isStringAttribute() const {
|
bool Attribute::isStringAttribute() const {
|
||||||
@ -106,15 +106,15 @@ bool Attribute::isStringAttribute() const {
|
|||||||
|
|
||||||
Attribute::AttrKind Attribute::getKindAsEnum() const {
|
Attribute::AttrKind Attribute::getKindAsEnum() const {
|
||||||
if (!pImpl) return None;
|
if (!pImpl) return None;
|
||||||
assert((isEnumAttribute() || isAlignAttribute()) &&
|
assert((isEnumAttribute() || isIntAttribute()) &&
|
||||||
"Invalid attribute type to get the kind as an enum!");
|
"Invalid attribute type to get the kind as an enum!");
|
||||||
return pImpl ? pImpl->getKindAsEnum() : None;
|
return pImpl ? pImpl->getKindAsEnum() : None;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Attribute::getValueAsInt() const {
|
uint64_t Attribute::getValueAsInt() const {
|
||||||
if (!pImpl) return 0;
|
if (!pImpl) return 0;
|
||||||
assert(isAlignAttribute() &&
|
assert(isIntAttribute() &&
|
||||||
"Expected the attribute to be an alignment attribute!");
|
"Expected the attribute to be an integer attribute!");
|
||||||
return pImpl ? pImpl->getValueAsInt() : 0;
|
return pImpl ? pImpl->getValueAsInt() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ bool Attribute::operator<(Attribute A) const {
|
|||||||
// Pin the vtables to this file.
|
// Pin the vtables to this file.
|
||||||
AttributeImpl::~AttributeImpl() {}
|
AttributeImpl::~AttributeImpl() {}
|
||||||
void EnumAttributeImpl::anchor() {}
|
void EnumAttributeImpl::anchor() {}
|
||||||
void AlignAttributeImpl::anchor() {}
|
void IntAttributeImpl::anchor() {}
|
||||||
void StringAttributeImpl::anchor() {}
|
void StringAttributeImpl::anchor() {}
|
||||||
|
|
||||||
bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
|
bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
|
||||||
@ -310,13 +310,13 @@ bool AttributeImpl::hasAttribute(StringRef Kind) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Attribute::AttrKind AttributeImpl::getKindAsEnum() const {
|
Attribute::AttrKind AttributeImpl::getKindAsEnum() const {
|
||||||
assert(isEnumAttribute() || isAlignAttribute());
|
assert(isEnumAttribute() || isIntAttribute());
|
||||||
return static_cast<const EnumAttributeImpl *>(this)->getEnumKind();
|
return static_cast<const EnumAttributeImpl *>(this)->getEnumKind();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t AttributeImpl::getValueAsInt() const {
|
uint64_t AttributeImpl::getValueAsInt() const {
|
||||||
assert(isAlignAttribute());
|
assert(isIntAttribute());
|
||||||
return static_cast<const AlignAttributeImpl *>(this)->getAlignment();
|
return static_cast<const IntAttributeImpl *>(this)->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef AttributeImpl::getKindAsString() const {
|
StringRef AttributeImpl::getKindAsString() const {
|
||||||
@ -334,18 +334,18 @@ bool AttributeImpl::operator<(const AttributeImpl &AI) const {
|
|||||||
// relative to their enum value) and then strings.
|
// relative to their enum value) and then strings.
|
||||||
if (isEnumAttribute()) {
|
if (isEnumAttribute()) {
|
||||||
if (AI.isEnumAttribute()) return getKindAsEnum() < AI.getKindAsEnum();
|
if (AI.isEnumAttribute()) return getKindAsEnum() < AI.getKindAsEnum();
|
||||||
if (AI.isAlignAttribute()) return true;
|
if (AI.isIntAttribute()) return true;
|
||||||
if (AI.isStringAttribute()) return true;
|
if (AI.isStringAttribute()) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAlignAttribute()) {
|
if (isIntAttribute()) {
|
||||||
if (AI.isEnumAttribute()) return false;
|
if (AI.isEnumAttribute()) return false;
|
||||||
if (AI.isAlignAttribute()) return getValueAsInt() < AI.getValueAsInt();
|
if (AI.isIntAttribute()) return getValueAsInt() < AI.getValueAsInt();
|
||||||
if (AI.isStringAttribute()) return true;
|
if (AI.isStringAttribute()) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AI.isEnumAttribute()) return false;
|
if (AI.isEnumAttribute()) return false;
|
||||||
if (AI.isAlignAttribute()) return false;
|
if (AI.isIntAttribute()) return false;
|
||||||
if (getKindAsString() == AI.getKindAsString())
|
if (getKindAsString() == AI.getKindAsString())
|
||||||
return getValueAsString() < AI.getValueAsString();
|
return getValueAsString() < AI.getValueAsString();
|
||||||
return getKindAsString() < AI.getKindAsString();
|
return getKindAsString() < AI.getKindAsString();
|
||||||
@ -1029,7 +1029,7 @@ AttrBuilder &AttrBuilder::removeAttributes(AttributeSet A, uint64_t Index) {
|
|||||||
|
|
||||||
for (AttributeSet::iterator I = A.begin(Slot), E = A.end(Slot); I != E; ++I) {
|
for (AttributeSet::iterator I = A.begin(Slot), E = A.end(Slot); I != E; ++I) {
|
||||||
Attribute Attr = *I;
|
Attribute Attr = *I;
|
||||||
if (Attr.isEnumAttribute() || Attr.isAlignAttribute()) {
|
if (Attr.isEnumAttribute() || Attr.isIntAttribute()) {
|
||||||
Attribute::AttrKind Kind = I->getKindAsEnum();
|
Attribute::AttrKind Kind = I->getKindAsEnum();
|
||||||
Attrs[Kind] = false;
|
Attrs[Kind] = false;
|
||||||
|
|
||||||
@ -1117,7 +1117,7 @@ bool AttrBuilder::hasAttributes(AttributeSet A, uint64_t Index) const {
|
|||||||
for (AttributeSet::iterator I = A.begin(Slot), E = A.end(Slot);
|
for (AttributeSet::iterator I = A.begin(Slot), E = A.end(Slot);
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
Attribute Attr = *I;
|
Attribute Attr = *I;
|
||||||
if (Attr.isEnumAttribute() || Attr.isAlignAttribute()) {
|
if (Attr.isEnumAttribute() || Attr.isIntAttribute()) {
|
||||||
if (Attrs[I->getKindAsEnum()])
|
if (Attrs[I->getKindAsEnum()])
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user