C API: Add LLVMAddTargetDependentFunctionAttr()
authorTom Stellard <thomas.stellard@amd.com>
Tue, 16 Apr 2013 23:12:43 +0000 (23:12 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Tue, 16 Apr 2013 23:12:43 +0000 (23:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179645 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm-c/Core.h
lib/IR/Core.cpp

index 675277507203d6f8e8dba9c131267036f73ec8d7..3d54a216178d9c2c364b80724705e8b192818424 100644 (file)
@@ -1705,6 +1705,13 @@ void LLVMSetGC(LLVMValueRef Fn, const char *Name);
  */
 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
 
+/**
+ * Add a target-dependent attribute to a fuction
+ * @see llvm::AttrBuilder::addAttribute()
+ */
+void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
+                                        const char *V);
+
 /**
  * Obtain an attribute from a function.
  *
index f1f7eb31bb38375545bea85d322e6853b96ce6c9..e769ab4e7d0c6a7d71f7da89ccec9da35dd111c4 100644 (file)
@@ -1443,6 +1443,17 @@ void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
   Func->setAttributes(PALnew);
 }
 
+void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
+                                        const char *V) {
+  Function *Func = unwrap<Function>(Fn);
+  int Idx = AttributeSet::FunctionIndex;
+  AttrBuilder B;
+
+  B.addAttribute(A, V);
+  AttributeSet Set = AttributeSet::get(Func->getContext(), Idx, B);
+  Func->addAttributes(Idx, Set);
+}
+
 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
   Function *Func = unwrap<Function>(Fn);
   const AttributeSet PAL = Func->getAttributes();