Mercurial > projects > ldc
comparison tools/binding/llvm/c/Core.d @ 1585:29b0f2d11c92
Updated C binding to be more up to date with LLVM.
author | tomas@localhost.localdomain |
---|---|
date | Thu, 22 Oct 2009 13:30:30 +0200 |
parents | 4ff9ab0d472c |
children |
comparison
equal
deleted
inserted
replaced
1584:f4c56ed32238 | 1585:29b0f2d11c92 |
---|---|
34 \*===----------------------------------------------------------------------===*/ | 34 \*===----------------------------------------------------------------------===*/ |
35 module llvm.c.Core; | 35 module llvm.c.Core; |
36 | 36 |
37 extern(C): | 37 extern(C): |
38 | 38 |
39 /* Opaque types. */ | |
40 | |
41 private | |
42 { | |
43 struct LLVM_OpaqueModule {} | |
44 struct LLVM_OpaqueType {} | |
45 struct LLVM_OpaqueTypeHandle {} | |
46 struct LLVM_OpaqueValue {} | |
47 struct LLVM_OpaqueBasicBlock {} | |
48 struct LLVM_OpaqueBuilder {} | |
49 struct LLVM_OpaqueModuleProvider {} | |
50 struct LLVM_OpaqueMemoryBuffer {} | |
51 struct LLVM_OpaquePassManager {} | |
52 } | |
53 | |
54 /** | 39 /** |
55 * The top-level container for all other LLVM Intermediate Representation (IR) | 40 * The top-level container for all other LLVM Intermediate Representation (IR) |
56 * objects. See the llvm::Module class. | 41 * objects. See the llvm::Module class. |
57 */ | 42 */ |
58 typedef LLVM_OpaqueModule* LLVMModuleRef; | 43 typedef void* LLVMModuleRef; |
59 | 44 |
60 /** | 45 /** |
61 * Each value in the LLVM IR has a type, an instance of [lltype]. See the | 46 * Each value in the LLVM IR has a type, an instance of [lltype]. See the |
62 * llvm::Type class. | 47 * llvm::Type class. |
63 */ | 48 */ |
64 typedef LLVM_OpaqueType* LLVMTypeRef; | 49 typedef void* LLVMTypeRef; |
65 | 50 |
66 /** | 51 /** |
67 * When building recursive types using [refine_type], [lltype] values may become | 52 * When building recursive types using [refine_type], [lltype] values may become |
68 * invalid; use [lltypehandle] to resolve this problem. See the | 53 * invalid; use [lltypehandle] to resolve this problem. See the |
69 * llvm::AbstractTypeHolder] class. | 54 * llvm::AbstractTypeHolder] class. |
70 */ | 55 */ |
71 typedef LLVM_OpaqueTypeHandle* LLVMTypeHandleRef; | 56 typedef void* LLVMTypeHandleRef; |
72 | 57 |
73 typedef LLVM_OpaqueValue* LLVMValueRef; | 58 typedef void* LLVMValueRef; |
74 typedef LLVM_OpaqueBasicBlock* LLVMBasicBlockRef; | 59 typedef void* LLVMBasicBlockRef; |
75 typedef LLVM_OpaqueBuilder* LLVMBuilderRef; | 60 typedef void* LLVMBuilderRef; |
76 | 61 |
77 /* Used to provide a module to JIT or interpreter. | 62 /* Used to provide a module to JIT or interpreter. |
78 * See the llvm::ModuleProvider class. | 63 * See the llvm::ModuleProvider class. |
79 */ | 64 */ |
80 typedef LLVM_OpaqueModuleProvider* LLVMModuleProviderRef; | 65 typedef void* LLVMModuleProviderRef; |
81 | 66 |
82 /* Used to provide a module to JIT or interpreter. | 67 /* Used to provide a module to JIT or interpreter. |
83 * See the llvm::MemoryBuffer class. | 68 * See the llvm::MemoryBuffer class. |
84 */ | 69 */ |
85 typedef LLVM_OpaqueMemoryBuffer* LLVMMemoryBufferRef; | 70 typedef void* LLVMMemoryBufferRef; |
86 | 71 |
87 /** See the llvm::PassManagerBase class. */ | 72 /** See the llvm::PassManagerBase class. */ |
88 typedef LLVM_OpaquePassManager* LLVMPassManagerRef; | 73 typedef void* LLVMPassManagerRef; |
89 | 74 |
90 enum LLVMParamAttr { | 75 enum LLVMAttribute { |
91 ZExt = 1<<0, | 76 ZExt = 1<<0, |
92 SExt = 1<<1, | 77 SExt = 1<<1, |
93 NoReturn = 1<<2, | 78 NoReturn = 1<<2, |
94 InReg = 1<<3, | 79 InReg = 1<<3, |
95 StructRet = 1<<4, | 80 StructRet = 1<<4, |
96 NoUnwind = 1<<5, | 81 NoUnwind = 1<<5, |
97 NoAlias = 1<<6, | 82 NoAlias = 1<<6, |
98 ByVal = 1<<7, | 83 ByVal = 1<<7, |
99 Nest = 1<<8, | 84 Nest = 1<<8, |
100 ReadNone = 1<<9, | 85 ReadNone = 1<<9, |
101 ReadOnly = 1<<10 | 86 ReadOnly = 1<<10, |
87 NoInline = 1<<11, | |
88 AlwaysInline = 1<<12, | |
89 OptimizeForSize = 1<<13, | |
90 StackProtect = 1<<14, | |
91 StackProtectReq = 1<<15, | |
92 NoCapture = 1<<21, | |
93 NoRedZone = 1<<22, | |
94 NoImplicitFloat = 1<<23, | |
95 Naked = 1<<24 | |
102 } | 96 } |
103 | 97 |
104 enum LLVMTypeKind { | 98 enum LLVMTypeKind { |
105 Void, /**< type with no size */ | 99 Void, /**< type with no size */ |
106 Float, /**< 32 bit floating point type */ | 100 Float, /**< 32 bit floating point type */ |
107 Double, /**< 64 bit floating point type */ | 101 Double, /**< 64 bit floating point type */ |
108 X86_FP80, /**< 80 bit floating point type (X87) */ | 102 X86_FP80, /**< 80 bit floating point type (X87) */ |
109 FP128, /**< 128 bit floating point type (112-bit mantissa)*/ | 103 FP128, /**< 128 bit floating point type (112-bit mantissa)*/ |
110 PPC_FP128, /**< 128 bit floating point type (two 64-bits) */ | 104 PPC_FP128, /**< 128 bit floating point type (two 64-bits) */ |
111 Label, /**< Labels */ | 105 Label, /**< Labels */ |
112 Integer, /**< Arbitrary bit width integers */ | 106 Integer, /**< Arbitrary bit width integers */ |
113 Function, /**< Functions */ | 107 Function, /**< Functions */ |
114 Struct, /**< Structures */ | 108 Struct, /**< Structures */ |
115 Array, /**< Arrays */ | 109 Array, /**< Arrays */ |
116 Pointer, /**< Pointers */ | 110 Pointer, /**< Pointers */ |
117 Opaque, /**< Opaque: type with unknown structure */ | 111 Opaque, /**< Opaque: type with unknown structure */ |
118 Vector /**< SIMD 'packed' format, or other vector type */ | 112 Vector, /**< SIMD 'packed' format, or other vector type */ |
113 Metadata /**< Metadata */ | |
119 } | 114 } |
120 | 115 |
121 enum LLVMLinkage { | 116 enum LLVMLinkage { |
122 External, /**< Externally visible function */ | 117 External, /**< Externally visible function */ |
123 LinkOnce, /**< Keep one copy of function when linking (inline)*/ | 118 AvailableExternally, |
124 Weak, /**< Keep one copy of function when linking (weak) */ | 119 LinkOnceAny, /**< Keep one copy of function when linking (inline)*/ |
125 Appending, /**< Special purpose, only applies to global arrays */ | 120 LinkOnceODR, /**< Same, but only replaced by something |
126 Internal, /**< Rename collisions when linking (static functions) */ | 121 equivalent. */ |
127 DLLImport, /**< Function to be imported from DLL */ | 122 WeakAny, /**< Keep one copy of function when linking (weak) */ |
128 DLLExport, /**< Function to be accessible from DLL */ | 123 WeakODR, /**< Same, but only replaced by something |
129 ExternalWeak,/**< ExternalWeak linkage description */ | 124 equivalent. */ |
130 Ghost /**< Stand-in functions for streaming fns from bitcode */ | 125 Appending, /**< Special purpose, only applies to global arrays */ |
126 Internal, /**< Rename collisions when linking (static | |
127 functions) */ | |
128 Private, /**< Like Internal, but omit from symbol table */ | |
129 DLLImport, /**< Function to be imported from DLL */ | |
130 DLLExport, /**< Function to be accessible from DLL */ | |
131 ExternalWeak,/**< ExternalWeak linkage description */ | |
132 Ghost, /**< Stand-in functions for streaming fns from | |
133 bitcode */ | |
134 Common, /**< Tentative definitions */ | |
135 LinkerPrivate /**< Like Private, but linker removes. */ | |
131 } | 136 } |
132 | 137 |
133 enum LLVMVisibility { | 138 enum LLVMVisibility { |
134 Default, /**< The GV is visible */ | 139 Default, /**< The GV is visible */ |
135 Hidden, /**< The GV is hidden */ | 140 Hidden, /**< The GV is hidden */ |
182 | 187 |
183 | 188 |
184 /*===-- Modules -----------------------------------------------------------===*/ | 189 /*===-- Modules -----------------------------------------------------------===*/ |
185 | 190 |
186 /* Create and destroy modules. */ | 191 /* Create and destroy modules. */ |
187 /** See llvm::Module::Module. */ | 192 /** See llvm::Module::Module. */ |
188 LLVMModuleRef LLVMModuleCreateWithName(/*const*/ char *ModuleID); | 193 LLVMModuleRef LLVMModuleCreateWithName(/*const*/ char *ModuleID); |
189 | 194 |
190 /** See llvm::Module::~Module. */ | 195 /** See llvm::Module::~Module. */ |
191 void LLVMDisposeModule(LLVMModuleRef M); | 196 void LLVMDisposeModule(LLVMModuleRef M); |
192 | 197 |
193 /** Data layout. See Module::getDataLayout. */ | 198 /** Data layout. See Module::getDataLayout. */ |
194 /*const*/ char *LLVMGetDataLayout(LLVMModuleRef M); | 199 /*const*/ char *LLVMGetDataLayout(LLVMModuleRef M); |
195 void LLVMSetDataLayout(LLVMModuleRef M, /*const*/ char *Triple); | 200 void LLVMSetDataLayout(LLVMModuleRef M, /*const*/ char *DataLayout); |
196 | 201 |
197 /** Target triple. See Module::getTargetTriple. */ | 202 /** Target triple. See Module::getTargetTriple. */ |
198 /*const*/ char *LLVMGetTarget(LLVMModuleRef M); | 203 /*const*/ char *LLVMGetTarget(LLVMModuleRef M); |
199 void LLVMSetTarget(LLVMModuleRef M, /*const*/ char *Triple); | 204 void LLVMSetTarget(LLVMModuleRef M, /*const*/ char *Triple); |
200 | 205 |
206 void LLVMDumpModule(LLVMModuleRef M); | 211 void LLVMDumpModule(LLVMModuleRef M); |
207 | 212 |
208 /*===-- Types -------------------------------------------------------------===*/ | 213 /*===-- Types -------------------------------------------------------------===*/ |
209 | 214 |
210 /* LLVM types conform to the following hierarchy: | 215 /* LLVM types conform to the following hierarchy: |
211 * | 216 * |
212 * types: | 217 * types: |
213 * integer type | 218 * integer type |
214 * real type | 219 * real type |
215 * function type | 220 * function type |
216 * sequence types: | 221 * sequence types: |
280 | 285 |
281 /*===-- Values ------------------------------------------------------------===*/ | 286 /*===-- Values ------------------------------------------------------------===*/ |
282 | 287 |
283 /* The bulk of LLVM's object model consists of values, which comprise a very | 288 /* The bulk of LLVM's object model consists of values, which comprise a very |
284 * rich type hierarchy. | 289 * rich type hierarchy. |
285 * | 290 * |
286 * values: | 291 * values: |
287 * constants: | 292 * constants: |
288 * scalar constants | 293 * scalar constants |
289 * composite contants | 294 * composite contants |
290 * globals: | 295 * globals: |
309 int LLVMIsUndef(LLVMValueRef Val); | 314 int LLVMIsUndef(LLVMValueRef Val); |
310 | 315 |
311 /* Operations on scalar constants */ | 316 /* Operations on scalar constants */ |
312 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, ulong N, | 317 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, ulong N, |
313 int SignExtend); | 318 int SignExtend); |
319 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, /*const*/ char *Text, | |
320 ubyte Radix); | |
321 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, /*const*/ char *Text, | |
322 uint SLen, ubyte Radix); | |
314 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); | 323 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); |
315 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, /*const*/ char *Text); | 324 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, /*const*/ char *Text); |
325 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, /*const*/ char *Text, | |
326 uint SLen); | |
316 | 327 |
317 /* Operations on composite constants */ | 328 /* Operations on composite constants */ |
318 LLVMValueRef LLVMConstString(/*const*/ char *Str, uint Length, | 329 LLVMValueRef LLVMConstString(/*const*/ char *Str, uint Length, |
319 int DontNullTerminate); | 330 int DontNullTerminate); |
320 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, | 331 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, |
416 uint LLVMGetIntrinsicID(LLVMValueRef Fn); | 427 uint LLVMGetIntrinsicID(LLVMValueRef Fn); |
417 uint LLVMGetFunctionCallConv(LLVMValueRef Fn); | 428 uint LLVMGetFunctionCallConv(LLVMValueRef Fn); |
418 void LLVMSetFunctionCallConv(LLVMValueRef Fn, uint CC); | 429 void LLVMSetFunctionCallConv(LLVMValueRef Fn, uint CC); |
419 /*const*/ char *LLVMGetGC(LLVMValueRef Fn); | 430 /*const*/ char *LLVMGetGC(LLVMValueRef Fn); |
420 void LLVMSetGC(LLVMValueRef Fn, /*const*/ char *Name); | 431 void LLVMSetGC(LLVMValueRef Fn, /*const*/ char *Name); |
432 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); | |
433 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); | |
421 | 434 |
422 /* Operations on parameters */ | 435 /* Operations on parameters */ |
423 uint LLVMCountParams(LLVMValueRef Fn); | 436 uint LLVMCountParams(LLVMValueRef Fn); |
424 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); | 437 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); |
425 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, uint Index); | 438 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, uint Index); |
426 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst); | 439 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst); |
427 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); | 440 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); |
428 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); | 441 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); |
429 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); | 442 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); |
430 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); | 443 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); |
431 void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA); | 444 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA); |
432 void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA); | 445 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA); |
433 void LLVMSetParamAlignment(LLVMValueRef Arg, uint alignm); | 446 void LLVMSetParamAlignment(LLVMValueRef Arg, uint alignm); |
434 | 447 |
435 | 448 |
436 /* Operations on basic blocks */ | 449 /* Operations on basic blocks */ |
437 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef Bb); | 450 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef Bb); |
458 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); | 471 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); |
459 | 472 |
460 /* Operations on call sites */ | 473 /* Operations on call sites */ |
461 void LLVMSetInstructionCallConv(LLVMValueRef Instr, uint CC); | 474 void LLVMSetInstructionCallConv(LLVMValueRef Instr, uint CC); |
462 uint LLVMGetInstructionCallConv(LLVMValueRef Instr); | 475 uint LLVMGetInstructionCallConv(LLVMValueRef Instr); |
463 void LLVMAddInstrParamAttr(LLVMValueRef Instr, uint index, LLVMParamAttr); | 476 void LLVMAddInstrAttribute(LLVMValueRef Instr, uint index, LLVMAttribute); |
464 void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, uint index, | 477 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, uint index, LLVMAttribute); |
465 LLVMParamAttr); | 478 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, uint index, uint alignm); |
466 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, uint index, | 479 |
467 uint alignm); | 480 /* Operations on call instructions (only) */ |
468 | 481 int LLVMIsTailCall(LLVMValueRef CallInst); |
482 void LLVMSetTailCall(LLVMValueRef CallInst, int IsTailCall); | |
469 | 483 |
470 /* Operations on phi nodes */ | 484 /* Operations on phi nodes */ |
471 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, | 485 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, |
472 LLVMBasicBlockRef *IncomingBlocks, uint Count); | 486 LLVMBasicBlockRef *IncomingBlocks, uint Count); |
473 uint LLVMCountIncoming(LLVMValueRef PhiNode); | 487 uint LLVMCountIncoming(LLVMValueRef PhiNode); |
553 /*const*/ char *Name); | 567 /*const*/ char *Name); |
554 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); | 568 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); |
555 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, | 569 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, |
556 LLVMValueRef *Indices, uint NumIndices, | 570 LLVMValueRef *Indices, uint NumIndices, |
557 /*const*/ char *Name); | 571 /*const*/ char *Name); |
572 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, | |
573 LLVMValueRef *Indices, uint NumIndices, | |
574 /*const*/ char *Name); | |
558 | 575 |
559 /* Casts */ | 576 /* Casts */ |
560 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, | 577 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, |
561 LLVMTypeRef DestTy, /*const*/ char *Name); | 578 LLVMTypeRef DestTy, /*const*/ char *Name); |
562 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, | 579 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, |