spice_packages/llvm/src/target-wrapper.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* llvm-c/Target.h helper functions wrappers. | ||
| 2 | * | ||
| 3 | * The LLVMInitializeAll* functions and friends are defined `static inline`, so | ||
| 4 | * we can't bind directly to them (the function body is generated via macro), | ||
| 5 | * so here are some wrappers. | ||
| 6 | */ | ||
| 7 | #include <llvm-c/Target.h> | ||
| 8 | |||
| 9 | /* The LLVMInitializeAll* functions of llvm-c/Target.h initialize every target of the LLVM build (see | ||
| 10 | * llvm/Config/Targets.def), but these bindings only link the libraries of the AArch64, WebAssembly and X86 targets (see | ||
| 11 | * linker-flags.spice). With an LLVM that was built with more targets, they reference libraries that are not linked, so | ||
| 12 | * the "All" wrappers initialize exactly the linked targets instead. Keep them in sync with linker-flags.spice. */ | ||
| 13 | |||
| 14 | /* Declared here as well, because llvm-c/Target.h only declares them for the targets of the LLVM build */ | ||
| 15 | #define SPICE_DECLARE_TARGET(Name) \ | ||
| 16 | LLVM_C_ABI void LLVMInitialize##Name##TargetInfo(void); \ | ||
| 17 | LLVM_C_ABI void LLVMInitialize##Name##Target(void); \ | ||
| 18 | LLVM_C_ABI void LLVMInitialize##Name##TargetMC(void); \ | ||
| 19 | LLVM_C_ABI void LLVMInitialize##Name##AsmPrinter(void); \ | ||
| 20 | LLVM_C_ABI void LLVMInitialize##Name##AsmParser(void); \ | ||
| 21 | LLVM_C_ABI void LLVMInitialize##Name##Disassembler(void); | ||
| 22 | SPICE_DECLARE_TARGET(AArch64) | ||
| 23 | SPICE_DECLARE_TARGET(WebAssembly) | ||
| 24 | SPICE_DECLARE_TARGET(X86) | ||
| 25 | #undef SPICE_DECLARE_TARGET | ||
| 26 | |||
| 27 | 53 | void LLVM_InitializeAllTargetInfos(void) { | |
| 28 | 53 | LLVMInitializeAArch64TargetInfo(); | |
| 29 | 53 | LLVMInitializeWebAssemblyTargetInfo(); | |
| 30 | 53 | LLVMInitializeX86TargetInfo(); | |
| 31 | 53 | } | |
| 32 | |||
| 33 | 53 | void LLVM_InitializeAllTargets(void) { | |
| 34 | 53 | LLVMInitializeAArch64Target(); | |
| 35 | 53 | LLVMInitializeWebAssemblyTarget(); | |
| 36 | 53 | LLVMInitializeX86Target(); | |
| 37 | 53 | } | |
| 38 | |||
| 39 | 53 | void LLVM_InitializeAllTargetMCs(void) { | |
| 40 | 53 | LLVMInitializeAArch64TargetMC(); | |
| 41 | 53 | LLVMInitializeWebAssemblyTargetMC(); | |
| 42 | 53 | LLVMInitializeX86TargetMC(); | |
| 43 | 53 | } | |
| 44 | |||
| 45 | 53 | void LLVM_InitializeAllAsmPrinters(void) { | |
| 46 | 53 | LLVMInitializeAArch64AsmPrinter(); | |
| 47 | 53 | LLVMInitializeWebAssemblyAsmPrinter(); | |
| 48 | 53 | LLVMInitializeX86AsmPrinter(); | |
| 49 | 53 | } | |
| 50 | |||
| 51 | 53 | void LLVM_InitializeAllAsmParsers(void) { | |
| 52 | 53 | LLVMInitializeAArch64AsmParser(); | |
| 53 | 53 | LLVMInitializeWebAssemblyAsmParser(); | |
| 54 | 53 | LLVMInitializeX86AsmParser(); | |
| 55 | 53 | } | |
| 56 | |||
| 57 | ✗ | void LLVM_InitializeAllDisassemblers(void) { | |
| 58 | ✗ | LLVMInitializeAArch64Disassembler(); | |
| 59 | ✗ | LLVMInitializeWebAssemblyDisassembler(); | |
| 60 | ✗ | LLVMInitializeX86Disassembler(); | |
| 61 | ✗ | } | |
| 62 | |||
| 63 | /* These functions return true on failure. */ | ||
| 64 | 1185 | LLVMBool LLVM_InitializeNativeTarget(void) { return LLVMInitializeNativeTarget(); } | |
| 65 | |||
| 66 | 1183 | LLVMBool LLVM_InitializeNativeAsmParser(void) { return LLVMInitializeNativeAsmParser(); } | |
| 67 | |||
| 68 | 1185 | LLVMBool LLVM_InitializeNativeAsmPrinter(void) { return LLVMInitializeNativeAsmPrinter(); } | |
| 69 | |||
| 70 | ✗ | LLVMBool LLVM_InitializeNativeDisassembler(void) { return LLVMInitializeNativeDisassembler(); } | |
| 71 |