Go: add binding for LLVMSetUnnamedAddr.
[oota-llvm.git] / bindings / go / llvm / IRBindings.cpp
1 //===- IRBindings.cpp - Additional bindings for ir ------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines additional C bindings for the ir component.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "IRBindings.h"
15
16 #include "llvm/IR/Attributes.h"
17 #include "llvm/IR/Function.h"
18
19 using namespace llvm;
20
21 void LLVMAddFunctionAttr2(LLVMValueRef Fn, uint64_t PA) {
22   Function *Func = unwrap<Function>(Fn);
23   const AttributeSet PAL = Func->getAttributes();
24   AttrBuilder B(PA);
25   const AttributeSet PALnew =
26     PAL.addAttributes(Func->getContext(), AttributeSet::FunctionIndex,
27                       AttributeSet::get(Func->getContext(),
28                                         AttributeSet::FunctionIndex, B));
29   Func->setAttributes(PALnew);
30 }
31
32 uint64_t LLVMGetFunctionAttr2(LLVMValueRef Fn) {
33   Function *Func = unwrap<Function>(Fn);
34   const AttributeSet PAL = Func->getAttributes();
35   return PAL.Raw(AttributeSet::FunctionIndex);
36 }
37
38 void LLVMRemoveFunctionAttr2(LLVMValueRef Fn, uint64_t PA) {
39   Function *Func = unwrap<Function>(Fn);
40   const AttributeSet PAL = Func->getAttributes();
41   AttrBuilder B(PA);
42   const AttributeSet PALnew =
43     PAL.removeAttributes(Func->getContext(), AttributeSet::FunctionIndex,
44                          AttributeSet::get(Func->getContext(),
45                                            AttributeSet::FunctionIndex, B));
46   Func->setAttributes(PALnew);
47 }