1 
2 module llvm.c.types;
3 
4 private
5 {
6 	import std.stdint : uintptr_t;
7 
8 	import llvm.c.versions;
9 }
10 
11 /+ Analysis +/
12 
13 alias int LLVMVerifierFailureAction;
14 
15 /+ Transforms +/
16 
17 /++ Pass manager builder ++/
18 
19 struct LLVMOpaquePassManagerBuilder {}; alias LLVMOpaquePassManagerBuilder* LLVMPassManagerBuilderRef;
20 
21 /+ Core +/
22 
23 static if(LLVM_Version >= LLVMDVersion(3, 4, 0))
24 {
25 	alias extern(C) void function(const char* Reason) LLVMFatalErrorHandler;
26 }
27 
28 static if(LLVM_Version >= LLVMDVersion(3, 5, 0))
29 {
30 	//This is here because putting it where it semantically belongs creates a forward reference issues.
31 	struct LLVMOpaqueDiagnosticInfo {}; alias LLVMOpaqueDiagnosticInfo* LLVMDiagnosticInfoRef;
32 
33 	alias extern(C) void function(LLVMDiagnosticInfoRef, void*) LLVMDiagnosticHandler;
34 	alias extern(C) void function(LLVMContextRef, void *) LLVMYieldCallback;
35 }
36 
37 /++ Types and Enumerations ++/
38 
39 alias int LLVMBool;
40 struct LLVMOpaqueContext {}; alias LLVMOpaqueContext* LLVMContextRef;
41 struct LLVMOpaqueModule {}; alias LLVMOpaqueModule* LLVMModuleRef;
42 struct LLVMOpaqueType {}; alias LLVMOpaqueType* LLVMTypeRef;
43 struct LLVMOpaqueValue {}; alias LLVMOpaqueValue* LLVMValueRef;
44 struct LLVMOpaqueBasicBlock {}; alias LLVMOpaqueBasicBlock* LLVMBasicBlockRef;
45 struct LLVMOpaqueBuilder {}; alias LLVMOpaqueBuilder* LLVMBuilderRef;
46 struct LLVMOpaqueModuleProvider {}; alias LLVMOpaqueModuleProvider* LLVMModuleProviderRef;
47 struct LLVMOpaqueMemoryBuffer {}; alias LLVMOpaqueMemoryBuffer* LLVMMemoryBufferRef;
48 struct LLVMOpaquePassManager {}; alias LLVMOpaquePassManager* LLVMPassManagerRef;
49 struct LLVMOpaquePassRegistry {}; alias LLVMOpaquePassRegistry* LLVMPassRegistryRef;
50 struct LLVMOpaqueUse {}; alias LLVMOpaqueUse* LLVMUseRef;
51 
52 alias long LLVMAttribute;
53 alias int LLVMOpcode;
54 alias int LLVMTypeKind;
55 alias int LLVMLinkage;
56 alias int LLVMVisibility;
57 alias int LLVMDLLStorageClass;
58 alias int LLVMCallConv;
59 alias int LLVMIntPredicate;
60 alias int LLVMRealPredicate;
61 alias int LLVMLandingPadClauseTy;
62 static if(LLVM_Version >= LLVMDVersion(3, 3, 0))
63 {
64 	alias int LLVMThreadLocalMode;
65 	alias int LLVMAtomicOrdering;
66 	alias int LLVMAtomicRMWBinOp;
67 }
68 static if(LLVM_Version >= LLVMDVersion(3, 5, 0))
69 {
70 	alias int LLVMDiagnosticSeverity;
71 }
72 
73 /+ Disassembler +/
74 
75 alias void* LLVMDisasmContextRef;
76 alias extern(C) int function(void* DisInfo, ulong PC, ulong Offset, ulong Size, int TagType, void* TagBuf) LLVMOpInfoCallback;
77 alias extern(C) const char* function(void* DisInfo, ulong ReferenceValue, ulong* ReferenceType, ulong ReferencePC, const char** ReferenceName) LLVMSymbolLookupCallback;
78 
79 struct LLVMOpInfoSymbol1
80 {
81 	ulong Present;
82 	const char* Name;
83 	ulong Value;
84 }
85 
86 struct LLVMOpInfo1
87 {
88 	LLVMOpInfoSymbol1 AddSymbol;
89 	LLVMOpInfoSymbol1 SubtractSymbol;
90 	ulong Value;
91 	ulong VariantKind;
92 }
93 
94 static if(LLVM_Version < LLVMDVersion(3, 3, 0))
95 {
96 	/+ Enhanced Disassembly +/
97 
98 	alias void* EDDisassemblerRef;
99 	alias void* EDInstRef;
100 	alias void* EDTokenRef;
101 	alias void* EDOperandRef;
102 
103 	alias int EDAssemblySyntax_t;
104 
105 	alias extern(C) int function(ubyte* Byte, ulong address, void* arg) EDByteReaderCallback;
106 	alias extern(C) int function(ulong* value, uint regID, void* arg) EDRegisterReaderCallback;
107 
108 	alias extern(C) int function(ubyte* Byte, ulong address) EDByteBlock_t;
109 	alias extern(C) int function(ulong* value, uint regID) EDRegisterBlock_t;
110 	alias extern(C) int function(EDTokenRef token) EDTokenVisitor_t;
111 }
112 
113 /+ Execution Engine +/
114 
115 struct LLVMOpaqueGenericValue {}; alias LLVMOpaqueGenericValue* LLVMGenericValueRef;
116 struct LLVMOpaqueExecutionEngine {}; alias LLVMOpaqueExecutionEngine* LLVMExecutionEngineRef;
117 
118 static if(LLVM_Version >= LLVMDVersion(3, 3, 0))
119 {
120 	static if(LLVM_Version >= 3.4)
121 	{
122 		struct LLVMOpaqueMCJITMemoryManager {}; alias LLVMOpaqueMCJITMemoryManager* LLVMMCJITMemoryManagerRef;
123 
124 		struct LLVMMCJITCompilerOptions
125 		{
126 			uint OptLevel;
127 			LLVMCodeModel CodeModel;
128 			LLVMBool NoFramePointerElim;
129 			LLVMBool EnableFastISel;
130 			LLVMMCJITMemoryManagerRef MCJMM;
131 		}
132 
133 		alias extern(C) ubyte function(void* Opaque, uintptr_t Size, uint Alignment, uint SectionID, const char* SectionName) LLVMMemoryManagerAllocateCodeSectionCallback;
134 		alias extern(C) ubyte function(void* Opaque, uintptr_t Size, uint Alignment, uint SectionID, const char* SectionName, LLVMBool IsReadOnly) LLVMMemoryManagerAllocateDataSectionCallback;
135 		alias extern(C) LLVMBool function(void* Opaque, char** ErrMsg) LLVMMemoryManagerFinalizeMemoryCallback;
136 		alias extern(C) void function(void* Opaque) LLVMMemoryManagerDestroyCallback;
137 	}
138 	else
139 	{
140 		struct LLVMMCJITCompilerOptions
141 		{
142 			uint OptLevel;
143 			LLVMCodeModel CodeModel;
144 			LLVMBool NoFramePointerElim;
145 			LLVMBool EnableFastISel;
146 		}
147 	}
148 }
149 
150 static if(LLVM_Version >= LLVMDVersion(3, 2, 0))
151 {
152 	/+ Linker +/
153 
154 	alias int LLVMLinkerMode;
155 }
156 
157 /+ Link Time Optimization +/
158 
159 alias void* llvm_lto_t;
160 alias llvm_lto_status llvm_lto_status_t;
161 
162 
163 alias int llvm_lto_status;
164 
165 /+ LTO +/
166 
167 static if(LLVM_Version >= LLVMDVersion(3, 5, 0))
168 {
169 	struct LLVMOpaqueLTOModule {}; alias LLVMOpaqueLTOModule* lto_module_t;
170 }
171 else
172 {
173 	struct LTOModule {}; alias LTOModule* lto_module_t;
174 }
175 static if(LLVM_Version >= LLVMDVersion(3, 5, 0))
176 {
177 	struct LLVMOpaqueLTOCodeGenerator {}; alias LLVMOpaqueLTOCodeGenerator* lto_code_gen_t;
178 }
179 else
180 {
181 	struct LTOCodeGenerator {}; alias LTOCodeGenerator* lto_code_gen_t;
182 }
183 
184 alias int lto_symbol_attributes;
185 alias int lto_debug_model;
186 alias int lto_codegen_model;
187 alias int lto_codegen_diagnostic_severity_t;
188 alias extern(C) void function(lto_codegen_diagnostic_severity_t severity, const(char)* diag, void* ctxt) lto_diagnostic_handler_t;
189 
190 /+ Object file reading and writing +/
191 
192 struct LLVMOpaqueObjectFile {}; alias LLVMOpaqueObjectFile* LLVMObjectFileRef;
193 struct LLVMOpaqueSectionIterator {}; alias LLVMOpaqueSectionIterator* LLVMSectionIteratorRef;
194 struct LLVMOpaqueSymbolIterator {}; alias LLVMOpaqueSymbolIterator* LLVMSymbolIteratorRef;
195 struct LLVMOpaqueRelocationIterator {}; alias LLVMOpaqueRelocationIterator* LLVMRelocationIteratorRef;
196 
197 /+ Target information +/
198 
199 struct LLVMOpaqueTargetData {}; alias LLVMOpaqueTargetData* LLVMTargetDataRef;
200 struct LLVMOpaqueTargetLibraryInfotData {}; alias LLVMOpaqueTargetLibraryInfotData* LLVMTargetLibraryInfoRef;
201 static if(LLVM_Version < LLVMDVersion(3, 4, 0))
202 {
203 	struct LLVMStructLayout {}; alias LLVMStructLayout* LLVMStructLayoutRef;
204 }
205 alias int LLVMByteOrdering;
206 
207 /+ Target machine +/
208 
209 struct LLVMOpaqueTargetMachine {}; alias LLVMOpaqueTargetMachine* LLVMTargetMachineRef;
210 struct LLVMTarget {}; alias LLVMTarget* LLVMTargetRef;
211 
212 alias int LLVMCodeGenOptLevel;
213 alias int LLVMRelocMode;
214 alias int LLVMCodeModel;
215 alias int LLVMCodeGenFileType;
216 
217 static if(LLVM_Version >= LLVMDVersion(3, 8, 0))
218 {
219 	/+ JIT compilation of LLVM IR +/
220 	
221 	struct LLVMOrcOpaqueJITStack {}; alias LLVMOrcOpaqueJITStack* LLVMOrcJITStackRef;
222 
223 	alias uint LLVMOrcModuleHandle;
224 	alias uint LLVMOrcTargetAddress;
225 
226 	alias extern(C) ulong function(const(char)* Name, void* LookupCtx) LLVMOrcSymbolResolverFn;
227 	alias extern(C) ulong function(LLVMOrcJITStackRef JITStack, void* CallbackCtx) LLVMOrcLazyCompileCallbackFn;
228 }