1 //===- IRBindings.cpp - Additional bindings for ir ------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines additional C bindings for the ir component.
12 //===----------------------------------------------------------------------===//
14 #include "IRBindings.h"
16 #include "llvm/IR/Attributes.h"
17 #include "llvm/IR/Function.h"
21 void LLVMAddFunctionAttr2(LLVMValueRef Fn, uint64_t PA) {
22 Function *Func = unwrap<Function>(Fn);
23 const AttributeSet PAL = Func->getAttributes();
25 const AttributeSet PALnew =
26 PAL.addAttributes(Func->getContext(), AttributeSet::FunctionIndex,
27 AttributeSet::get(Func->getContext(),
28 AttributeSet::FunctionIndex, B));
29 Func->setAttributes(PALnew);
32 uint64_t LLVMGetFunctionAttr2(LLVMValueRef Fn) {
33 Function *Func = unwrap<Function>(Fn);
34 const AttributeSet PAL = Func->getAttributes();
35 return PAL.Raw(AttributeSet::FunctionIndex);
38 void LLVMRemoveFunctionAttr2(LLVMValueRef Fn, uint64_t PA) {
39 Function *Func = unwrap<Function>(Fn);
40 const AttributeSet PAL = Func->getAttributes();
42 const AttributeSet PALnew =
43 PAL.removeAttributes(Func->getContext(), AttributeSet::FunctionIndex,
44 AttributeSet::get(Func->getContext(),
45 AttributeSet::FunctionIndex, B));
46 Func->setAttributes(PALnew);