1 module llvm.functions;
2 
3 import std.array : array;
4 import std.algorithm.iteration : map, joiner;
5 import std.range : chain;
6 
7 import llvm.config;
8 import llvm.types;
9 
10 private nothrow auto orEmpty(T)(T v)
11 {
12     return v? v : "";
13 }
14 
15 nothrow void LLVMInitializeAllTargetInfos()
16 {
17     mixin(LLVM_Targets.map!(t => "LLVMInitialize" ~ t ~ "TargetInfo();").joiner.array.orEmpty);
18 }
19 
20 nothrow void LLVMInitializeAllTargets()
21 {
22     mixin(LLVM_Targets.map!(t => "LLVMInitialize" ~ t ~ "Target();").joiner.array.orEmpty);
23 }
24 
25 nothrow void LLVMInitializeAllTargetMCs()
26 {
27     mixin(LLVM_Targets.map!(t => "LLVMInitialize" ~ t ~ "TargetMC();").joiner.array.orEmpty);
28 }
29 
30 nothrow void LLVMInitializeAllAsmPrinters()
31 {
32     mixin(LLVM_AsmPrinters.map!(t => "LLVMInitialize" ~ t ~ "AsmPrinter();").joiner.array.orEmpty);
33 }
34 
35 nothrow void LLVMInitializeAllAsmParsers()
36 {
37     mixin(LLVM_AsmParsers.map!(t => "LLVMInitialize" ~ t ~ "AsmParser();").joiner.array.orEmpty);
38 }
39 
40 nothrow void LLVMInitializeAllDisassemblers()
41 {
42     mixin(LLVM_Disassemblers.map!(t => "LLVMInitialize" ~ t ~ "Disassembler();").joiner.array.orEmpty);
43 }
44 
45 nothrow LLVMBool LLVMInitializeNativeTarget()
46 {
47     static if (LLVM_NativeTarget != "") {
48         mixin("LLVMInitialize" ~ LLVM_NativeTarget ~ "TargetInfo();");
49         mixin("LLVMInitialize" ~ LLVM_NativeTarget ~ "Target();");
50         mixin("LLVMInitialize" ~ LLVM_NativeTarget ~ "TargetMC();");
51         return 0;
52     } else {
53         return 1;
54     }
55 }
56 
57 static if (LLVM_Version >= asVersion(3, 4, 0))
58 {
59     nothrow LLVMBool LLVMInitializeNativeAsmParser()
60     {
61         static if (LLVM_NativeTarget != "") {
62             mixin("LLVMInitialize" ~ LLVM_NativeTarget ~ "AsmParser();");
63             return 0;
64         } else {
65             return 1;
66         }
67     }
68 
69     nothrow LLVMBool LLVMInitializeNativeAsmPrinter()
70     {
71         static if (LLVM_NativeTarget != "") {
72             mixin("LLVMInitialize" ~ LLVM_NativeTarget ~ "AsmPrinter();");
73             return 0;
74         } else {
75             return 1;
76         }
77     }
78 
79     nothrow LLVMBool LLVMInitializeNativeDisassembler()
80     {
81         static if (LLVM_NativeTarget != "") {
82             mixin("LLVMInitialize" ~ LLVM_NativeTarget ~ "Disassembler();");
83             return 0;
84         } else {
85             return 1;
86         }
87     }
88 }
89 
90      version (LLVM_Load) public import llvm.functions.load;
91 else                     public import llvm.functions.link;