1//! We do this instead of @cImport because the self-hosted compiler is easier
2//! to bootstrap if it does not depend on translate-c.
3
4/// Do not compare directly to .True, use toBool() instead.
5pub const Bool = enum(c_int) {
6    False,
7    True,
8    _,
9
10    pub fn fromBool(b: bool) Bool {
11        return @intToEnum(Bool, @boolToInt(b));
12    }
13
14    pub fn toBool(b: Bool) bool {
15        return b != .False;
16    }
17};
18pub const AttributeIndex = c_uint;
19
20/// Make sure to use the *InContext functions instead of the global ones.
21pub const Context = opaque {
22    pub const create = LLVMContextCreate;
23    extern fn LLVMContextCreate() *const Context;
24
25    pub const dispose = LLVMContextDispose;
26    extern fn LLVMContextDispose(C: *const Context) void;
27
28    pub const createEnumAttribute = LLVMCreateEnumAttribute;
29    extern fn LLVMCreateEnumAttribute(*const Context, KindID: c_uint, Val: u64) *const Attribute;
30
31    pub const createStringAttribute = LLVMCreateStringAttribute;
32    extern fn LLVMCreateStringAttribute(*const Context, Key: [*]const u8, Key_Len: c_uint, Value: [*]const u8, Value_Len: c_uint) *const Attribute;
33
34    pub const intType = LLVMIntTypeInContext;
35    extern fn LLVMIntTypeInContext(C: *const Context, NumBits: c_uint) *const Type;
36
37    pub const halfType = LLVMHalfTypeInContext;
38    extern fn LLVMHalfTypeInContext(C: *const Context) *const Type;
39
40    pub const floatType = LLVMFloatTypeInContext;
41    extern fn LLVMFloatTypeInContext(C: *const Context) *const Type;
42
43    pub const doubleType = LLVMDoubleTypeInContext;
44    extern fn LLVMDoubleTypeInContext(C: *const Context) *const Type;
45
46    pub const x86FP80Type = LLVMX86FP80TypeInContext;
47    extern fn LLVMX86FP80TypeInContext(C: *const Context) *const Type;
48
49    pub const fp128Type = LLVMFP128TypeInContext;
50    extern fn LLVMFP128TypeInContext(C: *const Context) *const Type;
51
52    pub const voidType = LLVMVoidTypeInContext;
53    extern fn LLVMVoidTypeInContext(C: *const Context) *const Type;
54
55    pub const structType = LLVMStructTypeInContext;
56    extern fn LLVMStructTypeInContext(
57        C: *const Context,
58        ElementTypes: [*]const *const Type,
59        ElementCount: c_uint,
60        Packed: Bool,
61    ) *const Type;
62
63    const structCreateNamed = LLVMStructCreateNamed;
64    extern fn LLVMStructCreateNamed(C: *const Context, Name: [*:0]const u8) *const Type;
65
66    pub const constString = LLVMConstStringInContext;
67    extern fn LLVMConstStringInContext(C: *const Context, Str: [*]const u8, Length: c_uint, DontNullTerminate: Bool) *const Value;
68
69    pub const constStruct = LLVMConstStructInContext;
70    extern fn LLVMConstStructInContext(
71        C: *const Context,
72        ConstantVals: [*]const *const Value,
73        Count: c_uint,
74        Packed: Bool,
75    ) *const Value;
76
77    pub const createBasicBlock = LLVMCreateBasicBlockInContext;
78    extern fn LLVMCreateBasicBlockInContext(C: *const Context, Name: [*:0]const u8) *const BasicBlock;
79
80    pub const appendBasicBlock = LLVMAppendBasicBlockInContext;
81    extern fn LLVMAppendBasicBlockInContext(C: *const Context, Fn: *const Value, Name: [*:0]const u8) *const BasicBlock;
82
83    pub const createBuilder = LLVMCreateBuilderInContext;
84    extern fn LLVMCreateBuilderInContext(C: *const Context) *const Builder;
85};
86
87pub const Value = opaque {
88    pub const addAttributeAtIndex = LLVMAddAttributeAtIndex;
89    extern fn LLVMAddAttributeAtIndex(*const Value, Idx: AttributeIndex, A: *const Attribute) void;
90
91    pub const removeEnumAttributeAtIndex = LLVMRemoveEnumAttributeAtIndex;
92    extern fn LLVMRemoveEnumAttributeAtIndex(F: *const Value, Idx: AttributeIndex, KindID: c_uint) void;
93
94    pub const getFirstBasicBlock = LLVMGetFirstBasicBlock;
95    extern fn LLVMGetFirstBasicBlock(Fn: *const Value) ?*const BasicBlock;
96
97    pub const appendExistingBasicBlock = LLVMAppendExistingBasicBlock;
98    extern fn LLVMAppendExistingBasicBlock(Fn: *const Value, BB: *const BasicBlock) void;
99
100    pub const addIncoming = LLVMAddIncoming;
101    extern fn LLVMAddIncoming(
102        PhiNode: *const Value,
103        IncomingValues: [*]const *const Value,
104        IncomingBlocks: [*]const *const BasicBlock,
105        Count: c_uint,
106    ) void;
107
108    pub const getNextInstruction = LLVMGetNextInstruction;
109    extern fn LLVMGetNextInstruction(Inst: *const Value) ?*const Value;
110
111    pub const typeOf = LLVMTypeOf;
112    extern fn LLVMTypeOf(Val: *const Value) *const Type;
113
114    pub const setGlobalConstant = LLVMSetGlobalConstant;
115    extern fn LLVMSetGlobalConstant(GlobalVar: *const Value, IsConstant: Bool) void;
116
117    pub const setLinkage = LLVMSetLinkage;
118    extern fn LLVMSetLinkage(Global: *const Value, Linkage: Linkage) void;
119
120    pub const setUnnamedAddr = LLVMSetUnnamedAddr;
121    extern fn LLVMSetUnnamedAddr(Global: *const Value, HasUnnamedAddr: Bool) void;
122
123    pub const deleteGlobal = LLVMDeleteGlobal;
124    extern fn LLVMDeleteGlobal(GlobalVar: *const Value) void;
125
126    pub const getNextGlobalAlias = LLVMGetNextGlobalAlias;
127    extern fn LLVMGetNextGlobalAlias(GA: *const Value) *const Value;
128
129    pub const getAliasee = LLVMAliasGetAliasee;
130    extern fn LLVMAliasGetAliasee(Alias: *const Value) *const Value;
131
132    pub const setAliasee = LLVMAliasSetAliasee;
133    extern fn LLVMAliasSetAliasee(Alias: *const Value, Aliasee: *const Value) void;
134
135    pub const constInBoundsGEP = LLVMConstInBoundsGEP;
136    extern fn LLVMConstInBoundsGEP(
137        ConstantVal: *const Value,
138        ConstantIndices: [*]const *const Value,
139        NumIndices: c_uint,
140    ) *const Value;
141
142    pub const constBitCast = LLVMConstBitCast;
143    extern fn LLVMConstBitCast(ConstantVal: *const Value, ToType: *const Type) *const Value;
144
145    pub const constIntToPtr = LLVMConstIntToPtr;
146    extern fn LLVMConstIntToPtr(ConstantVal: *const Value, ToType: *const Type) *const Value;
147
148    pub const constPtrToInt = LLVMConstPtrToInt;
149    extern fn LLVMConstPtrToInt(ConstantVal: *const Value, ToType: *const Type) *const Value;
150
151    pub const setWeak = LLVMSetWeak;
152    extern fn LLVMSetWeak(CmpXchgInst: *const Value, IsWeak: Bool) void;
153
154    pub const setOrdering = LLVMSetOrdering;
155    extern fn LLVMSetOrdering(MemoryAccessInst: *const Value, Ordering: AtomicOrdering) void;
156
157    pub const setVolatile = LLVMSetVolatile;
158    extern fn LLVMSetVolatile(MemoryAccessInst: *const Value, IsVolatile: Bool) void;
159
160    pub const setAlignment = LLVMSetAlignment;
161    extern fn LLVMSetAlignment(V: *const Value, Bytes: c_uint) void;
162
163    pub const getFunctionCallConv = LLVMGetFunctionCallConv;
164    extern fn LLVMGetFunctionCallConv(Fn: *const Value) CallConv;
165
166    pub const setFunctionCallConv = LLVMSetFunctionCallConv;
167    extern fn LLVMSetFunctionCallConv(Fn: *const Value, CC: CallConv) void;
168
169    pub const setValueName = LLVMSetValueName;
170    extern fn LLVMSetValueName(Val: *const Value, Name: [*:0]const u8) void;
171
172    pub const setValueName2 = LLVMSetValueName2;
173    extern fn LLVMSetValueName2(Val: *const Value, Name: [*]const u8, NameLen: usize) void;
174
175    pub const deleteFunction = LLVMDeleteFunction;
176    extern fn LLVMDeleteFunction(Fn: *const Value) void;
177
178    pub const addSretAttr = ZigLLVMAddSretAttr;
179    extern fn ZigLLVMAddSretAttr(fn_ref: *const Value, ArgNo: c_uint, type_val: *const Type) void;
180
181    pub const setCallSret = ZigLLVMSetCallSret;
182    extern fn ZigLLVMSetCallSret(Call: *const Value, return_type: *const Type) void;
183
184    pub const getParam = LLVMGetParam;
185    extern fn LLVMGetParam(Fn: *const Value, Index: c_uint) *const Value;
186
187    pub const setInitializer = LLVMSetInitializer;
188    extern fn LLVMSetInitializer(GlobalVar: *const Value, ConstantVal: *const Value) void;
189
190    pub const addCase = LLVMAddCase;
191    extern fn LLVMAddCase(Switch: *const Value, OnVal: *const Value, Dest: *const BasicBlock) void;
192};
193
194pub const Type = opaque {
195    pub const constNull = LLVMConstNull;
196    extern fn LLVMConstNull(Ty: *const Type) *const Value;
197
198    pub const constAllOnes = LLVMConstAllOnes;
199    extern fn LLVMConstAllOnes(Ty: *const Type) *const Value;
200
201    pub const constInt = LLVMConstInt;
202    extern fn LLVMConstInt(IntTy: *const Type, N: c_ulonglong, SignExtend: Bool) *const Value;
203
204    pub const constIntOfArbitraryPrecision = LLVMConstIntOfArbitraryPrecision;
205    extern fn LLVMConstIntOfArbitraryPrecision(IntTy: *const Type, NumWords: c_uint, Words: [*]const u64) *const Value;
206
207    pub const constReal = LLVMConstReal;
208    extern fn LLVMConstReal(RealTy: *const Type, N: f64) *const Value;
209
210    pub const constArray = LLVMConstArray;
211    extern fn LLVMConstArray(ElementTy: *const Type, ConstantVals: [*]const *const Value, Length: c_uint) *const Value;
212
213    pub const constNamedStruct = LLVMConstNamedStruct;
214    extern fn LLVMConstNamedStruct(
215        StructTy: *const Type,
216        ConstantVals: [*]const *const Value,
217        Count: c_uint,
218    ) *const Value;
219
220    pub const getUndef = LLVMGetUndef;
221    extern fn LLVMGetUndef(Ty: *const Type) *const Value;
222
223    pub const pointerType = LLVMPointerType;
224    extern fn LLVMPointerType(ElementType: *const Type, AddressSpace: c_uint) *const Type;
225
226    pub const arrayType = LLVMArrayType;
227    extern fn LLVMArrayType(ElementType: *const Type, ElementCount: c_uint) *const Type;
228
229    pub const vectorType = LLVMVectorType;
230    extern fn LLVMVectorType(ElementType: *const Type, ElementCount: c_uint) *const Type;
231
232    pub const structSetBody = LLVMStructSetBody;
233    extern fn LLVMStructSetBody(
234        StructTy: *const Type,
235        ElementTypes: [*]*const Type,
236        ElementCount: c_uint,
237        Packed: Bool,
238    ) void;
239
240    pub const structGetTypeAtIndex = LLVMStructGetTypeAtIndex;
241    extern fn LLVMStructGetTypeAtIndex(StructTy: *const Type, i: c_uint) *const Type;
242
243    pub const getTypeKind = LLVMGetTypeKind;
244    extern fn LLVMGetTypeKind(Ty: *const Type) TypeKind;
245
246    pub const getElementType = LLVMGetElementType;
247    extern fn LLVMGetElementType(Ty: *const Type) *const Type;
248};
249
250pub const Module = opaque {
251    pub const createWithName = LLVMModuleCreateWithNameInContext;
252    extern fn LLVMModuleCreateWithNameInContext(ModuleID: [*:0]const u8, C: *const Context) *const Module;
253
254    pub const dispose = LLVMDisposeModule;
255    extern fn LLVMDisposeModule(*const Module) void;
256
257    pub const verify = LLVMVerifyModule;
258    extern fn LLVMVerifyModule(*const Module, Action: VerifierFailureAction, OutMessage: *[*:0]const u8) Bool;
259
260    pub const setModuleDataLayout = LLVMSetModuleDataLayout;
261    extern fn LLVMSetModuleDataLayout(*const Module, *const TargetData) void;
262
263    pub const addFunction = LLVMAddFunction;
264    extern fn LLVMAddFunction(*const Module, Name: [*:0]const u8, FunctionTy: *const Type) *const Value;
265
266    pub const addFunctionInAddressSpace = ZigLLVMAddFunctionInAddressSpace;
267    extern fn ZigLLVMAddFunctionInAddressSpace(*const Module, Name: [*:0]const u8, FunctionTy: *const Type, AddressSpace: c_uint) *const Value;
268
269    pub const getNamedFunction = LLVMGetNamedFunction;
270    extern fn LLVMGetNamedFunction(*const Module, Name: [*:0]const u8) ?*const Value;
271
272    pub const getIntrinsicDeclaration = LLVMGetIntrinsicDeclaration;
273    extern fn LLVMGetIntrinsicDeclaration(Mod: *const Module, ID: c_uint, ParamTypes: ?[*]*const Type, ParamCount: usize) *const Value;
274
275    pub const printToString = LLVMPrintModuleToString;
276    extern fn LLVMPrintModuleToString(*const Module) [*:0]const u8;
277
278    pub const addGlobal = LLVMAddGlobal;
279    extern fn LLVMAddGlobal(M: *const Module, Ty: *const Type, Name: [*:0]const u8) *const Value;
280
281    pub const addGlobalInAddressSpace = LLVMAddGlobalInAddressSpace;
282    extern fn LLVMAddGlobalInAddressSpace(M: *const Module, Ty: *const Type, Name: [*:0]const u8, AddressSpace: c_uint) *const Value;
283
284    pub const getNamedGlobal = LLVMGetNamedGlobal;
285    extern fn LLVMGetNamedGlobal(M: *const Module, Name: [*:0]const u8) ?*const Value;
286
287    pub const dump = LLVMDumpModule;
288    extern fn LLVMDumpModule(M: *const Module) void;
289
290    pub const getFirstGlobalAlias = LLVMGetFirstGlobalAlias;
291    extern fn LLVMGetFirstGlobalAlias(M: *const Module) *const Value;
292
293    pub const getLastGlobalAlias = LLVMGetLastGlobalAlias;
294    extern fn LLVMGetLastGlobalAlias(M: *const Module) *const Value;
295
296    pub const addAlias = LLVMAddAlias;
297    extern fn LLVMAddAlias(
298        M: *const Module,
299        Ty: *const Type,
300        Aliasee: *const Value,
301        Name: [*:0]const u8,
302    ) *const Value;
303
304    pub const getNamedGlobalAlias = LLVMGetNamedGlobalAlias;
305    extern fn LLVMGetNamedGlobalAlias(
306        M: *const Module,
307        /// Empirically, LLVM will call strlen() on `Name` and so it
308        /// must be both null terminated and also have `NameLen` set
309        /// to the size.
310        Name: [*:0]const u8,
311        NameLen: usize,
312    ) ?*const Value;
313};
314
315pub const lookupIntrinsicID = LLVMLookupIntrinsicID;
316extern fn LLVMLookupIntrinsicID(Name: [*]const u8, NameLen: usize) c_uint;
317
318pub const disposeMessage = LLVMDisposeMessage;
319extern fn LLVMDisposeMessage(Message: [*:0]const u8) void;
320
321pub const VerifierFailureAction = enum(c_int) {
322    AbortProcess,
323    PrintMessage,
324    ReturnStatus,
325};
326
327pub const constNeg = LLVMConstNeg;
328extern fn LLVMConstNeg(ConstantVal: *const Value) *const Value;
329
330pub const constVector = LLVMConstVector;
331extern fn LLVMConstVector(
332    ScalarConstantVals: [*]*const Value,
333    Size: c_uint,
334) *const Value;
335
336pub const getEnumAttributeKindForName = LLVMGetEnumAttributeKindForName;
337extern fn LLVMGetEnumAttributeKindForName(Name: [*]const u8, SLen: usize) c_uint;
338
339pub const getInlineAsm = LLVMGetInlineAsm;
340extern fn LLVMGetInlineAsm(
341    Ty: *const Type,
342    AsmString: [*]const u8,
343    AsmStringSize: usize,
344    Constraints: [*]const u8,
345    ConstraintsSize: usize,
346    HasSideEffects: Bool,
347    IsAlignStack: Bool,
348    Dialect: InlineAsmDialect,
349    CanThrow: Bool,
350) *const Value;
351
352pub const functionType = LLVMFunctionType;
353extern fn LLVMFunctionType(
354    ReturnType: *const Type,
355    ParamTypes: [*]const *const Type,
356    ParamCount: c_uint,
357    IsVarArg: Bool,
358) *const Type;
359
360pub const InlineAsmDialect = enum(c_uint) { ATT, Intel };
361
362pub const Attribute = opaque {};
363
364pub const Builder = opaque {
365    pub const dispose = LLVMDisposeBuilder;
366    extern fn LLVMDisposeBuilder(Builder: *const Builder) void;
367
368    pub const positionBuilder = LLVMPositionBuilder;
369    extern fn LLVMPositionBuilder(
370        Builder: *const Builder,
371        Block: *const BasicBlock,
372        Instr: *const Value,
373    ) void;
374
375    pub const positionBuilderAtEnd = LLVMPositionBuilderAtEnd;
376    extern fn LLVMPositionBuilderAtEnd(Builder: *const Builder, Block: *const BasicBlock) void;
377
378    pub const getInsertBlock = LLVMGetInsertBlock;
379    extern fn LLVMGetInsertBlock(Builder: *const Builder) *const BasicBlock;
380
381    pub const buildZExt = LLVMBuildZExt;
382    extern fn LLVMBuildZExt(
383        *const Builder,
384        Value: *const Value,
385        DestTy: *const Type,
386        Name: [*:0]const u8,
387    ) *const Value;
388
389    pub const buildSExt = LLVMBuildSExt;
390    extern fn LLVMBuildSExt(
391        *const Builder,
392        Val: *const Value,
393        DestTy: *const Type,
394        Name: [*:0]const u8,
395    ) *const Value;
396
397    pub const buildCall = ZigLLVMBuildCall;
398    extern fn ZigLLVMBuildCall(
399        *const Builder,
400        Fn: *const Value,
401        Args: [*]const *const Value,
402        NumArgs: c_uint,
403        CC: CallConv,
404        attr: CallAttr,
405        Name: [*:0]const u8,
406    ) *const Value;
407
408    pub const buildRetVoid = LLVMBuildRetVoid;
409    extern fn LLVMBuildRetVoid(*const Builder) *const Value;
410
411    pub const buildRet = LLVMBuildRet;
412    extern fn LLVMBuildRet(*const Builder, V: *const Value) *const Value;
413
414    pub const buildUnreachable = LLVMBuildUnreachable;
415    extern fn LLVMBuildUnreachable(*const Builder) *const Value;
416
417    pub const buildAlloca = LLVMBuildAlloca;
418    extern fn LLVMBuildAlloca(*const Builder, Ty: *const Type, Name: [*:0]const u8) *const Value;
419
420    pub const buildStore = LLVMBuildStore;
421    extern fn LLVMBuildStore(*const Builder, Val: *const Value, Ptr: *const Value) *const Value;
422
423    pub const buildLoad = LLVMBuildLoad;
424    extern fn LLVMBuildLoad(*const Builder, PointerVal: *const Value, Name: [*:0]const u8) *const Value;
425
426    pub const buildNeg = LLVMBuildNeg;
427    extern fn LLVMBuildNeg(*const Builder, V: *const Value, Name: [*:0]const u8) *const Value;
428
429    pub const buildNot = LLVMBuildNot;
430    extern fn LLVMBuildNot(*const Builder, V: *const Value, Name: [*:0]const u8) *const Value;
431
432    pub const buildFAdd = LLVMBuildFAdd;
433    extern fn LLVMBuildFAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
434
435    pub const buildAdd = LLVMBuildAdd;
436    extern fn LLVMBuildAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
437
438    pub const buildNSWAdd = LLVMBuildNSWAdd;
439    extern fn LLVMBuildNSWAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
440
441    pub const buildNUWAdd = LLVMBuildNUWAdd;
442    extern fn LLVMBuildNUWAdd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
443
444    pub const buildSAddSat = ZigLLVMBuildSAddSat;
445    extern fn ZigLLVMBuildSAddSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
446
447    pub const buildUAddSat = ZigLLVMBuildUAddSat;
448    extern fn ZigLLVMBuildUAddSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
449
450    pub const buildFSub = LLVMBuildFSub;
451    extern fn LLVMBuildFSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
452
453    pub const buildSub = LLVMBuildSub;
454    extern fn LLVMBuildSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
455
456    pub const buildNSWSub = LLVMBuildNSWSub;
457    extern fn LLVMBuildNSWSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
458
459    pub const buildNUWSub = LLVMBuildNUWSub;
460    extern fn LLVMBuildNUWSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
461
462    pub const buildSSubSat = ZigLLVMBuildSSubSat;
463    extern fn ZigLLVMBuildSSubSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
464
465    pub const buildUSubSat = ZigLLVMBuildUSubSat;
466    extern fn ZigLLVMBuildUSubSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
467
468    pub const buildFMul = LLVMBuildFMul;
469    extern fn LLVMBuildFMul(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
470
471    pub const buildMul = LLVMBuildMul;
472    extern fn LLVMBuildMul(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
473
474    pub const buildNSWMul = LLVMBuildNSWMul;
475    extern fn LLVMBuildNSWMul(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
476
477    pub const buildNUWMul = LLVMBuildNUWMul;
478    extern fn LLVMBuildNUWMul(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
479
480    pub const buildSMulFixSat = ZigLLVMBuildSMulFixSat;
481    extern fn ZigLLVMBuildSMulFixSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
482
483    pub const buildUMulFixSat = ZigLLVMBuildUMulFixSat;
484    extern fn ZigLLVMBuildUMulFixSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
485
486    pub const buildUDiv = LLVMBuildUDiv;
487    extern fn LLVMBuildUDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
488
489    pub const buildSDiv = LLVMBuildSDiv;
490    extern fn LLVMBuildSDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
491
492    pub const buildFDiv = LLVMBuildFDiv;
493    extern fn LLVMBuildFDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
494
495    pub const buildURem = LLVMBuildURem;
496    extern fn LLVMBuildURem(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
497
498    pub const buildSRem = LLVMBuildSRem;
499    extern fn LLVMBuildSRem(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
500
501    pub const buildFRem = LLVMBuildFRem;
502    extern fn LLVMBuildFRem(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
503
504    pub const buildAnd = LLVMBuildAnd;
505    extern fn LLVMBuildAnd(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
506
507    pub const buildLShr = LLVMBuildLShr;
508    extern fn LLVMBuildLShr(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
509
510    pub const buildAShr = LLVMBuildAShr;
511    extern fn LLVMBuildAShr(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
512
513    pub const buildShl = LLVMBuildShl;
514    extern fn LLVMBuildShl(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
515
516    pub const buildNUWShl = ZigLLVMBuildNUWShl;
517    extern fn ZigLLVMBuildNUWShl(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
518
519    pub const buildNSWShl = ZigLLVMBuildNSWShl;
520    extern fn ZigLLVMBuildNSWShl(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
521
522    pub const buildSShlSat = ZigLLVMBuildSShlSat;
523    extern fn ZigLLVMBuildSShlSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
524
525    pub const buildUShlSat = ZigLLVMBuildUShlSat;
526    extern fn ZigLLVMBuildUShlSat(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
527
528    pub const buildOr = LLVMBuildOr;
529    extern fn LLVMBuildOr(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
530
531    pub const buildXor = LLVMBuildXor;
532    extern fn LLVMBuildXor(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
533
534    pub const buildIntCast2 = LLVMBuildIntCast2;
535    extern fn LLVMBuildIntCast2(*const Builder, Val: *const Value, DestTy: *const Type, IsSigned: Bool, Name: [*:0]const u8) *const Value;
536
537    pub const buildBitCast = LLVMBuildBitCast;
538    extern fn LLVMBuildBitCast(*const Builder, Val: *const Value, DestTy: *const Type, Name: [*:0]const u8) *const Value;
539
540    pub const buildInBoundsGEP = LLVMBuildInBoundsGEP;
541    extern fn LLVMBuildInBoundsGEP(
542        B: *const Builder,
543        Pointer: *const Value,
544        Indices: [*]const *const Value,
545        NumIndices: c_uint,
546        Name: [*:0]const u8,
547    ) *const Value;
548
549    pub const buildInBoundsGEP2 = LLVMBuildInBoundsGEP2;
550    extern fn LLVMBuildInBoundsGEP2(
551        B: *const Builder,
552        Ty: *const Type,
553        Pointer: *const Value,
554        Indices: [*]const *const Value,
555        NumIndices: c_uint,
556        Name: [*:0]const u8,
557    ) *const Value;
558
559    pub const buildICmp = LLVMBuildICmp;
560    extern fn LLVMBuildICmp(*const Builder, Op: IntPredicate, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
561
562    pub const buildFCmp = LLVMBuildFCmp;
563    extern fn LLVMBuildFCmp(*const Builder, Op: RealPredicate, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
564
565    pub const buildBr = LLVMBuildBr;
566    extern fn LLVMBuildBr(*const Builder, Dest: *const BasicBlock) *const Value;
567
568    pub const buildCondBr = LLVMBuildCondBr;
569    extern fn LLVMBuildCondBr(*const Builder, If: *const Value, Then: *const BasicBlock, Else: *const BasicBlock) *const Value;
570
571    pub const buildSwitch = LLVMBuildSwitch;
572    extern fn LLVMBuildSwitch(*const Builder, V: *const Value, Else: *const BasicBlock, NumCases: c_uint) *const Value;
573
574    pub const buildPhi = LLVMBuildPhi;
575    extern fn LLVMBuildPhi(*const Builder, Ty: *const Type, Name: [*:0]const u8) *const Value;
576
577    pub const buildExtractValue = LLVMBuildExtractValue;
578    extern fn LLVMBuildExtractValue(
579        *const Builder,
580        AggVal: *const Value,
581        Index: c_uint,
582        Name: [*:0]const u8,
583    ) *const Value;
584
585    pub const buildExtractElement = LLVMBuildExtractElement;
586    extern fn LLVMBuildExtractElement(
587        *const Builder,
588        VecVal: *const Value,
589        Index: *const Value,
590        Name: [*:0]const u8,
591    ) *const Value;
592
593    pub const buildInsertElement = LLVMBuildInsertElement;
594    extern fn LLVMBuildInsertElement(
595        *const Builder,
596        VecVal: *const Value,
597        EltVal: *const Value,
598        Index: *const Value,
599        Name: [*:0]const u8,
600    ) *const Value;
601
602    pub const buildPtrToInt = LLVMBuildPtrToInt;
603    extern fn LLVMBuildPtrToInt(
604        *const Builder,
605        Val: *const Value,
606        DestTy: *const Type,
607        Name: [*:0]const u8,
608    ) *const Value;
609
610    pub const buildIntToPtr = LLVMBuildIntToPtr;
611    extern fn LLVMBuildIntToPtr(
612        *const Builder,
613        Val: *const Value,
614        DestTy: *const Type,
615        Name: [*:0]const u8,
616    ) *const Value;
617
618    pub const buildStructGEP = LLVMBuildStructGEP;
619    extern fn LLVMBuildStructGEP(
620        B: *const Builder,
621        Pointer: *const Value,
622        Idx: c_uint,
623        Name: [*:0]const u8,
624    ) *const Value;
625
626    pub const buildTrunc = LLVMBuildTrunc;
627    extern fn LLVMBuildTrunc(
628        *const Builder,
629        Val: *const Value,
630        DestTy: *const Type,
631        Name: [*:0]const u8,
632    ) *const Value;
633
634    pub const buildInsertValue = LLVMBuildInsertValue;
635    extern fn LLVMBuildInsertValue(
636        *const Builder,
637        AggVal: *const Value,
638        EltVal: *const Value,
639        Index: c_uint,
640        Name: [*:0]const u8,
641    ) *const Value;
642
643    pub const buildAtomicCmpXchg = LLVMBuildAtomicCmpXchg;
644    extern fn LLVMBuildAtomicCmpXchg(
645        builder: *const Builder,
646        ptr: *const Value,
647        cmp: *const Value,
648        new_val: *const Value,
649        success_ordering: AtomicOrdering,
650        failure_ordering: AtomicOrdering,
651        is_single_threaded: Bool,
652    ) *const Value;
653
654    pub const buildSelect = LLVMBuildSelect;
655    extern fn LLVMBuildSelect(
656        *const Builder,
657        If: *const Value,
658        Then: *const Value,
659        Else: *const Value,
660        Name: [*:0]const u8,
661    ) *const Value;
662
663    pub const buildFence = LLVMBuildFence;
664    extern fn LLVMBuildFence(
665        B: *const Builder,
666        ordering: AtomicOrdering,
667        singleThread: Bool,
668        Name: [*:0]const u8,
669    ) *const Value;
670
671    pub const buildAtomicRmw = LLVMBuildAtomicRMW;
672    extern fn LLVMBuildAtomicRMW(
673        B: *const Builder,
674        op: AtomicRMWBinOp,
675        PTR: *const Value,
676        Val: *const Value,
677        ordering: AtomicOrdering,
678        singleThread: Bool,
679    ) *const Value;
680
681    pub const buildFPToUI = LLVMBuildFPToUI;
682    extern fn LLVMBuildFPToUI(
683        *const Builder,
684        Val: *const Value,
685        DestTy: *const Type,
686        Name: [*:0]const u8,
687    ) *const Value;
688
689    pub const buildFPToSI = LLVMBuildFPToSI;
690    extern fn LLVMBuildFPToSI(
691        *const Builder,
692        Val: *const Value,
693        DestTy: *const Type,
694        Name: [*:0]const u8,
695    ) *const Value;
696
697    pub const buildUIToFP = LLVMBuildUIToFP;
698    extern fn LLVMBuildUIToFP(
699        *const Builder,
700        Val: *const Value,
701        DestTy: *const Type,
702        Name: [*:0]const u8,
703    ) *const Value;
704
705    pub const buildSIToFP = LLVMBuildSIToFP;
706    extern fn LLVMBuildSIToFP(
707        *const Builder,
708        Val: *const Value,
709        DestTy: *const Type,
710        Name: [*:0]const u8,
711    ) *const Value;
712
713    pub const buildFPTrunc = LLVMBuildFPTrunc;
714    extern fn LLVMBuildFPTrunc(
715        *const Builder,
716        Val: *const Value,
717        DestTy: *const Type,
718        Name: [*:0]const u8,
719    ) *const Value;
720
721    pub const buildFPExt = LLVMBuildFPExt;
722    extern fn LLVMBuildFPExt(
723        *const Builder,
724        Val: *const Value,
725        DestTy: *const Type,
726        Name: [*:0]const u8,
727    ) *const Value;
728
729    pub const buildMemSet = ZigLLVMBuildMemSet;
730    extern fn ZigLLVMBuildMemSet(
731        B: *const Builder,
732        Ptr: *const Value,
733        Val: *const Value,
734        Len: *const Value,
735        Align: c_uint,
736        is_volatile: bool,
737    ) *const Value;
738
739    pub const buildMemCpy = ZigLLVMBuildMemCpy;
740    extern fn ZigLLVMBuildMemCpy(
741        B: *const Builder,
742        Dst: *const Value,
743        DstAlign: c_uint,
744        Src: *const Value,
745        SrcAlign: c_uint,
746        Size: *const Value,
747        is_volatile: bool,
748    ) *const Value;
749
750    pub const buildMaxNum = ZigLLVMBuildMaxNum;
751    extern fn ZigLLVMBuildMaxNum(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
752
753    pub const buildMinNum = ZigLLVMBuildMinNum;
754    extern fn ZigLLVMBuildMinNum(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
755
756    pub const buildUMax = ZigLLVMBuildUMax;
757    extern fn ZigLLVMBuildUMax(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
758
759    pub const buildUMin = ZigLLVMBuildUMin;
760    extern fn ZigLLVMBuildUMin(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
761
762    pub const buildSMax = ZigLLVMBuildSMax;
763    extern fn ZigLLVMBuildSMax(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
764
765    pub const buildSMin = ZigLLVMBuildSMin;
766    extern fn ZigLLVMBuildSMin(builder: *const Builder, LHS: *const Value, RHS: *const Value, name: [*:0]const u8) *const Value;
767
768    pub const buildExactUDiv = LLVMBuildExactUDiv;
769    extern fn LLVMBuildExactUDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
770
771    pub const buildExactSDiv = LLVMBuildExactSDiv;
772    extern fn LLVMBuildExactSDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
773};
774
775pub const IntPredicate = enum(c_uint) {
776    EQ = 32,
777    NE = 33,
778    UGT = 34,
779    UGE = 35,
780    ULT = 36,
781    ULE = 37,
782    SGT = 38,
783    SGE = 39,
784    SLT = 40,
785    SLE = 41,
786};
787
788pub const RealPredicate = enum(c_uint) {
789    OEQ = 1,
790    OGT = 2,
791    OGE = 3,
792    OLT = 4,
793    OLE = 5,
794    ONE = 6,
795    ORD = 7,
796    UNO = 8,
797    UEQ = 9,
798    UGT = 10,
799    UGE = 11,
800    ULT = 12,
801    ULE = 13,
802    UNE = 14,
803};
804
805pub const BasicBlock = opaque {
806    pub const deleteBasicBlock = LLVMDeleteBasicBlock;
807    extern fn LLVMDeleteBasicBlock(BB: *const BasicBlock) void;
808
809    pub const getFirstInstruction = LLVMGetFirstInstruction;
810    extern fn LLVMGetFirstInstruction(BB: *const BasicBlock) ?*const Value;
811};
812
813pub const TargetMachine = opaque {
814    pub const create = ZigLLVMCreateTargetMachine;
815    extern fn ZigLLVMCreateTargetMachine(
816        T: *const Target,
817        Triple: [*:0]const u8,
818        CPU: ?[*:0]const u8,
819        Features: ?[*:0]const u8,
820        Level: CodeGenOptLevel,
821        Reloc: RelocMode,
822        CodeModel: CodeModel,
823        function_sections: bool,
824        float_abi: ABIType,
825        abi_name: ?[*:0]const u8,
826    ) *const TargetMachine;
827
828    pub const dispose = LLVMDisposeTargetMachine;
829    extern fn LLVMDisposeTargetMachine(T: *const TargetMachine) void;
830
831    pub const emitToFile = ZigLLVMTargetMachineEmitToFile;
832    extern fn ZigLLVMTargetMachineEmitToFile(
833        T: *const TargetMachine,
834        M: *const Module,
835        ErrorMessage: *[*:0]const u8,
836        is_debug: bool,
837        is_small: bool,
838        time_report: bool,
839        tsan: bool,
840        lto: bool,
841        asm_filename: ?[*:0]const u8,
842        bin_filename: ?[*:0]const u8,
843        llvm_ir_filename: ?[*:0]const u8,
844        bitcode_filename: ?[*:0]const u8,
845    ) bool;
846
847    pub const createTargetDataLayout = LLVMCreateTargetDataLayout;
848    extern fn LLVMCreateTargetDataLayout(*const TargetMachine) *const TargetData;
849};
850
851pub const TargetData = opaque {
852    pub const dispose = LLVMDisposeTargetData;
853    extern fn LLVMDisposeTargetData(*const TargetData) void;
854};
855
856pub const CodeModel = enum(c_int) {
857    Default,
858    JITDefault,
859    Tiny,
860    Small,
861    Kernel,
862    Medium,
863    Large,
864};
865
866pub const CodeGenOptLevel = enum(c_int) {
867    None,
868    Less,
869    Default,
870    Aggressive,
871};
872
873pub const RelocMode = enum(c_int) {
874    Default,
875    Static,
876    PIC,
877    DynamicNoPIC,
878    ROPI,
879    RWPI,
880    ROPI_RWPI,
881};
882
883pub const CodeGenFileType = enum(c_int) {
884    AssemblyFile,
885    ObjectFile,
886};
887
888pub const ABIType = enum(c_int) {
889    /// Target-specific (either soft or hard depending on triple, etc).
890    Default,
891    /// Soft float.
892    Soft,
893    // Hard float.
894    Hard,
895};
896
897pub const Target = opaque {
898    pub const getFromTriple = LLVMGetTargetFromTriple;
899    extern fn LLVMGetTargetFromTriple(Triple: [*:0]const u8, T: **const Target, ErrorMessage: *[*:0]const u8) Bool;
900};
901
902pub extern fn LLVMInitializeAArch64TargetInfo() void;
903pub extern fn LLVMInitializeAMDGPUTargetInfo() void;
904pub extern fn LLVMInitializeARMTargetInfo() void;
905pub extern fn LLVMInitializeAVRTargetInfo() void;
906pub extern fn LLVMInitializeBPFTargetInfo() void;
907pub extern fn LLVMInitializeHexagonTargetInfo() void;
908pub extern fn LLVMInitializeLanaiTargetInfo() void;
909pub extern fn LLVMInitializeMipsTargetInfo() void;
910pub extern fn LLVMInitializeMSP430TargetInfo() void;
911pub extern fn LLVMInitializeNVPTXTargetInfo() void;
912pub extern fn LLVMInitializePowerPCTargetInfo() void;
913pub extern fn LLVMInitializeRISCVTargetInfo() void;
914pub extern fn LLVMInitializeSparcTargetInfo() void;
915pub extern fn LLVMInitializeSystemZTargetInfo() void;
916pub extern fn LLVMInitializeWebAssemblyTargetInfo() void;
917pub extern fn LLVMInitializeX86TargetInfo() void;
918pub extern fn LLVMInitializeXCoreTargetInfo() void;
919pub extern fn LLVMInitializeM68kTargetInfo() void;
920pub extern fn LLVMInitializeCSKYTargetInfo() void;
921pub extern fn LLVMInitializeVETargetInfo() void;
922pub extern fn LLVMInitializeARCTargetInfo() void;
923
924pub extern fn LLVMInitializeAArch64Target() void;
925pub extern fn LLVMInitializeAMDGPUTarget() void;
926pub extern fn LLVMInitializeARMTarget() void;
927pub extern fn LLVMInitializeAVRTarget() void;
928pub extern fn LLVMInitializeBPFTarget() void;
929pub extern fn LLVMInitializeHexagonTarget() void;
930pub extern fn LLVMInitializeLanaiTarget() void;
931pub extern fn LLVMInitializeMipsTarget() void;
932pub extern fn LLVMInitializeMSP430Target() void;
933pub extern fn LLVMInitializeNVPTXTarget() void;
934pub extern fn LLVMInitializePowerPCTarget() void;
935pub extern fn LLVMInitializeRISCVTarget() void;
936pub extern fn LLVMInitializeSparcTarget() void;
937pub extern fn LLVMInitializeSystemZTarget() void;
938pub extern fn LLVMInitializeWebAssemblyTarget() void;
939pub extern fn LLVMInitializeX86Target() void;
940pub extern fn LLVMInitializeXCoreTarget() void;
941pub extern fn LLVMInitializeM68kTarget() void;
942pub extern fn LLVMInitializeVETarget() void;
943pub extern fn LLVMInitializeCSKYTarget() void;
944pub extern fn LLVMInitializeARCTarget() void;
945
946pub extern fn LLVMInitializeAArch64TargetMC() void;
947pub extern fn LLVMInitializeAMDGPUTargetMC() void;
948pub extern fn LLVMInitializeARMTargetMC() void;
949pub extern fn LLVMInitializeAVRTargetMC() void;
950pub extern fn LLVMInitializeBPFTargetMC() void;
951pub extern fn LLVMInitializeHexagonTargetMC() void;
952pub extern fn LLVMInitializeLanaiTargetMC() void;
953pub extern fn LLVMInitializeMipsTargetMC() void;
954pub extern fn LLVMInitializeMSP430TargetMC() void;
955pub extern fn LLVMInitializeNVPTXTargetMC() void;
956pub extern fn LLVMInitializePowerPCTargetMC() void;
957pub extern fn LLVMInitializeRISCVTargetMC() void;
958pub extern fn LLVMInitializeSparcTargetMC() void;
959pub extern fn LLVMInitializeSystemZTargetMC() void;
960pub extern fn LLVMInitializeWebAssemblyTargetMC() void;
961pub extern fn LLVMInitializeX86TargetMC() void;
962pub extern fn LLVMInitializeXCoreTargetMC() void;
963pub extern fn LLVMInitializeM68kTargetMC() void;
964pub extern fn LLVMInitializeCSKYTargetMC() void;
965pub extern fn LLVMInitializeVETargetMC() void;
966pub extern fn LLVMInitializeARCTargetMC() void;
967
968pub extern fn LLVMInitializeAArch64AsmPrinter() void;
969pub extern fn LLVMInitializeAMDGPUAsmPrinter() void;
970pub extern fn LLVMInitializeARMAsmPrinter() void;
971pub extern fn LLVMInitializeAVRAsmPrinter() void;
972pub extern fn LLVMInitializeBPFAsmPrinter() void;
973pub extern fn LLVMInitializeHexagonAsmPrinter() void;
974pub extern fn LLVMInitializeLanaiAsmPrinter() void;
975pub extern fn LLVMInitializeMipsAsmPrinter() void;
976pub extern fn LLVMInitializeMSP430AsmPrinter() void;
977pub extern fn LLVMInitializeNVPTXAsmPrinter() void;
978pub extern fn LLVMInitializePowerPCAsmPrinter() void;
979pub extern fn LLVMInitializeRISCVAsmPrinter() void;
980pub extern fn LLVMInitializeSparcAsmPrinter() void;
981pub extern fn LLVMInitializeSystemZAsmPrinter() void;
982pub extern fn LLVMInitializeWebAssemblyAsmPrinter() void;
983pub extern fn LLVMInitializeX86AsmPrinter() void;
984pub extern fn LLVMInitializeXCoreAsmPrinter() void;
985pub extern fn LLVMInitializeM68kAsmPrinter() void;
986pub extern fn LLVMInitializeVEAsmPrinter() void;
987pub extern fn LLVMInitializeARCAsmPrinter() void;
988
989pub extern fn LLVMInitializeAArch64AsmParser() void;
990pub extern fn LLVMInitializeAMDGPUAsmParser() void;
991pub extern fn LLVMInitializeARMAsmParser() void;
992pub extern fn LLVMInitializeAVRAsmParser() void;
993pub extern fn LLVMInitializeBPFAsmParser() void;
994pub extern fn LLVMInitializeHexagonAsmParser() void;
995pub extern fn LLVMInitializeLanaiAsmParser() void;
996pub extern fn LLVMInitializeMipsAsmParser() void;
997pub extern fn LLVMInitializeMSP430AsmParser() void;
998pub extern fn LLVMInitializePowerPCAsmParser() void;
999pub extern fn LLVMInitializeRISCVAsmParser() void;
1000pub extern fn LLVMInitializeSparcAsmParser() void;
1001pub extern fn LLVMInitializeSystemZAsmParser() void;
1002pub extern fn LLVMInitializeWebAssemblyAsmParser() void;
1003pub extern fn LLVMInitializeX86AsmParser() void;
1004pub extern fn LLVMInitializeM68kAsmParser() void;
1005pub extern fn LLVMInitializeCSKYAsmParser() void;
1006pub extern fn LLVMInitializeVEAsmParser() void;
1007
1008extern fn ZigLLDLinkCOFF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
1009extern fn ZigLLDLinkELF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
1010extern fn ZigLLDLinkWasm(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
1011
1012pub const LinkCOFF = ZigLLDLinkCOFF;
1013pub const LinkELF = ZigLLDLinkELF;
1014pub const LinkWasm = ZigLLDLinkWasm;
1015
1016pub const ObjectFormatType = enum(c_int) {
1017    Unknown,
1018    COFF,
1019    ELF,
1020    GOFF,
1021    MachO,
1022    Wasm,
1023    XCOFF,
1024};
1025
1026pub const WriteArchive = ZigLLVMWriteArchive;
1027extern fn ZigLLVMWriteArchive(
1028    archive_name: [*:0]const u8,
1029    file_names_ptr: [*]const [*:0]const u8,
1030    file_names_len: usize,
1031    os_type: OSType,
1032) bool;
1033
1034pub const OSType = enum(c_int) {
1035    UnknownOS,
1036    Ananas,
1037    CloudABI,
1038    Darwin,
1039    DragonFly,
1040    FreeBSD,
1041    Fuchsia,
1042    IOS,
1043    KFreeBSD,
1044    Linux,
1045    Lv2,
1046    MacOSX,
1047    NetBSD,
1048    OpenBSD,
1049    Solaris,
1050    Win32,
1051    ZOS,
1052    Haiku,
1053    Minix,
1054    RTEMS,
1055    NaCl,
1056    AIX,
1057    CUDA,
1058    NVCL,
1059    AMDHSA,
1060    PS4,
1061    ELFIAMCU,
1062    TvOS,
1063    WatchOS,
1064    Mesa3D,
1065    Contiki,
1066    AMDPAL,
1067    HermitCore,
1068    Hurd,
1069    WASI,
1070    Emscripten,
1071};
1072
1073pub const ArchType = enum(c_int) {
1074    UnknownArch,
1075    arm,
1076    armeb,
1077    aarch64,
1078    aarch64_be,
1079    aarch64_32,
1080    arc,
1081    avr,
1082    bpfel,
1083    bpfeb,
1084    csky,
1085    hexagon,
1086    m68k,
1087    mips,
1088    mipsel,
1089    mips64,
1090    mips64el,
1091    msp430,
1092    ppc,
1093    ppcle,
1094    ppc64,
1095    ppc64le,
1096    r600,
1097    amdgcn,
1098    riscv32,
1099    riscv64,
1100    sparc,
1101    sparcv9,
1102    sparcel,
1103    systemz,
1104    tce,
1105    tcele,
1106    thumb,
1107    thumbeb,
1108    x86,
1109    x86_64,
1110    xcore,
1111    nvptx,
1112    nvptx64,
1113    le32,
1114    le64,
1115    amdil,
1116    amdil64,
1117    hsail,
1118    hsail64,
1119    spir,
1120    spir64,
1121    kalimba,
1122    shave,
1123    lanai,
1124    wasm32,
1125    wasm64,
1126    renderscript32,
1127    renderscript64,
1128    ve,
1129};
1130
1131pub const ParseCommandLineOptions = ZigLLVMParseCommandLineOptions;
1132extern fn ZigLLVMParseCommandLineOptions(argc: usize, argv: [*]const [*:0]const u8) void;
1133
1134pub const WriteImportLibrary = ZigLLVMWriteImportLibrary;
1135extern fn ZigLLVMWriteImportLibrary(
1136    def_path: [*:0]const u8,
1137    arch: ArchType,
1138    output_lib_path: [*c]const u8,
1139    kill_at: bool,
1140) bool;
1141
1142pub const Linkage = enum(c_uint) {
1143    External,
1144    AvailableExternally,
1145    LinkOnceAny,
1146    LinkOnceODR,
1147    LinkOnceODRAutoHide,
1148    WeakAny,
1149    WeakODR,
1150    Appending,
1151    Internal,
1152    Private,
1153    DLLImport,
1154    DLLExport,
1155    ExternalWeak,
1156    Ghost,
1157    Common,
1158    LinkerPrivate,
1159    LinkerPrivateWeak,
1160};
1161
1162pub const AtomicOrdering = enum(c_uint) {
1163    NotAtomic = 0,
1164    Unordered = 1,
1165    Monotonic = 2,
1166    Acquire = 4,
1167    Release = 5,
1168    AcquireRelease = 6,
1169    SequentiallyConsistent = 7,
1170};
1171
1172pub const AtomicRMWBinOp = enum(c_int) {
1173    Xchg,
1174    Add,
1175    Sub,
1176    And,
1177    Nand,
1178    Or,
1179    Xor,
1180    Max,
1181    Min,
1182    UMax,
1183    UMin,
1184    FAdd,
1185    FSub,
1186};
1187
1188pub const TypeKind = enum(c_int) {
1189    Void,
1190    Half,
1191    Float,
1192    Double,
1193    X86_FP80,
1194    FP128,
1195    PPC_FP128,
1196    Label,
1197    Integer,
1198    Function,
1199    Struct,
1200    Array,
1201    Pointer,
1202    Vector,
1203    Metadata,
1204    X86_MMX,
1205    Token,
1206    ScalableVector,
1207    BFloat,
1208    X86_AMX,
1209};
1210
1211pub const CallConv = enum(c_uint) {
1212    C = 0,
1213    Fast = 8,
1214    Cold = 9,
1215    GHC = 10,
1216    HiPE = 11,
1217    WebKit_JS = 12,
1218    AnyReg = 13,
1219    PreserveMost = 14,
1220    PreserveAll = 15,
1221    Swift = 16,
1222    CXX_FAST_TLS = 17,
1223
1224    X86_StdCall = 64,
1225    X86_FastCall = 65,
1226    ARM_APCS = 66,
1227    ARM_AAPCS = 67,
1228    ARM_AAPCS_VFP = 68,
1229    MSP430_INTR = 69,
1230    X86_ThisCall = 70,
1231    PTX_Kernel = 71,
1232    PTX_Device = 72,
1233    SPIR_FUNC = 75,
1234    SPIR_KERNEL = 76,
1235    Intel_OCL_BI = 77,
1236    X86_64_SysV = 78,
1237    Win64 = 79,
1238    X86_VectorCall = 80,
1239    HHVM = 81,
1240    HHVM_C = 82,
1241    X86_INTR = 83,
1242    AVR_INTR = 84,
1243    AVR_SIGNAL = 85,
1244    AVR_BUILTIN = 86,
1245    AMDGPU_VS = 87,
1246    AMDGPU_GS = 88,
1247    AMDGPU_PS = 89,
1248    AMDGPU_CS = 90,
1249    AMDGPU_KERNEL = 91,
1250    X86_RegCall = 92,
1251    AMDGPU_HS = 93,
1252    MSP430_BUILTIN = 94,
1253    AMDGPU_LS = 95,
1254    AMDGPU_ES = 96,
1255    AArch64_VectorCall = 97,
1256};
1257
1258pub const CallAttr = enum(c_int) {
1259    Auto,
1260    NeverTail,
1261    NeverInline,
1262    AlwaysTail,
1263    AlwaysInline,
1264};
1265
1266pub const address_space = struct {
1267    pub const default: c_uint = 0;
1268
1269    // See llvm/lib/Target/X86/X86.h
1270    pub const x86_64 = x86;
1271    pub const x86 = struct {
1272        pub const gs: c_uint = 256;
1273        pub const fs: c_uint = 257;
1274        pub const ss: c_uint = 258;
1275
1276        pub const ptr32_sptr: c_uint = 270;
1277        pub const ptr32_uptr: c_uint = 271;
1278        pub const ptr64: c_uint = 272;
1279    };
1280
1281    // See llvm/lib/Target/AVR/AVR.h
1282    pub const avr = struct {
1283        pub const data_memory: c_uint = 0;
1284        pub const program_memory: c_uint = 1;
1285    };
1286
1287    // See llvm/lib/Target/NVPTX/NVPTX.h
1288    pub const nvptx = struct {
1289        pub const generic: c_uint = 0;
1290        pub const global: c_uint = 1;
1291        pub const constant: c_uint = 2;
1292        pub const shared: c_uint = 3;
1293        pub const param: c_uint = 4;
1294        pub const local: c_uint = 5;
1295    };
1296
1297    // See llvm/lib/Target/AMDGPU/AMDGPU.h
1298    pub const amdgpu = struct {
1299        pub const flat: c_uint = 0;
1300        pub const global: c_uint = 1;
1301        pub const region: c_uint = 2;
1302        pub const local: c_uint = 3;
1303        pub const constant: c_uint = 4;
1304        pub const private: c_uint = 5;
1305        pub const constant_32bit: c_uint = 6;
1306        pub const buffer_fat_pointer: c_uint = 7;
1307        pub const param_d: c_uint = 6;
1308        pub const param_i: c_uint = 7;
1309        pub const constant_buffer_0: c_uint = 8;
1310        pub const constant_buffer_1: c_uint = 9;
1311        pub const constant_buffer_2: c_uint = 10;
1312        pub const constant_buffer_3: c_uint = 11;
1313        pub const constant_buffer_4: c_uint = 12;
1314        pub const constant_buffer_5: c_uint = 13;
1315        pub const constant_buffer_6: c_uint = 14;
1316        pub const constant_buffer_7: c_uint = 15;
1317        pub const constant_buffer_8: c_uint = 16;
1318        pub const constant_buffer_9: c_uint = 17;
1319        pub const constant_buffer_10: c_uint = 18;
1320        pub const constant_buffer_11: c_uint = 19;
1321        pub const constant_buffer_12: c_uint = 20;
1322        pub const constant_buffer_13: c_uint = 21;
1323        pub const constant_buffer_14: c_uint = 22;
1324        pub const constant_buffer_15: c_uint = 23;
1325    };
1326};
1327