[llvm] r174481 - Add a 'StringRef' version of hasAttribute.
Bill Wendling
isanbard at gmail.com
Tue Feb 5 17:33:42 PST 2013
Author: void
Date: Tue Feb 5 19:33:42 2013
New Revision: 174481
URL: http://llvm.org/viewvc/llvm-project?rev=174481&view=rev
Log:
Add a 'StringRef' version of hasAttribute.
Fix the 'operator==' and 'hasAttributes' queries to take into account
target-dependent attributes.
Modified:
llvm/trunk/include/llvm/IR/Attributes.h
llvm/trunk/lib/IR/Attributes.cpp
Modified: llvm/trunk/include/llvm/IR/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Attributes.h?rev=174481&r1=174480&r2=174481&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Attributes.h (original)
+++ llvm/trunk/include/llvm/IR/Attributes.h Tue Feb 5 19:33:42 2013
@@ -404,6 +404,10 @@ public:
/// \brief Return true if the builder has the specified attribute.
bool contains(Attribute::AttrKind A) const;
+ /// \brief Return true if the builder has the specified target-dependent
+ /// attribute.
+ bool contains(StringRef A) const;
+
/// \brief Return true if the builder has IR-level attributes.
bool hasAttributes() const;
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=174481&r1=174480&r2=174481&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Tue Feb 5 19:33:42 2013
@@ -977,8 +977,12 @@ bool AttrBuilder::contains(Attribute::At
return Attrs.count(A);
}
+bool AttrBuilder::contains(StringRef A) const {
+ return TargetDepAttrs.find(A) != TargetDepAttrs.end();
+}
+
bool AttrBuilder::hasAttributes() const {
- return !Attrs.empty();
+ return !Attrs.empty() || !TargetDepAttrs.empty();
}
bool AttrBuilder::hasAttributes(AttributeSet A, uint64_t Index) const {
@@ -1005,9 +1009,17 @@ bool AttrBuilder::hasAlignmentAttr() con
}
bool AttrBuilder::operator==(const AttrBuilder &B) {
- SmallVector<Attribute::AttrKind, 8> This(Attrs.begin(), Attrs.end());
- SmallVector<Attribute::AttrKind, 8> That(B.Attrs.begin(), B.Attrs.end());
- return This == That;
+ for (DenseSet<Attribute::AttrKind>::iterator I = Attrs.begin(),
+ E = Attrs.end(); I != E; ++I)
+ if (!B.Attrs.count(*I))
+ return false;
+
+ for (td_const_iterator I = TargetDepAttrs.begin(),
+ E = TargetDepAttrs.end(); I != E; ++I)
+ if (B.TargetDepAttrs.find(I->first) == B.TargetDepAttrs.end())
+ return false;
+
+ return Alignment == B.Alignment && StackAlignment == B.StackAlignment;
}
AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
More information about the llvm-commits
mailing list