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 belongs creates 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,
189 		const char *diag, void *ctxt) lto_diagnostic_handler_t;
190 
191 /+ Object file reading and writing +/
192 
193 struct LLVMOpaqueObjectFile {}; alias LLVMOpaqueObjectFile* LLVMObjectFileRef;
194 struct LLVMOpaqueSectionIterator {}; alias LLVMOpaqueSectionIterator* LLVMSectionIteratorRef;
195 struct LLVMOpaqueSymbolIterator {}; alias LLVMOpaqueSymbolIterator* LLVMSymbolIteratorRef;
196 struct LLVMOpaqueRelocationIterator {}; alias LLVMOpaqueRelocationIterator* LLVMRelocationIteratorRef;
197 
198 /+ Target information +/
199 
200 struct LLVMOpaqueTargetData {}; alias LLVMOpaqueTargetData* LLVMTargetDataRef;
201 struct LLVMOpaqueTargetLibraryInfotData {}; alias LLVMOpaqueTargetLibraryInfotData* LLVMTargetLibraryInfoRef;
202 static if(LLVM_Version < LLVMDVersion(3, 4, 0))
203 {
204 	struct LLVMStructLayout {}; alias LLVMStructLayout* LLVMStructLayoutRef;
205 }
206 alias int LLVMByteOrdering;
207 
208 /+ Target machine +/
209 
210 struct LLVMOpaqueTargetMachine {}; alias LLVMOpaqueTargetMachine* LLVMTargetMachineRef;
211 struct LLVMTarget {}; alias LLVMTarget* LLVMTargetRef;
212 
213 alias int LLVMCodeGenOptLevel;
214 alias int LLVMRelocMode;
215 alias int LLVMCodeModel;
216 alias int LLVMCodeGenFileType;