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 26extern "C" { 27#endif 28 29typedef 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 36void LLVMAddFunctionAttr2(LLVMValueRef Fn, uint64_t PA); 37uint64_t LLVMGetFunctionAttr2(LLVMValueRef Fn); 38void LLVMRemoveFunctionAttr2(LLVMValueRef Fn, uint64_t PA); 39 40LLVMMetadataRef LLVMConstantAsMetadata(LLVMValueRef Val); 41 42LLVMMetadataRef LLVMMDString2(LLVMContextRef C, const char *Str, unsigned SLen); 43LLVMMetadataRef LLVMMDNode2(LLVMContextRef C, LLVMMetadataRef *MDs, 44 unsigned Count); 45LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef C, LLVMMetadataRef *MDs, 46 unsigned Count); 47 48void LLVMAddNamedMetadataOperand2(LLVMModuleRef M, const char *name, 49 LLVMMetadataRef Val); 50void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD); 51 52void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef MD, LLVMMetadataRef New); 53 54void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line, 55 unsigned Col, LLVMMetadataRef Scope, 56 LLVMMetadataRef InlinedAt); 57 58void LLVMSetSubprogram(LLVMValueRef Fn, LLVMMetadataRef SP); 59 60#ifdef __cplusplus 61} 62 63namespace llvm { 64 65DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef) 66 67inline Metadata **unwrap(LLVMMetadataRef *Vals) { 68 return reinterpret_cast<Metadata**>(Vals); 69} 70 71} 72 73#endif 74 75#endif 76