1 
2 module llvm.c.constants;
3 
4 private
5 {
6 	import llvm.util.templates;
7 
8 	import llvm.c.types;
9 	import llvm.c.versions;
10 }
11 
12 /+ Analysis +/
13 
14 enum : LLVMVerifierFailureAction
15 {
16 	LLVMAbortProcessAction,
17 	LLVMPrintMessageAction,
18 	LLVMReturnStatusAction
19 }
20 
21 /+ Core +/
22 
23 /++ Types and Enumerations ++/
24 
25 enum : LLVMAttribute
26 {
27 	LLVMZExtAttribute = 1<<0,
28 	LLVMSExtAttribute = 1<<1,
29 	LLVMNoReturnAttribute = 1<<2,
30 	LLVMInRegAttribute = 1<<3,
31 	LLVMStructRetAttribute = 1<<4,
32 	LLVMNoUnwindAttribute = 1<<5,
33 	LLVMNoAliasAttribute = 1<<6,
34 	LLVMByValAttribute = 1<<7,
35 	LLVMNestAttribute = 1<<8,
36 	LLVMReadNoneAttribute = 1<<9,
37 	LLVMReadOnlyAttribute = 1<<10,
38 	LLVMNoInlineAttribute = 1<<11,
39 	LLVMAlwaysInlineAttribute = 1<<12,
40 	LLVMOptimizeForSizeAttribute = 1<<13,
41 	LLVMStackProtectAttribute = 1<<14,
42 	LLVMStackProtectReqAttribute = 1<<15,
43 	LLVMAlignment = 31<<16,
44 	LLVMNoCaptureAttribute = 1<<21,
45 	LLVMNoRedZoneAttribute = 1<<22,
46 	LLVMNoImplicitFloatAttribute = 1<<23,
47 	LLVMNakedAttribute = 1<<24,
48 	LLVMInlineHintAttribute = 1<<25,
49 	LLVMStackAlignment = 7<<26,
50 	LLVMReturnsTwice = 1<<29,
51 	LLVMUWTable = 1<<30,
52 	LLVMNonLazyBind = 1<<31
53 }
54 
55 mixin(MixinMap_VersionedEnum(
56 			  "", "LLVMOpcode", LLVM_Version,
57 			  ["LLVMRet            = 1" : null,
58 			   "LLVMBr             = 2" : null,
59 			   "LLVMSwitch         = 3" : null,
60 			   "LLVMIndirectBr     = 4" : null,
61 			   "LLVMInvoke         = 5" : null,
62 			   "LLVMUnreachable    = 7" : null,
63 			   "LLVMAdd            = 8" : null,
64 			   "LLVMFAdd           = 9" : null,
65 			   "LLVMSub            = 10" : null,
66 			   "LLVMFSub           = 11" : null,
67 			   "LLVMMul            = 12" : null,
68 			   "LLVMFMul           = 13" : null,
69 			   "LLVMUDiv           = 14" : null,
70 			   "LLVMSDiv           = 15" : null,
71 			   "LLVMFDiv           = 16" : null,
72 			   "LLVMURem           = 17" : null,
73 			   "LLVMSRem           = 18" : null,
74 			   "LLVMFRem           = 19" : null,
75 			   "LLVMShl            = 20" : null,
76 			   "LLVMLShr           = 21" : null,
77 			   "LLVMAShr           = 22" : null,
78 			   "LLVMAnd            = 23" : null,
79 			   "LLVMOr             = 24" : null,
80 			   "LLVMXor            = 25" : null,
81 			   "LLVMAlloca         = 26" : null,
82 			   "LLVMLoad           = 27" : null,
83 			   "LLVMStore          = 28" : null,
84 			   "LLVMGetElementPtr  = 29" : null,
85 			   "LLVMTrunc          = 30" : null,
86 			   "LLVMZExt           = 31" : null,
87 			   "LLVMSExt           = 32" : null,
88 			   "LLVMFPToUI         = 33" : null,
89 			   "LLVMFPToSI         = 34" : null,
90 			   "LLVMUIToFP         = 35" : null,
91 			   "LLVMSIToFP         = 36" : null,
92 			   "LLVMFPTrunc        = 37" : null,
93 			   "LLVMFPExt          = 38" : null,
94 			   "LLVMPtrToInt       = 39" : null,
95 			   "LLVMIntToPtr       = 40" : null,
96 			   "LLVMBitCast        = 41" : null,
97 			   "LLVMAddrSpaceCast  = 60" : ["+", "3", "4", "0"],
98 			   "LLVMICmp           = 42" : null,
99 			   "LLVMFCmp           = 43" : null,
100 			   "LLVMPHI            = 44" : null,
101 			   "LLVMCall           = 45" : null,
102 			   "LLVMSelect         = 46" : null,
103 			   "LLVMUserOp1        = 47" : null,
104 			   "LLVMUserOp2        = 48" : null,
105 			   "LLVMVAArg          = 49" : null,
106 			   "LLVMExtractElement = 50" : null,
107 			   "LLVMInsertElement  = 51" : null,
108 			   "LLVMShuffleVector  = 52" : null,
109 			   "LLVMExtractValue   = 53" : null,
110 			   "LLVMInsertValue    = 54" : null,
111 			   "LLVMFence          = 55" : null,
112 			   "LLVMAtomicCmpXchg  = 56" : null,
113 			   "LLVMAtomicRMW      = 57" : null,
114 			   "LLVMResume         = 58" : null,
115 			   "LLVMLandingPad     = 59" : null]));
116 
117 enum : LLVMTypeKind
118 {
119 	LLVMVoidTypeKind,
120 	LLVMHalfTypeKind,
121 	LLVMFloatTypeKind,
122 	LLVMDoubleTypeKind,
123 	LLVMX86_FP80TypeKind,
124 	LLVMFP128TypeKind,
125 	LLVMPPC_FP128TypeKind,
126 	LLVMLabelTypeKind,
127 	LLVMIntegerTypeKind,
128 	LLVMFunctionTypeKind,
129 	LLVMStructTypeKind,
130 	LLVMArrayTypeKind,
131 	LLVMPointerTypeKind,
132 	LLVMVectorTypeKind,
133 	LLVMMetadataTypeKind,
134 	LLVMX86_MMXTypeKind
135 }
136 
137 mixin(MixinMap_VersionedEnum(
138 	      "", "LLVMLinkage", LLVM_Version,
139 	      ["LLVMExternalLinkage" : null,
140 	       "LLVMAvailableExternallyLinkage" : null,
141 	       "LLVMLinkOnceAnyLinkage" : null,
142 	       "LLVMLinkOnceODRLinkage" : null,
143 	       "LLVMLinkOnceODRAutoHideLinkage" : ["+", "3", "2", "0"],
144 	       "LLVMWeakAnyLinkage" : null,
145 	       "LLVMWeakODRLinkage" : null,
146 	       "LLVMAppendingLinkage" : null,
147 	       "LLVMInternalLinkage" : null,
148 	       "LLVMPrivateLinkage" : null,
149 	       "LLVMDLLImportLinkage" : null,
150 	       "LLVMDLLExportLinkage" : null,
151 	       "LLVMExternalWeakLinkage" : null,
152 	       "LLVMGhostLinkage" : null,
153 	       "LLVMCommonLinkage" : null,
154 	       "LLVMLinkerPrivateLinkage" : null,
155 	       "LLVMLinkerPrivateWeakLinkage" : null,
156 	       "LLVMLinkerPrivateWeakDefAutoLinkage" : ["-", "3", "2", "0"]]));
157 
158 enum : LLVMVisibility
159 {
160 	LLVMDefaultVisibility,
161 	LLVMHiddenVisibility,
162 	LLVMProtectedVisibility
163 }
164 
165 static if(LLVM_Version >= LLVMDVersion(3, 5, 0))
166 {
167 	enum : LLVMDLLStorageClass {
168 		LLVMDefaultStorageClass = 0,
169 		LLVMDLLImportStorageClass = 1,
170 		LLVMDLLExportStorageClass = 2
171 	}
172 }
173 
174 mixin(MixinMap_VersionedEnum(
175 			  "", "LLVMCallConv", LLVM_Version,
176 			  ["LLVMCCallConv           = 0" : null,
177 			   "LLVMFastCallConv        = 8" : null,
178 			   "LLVMColdCallConv        = 9" : null,
179 			   "LLVMWebKitJSCallConv    = 12" : ["+", "3", "4", "0"],
180 			   "LLVMAnyRegCallConv      = 13" : ["+", "3", "4", "0"],
181 			   "LLVMX86StdcallCallConv  = 64" : null,
182 			   "LLVMX86FastcallCallConv = 65" : null]));
183 
184 enum : LLVMIntPredicate
185 {
186 	LLVMIntEQ = 32,
187 	LLVMIntNE,
188 	LLVMIntUGT,
189 	LLVMIntUGE,
190 	LLVMIntULT,
191 	LLVMIntULE,
192 	LLVMIntSGT,
193 	LLVMIntSGE,
194 	LLVMIntSLT,
195 	LLVMIntSLE
196 }
197 
198 enum : LLVMRealPredicate
199 {
200 	LLVMRealPredicateFalse,
201 	LLVMRealOEQ,
202 	LLVMRealOGT,
203 	LLVMRealOGE,
204 	LLVMRealOLT,
205 	LLVMRealOLE,
206 	LLVMRealONE,
207 	LLVMRealORD,
208 	LLVMRealUNO,
209 	LLVMRealUEQ,
210 	LLVMRealUGT,
211 	LLVMRealUGE,
212 	LLVMRealULT,
213 	LLVMRealULE,
214 	LLVMRealUNE,
215 	LLVMRealPredicateTrue
216 }
217 
218 enum : LLVMLandingPadClauseTy
219 {
220 	LLVMLandingPadCatch,
221 	LLVMLandingPadFilter
222 }
223 
224 static if(LLVM_Version >= LLVMDVersion(3, 3, 0))
225 {
226 	enum : LLVMThreadLocalMode
227 	{
228 		LLVMNotThreadLocal = 0,
229 		LLVMGeneralDynamicTLSModel,
230 		LLVMLocalDynamicTLSModel,
231 		LLVMInitialExecTLSModel,
232 		LLVMLocalExecTLSModel
233 	}
234 
235 	enum : LLVMAtomicOrdering
236 	{
237 		LLVMAtomicOrderingNotAtomic = 0,
238 		LLVMAtomicOrderingUnordered = 1,
239 		LLVMAtomicOrderingMonotonic = 2,
240 		LLVMAtomicOrderingAcquire = 4,
241 		LLVMAtomicOrderingRelease = 5,
242 		LLVMAtomicOrderingAcquireRelease = 6,
243 		LLVMAtomicOrderingSequentiallyConsistent = 7
244 	}
245 
246 	enum : LLVMAtomicRMWBinOp
247 	{
248 		LLVMAtomicRMWBinOpXchg,
249 		LLVMAtomicRMWBinOpAdd,
250 		LLVMAtomicRMWBinOpSub,
251 		LLVMAtomicRMWBinOpAnd,
252 		LLVMAtomicRMWBinOpNand,
253 		LLVMAtomicRMWBinOpOr,
254 		LLVMAtomicRMWBinOpXor,
255 		LLVMAtomicRMWBinOpMax,
256 		LLVMAtomicRMWBinOpMin,
257 		LLVMAtomicRMWBinOpUMax,
258 		LLVMAtomicRMWBinOpUMin
259 	}
260 }
261 static if(LLVM_Version > LLVMDVersion(3, 5, 0))
262 {
263 	enum : LLVMDiagnosticSeverity {
264 		LLVMDSError,
265 		LLVMDSWarning,
266 		LLVMDSRemark,
267 		LLVMDSNote
268 	}
269 }
270 
271 /+ Disassembler +/
272 
273 //TODO: replace const with enum?
274 const
275 {
276 	uint LLVMDisassembler_VariantKind_None = 0;
277 	uint LLVMDisassembler_VariantKind_ARM_HI16 = 1;
278 	uint LLVMDisassembler_VariantKind_ARM_LO16 = 2;
279 	static if(LLVM_Version >= 3.5)
280 	{
281 		uint LLVMDisassembler_VariantKind_ARM64_PAGE = 1;
282 		uint LLVMDisassembler_VariantKind_ARM64_PAGEOFF = 2;
283 		uint LLVMDisassembler_VariantKind_ARM64_GOTPAGE = 3;
284 		uint LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF = 4;
285 		uint LLVMDisassembler_VariantKind_ARM64_TLVP = 5;
286 		uint LLVMDisassembler_VariantKind_ARM64_TLVOFF = 6;
287 	}
288 	uint LLVMDisassembler_ReferenceType_InOut_None = 0;
289 	uint LLVMDisassembler_ReferenceType_In_Branch = 1;
290 	uint LLVMDisassembler_ReferenceType_In_PCrel_Load = 2;
291 	static if(LLVM_Version >= 3.5)
292 	{
293 		ulong LLVMDisassembler_ReferenceType_In_ARM64_ADRP = 0x100000001;
294 		ulong LLVMDisassembler_ReferenceType_In_ARM64_ADDXri = 0x100000002;
295 		ulong LLVMDisassembler_ReferenceType_In_ARM64_LDRXui = 0x100000003;
296 		ulong LLVMDisassembler_ReferenceType_In_ARM64_LDRXl = 0x100000004;
297 		ulong LLVMDisassembler_ReferenceType_In_ARM64_ADR = 0x100000005;
298 	}
299 	uint LLVMDisassembler_ReferenceType_Out_SymbolStub = 1;
300 	uint LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr = 2;
301 	uint LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr = 3;
302 	static if(LLVM_Version >= 3.2)
303 	{
304 		uint LLVMDisassembler_Option_UseMarkup = 1;
305 	}
306 	static if(LLVM_Version >= 3.3)
307 	{
308 		uint LLVMDisassembler_Option_PrintImmHex = 2;
309 		uint LLVMDisassembler_Option_AsmPrinterVariant = 4;
310 	}
311 	static if(LLVM_Version >= 3.4)
312 	{
313 		uint LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref = 4;
314 		uint LLVMDisassembler_ReferenceType_Out_Objc_Message = 5;
315 		uint LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref = 6;
316 		uint LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref = 7;
317 		uint LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref = 8;
318 		uint LLVMDisassembler_Option_SetInstrComments = 8;
319 		uint LLVMDisassembler_Option_PrintLatency = 16;
320 	}
321 	static if(LLVM_Version >= 3.5)
322 	{
323 		uint LLVMDisassembler_ReferenceType_DeMangled_Name = 9;
324 	}
325 }
326 
327 static if(LLVM_Version < LLVMDVersion(3, 3, 0))
328 {
329 	/+ Enhanced Disassembly +/
330 
331 	enum : EDAssemblySyntax_t
332 	{
333 		kEDAssemblySyntaxX86Intel = 0,
334 		kEDAssemblySyntaxX86ATT = 1,
335 		kEDAssemblySyntaxARMUAL = 2
336 	}
337 }
338 
339 static if(LLVM_Version >= LLVMDVersion(3, 2, 0))
340 {
341 	/+ Linker +/
342 
343 	mixin(MixinMap_VersionedEnum(
344 			  "", "LLVMLinkerMode", LLVM_Version,
345 			  ["LLVMLinkerDestroySource  = 0" : null,
346 			   "LLVMLinkerPreserveSource = 1" : ["-", "3", "7", "0"]]));
347 }
348 
349 /+ Link Time Optimization +/
350 
351 enum : llvm_lto_status
352 {
353 	LLVM_LTO_UNKNOWN,
354 	LLVM_LTO_OPT_SUCCESS,
355 	LLVM_LTO_READ_SUCCESS,
356 	LLVM_LTO_READ_FAILURE,
357 	LLVM_LTO_WRITE_FAILURE,
358 	LLVM_LTO_NO_TARGET,
359 	LLVM_LTO_NO_WORK,
360 	LLVM_LTO_MODULE_MERGE_FAILURE,
361 	LLVM_LTO_ASM_FAILURE,
362 	LLVM_LTO_NULL_OBJECT
363 }
364 
365 /+ LTO +/
366 
367 static if(LLVM_Version >= LLVMDVersion(3, 7, 0))
368 {
369 	const uint LTO_API_VERSION = 17;
370 }
371 else static if(LLVM_Version >= LLVMDVersion(3, 6, 0))
372 {
373 	const uint LTO_API_VERSION = 11;
374 }
375 else static if(LLVM_Version >= LLVMDVersion(3, 5, 0))
376 {
377 	const uint LTO_API_VERSION = 10;
378 }
379 else static if(LLVM_Version >= LLVMDVersion(3, 4, 0))
380 {
381 	const uint LTO_API_VERSION = 5;
382 }
383 else
384 {
385 	const uint LTO_API_VERSION = 4;
386 }
387 mixin(MixinMap_VersionedEnum(
388 			  "", "lto_symbol_attributes", LLVM_Version,
389 			  ["LTO_SYMBOL_ALIGNMENT_MASK =				 0x0000001F" : null,
390 			   "LTO_SYMBOL_PERMISSIONS_MASK =			 0x000000E0" : null,
391 			   "LTO_SYMBOL_PERMISSIONS_CODE =			 0x000000A0" : null,
392 			   "LTO_SYMBOL_PERMISSIONS_DATA =			 0x000000C0" : null,
393 			   "LTO_SYMBOL_PERMISSIONS_RODATA =			 0x00000080" : null,
394 			   "LTO_SYMBOL_DEFINITION_MASK =			 0x00000700" : null,
395 			   "LTO_SYMBOL_DEFINITION_REGULAR =			 0x00000100" : null,
396 			   "LTO_SYMBOL_DEFINITION_TENTATIVE =		 0x00000200" : null,
397 			   "LTO_SYMBOL_DEFINITION_WEAK =			 0x00000300" : null,
398 			   "LTO_SYMBOL_DEFINITION_UNDEFINED =		 0x00000400" : null,
399 			   "LTO_SYMBOL_DEFINITION_WEAKUNDEF =		 0x00000500" : null,
400 			   "LTO_SYMBOL_SCOPE_MASK =					 0x00003800" : null,
401 			   "LTO_SYMBOL_SCOPE_INTERNAL =			 	 0x00000800" : null,
402 			   "LTO_SYMBOL_SCOPE_HIDDEN =				 0x00001000" : null,
403 			   "LTO_SYMBOL_SCOPE_PROTECTED =			 0x00002000" : null,
404 			   "LTO_SYMBOL_SCOPE_DEFAULT =				 0x00001800" : null,
405 			   "LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x00002800" : null,
406 			   "LTO_SYMBOL_COMDAT =						 0x00004000" : ["+", "3", "7", "0"],
407 			   "LTO_SYMBOL_ALIAS =						 0x00008000" : ["+", "3", "7", "0"]]));
408 
409 enum : lto_debug_model
410 {
411 	LTO_DEBUG_MODEL_NONE = 0,
412 	LTO_DEBUG_MODEL_DWARF = 1
413 }
414 
415 enum : lto_codegen_model
416 {
417 	LTO_CODEGEN_PIC_MODEL_STATIC = 0,
418 	LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1,
419 	LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2,
420 	LTO_CODEGEN_PIC_MODEL_DEFAULT = 3
421 }
422 
423 static if(LLVM_Version >= LLVMDVersion(3, 5, 0))
424 {
425 	enum : lto_codegen_diagnostic_severity_t
426 	{
427 		LTO_DS_ERROR = 0,
428 		LTO_DS_WARNING = 1,
429 	   	LTO_DS_REMARK = 3,
430 		LTO_DS_NOTE = 2
431 	}
432 }
433 
434 /+ Target information +/
435 
436 enum : LLVMByteOrdering
437 {
438 	LLVMBigEndian,
439 	LLVMLittleEndian
440 }
441 
442 /+ Target machine +/
443 
444 enum : LLVMCodeGenOptLevel
445 {
446 	LLVMCodeGenLevelNone,
447 	LLVMCodeGenLevelLess,
448 	LLVMCodeGenLevelDefault,
449 	LLVMCodeGenLevelAggressive
450 }
451 
452 enum : LLVMRelocMode
453 {
454 	LLVMRelocDefault,
455 	LLVMRelocStatic,
456 	LLVMRelocPIC,
457 	LLVMRelocDynamicNoPic
458 }
459 
460 enum : LLVMCodeModel
461 {
462 	LLVMCodeModelDefault,
463 	LLVMCodeModelJITDefault,
464 	LLVMCodeModelSmall,
465 	LLVMCodeModelKernel,
466 	LLVMCodeModelMedium,
467 	LLVMCodeModelLarge
468 }
469 
470 enum : LLVMCodeGenFileType
471 {
472 	LLVMAssemblyFile,
473 	LLVMObjectFile
474 }