llvm_sys_featured/
lib.rs

1//! Bindings to LLVM's C API.
2//!
3//! Refer to the [LLVM documentation](http://llvm.org/docs/) for more
4//! information.
5
6#![allow(non_upper_case_globals)]
7#![allow(non_camel_case_types)]
8
9extern crate libc;
10
11use self::prelude::*;
12
13#[derive(Debug)]
14pub enum LLVMMemoryBuffer {}
15
16#[derive(Debug)]
17pub enum LLVMContext {}
18
19#[derive(Debug)]
20pub enum LLVMModule {}
21
22#[derive(Debug)]
23pub enum LLVMType {}
24
25#[derive(Debug)]
26pub enum LLVMValue {}
27
28#[derive(Debug)]
29pub enum LLVMBasicBlock {}
30
31#[derive(Debug)]
32pub enum LLVMOpaqueMetadata {}
33
34#[derive(Debug)]
35pub enum LLVMOpaqueNamedMDNode {}
36
37#[derive(Debug)]
38pub enum LLVMOpaqueValueMetadataEntry {}
39
40#[derive(Debug)]
41pub enum LLVMBuilder {}
42
43#[derive(Debug)]
44pub enum LLVMOpaqueDIBuilder {}
45
46#[derive(Debug)]
47pub enum LLVMModuleProvider {}
48
49#[derive(Debug)]
50pub enum LLVMPassManager {}
51
52#[derive(Debug)]
53pub enum LLVMPassRegistry {}
54
55#[derive(Debug)]
56pub enum LLVMUse {}
57
58#[derive(Debug)]
59pub enum LLVMDiagnosticInfo {}
60
61#[derive(Debug)]
62pub enum LLVMComdat {}
63
64#[derive(Debug)]
65pub enum LLVMOpaqueModuleFlagEntry {}
66
67#[derive(Debug)]
68pub enum LLVMOpaqueJITEventListener {}
69
70#[derive(Debug)]
71pub enum LLVMOpaqueAttributeRef {}
72
73/// Core types used throughout LLVM.
74///
75/// In most cases you will want to `use llvm::prelude::*`.
76pub mod prelude {
77    pub type LLVMBool = ::libc::c_int;
78    pub type LLVMMemoryBufferRef = *mut super::LLVMMemoryBuffer;
79    pub type LLVMContextRef = *mut super::LLVMContext;
80    pub type LLVMModuleRef = *mut super::LLVMModule;
81    pub type LLVMTypeRef = *mut super::LLVMType;
82    pub type LLVMValueRef = *mut super::LLVMValue;
83    pub type LLVMBasicBlockRef = *mut super::LLVMBasicBlock;
84    pub type LLVMMetadataRef = *mut super::LLVMOpaqueMetadata;
85    pub type LLVMNamedMDNodeRef = *mut super::LLVMOpaqueNamedMDNode;
86    pub type LLVMValueMetadataEntry = *mut super::LLVMOpaqueValueMetadataEntry;
87    pub type LLVMBuilderRef = *mut super::LLVMBuilder;
88    pub type LLVMDIBuilderRef = *mut super::LLVMOpaqueDIBuilder;
89    pub type LLVMModuleProviderRef = *mut super::LLVMModuleProvider;
90    pub type LLVMPassManagerRef = *mut super::LLVMPassManager;
91    pub type LLVMPassRegistryRef = *mut super::LLVMPassRegistry;
92    pub type LLVMUseRef = *mut super::LLVMUse;
93    pub type LLVMDiagnosticInfoRef = *mut super::LLVMDiagnosticInfo;
94    pub type LLVMComdatRef = *mut super::LLVMComdat;
95    pub type LLVMModuleFlagEntry = *mut super::LLVMOpaqueModuleFlagEntry;
96    pub type LLVMJITEventListenerRef = *mut super::LLVMOpaqueJITEventListener;
97    pub type LLVMAttributeRef = *mut super::LLVMOpaqueAttributeRef;
98}
99
100pub mod analysis;
101pub mod bit_reader;
102pub mod bit_writer;
103pub mod comdat;
104pub mod core;
105pub mod debuginfo;
106pub mod disassembler;
107pub mod error;
108pub mod error_handling;
109pub mod execution_engine;
110pub mod initialization;
111pub mod ir_reader;
112pub mod link_time_optimizer;
113pub mod linker;
114pub mod lto;
115pub mod object;
116pub mod orc;
117#[cfg(LLVM_VERSION_8_OR_LOWER)]
118pub mod opt_remarks;
119#[cfg(LLVM_VERSION_9_OR_GREATER)]
120pub mod remarks;
121pub mod support;
122pub mod target;
123pub mod target_machine;
124
125pub mod transforms {
126    pub mod aggressive_instcombine;
127    pub mod coroutines;
128    pub mod instcombine;
129    pub mod ipo;
130    pub mod pass_manager_builder;
131    pub mod scalar;
132    pub mod util;
133    pub mod vectorize;
134}
135
136#[repr(C)]
137#[derive(Clone, Copy, Debug, PartialEq)]
138pub enum LLVMOpcode {
139    LLVMRet = 1,
140    LLVMBr = 2,
141    LLVMSwitch = 3,
142    LLVMIndirectBr = 4,
143    LLVMInvoke = 5,
144    LLVMUnreachable = 7,
145    #[cfg(LLVM_VERSION_9_OR_GREATER)]
146    LLVMCallBr = 67,
147    LLVMFNeg = 66,
148    LLVMAdd = 8,
149    LLVMFAdd = 9,
150    LLVMSub = 10,
151    LLVMFSub = 11,
152    LLVMMul = 12,
153    LLVMFMul = 13,
154    LLVMUDiv = 14,
155    LLVMSDiv = 15,
156    LLVMFDiv = 16,
157    LLVMURem = 17,
158    LLVMSRem = 18,
159    LLVMFRem = 19,
160    LLVMShl = 20,
161    LLVMLShr = 21,
162    LLVMAShr = 22,
163    LLVMAnd = 23,
164    LLVMOr = 24,
165    LLVMXor = 25,
166    LLVMAlloca = 26,
167    LLVMLoad = 27,
168    LLVMStore = 28,
169    LLVMGetElementPtr = 29,
170    LLVMTrunc = 30,
171    LLVMZExt = 31,
172    LLVMSExt = 32,
173    LLVMFPToUI = 33,
174    LLVMFPToSI = 34,
175    LLVMUIToFP = 35,
176    LLVMSIToFP = 36,
177    LLVMFPTrunc = 37,
178    LLVMFPExt = 38,
179    LLVMPtrToInt = 39,
180    LLVMIntToPtr = 40,
181    LLVMBitCast = 41,
182    LLVMAddrSpaceCast = 60,
183    LLVMICmp = 42,
184    LLVMFCmp = 43,
185    LLVMPHI = 44,
186    LLVMCall = 45,
187    LLVMSelect = 46,
188    LLVMUserOp1 = 47,
189    LLVMUserOp2 = 48,
190    LLVMVAArg = 49,
191    LLVMExtractElement = 50,
192    LLVMInsertElement = 51,
193    LLVMShuffleVector = 52,
194    LLVMExtractValue = 53,
195    LLVMInsertValue = 54,
196    #[cfg(LLVM_VERSION_10_OR_GREATER)]
197    LLVMFreeze = 68,
198    LLVMFence = 55,
199    LLVMAtomicCmpXchg = 56,
200    LLVMAtomicRMW = 57,
201    LLVMResume = 58,
202    LLVMLandingPad = 59,
203    LLVMCleanupRet = 61,
204    LLVMCatchRet = 62,
205    LLVMCatchPad = 63,
206    LLVMCleanupPad = 64,
207    LLVMCatchSwitch = 65,
208}
209
210#[repr(C)]
211#[derive(Clone, Copy, Debug, PartialEq)]
212pub enum LLVMTypeKind {
213    LLVMVoidTypeKind = 0,
214    LLVMHalfTypeKind = 1,
215    LLVMFloatTypeKind = 2,
216    LLVMDoubleTypeKind = 3,
217    LLVMX86_FP80TypeKind = 4,
218    LLVMFP128TypeKind = 5,
219    LLVMPPC_FP128TypeKind = 6,
220    LLVMLabelTypeKind = 7,
221    LLVMIntegerTypeKind = 8,
222    LLVMFunctionTypeKind = 9,
223    LLVMStructTypeKind = 10,
224    LLVMArrayTypeKind = 11,
225    LLVMPointerTypeKind = 12,
226    LLVMVectorTypeKind = 13,
227    LLVMMetadataTypeKind = 14,
228    LLVMX86_MMXTypeKind = 15,
229    LLVMTokenTypeKind = 16,
230}
231
232#[repr(C)]
233#[derive(Clone, Copy, Debug, PartialEq)]
234pub enum LLVMLinkage {
235    LLVMExternalLinkage = 0,
236    LLVMAvailableExternallyLinkage = 1,
237    LLVMLinkOnceAnyLinkage = 2,
238    LLVMLinkOnceODRLinkage = 3,
239    LLVMLinkOnceODRAutoHideLinkage = 4,
240    LLVMWeakAnyLinkage = 5,
241    LLVMWeakODRLinkage = 6,
242    LLVMAppendingLinkage = 7,
243    LLVMInternalLinkage = 8,
244    LLVMPrivateLinkage = 9,
245    LLVMDLLImportLinkage = 10,
246    LLVMDLLExportLinkage = 11,
247    LLVMExternalWeakLinkage = 12,
248    LLVMGhostLinkage = 13,
249    LLVMCommonLinkage = 14,
250    LLVMLinkerPrivateLinkage = 15,
251    LLVMLinkerPrivateWeakLinkage = 16,
252}
253
254#[repr(C)]
255#[derive(Clone, Copy, Debug, PartialEq)]
256pub enum LLVMVisibility {
257    LLVMDefaultVisibility = 0,
258    LLVMHiddenVisibility = 1,
259    LLVMProtectedVisibility = 2,
260}
261
262#[repr(C)]
263#[derive(Clone, Copy, Debug, PartialEq)]
264pub enum LLVMUnnamedAddr {
265    /// Address of the GV is significant.
266    LLVMNoUnnamedAddr,
267    /// Address of the GV is locally insignificant.
268    LLVMLocalUnnamedAddr,
269    /// Address of the GV is globally insignificant.
270    LLVMGlobalUnnamedAddr,
271}
272
273#[repr(C)]
274#[derive(Clone, Copy, Debug, PartialEq)]
275pub enum LLVMDLLStorageClass {
276    LLVMDefaultStorageClass = 0,
277    LLVMDLLImportStorageClass = 1,
278    LLVMDLLExportStorageClass = 2,
279}
280
281#[repr(C)]
282#[derive(Clone, Copy, Debug, PartialEq)]
283pub enum LLVMCallConv {
284    LLVMCCallConv = 0,
285    LLVMFastCallConv = 8,
286    LLVMColdCallConv = 9,
287    LLVMGHCCallConv = 10,
288    LLVMHiPECallConv = 11,
289    LLVMWebKitJSCallConv = 12,
290    LLVMAnyRegCallConv = 13,
291    LLVMPreserveMostCallConv = 14,
292    LLVMPreserveAllCallConv = 15,
293    LLVMSwiftCallConv = 16,
294    LLVMCXXFASTTLSCallConv = 17,
295    LLVMX86StdcallCallConv = 64,
296    LLVMX86FastcallCallConv = 65,
297    LLVMARMAPCSCallConv = 66,
298    LLVMARMAAPCSCallConv = 67,
299    LLVMARMAAPCSVFPCallConv = 68,
300    LLVMMSP430INTRCallConv = 69,
301    LLVMX86ThisCallCallConv = 70,
302    LLVMPTXKernelCallConv = 71,
303    LLVMPTXDeviceCallConv = 72,
304    LLVMSPIRFUNCCallConv = 75,
305    LLVMSPIRKERNELCallConv = 76,
306    LLVMIntelOCLBICallConv = 77,
307    LLVMX8664SysVCallConv = 78,
308    LLVMWin64CallConv = 79,
309    LLVMX86VectorCallCallConv = 80,
310    LLVMHHVMCallConv = 81,
311    LLVMHHVMCCallConv = 82,
312    LLVMX86INTRCallConv = 83,
313    LLVMAVRINTRCallConv = 84,
314    LLVMAVRSIGNALCallConv = 85,
315    LLVMAVRBUILTINCallConv = 86,
316    LLVMAMDGPUVSCallConv = 87,
317    LLVMAMDGPUGSCallConv = 88,
318    LLVMAMDGPUPSCallConv = 89,
319    LLVMAMDGPUCSCallConv = 90,
320    LLVMAMDGPUKERNELCallConv = 91,
321    LLVMX86RegCallCallConv = 92,
322    LLVMAMDGPUHSCallConv = 93,
323    LLVMMSP430BUILTINCallConv = 94,
324    LLVMAMDGPULSCallConv = 95,
325    LLVMAMDGPUESCallConv = 96,
326}
327
328#[repr(C)]
329#[derive(Clone, Copy, Debug, PartialEq)]
330pub enum LLVMValueKind {
331    LLVMArgumentValueKind,
332    LLVMBasicBlockValueKind,
333    LLVMMemoryUseValueKind,
334    LLVMMemoryDefValueKind,
335    LLVMMemoryPhiValueKind,
336
337    LLVMFunctionValueKind,
338    LLVMGlobalAliasValueKind,
339    LLVMGlobalIFuncValueKind,
340    LLVMGlobalVariableValueKind,
341    LLVMBlockAddressValueKind,
342    LLVMConstantExprValueKind,
343    LLVMConstantArrayValueKind,
344    LLVMConstantStructValueKind,
345    LLVMConstantVectorValueKind,
346    LLVMUndefValueValueKind,
347    LLVMConstantAggregateZeroValueKind,
348    LLVMConstantDataArrayValueKind,
349    LLVMConstantDataVectorValueKind,
350    LLVMConstantIntValueKind,
351    LLVMConstantFPValueKind,
352    LLVMConstantPointerNullValueKind,
353    LLVMConstantTokenNoneValueKind,
354
355    LLVMMetadataAsValueValueKind,
356    LLVMInlineAsmValueKind,
357
358    LLVMInstructionValueKind,
359}
360
361#[repr(C)]
362#[derive(Clone, Copy, Debug, PartialEq)]
363pub enum LLVMIntPredicate {
364    LLVMIntEQ = 32,
365    LLVMIntNE = 33,
366    LLVMIntUGT = 34,
367    LLVMIntUGE = 35,
368    LLVMIntULT = 36,
369    LLVMIntULE = 37,
370    LLVMIntSGT = 38,
371    LLVMIntSGE = 39,
372    LLVMIntSLT = 40,
373    LLVMIntSLE = 41,
374}
375
376#[repr(C)]
377#[derive(Clone, Copy, Debug, PartialEq)]
378pub enum LLVMRealPredicate {
379    LLVMRealPredicateFalse = 0,
380    LLVMRealOEQ = 1,
381    LLVMRealOGT = 2,
382    LLVMRealOGE = 3,
383    LLVMRealOLT = 4,
384    LLVMRealOLE = 5,
385    LLVMRealONE = 6,
386    LLVMRealORD = 7,
387    LLVMRealUNO = 8,
388    LLVMRealUEQ = 9,
389    LLVMRealUGT = 10,
390    LLVMRealUGE = 11,
391    LLVMRealULT = 12,
392    LLVMRealULE = 13,
393    LLVMRealUNE = 14,
394    LLVMRealPredicateTrue = 15,
395}
396
397#[repr(C)]
398#[derive(Clone, Copy, Debug, PartialEq)]
399pub enum LLVMLandingPadClauseTy {
400    LLVMLandingPadCatch = 0,
401    LLVMLandingPadFilter = 1,
402}
403
404#[repr(C)]
405#[derive(Clone, Copy, Debug, PartialEq)]
406pub enum LLVMThreadLocalMode {
407    LLVMNotThreadLocal = 0,
408    LLVMGeneralDynamicTLSModel = 1,
409    LLVMLocalDynamicTLSModel = 2,
410    LLVMInitialExecTLSModel = 3,
411    LLVMLocalExecTLSModel = 4,
412}
413
414#[repr(C)]
415#[derive(Clone, Copy, Debug, PartialEq)]
416pub enum LLVMAtomicOrdering {
417    LLVMAtomicOrderingNotAtomic = 0,
418    LLVMAtomicOrderingUnordered = 1,
419    LLVMAtomicOrderingMonotonic = 2,
420    LLVMAtomicOrderingAcquire = 4,
421    LLVMAtomicOrderingRelease = 5,
422    LLVMAtomicOrderingAcquireRelease = 6,
423    LLVMAtomicOrderingSequentiallyConsistent = 7,
424}
425
426#[repr(C)]
427#[derive(Clone, Copy, Debug, PartialEq)]
428pub enum LLVMAtomicRMWBinOp {
429    LLVMAtomicRMWBinOpXchg = 0,
430    LLVMAtomicRMWBinOpAdd = 1,
431    LLVMAtomicRMWBinOpSub = 2,
432    LLVMAtomicRMWBinOpAnd = 3,
433    LLVMAtomicRMWBinOpNand = 4,
434    LLVMAtomicRMWBinOpOr = 5,
435    LLVMAtomicRMWBinOpXor = 6,
436    LLVMAtomicRMWBinOpMax = 7,
437    LLVMAtomicRMWBinOpMin = 8,
438    LLVMAtomicRMWBinOpUMax = 9,
439    LLVMAtomicRMWBinOpUMin = 10,
440    #[cfg(LLVM_VERSION_10_OR_GREATER)]
441    LLVMAtomicRMWBinOpFAdd = 11,
442    #[cfg(LLVM_VERSION_10_OR_GREATER)]
443    LLVMAtomicRMWBinOpFSub = 12,
444}
445
446#[repr(C)]
447#[derive(Clone, Copy, Debug, PartialEq)]
448pub enum LLVMDiagnosticSeverity {
449    LLVMDSError = 0,
450    LLVMDSWarning = 1,
451    LLVMDSRemark = 2,
452    LLVMDSNote = 3,
453}
454
455#[repr(C)]
456#[derive(Clone, Copy, Debug, PartialEq)]
457pub enum LLVMInlineAsmDialect {
458    LLVMInlineAsmDialectATT,
459    LLVMInlineAsmDialectIntel,
460}
461
462#[repr(C)]
463#[derive(Clone, Copy, Debug, PartialEq)]
464pub enum LLVMModuleFlagBehavior {
465    /// Emits an error if two values disagree, otherwise the resulting value is that of the operands.
466    LLVMModuleFlagBehaviorError,
467    /// Emits a warning if two values disagree. The result value will be the operand for the flag from the first module being linked.
468    LLVMModuleFlagBehaviorWarning,
469    /// Adds a requirement that another module flag be present and have a specified value after linking is performed. The value must be a metadata pair, where the first element of the pair is the ID of the module flag to be restricted, and the second element of the pair is the value the module flag should be restricted to. This behavior can be used to restrict the allowable results (via triggering of an error) of linking IDs with the **Override** behavior.
470    LLVMModuleFlagBehaviorRequire,
471    /// Uses the specified value, regardless of the behavior or value of the other module. If both modules specify **Override**, but the values differ, an error will be emitted.
472    LLVMModuleFlagBehaviorOverride,
473    /// Appends the two values, which are required to be metadata nodes.
474    LLVMModuleFlagBehaviorAppend,
475    /// Appends the two values, which are required to be metadata nodes. However, duplicate entries in the second list are dropped during the append operation.
476    LLVMModuleFlagBehaviorAppendUnique,
477}
478
479pub const LLVMAttributeReturnIndex: ::libc::c_uint = 0;
480pub const LLVMAttributeFunctionIndex: ::libc::c_uint = !0; // -1
481/// Either LLVMAttributeReturnIndex, LLVMAttributeFunctionIndex, or a parameter
482/// number from 1 to N.
483pub type LLVMAttributeIndex = ::libc::c_uint;
484
485pub type LLVMDiagnosticHandler =
486    Option<extern "C" fn(arg1: LLVMDiagnosticInfoRef, arg2: *mut ::libc::c_void)>;
487pub type LLVMYieldCallback = Option<extern "C" fn(arg1: LLVMContextRef, arg2: *mut ::libc::c_void)>;
488
489#[cfg(all(not(doc),LLVM_SYS_NOT_FOUND))]
490std::compile_error!(concat!(
491      "No suitable version of LLVM was found system-wide or pointed
492       to by LLVM_SYS_FEATURED_PREFIX.
493
494       Consider using `llvmenv` to compile an appropriate copy of LLVM, and
495       refer to the llvm-sys-featured documentation for more information.
496
497       llvm-sys-featured: https://crates.io/crates/llvm-sys-featured
498       llvmenv: https://crates.io/crates/llvmenv"));