llvm.org GIT mirror llvm / d026168
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213352 91177308-0d34-0410-b5e6-96231b3b80d8 Hal Finkel 5 years ago
5 changed file(s) with 33 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
140140 /// \brief Return true if the attribute is an Attribute::AttrKind type.
141141 bool isEnumAttribute() const;
142142
143 /// \brief Return true if the attribute is an alignment attribute.
144 bool isAlignAttribute() const;
143 /// \brief Return true if the attribute is an integer attribute.
144 bool isIntAttribute() const;
145145
146146 /// \brief Return true if the attribute is a string (target-dependent)
147147 /// attribute.
682682 return EC;
683683
684684 B.addAttribute(Kind);
685 } else if (Record[i] == 1) { // Align attribute
685 } else if (Record[i] == 1) { // Integer attribute
686686 Attribute::AttrKind Kind;
687687 if (std::error_code EC = ParseAttrKind(Record[++i], &Kind))
688688 return EC;
271271 if (Attr.isEnumAttribute()) {
272272 Record.push_back(0);
273273 Record.push_back(getAttrKindEncoding(Attr.getKindAsEnum()));
274 } else if (Attr.isAlignAttribute()) {
274 } else if (Attr.isIntAttribute()) {
275275 Record.push_back(1);
276276 Record.push_back(getAttrKindEncoding(Attr.getKindAsEnum()));
277277 Record.push_back(Attr.getValueAsInt());
3838 protected:
3939 enum AttrEntryKind {
4040 EnumAttrEntry,
41 AlignAttrEntry,
41 IntAttrEntry,
4242 StringAttrEntry
4343 };
4444
4848 virtual ~AttributeImpl();
4949
5050 bool isEnumAttribute() const { return KindID == EnumAttrEntry; }
51 bool isAlignAttribute() const { return KindID == AlignAttrEntry; }
51 bool isIntAttribute() const { return KindID == IntAttrEntry; }
5252 bool isStringAttribute() const { return KindID == StringAttrEntry; }
5353
5454 bool hasAttribute(Attribute::AttrKind A) const;
6666 void Profile(FoldingSetNodeID &ID) const {
6767 if (isEnumAttribute())
6868 Profile(ID, getKindAsEnum(), 0);
69 else if (isAlignAttribute())
69 else if (isIntAttribute())
7070 Profile(ID, getKindAsEnum(), getValueAsInt());
7171 else
7272 Profile(ID, getKindAsString(), getValueAsString());
107107 Attribute::AttrKind getEnumKind() const { return Kind; }
108108 };
109109
110 class AlignAttributeImpl : public EnumAttributeImpl {
110 class IntAttributeImpl : public EnumAttributeImpl {
111111 void anchor() override;
112 unsigned Align;
113
114 public:
115 AlignAttributeImpl(Attribute::AttrKind Kind, unsigned Align)
116 : EnumAttributeImpl(AlignAttrEntry, Kind), Align(Align) {
112 uint64_t Val;
113
114 public:
115 IntAttributeImpl(Attribute::AttrKind Kind, uint64_t Val)
116 : EnumAttributeImpl(IntAttrEntry, Kind), Val(Val) {
117117 assert(
118118 (Kind == Attribute::Alignment || Kind == Attribute::StackAlignment) &&
119 "Wrong kind for alignment attribute!");
120 }
121
122 unsigned getAlignment() const { return Align; }
119 "Wrong kind for int attribute!");
120 }
121
122 uint64_t getValue() const { return Val; }
123123 };
124124
125125 class StringAttributeImpl : public AttributeImpl {
4646 if (!Val)
4747 PA = new EnumAttributeImpl(Kind);
4848 else
49 PA = new AlignAttributeImpl(Kind, Val);
49 PA = new IntAttributeImpl(Kind, Val);
5050 pImpl->AttrsSet.InsertNode(PA, InsertPoint);
5151 }
5252
9595 return pImpl && pImpl->isEnumAttribute();
9696 }
9797
98 bool Attribute::isAlignAttribute() const {
99 return pImpl && pImpl->isAlignAttribute();
98 bool Attribute::isIntAttribute() const {
99 return pImpl && pImpl->isIntAttribute();
100100 }
101101
102102 bool Attribute::isStringAttribute() const {
105105
106106 Attribute::AttrKind Attribute::getKindAsEnum() const {
107107 if (!pImpl) return None;
108 assert((isEnumAttribute() || isAlignAttribute()) &&
108 assert((isEnumAttribute() || isIntAttribute()) &&
109109 "Invalid attribute type to get the kind as an enum!");
110110 return pImpl ? pImpl->getKindAsEnum() : None;
111111 }
112112
113113 uint64_t Attribute::getValueAsInt() const {
114114 if (!pImpl) return 0;
115 assert(isAlignAttribute() &&
116 "Expected the attribute to be an alignment attribute!");
115 assert(isIntAttribute() &&
116 "Expected the attribute to be an integer attribute!");
117117 return pImpl ? pImpl->getValueAsInt() : 0;
118118 }
119119
295295 // Pin the vtables to this file.
296296 AttributeImpl::~AttributeImpl() {}
297297 void EnumAttributeImpl::anchor() {}
298 void AlignAttributeImpl::anchor() {}
298 void IntAttributeImpl::anchor() {}
299299 void StringAttributeImpl::anchor() {}
300300
301301 bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
309309 }
310310
311311 Attribute::AttrKind AttributeImpl::getKindAsEnum() const {
312 assert(isEnumAttribute() || isAlignAttribute());
312 assert(isEnumAttribute() || isIntAttribute());
313313 return static_cast(this)->getEnumKind();
314314 }
315315
316316 uint64_t AttributeImpl::getValueAsInt() const {
317 assert(isAlignAttribute());
318 return static_cast(this)->getAlignment();
317 assert(isIntAttribute());
318 return static_cast(this)->getValue();
319319 }
320320
321321 StringRef AttributeImpl::getKindAsString() const {
333333 // relative to their enum value) and then strings.
334334 if (isEnumAttribute()) {
335335 if (AI.isEnumAttribute()) return getKindAsEnum() < AI.getKindAsEnum();
336 if (AI.isAlignAttribute()) return true;
336 if (AI.isIntAttribute()) return true;
337337 if (AI.isStringAttribute()) return true;
338338 }
339339
340 if (isAlignAttribute()) {
340 if (isIntAttribute()) {
341341 if (AI.isEnumAttribute()) return false;
342 if (AI.isAlignAttribute()) return getValueAsInt() < AI.getValueAsInt();
342 if (AI.isIntAttribute()) return getValueAsInt() < AI.getValueAsInt();
343343 if (AI.isStringAttribute()) return true;
344344 }
345345
346346 if (AI.isEnumAttribute()) return false;
347 if (AI.isAlignAttribute()) return false;
347 if (AI.isIntAttribute()) return false;
348348 if (getKindAsString() == AI.getKindAsString())
349349 return getValueAsString() < AI.getValueAsString();
350350 return getKindAsString() < AI.getKindAsString();
10281028
10291029 for (AttributeSet::iterator I = A.begin(Slot), E = A.end(Slot); I != E; ++I) {
10301030 Attribute Attr = *I;
1031 if (Attr.isEnumAttribute() || Attr.isAlignAttribute()) {
1031 if (Attr.isEnumAttribute() || Attr.isIntAttribute()) {
10321032 Attribute::AttrKind Kind = I->getKindAsEnum();
10331033 Attrs[Kind] = false;
10341034
11161116 for (AttributeSet::iterator I = A.begin(Slot), E = A.end(Slot);
11171117 I != E; ++I) {
11181118 Attribute Attr = *I;
1119 if (Attr.isEnumAttribute() || Attr.isAlignAttribute()) {
1119 if (Attr.isEnumAttribute() || Attr.isIntAttribute()) {
11201120 if (Attrs[I->getKindAsEnum()])
11211121 return true;
11221122 } else {