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