[llvm] r174467 - Add the target-dependent (string) attributes from the AttrBuilder to the AttributeSet.
Bill Wendling
isanbard at gmail.com
Tue Feb 5 15:48:36 PST 2013
Author: void
Date: Tue Feb 5 17:48:36 2013
New Revision: 174467
URL: http://llvm.org/viewvc/llvm-project?rev=174467&view=rev
Log:
Add the target-dependent (string) attributes from the AttrBuilder to the AttributeSet.
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=174467&r1=174466&r2=174467&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Attributes.h (original)
+++ llvm/trunk/include/llvm/IR/Attributes.h Tue Feb 5 17:48:36 2013
@@ -140,6 +140,9 @@ public:
/// \brief Return true if the attribute is present.
bool hasAttribute(AttrKind Val) const;
+ /// \brief Return true if the target-dependent attribute is present.
+ bool hasAttribute(StringRef Val) const;
+
/// \brief Return the attribute's kind as an enum (Attribute::AttrKind). This
/// requires the attribute to be an enum or alignment attribute.
Attribute::AttrKind getKindAsEnum() const;
@@ -418,6 +421,7 @@ public:
/// the form used internally in Attribute.
AttrBuilder &addStackAlignmentAttr(unsigned Align);
+ // Iterators for target-independent attributes.
typedef DenseSet<Attribute::AttrKind>::iterator iterator;
typedef DenseSet<Attribute::AttrKind>::const_iterator const_iterator;
@@ -427,6 +431,17 @@ public:
const_iterator begin() const { return Attrs.begin(); }
const_iterator end() const { return Attrs.end(); }
+ // Iterators for target-dependent attributes.
+ typedef std::pair<std::string, std::string> td_type;
+ typedef std::map<std::string, std::string>::iterator td_iterator;
+ typedef std::map<std::string, std::string>::const_iterator td_const_iterator;
+
+ td_iterator td_begin() { return TargetDepAttrs.begin(); }
+ td_iterator td_end() { return TargetDepAttrs.end(); }
+
+ td_const_iterator td_begin() const { return TargetDepAttrs.begin(); }
+ td_const_iterator td_end() const { return TargetDepAttrs.end(); }
+
/// \brief Remove attributes that are used on functions only.
void removeFunctionOnlyAttrs() {
removeAttribute(Attribute::NoReturn)
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=174467&r1=174466&r2=174467&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Tue Feb 5 17:48:36 2013
@@ -126,8 +126,13 @@ StringRef Attribute::getValueAsString()
return pImpl ? pImpl->getValueAsString() : StringRef();
}
-bool Attribute::hasAttribute(AttrKind Val) const {
- return (pImpl && pImpl->hasAttribute(Val)) || (!pImpl && Val == None);
+bool Attribute::hasAttribute(AttrKind Kind) const {
+ return (pImpl && pImpl->hasAttribute(Kind)) || (!pImpl && Kind == None);
+}
+
+bool Attribute::hasAttribute(StringRef Kind) const {
+ if (!isStringAttribute()) return false;
+ return pImpl && pImpl->hasAttribute(Kind);
}
/// This returns the alignment field of an attribute as a byte alignment value.
@@ -552,6 +557,7 @@ AttributeSet AttributeSet::get(LLVMConte
if (!B.hasAttributes())
return AttributeSet();
+ // Add target-independent attributes.
SmallVector<std::pair<unsigned, Attribute>, 8> Attrs;
for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I) {
Attribute::AttrKind Kind = *I;
@@ -565,6 +571,11 @@ AttributeSet AttributeSet::get(LLVMConte
Attrs.push_back(std::make_pair(Idx, Attribute::get(C, Kind)));
}
+ // Add target-dependent (string) attributes.
+ for (AttrBuilder::td_iterator I = B.td_begin(), E = B.td_end();
+ I != E; ++I)
+ Attrs.push_back(std::make_pair(Idx, Attribute::get(C, I->first,I->second)));
+
return get(C, Attrs);
}
More information about the llvm-commits
mailing list