[llvm] r174356 - Add target-dependent versions of addAttribute/removeAttribute to AttrBuilder.

Bill Wendling isanbard at gmail.com
Tue Feb 5 00:09:32 PST 2013


Author: void
Date: Tue Feb  5 02:09:32 2013
New Revision: 174356

URL: http://llvm.org/viewvc/llvm-project?rev=174356&view=rev
Log:
Add target-dependent versions of addAttribute/removeAttribute to AttrBuilder.

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=174356&r1=174355&r2=174356&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Attributes.h (original)
+++ llvm/trunk/include/llvm/IR/Attributes.h Tue Feb  5 02:09:32 2013
@@ -20,6 +20,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FoldingSet.h"
 #include <cassert>
+#include <map>
 #include <string>
 
 namespace llvm {
@@ -341,6 +342,7 @@ template<> struct DenseMapInfo<Attribute
 /// equality, presence of attributes, etc.
 class AttrBuilder {
   DenseSet<Attribute::AttrKind> Attrs;
+  std::map<std::string, std::string> TargetDepAttrs;
   uint64_t Alignment;
   uint64_t StackAlignment;
 public:
@@ -361,12 +363,18 @@ public:
   /// \brief Add the Attribute object to the builder.
   AttrBuilder &addAttribute(Attribute A);
 
+  /// \brief Add the target-dependent attribute to the builder.
+  AttrBuilder &addAttribute(StringRef A, StringRef V);
+
   /// \brief Remove an attribute from the builder.
   AttrBuilder &removeAttribute(Attribute::AttrKind Val);
 
   /// \brief Remove the attributes from the builder.
   AttrBuilder &removeAttributes(AttributeSet A, uint64_t Index);
 
+  /// \brief Remove the target-dependent attribute to the builder.
+  AttrBuilder &removeAttribute(StringRef A);
+
   /// \brief Return true if the builder has the specified attribute.
   bool contains(Attribute::AttrKind A) const;
 

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=174356&r1=174355&r2=174356&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Tue Feb  5 02:09:32 2013
@@ -46,7 +46,7 @@ Attribute Attribute::get(LLVMContext &Co
     pImpl->AttrsSet.InsertNode(PA, InsertPoint);
   }
 
-  // Return the AttributesList that we found or created.
+  // Return the Attribute that we found or created.
   return Attribute(PA);
 }
 
@@ -826,6 +826,11 @@ AttrBuilder &AttrBuilder::addAttribute(A
   return *this;
 }
 
+AttrBuilder &AttrBuilder::addAttribute(StringRef A, StringRef V) {
+  TargetDepAttrs[A] = V;
+  return *this;
+}
+
 AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
   Attrs.erase(Val);
 
@@ -861,6 +866,13 @@ AttrBuilder &AttrBuilder::removeAttribut
   return *this;
 }
 
+AttrBuilder &AttrBuilder::removeAttribute(StringRef A) {
+  std::map<std::string, std::string>::iterator I = TargetDepAttrs.find(A);
+  if (I != TargetDepAttrs.end())
+    TargetDepAttrs.erase(I);
+  return *this;
+}
+
 AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) {
   if (Align == 0) return *this;
 





More information about the llvm-commits mailing list