Add some additonal attribute helper functions. Test will be on follow
authorReed Kotler <rkotler@mips.com>
Wed, 13 Mar 2013 20:20:08 +0000 (20:20 +0000)
committerReed Kotler <rkotler@mips.com>
Wed, 13 Mar 2013 20:20:08 +0000 (20:20 +0000)
up putback to clang for mips16.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176968 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Attributes.h
include/llvm/IR/Function.h
lib/IR/Attributes.cpp

index 30c096533774424f7e9865b7230986adc6950e5d..ddb8ea41c15149ac038faa61a5b250e28df10e2d 100644 (file)
@@ -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,
index a7dea5ca3d7677e67ba324731048e5e24603a42b..f97929f658548d6b5a059804e1854f20ee65b660 100644 (file)
@@ -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);
index ed2bf05e90639f44b963789ab32c19d8794f6b91..2d828914cdca4cb17c5f13d67e93a6d8cb57769c 100644 (file)
@@ -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;