summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReed Kotler <rkotler@mips.com>2013-03-13 20:20:08 +0000
committerReed Kotler <rkotler@mips.com>2013-03-13 20:20:08 +0000
commit795c7b455cc36b2f70e8fb91d7f090a2ec967417 (patch)
tree9b60c1c58b05a21671535faf868c26846ac1e437
parent14c3fd84809397da9fa67c0788f29973ad6bbade (diff)
downloadbcm5719-llvm-795c7b455cc36b2f70e8fb91d7f090a2ec967417.tar.gz
bcm5719-llvm-795c7b455cc36b2f70e8fb91d7f090a2ec967417.zip
Add some additonal attribute helper functions. Test will be on follow
up putback to clang for mips16. llvm-svn: 176968
-rw-r--r--llvm/include/llvm/IR/Attributes.h5
-rw-r--r--llvm/include/llvm/IR/Function.h8
-rw-r--r--llvm/lib/IR/Attributes.cpp7
3 files changed, 20 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h
index 30c09653377..ddb8ea41c15 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -247,6 +247,11 @@ public:
AttributeSet addAttribute(LLVMContext &C, unsigned Idx,
Attribute::AttrKind Attr) const;
+ /// \brief Add an attribute to the attribute set at the given index. Since
+ /// attribute sets are immutable, this returns a new set.
+ AttributeSet addAttribute(LLVMContext &C, unsigned Idx,
+ StringRef Kind) const;
+
/// \brief Add attributes to the attribute set at the given index. Since
/// attribute sets are immutable, this returns a new set.
AttributeSet addAttributes(LLVMContext &C, unsigned Idx,
diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index a7dea5ca3d7..f97929f6585 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -181,6 +181,14 @@ public:
AttributeSet::FunctionIndex, N));
}
+ /// addFnAttr - Add function attributes to this function.
+ ///
+ void addFnAttr(StringRef Kind) {
+ setAttributes(
+ AttributeSets.addAttribute(getContext(),
+ AttributeSet::FunctionIndex, Kind));
+ }
+
/// \brief Return true if the function has the attribute.
bool hasFnAttribute(Attribute::AttrKind Kind) const {
return AttributeSets.hasAttribute(AttributeSet::FunctionIndex, Kind);
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index ed2bf05e906..2d828914cdc 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -649,6 +649,13 @@ AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Idx,
return addAttributes(C, Idx, AttributeSet::get(C, Idx, Attr));
}
+AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Idx,
+ StringRef Kind) const {
+ llvm::AttrBuilder B;
+ B.addAttribute(Kind);
+ return addAttributes(C, Idx, AttributeSet::get(C, Idx, B));
+}
+
AttributeSet AttributeSet::addAttributes(LLVMContext &C, unsigned Idx,
AttributeSet Attrs) const {
if (!pImpl) return Attrs;
OpenPOWER on IntegriCloud