From 68ee1520ce777871353e33fcc63725439e611f4e Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 16 Apr 2013 23:12:43 +0000 Subject: [PATCH] C API: Add LLVMAddTargetDependentFunctionAttr() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179645 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 7 +++++++ lib/IR/Core.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 67527750720..3d54a216178 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -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. * diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index f1f7eb31bb3..e769ab4e7d0 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -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(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(Fn); const AttributeSet PAL = Func->getAttributes(); -- 2.34.1