Go bindings: introduce Value.ConstantAsMetadata.
[oota-llvm.git] / bindings / go / llvm / IRBindings.h
1 //===- IRBindings.h - Additional bindings for IR ----------------*- C++ -*-===//
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 #ifndef LLVM_BINDINGS_GO_LLVM_IRBINDINGS_H
15 #define LLVM_BINDINGS_GO_LLVM_IRBINDINGS_H
16
17 #include "llvm-c/Core.h"
18 #ifdef __cplusplus
19 #include "llvm/IR/Metadata.h"
20 #include "llvm/Support/CBindingWrapping.h"
21 #endif
22
23 #include <stdint.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 typedef struct LLVMOpaqueMetadata *LLVMMetadataRef;
30
31 // These functions duplicate the LLVM*FunctionAttr functions in the stable C
32 // API. We cannot use the existing functions because they take 32-bit attribute
33 // values, and the Go bindings expose all of the LLVM attributes, some of which
34 // have values >= 1<<32.
35
36 void LLVMAddFunctionAttr2(LLVMValueRef Fn, uint64_t PA);
37 uint64_t LLVMGetFunctionAttr2(LLVMValueRef Fn);
38 void LLVMRemoveFunctionAttr2(LLVMValueRef Fn, uint64_t PA);
39
40 LLVMMetadataRef LLVMConstantAsMetadata(LLVMValueRef Val);
41
42 LLVMMetadataRef LLVMMDString2(LLVMContextRef C, const char *Str, unsigned SLen);
43 LLVMMetadataRef LLVMMDNode2(LLVMContextRef C, LLVMMetadataRef *MDs,
44                             unsigned Count);
45 LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef C, LLVMMetadataRef *MDs,
46                                     unsigned Count);
47
48 void LLVMAddNamedMetadataOperand2(LLVMModuleRef M, const char *name,
49                                   LLVMMetadataRef Val);
50 void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD);
51
52 void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef MD, LLVMMetadataRef New);
53
54 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
55                                   unsigned Col, LLVMMetadataRef Scope,
56                                   LLVMMetadataRef InlinedAt);
57
58 #ifdef __cplusplus
59 }
60
61 namespace llvm {
62
63 DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef)
64
65 inline Metadata **unwrap(LLVMMetadataRef *Vals) {
66   return reinterpret_cast<Metadata**>(Vals);
67 }
68
69 }
70
71 #endif
72
73 #endif