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 			   "LLVMCleanupRet     = 61" : ["+", "3", "8", "0"],
117 			   "LLVMCatchRet       = 62" : ["+", "3", "8", "0"],
118 			   "LLVMCatchPad       = 63" : ["+", "3", "8", "0"],
119 			   "LLVMCleanupPad     = 64" : ["+", "3", "8", "0"],
120 			   "LLVMCatchSwitch    = 65" : ["+", "3", "8", "0"]]));
121 
122 mixin(MixinMap_VersionedEnum(
123 	      "", "LLVMTypeKind", LLVM_Version,
124 	      ["LLVMVoidTypeKind" : null,
125            "LLVMHalfTypeKind" : null,
126            "LLVMFloatTypeKind" : null,
127            "LLVMDoubleTypeKind" : null,
128            "LLVMX86_FP80TypeKind" : null,
129            "LLVMFP128TypeKind" : null,
130            "LLVMPPC_FP128TypeKind" : null,
131            "LLVMLabelTypeKind" : null,
132            "LLVMIntegerTypeKind" : null,
133            "LLVMFunctionTypeKind" : null,
134            "LLVMStructTypeKind" : null,
135            "LLVMArrayTypeKind" : null,
136            "LLVMPointerTypeKind" : null,
137            "LLVMVectorTypeKind" : null,
138            "LLVMMetadataTypeKind" : null,
139            "LLVMX86_MMXTypeKind" : null,
140            "LLVMTokenTypeKind": ["+", "3", "8", "0"]]));
141 
142 mixin(MixinMap_VersionedEnum(
143 	      "", "LLVMLinkage", LLVM_Version,
144 	      ["LLVMExternalLinkage" : null,
145 	       "LLVMAvailableExternallyLinkage" : null,
146 	       "LLVMLinkOnceAnyLinkage" : null,
147 	       "LLVMLinkOnceODRLinkage" : null,
148 	       "LLVMLinkOnceODRAutoHideLinkage" : ["+", "3", "2", "0"],
149 	       "LLVMWeakAnyLinkage" : null,
150 	       "LLVMWeakODRLinkage" : null,
151 	       "LLVMAppendingLinkage" : null,
152 	       "LLVMInternalLinkage" : null,
153 	       "LLVMPrivateLinkage" : null,
154 	       "LLVMDLLImportLinkage" : null,
155 	       "LLVMDLLExportLinkage" : null,
156 	       "LLVMExternalWeakLinkage" : null,
157 	       "LLVMGhostLinkage" : null,
158 	       "LLVMCommonLinkage" : null,
159 	       "LLVMLinkerPrivateLinkage" : null,
160 	       "LLVMLinkerPrivateWeakLinkage" : null,
161 	       "LLVMLinkerPrivateWeakDefAutoLinkage" : ["-", "3", "2", "0"]]));
162 
163 enum : LLVMVisibility
164 {
165 	LLVMDefaultVisibility,
166 	LLVMHiddenVisibility,
167 	LLVMProtectedVisibility
168 }
169 
170 static if(LLVM_Version >= LLVMDVersion(3, 5, 0))
171 {
172 	enum : LLVMDLLStorageClass {
173 		LLVMDefaultStorageClass = 0,
174 		LLVMDLLImportStorageClass = 1,
175 		LLVMDLLExportStorageClass = 2
176 	}
177 }
178 
179 mixin(MixinMap_VersionedEnum(
180 			  "", "LLVMCallConv", LLVM_Version,
181 			  ["LLVMCCallConv           = 0" : null,
182 			   "LLVMFastCallConv        = 8" : null,
183 			   "LLVMColdCallConv        = 9" : null,
184 			   "LLVMWebKitJSCallConv    = 12" : ["+", "3", "4", "0"],
185 			   "LLVMAnyRegCallConv      = 13" : ["+", "3", "4", "0"],
186 			   "LLVMX86StdcallCallConv  = 64" : null,
187 			   "LLVMX86FastcallCallConv = 65" : null]));
188 
189 enum : LLVMIntPredicate
190 {
191 	LLVMIntEQ = 32,
192 	LLVMIntNE,
193 	LLVMIntUGT,
194 	LLVMIntUGE,
195 	LLVMIntULT,
196 	LLVMIntULE,
197 	LLVMIntSGT,
198 	LLVMIntSGE,
199 	LLVMIntSLT,
200 	LLVMIntSLE
201 }
202 
203 enum : LLVMRealPredicate
204 {
205 	LLVMRealPredicateFalse,
206 	LLVMRealOEQ,
207 	LLVMRealOGT,
208 	LLVMRealOGE,
209 	LLVMRealOLT,
210 	LLVMRealOLE,
211 	LLVMRealONE,
212 	LLVMRealORD,
213 	LLVMRealUNO,
214 	LLVMRealUEQ,
215 	LLVMRealUGT,
216 	LLVMRealUGE,
217 	LLVMRealULT,
218 	LLVMRealULE,
219 	LLVMRealUNE,
220 	LLVMRealPredicateTrue
221 }
222 
223 enum : LLVMLandingPadClauseTy
224 {
225 	LLVMLandingPadCatch,
226 	LLVMLandingPadFilter
227 }
228 
229 static if(LLVM_Version >= LLVMDVersion(3, 3, 0))
230 {
231 	enum : LLVMThreadLocalMode
232 	{
233 		LLVMNotThreadLocal = 0,
234 		LLVMGeneralDynamicTLSModel,
235 		LLVMLocalDynamicTLSModel,
236 		LLVMInitialExecTLSModel,
237 		LLVMLocalExecTLSModel
238 	}
239 
240 	enum : LLVMAtomicOrdering
241 	{
242 		LLVMAtomicOrderingNotAtomic = 0,
243 		LLVMAtomicOrderingUnordered = 1,
244 		LLVMAtomicOrderingMonotonic = 2,
245 		LLVMAtomicOrderingAcquire = 4,
246 		LLVMAtomicOrderingRelease = 5,
247 		LLVMAtomicOrderingAcquireRelease = 6,
248 		LLVMAtomicOrderingSequentiallyConsistent = 7
249 	}
250 
251 	enum : LLVMAtomicRMWBinOp
252 	{
253 		LLVMAtomicRMWBinOpXchg,
254 		LLVMAtomicRMWBinOpAdd,
255 		LLVMAtomicRMWBinOpSub,
256 		LLVMAtomicRMWBinOpAnd,
257 		LLVMAtomicRMWBinOpNand,
258 		LLVMAtomicRMWBinOpOr,
259 		LLVMAtomicRMWBinOpXor,
260 		LLVMAtomicRMWBinOpMax,
261 		LLVMAtomicRMWBinOpMin,
262 		LLVMAtomicRMWBinOpUMax,
263 		LLVMAtomicRMWBinOpUMin
264 	}
265 }
266 static if(LLVM_Version > LLVMDVersion(3, 5, 0))
267 {
268 	enum : LLVMDiagnosticSeverity {
269 		LLVMDSError,
270 		LLVMDSWarning,
271 		LLVMDSRemark,
272 		LLVMDSNote
273 	}
274 }
275 
276 /+ Disassembler +/
277 
278 //TODO: replace const with enum?
279 const
280 {
281 	uint LLVMDisassembler_VariantKind_None = 0;
282 	uint LLVMDisassembler_VariantKind_ARM_HI16 = 1;
283 	uint LLVMDisassembler_VariantKind_ARM_LO16 = 2;
284 	static if(LLVM_Version >= 3.5)
285 	{
286 		uint LLVMDisassembler_VariantKind_ARM64_PAGE = 1;
287 		uint LLVMDisassembler_VariantKind_ARM64_PAGEOFF = 2;
288 		uint LLVMDisassembler_VariantKind_ARM64_GOTPAGE = 3;
289 		uint LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF = 4;
290 		uint LLVMDisassembler_VariantKind_ARM64_TLVP = 5;
291 		uint LLVMDisassembler_VariantKind_ARM64_TLVOFF = 6;
292 	}
293 	uint LLVMDisassembler_ReferenceType_InOut_None = 0;
294 	uint LLVMDisassembler_ReferenceType_In_Branch = 1;
295 	uint LLVMDisassembler_ReferenceType_In_PCrel_Load = 2;
296 	static if(LLVM_Version >= 3.5)
297 	{
298 		ulong LLVMDisassembler_ReferenceType_In_ARM64_ADRP = 0x100000001;
299 		ulong LLVMDisassembler_ReferenceType_In_ARM64_ADDXri = 0x100000002;
300 		ulong LLVMDisassembler_ReferenceType_In_ARM64_LDRXui = 0x100000003;
301 		ulong LLVMDisassembler_ReferenceType_In_ARM64_LDRXl = 0x100000004;
302 		ulong LLVMDisassembler_ReferenceType_In_ARM64_ADR = 0x100000005;
303 	}
304 	uint LLVMDisassembler_ReferenceType_Out_SymbolStub = 1;
305 	uint LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr = 2;
306 	uint LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr = 3;
307 	static if(LLVM_Version >= 3.2)
308 	{
309 		uint LLVMDisassembler_Option_UseMarkup = 1;
310 	}
311 	static if(LLVM_Version >= 3.3)
312 	{
313 		uint LLVMDisassembler_Option_PrintImmHex = 2;
314 		uint LLVMDisassembler_Option_AsmPrinterVariant = 4;
315 	}
316 	static if(LLVM_Version >= 3.4)
317 	{
318 		uint LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref = 4;
319 		uint LLVMDisassembler_ReferenceType_Out_Objc_Message = 5;
320 		uint LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref = 6;
321 		uint LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref = 7;
322 		uint LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref = 8;
323 		uint LLVMDisassembler_Option_SetInstrComments = 8;
324 		uint LLVMDisassembler_Option_PrintLatency = 16;
325 	}
326 	static if(LLVM_Version >= 3.5)
327 	{
328 		uint LLVMDisassembler_ReferenceType_DeMangled_Name = 9;
329 	}
330 }
331 
332 static if(LLVM_Version < LLVMDVersion(3, 3, 0))
333 {
334 	/+ Enhanced Disassembly +/
335 
336 	enum : EDAssemblySyntax_t
337 	{
338 		kEDAssemblySyntaxX86Intel = 0,
339 		kEDAssemblySyntaxX86ATT = 1,
340 		kEDAssemblySyntaxARMUAL = 2
341 	}
342 }
343 
344 static if(LLVM_Version >= LLVMDVersion(3, 2, 0))
345 {
346 	/+ Linker +/
347 
348 	mixin(MixinMap_VersionedEnum(
349 			  "", "LLVMLinkerMode", LLVM_Version,
350 			  ["LLVMLinkerDestroySource  = 0" : null,
351 			   "LLVMLinkerPreserveSource = 1" : ["-", "3", "7", "0"]]));
352 }
353 
354 /+ Link Time Optimization +/
355 
356 enum : llvm_lto_status
357 {
358 	LLVM_LTO_UNKNOWN,
359 	LLVM_LTO_OPT_SUCCESS,
360 	LLVM_LTO_READ_SUCCESS,
361 	LLVM_LTO_READ_FAILURE,
362 	LLVM_LTO_WRITE_FAILURE,
363 	LLVM_LTO_NO_TARGET,
364 	LLVM_LTO_NO_WORK,
365 	LLVM_LTO_MODULE_MERGE_FAILURE,
366 	LLVM_LTO_ASM_FAILURE,
367 	LLVM_LTO_NULL_OBJECT
368 }
369 
370 /+ LTO +/
371 
372 static if(LLVM_Version >= LLVMDVersion(3, 7, 0))
373 {
374 	const uint LTO_API_VERSION = 17;
375 }
376 else static if(LLVM_Version >= LLVMDVersion(3, 6, 0))
377 {
378 	const uint LTO_API_VERSION = 11;
379 }
380 else static if(LLVM_Version >= LLVMDVersion(3, 5, 0))
381 {
382 	const uint LTO_API_VERSION = 10;
383 }
384 else static if(LLVM_Version >= LLVMDVersion(3, 4, 0))
385 {
386 	const uint LTO_API_VERSION = 5;
387 }
388 else
389 {
390 	const uint LTO_API_VERSION = 4;
391 }
392 mixin(MixinMap_VersionedEnum(
393 			  "", "lto_symbol_attributes", LLVM_Version,
394 			  ["LTO_SYMBOL_ALIGNMENT_MASK =				 0x0000001F" : null,
395 			   "LTO_SYMBOL_PERMISSIONS_MASK =			 0x000000E0" : null,
396 			   "LTO_SYMBOL_PERMISSIONS_CODE =			 0x000000A0" : null,
397 			   "LTO_SYMBOL_PERMISSIONS_DATA =			 0x000000C0" : null,
398 			   "LTO_SYMBOL_PERMISSIONS_RODATA =			 0x00000080" : null,
399 			   "LTO_SYMBOL_DEFINITION_MASK =			 0x00000700" : null,
400 			   "LTO_SYMBOL_DEFINITION_REGULAR =			 0x00000100" : null,
401 			   "LTO_SYMBOL_DEFINITION_TENTATIVE =		 0x00000200" : null,
402 			   "LTO_SYMBOL_DEFINITION_WEAK =			 0x00000300" : null,
403 			   "LTO_SYMBOL_DEFINITION_UNDEFINED =		 0x00000400" : null,
404 			   "LTO_SYMBOL_DEFINITION_WEAKUNDEF =		 0x00000500" : null,
405 			   "LTO_SYMBOL_SCOPE_MASK =					 0x00003800" : null,
406 			   "LTO_SYMBOL_SCOPE_INTERNAL =			 	 0x00000800" : null,
407 			   "LTO_SYMBOL_SCOPE_HIDDEN =				 0x00001000" : null,
408 			   "LTO_SYMBOL_SCOPE_PROTECTED =			 0x00002000" : null,
409 			   "LTO_SYMBOL_SCOPE_DEFAULT =				 0x00001800" : null,
410 			   "LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x00002800" : null,
411 			   "LTO_SYMBOL_COMDAT =						 0x00004000" : ["+", "3", "7", "0"],
412 			   "LTO_SYMBOL_ALIAS =						 0x00008000" : ["+", "3", "7", "0"]]));
413 
414 enum : lto_debug_model
415 {
416 	LTO_DEBUG_MODEL_NONE = 0,
417 	LTO_DEBUG_MODEL_DWARF = 1
418 }
419 
420 enum : lto_codegen_model
421 {
422 	LTO_CODEGEN_PIC_MODEL_STATIC = 0,
423 	LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1,
424 	LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2,
425 	LTO_CODEGEN_PIC_MODEL_DEFAULT = 3
426 }
427 
428 static if(LLVM_Version >= LLVMDVersion(3, 5, 0))
429 {
430 	enum : lto_codegen_diagnostic_severity_t
431 	{
432 		LTO_DS_ERROR = 0,
433 		LTO_DS_WARNING = 1,
434 	   	LTO_DS_REMARK = 3,
435 		LTO_DS_NOTE = 2
436 	}
437 }
438 
439 /+ Target information +/
440 
441 enum : LLVMByteOrdering
442 {
443 	LLVMBigEndian,
444 	LLVMLittleEndian
445 }
446 
447 /+ Target machine +/
448 
449 enum : LLVMCodeGenOptLevel
450 {
451 	LLVMCodeGenLevelNone,
452 	LLVMCodeGenLevelLess,
453 	LLVMCodeGenLevelDefault,
454 	LLVMCodeGenLevelAggressive
455 }
456 
457 enum : LLVMRelocMode
458 {
459 	LLVMRelocDefault,
460 	LLVMRelocStatic,
461 	LLVMRelocPIC,
462 	LLVMRelocDynamicNoPic
463 }
464 
465 enum : LLVMCodeModel
466 {
467 	LLVMCodeModelDefault,
468 	LLVMCodeModelJITDefault,
469 	LLVMCodeModelSmall,
470 	LLVMCodeModelKernel,
471 	LLVMCodeModelMedium,
472 	LLVMCodeModelLarge
473 }
474 
475 enum : LLVMCodeGenFileType
476 {
477 	LLVMAssemblyFile,
478 	LLVMObjectFile
479 }