Add target-dependent versions of addAttribute/removeAttribute to AttrBuilder.
[oota-llvm.git] / lib / IR / Attributes.cpp
index 909f22f15221f63d59924edf50e1c2d0a86429a4..8a0551cbf124f53abf3bbd251bbc9aaa8bb75f92 100644 (file)
@@ -46,7 +46,7 @@ Attribute Attribute::get(LLVMContext &Context, Constant *Kind, Constant *Val) {
     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(Attribute Attr) {
   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::removeAttributes(AttributeSet A, uint64_t Index) {
   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;