]> git.proxmox.com Git - rustc.git/blame - src/librustc_llvm/ffi.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / librustc_llvm / ffi.rs
CommitLineData
5bcae85e
SL
1// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
8bb4bdeb
XL
11// FIXME: Rename 'DIGlobalVariable' to 'DIGlobalVariableExpression'
12// once support for LLVM 3.9 is dropped.
13//
14// This method was changed in this LLVM patch:
15// https://reviews.llvm.org/D26769
16
c30ab7b3
SL
17use debuginfo::{DIBuilderRef, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType,
18 DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
19 DIGlobalVariable, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
476ff2be 20 DINameSpace, DIFlags};
5bcae85e
SL
21
22use libc::{c_uint, c_int, size_t, c_char};
23use libc::{c_longlong, c_ulonglong, c_void};
24
25use RustStringRef;
26
27pub type Opcode = u32;
28pub type Bool = c_uint;
29
30pub const True: Bool = 1 as Bool;
31pub const False: Bool = 0 as Bool;
32
33#[derive(Copy, Clone, PartialEq)]
34#[repr(C)]
35pub enum LLVMRustResult {
36 Success,
37 Failure,
38}
39// Consts for the LLVM CallConv type, pre-cast to usize.
40
41/// LLVM CallingConv::ID. Should we wrap this?
32a655c1 42#[derive(Copy, Clone, PartialEq, Debug)]
5bcae85e
SL
43#[repr(C)]
44pub enum CallConv {
45 CCallConv = 0,
46 FastCallConv = 8,
47 ColdCallConv = 9,
48 X86StdcallCallConv = 64,
49 X86FastcallCallConv = 65,
476ff2be 50 ArmAapcsCallConv = 67,
32a655c1 51 Msp430Intr = 69,
7cac9316 52 X86_ThisCall = 70,
32a655c1 53 PtxKernel = 71,
9e0c209e 54 X86_64_SysV = 78,
5bcae85e 55 X86_64_Win64 = 79,
c30ab7b3 56 X86_VectorCall = 80,
8bb4bdeb 57 X86_Intr = 83,
5bcae85e
SL
58}
59
9e0c209e 60/// LLVMRustLinkage
5bcae85e
SL
61#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
62#[repr(C)]
63pub enum Linkage {
64 ExternalLinkage = 0,
65 AvailableExternallyLinkage = 1,
66 LinkOnceAnyLinkage = 2,
67 LinkOnceODRLinkage = 3,
9e0c209e
SL
68 WeakAnyLinkage = 4,
69 WeakODRLinkage = 5,
70 AppendingLinkage = 6,
71 InternalLinkage = 7,
72 PrivateLinkage = 8,
73 ExternalWeakLinkage = 9,
74 CommonLinkage = 10,
5bcae85e
SL
75}
76
476ff2be
SL
77// LLVMRustVisibility
78#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
79#[repr(C)]
80pub enum Visibility {
81 Default = 0,
82 Hidden = 1,
83 Protected = 2,
84}
85
5bcae85e
SL
86/// LLVMDiagnosticSeverity
87#[derive(Copy, Clone, Debug)]
88#[repr(C)]
89pub enum DiagnosticSeverity {
90 Error = 0,
91 Warning = 1,
92 Remark = 2,
93 Note = 3,
94}
95
96/// LLVMDLLStorageClass
97#[derive(Copy, Clone)]
98#[repr(C)]
99pub enum DLLStorageClass {
c30ab7b3
SL
100 Default = 0,
101 DllImport = 1, // Function to be imported from DLL.
102 DllExport = 2, // Function to be accessible from DLL.
5bcae85e
SL
103}
104
476ff2be
SL
105/// Matches LLVMRustAttribute in rustllvm.h
106/// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
107/// though it is not ABI compatible (since it's a C++ enum)
108#[repr(C)]
109#[derive(Copy, Clone, Debug)]
110pub enum Attribute {
111 AlwaysInline = 0,
112 ByVal = 1,
113 Cold = 2,
114 InlineHint = 3,
115 MinSize = 4,
116 Naked = 5,
117 NoAlias = 6,
118 NoCapture = 7,
119 NoInline = 8,
120 NonNull = 9,
121 NoRedZone = 10,
122 NoReturn = 11,
123 NoUnwind = 12,
124 OptimizeForSize = 13,
125 ReadOnly = 14,
126 SExt = 15,
127 StructRet = 16,
128 UWTable = 17,
129 ZExt = 18,
32a655c1 130 InReg = 19,
8bb4bdeb
XL
131 SanitizeThread = 20,
132 SanitizeAddress = 21,
133 SanitizeMemory = 22,
5bcae85e
SL
134}
135
136/// LLVMIntPredicate
137#[derive(Copy, Clone)]
138#[repr(C)]
139pub enum IntPredicate {
140 IntEQ = 32,
141 IntNE = 33,
142 IntUGT = 34,
143 IntUGE = 35,
144 IntULT = 36,
145 IntULE = 37,
146 IntSGT = 38,
147 IntSGE = 39,
148 IntSLT = 40,
149 IntSLE = 41,
150}
151
152/// LLVMRealPredicate
153#[derive(Copy, Clone)]
154#[repr(C)]
155pub enum RealPredicate {
156 RealPredicateFalse = 0,
157 RealOEQ = 1,
158 RealOGT = 2,
159 RealOGE = 3,
160 RealOLT = 4,
161 RealOLE = 5,
162 RealONE = 6,
163 RealORD = 7,
164 RealUNO = 8,
165 RealUEQ = 9,
166 RealUGT = 10,
167 RealUGE = 11,
168 RealULT = 12,
169 RealULE = 13,
170 RealUNE = 14,
171 RealPredicateTrue = 15,
172}
173
174/// LLVMTypeKind
175#[derive(Copy, Clone, PartialEq, Debug)]
176#[repr(C)]
177pub enum TypeKind {
c30ab7b3
SL
178 Void = 0,
179 Half = 1,
180 Float = 2,
181 Double = 3,
182 X86_FP80 = 4,
183 FP128 = 5,
5bcae85e 184 PPC_FP128 = 6,
c30ab7b3
SL
185 Label = 7,
186 Integer = 8,
187 Function = 9,
188 Struct = 10,
189 Array = 11,
190 Pointer = 12,
191 Vector = 13,
192 Metadata = 14,
193 X86_MMX = 15,
194 Token = 16,
5bcae85e
SL
195}
196
197/// LLVMAtomicRmwBinOp
198#[derive(Copy, Clone)]
199#[repr(C)]
200pub enum AtomicRmwBinOp {
201 AtomicXchg = 0,
c30ab7b3
SL
202 AtomicAdd = 1,
203 AtomicSub = 2,
204 AtomicAnd = 3,
5bcae85e 205 AtomicNand = 4,
c30ab7b3
SL
206 AtomicOr = 5,
207 AtomicXor = 6,
208 AtomicMax = 7,
209 AtomicMin = 8,
5bcae85e
SL
210 AtomicUMax = 9,
211 AtomicUMin = 10,
212}
213
214/// LLVMAtomicOrdering
215#[derive(Copy, Clone)]
216#[repr(C)]
217pub enum AtomicOrdering {
218 NotAtomic = 0,
219 Unordered = 1,
220 Monotonic = 2,
221 // Consume = 3, // Not specified yet.
222 Acquire = 4,
223 Release = 5,
224 AcquireRelease = 6,
c30ab7b3 225 SequentiallyConsistent = 7,
5bcae85e
SL
226}
227
228/// LLVMRustSynchronizationScope
229#[derive(Copy, Clone)]
230#[repr(C)]
231pub enum SynchronizationScope {
232 Other,
233 SingleThread,
234 CrossThread,
235}
236
237/// LLVMRustFileType
238#[derive(Copy, Clone)]
239#[repr(C)]
240pub enum FileType {
241 Other,
242 AssemblyFile,
243 ObjectFile,
244}
245
9e0c209e 246/// LLVMMetadataType
5bcae85e
SL
247#[derive(Copy, Clone)]
248#[repr(C)]
249pub enum MetadataType {
250 MD_dbg = 0,
251 MD_tbaa = 1,
252 MD_prof = 2,
253 MD_fpmath = 3,
254 MD_range = 4,
255 MD_tbaa_struct = 5,
256 MD_invariant_load = 6,
257 MD_alias_scope = 7,
258 MD_noalias = 8,
259 MD_nontemporal = 9,
260 MD_mem_parallel_loop_access = 10,
261 MD_nonnull = 11,
262}
263
264/// LLVMRustAsmDialect
265#[derive(Copy, Clone)]
266#[repr(C)]
267pub enum AsmDialect {
268 Other,
269 Att,
270 Intel,
271}
272
273/// LLVMRustCodeGenOptLevel
274#[derive(Copy, Clone, PartialEq)]
275#[repr(C)]
276pub enum CodeGenOptLevel {
277 Other,
278 None,
279 Less,
280 Default,
281 Aggressive,
282}
283
284/// LLVMRelocMode
285#[derive(Copy, Clone, PartialEq)]
286#[repr(C)]
287pub enum RelocMode {
7cac9316
XL
288 Default,
289 Static,
290 PIC,
291 DynamicNoPic,
292 ROPI,
293 RWPI,
294 ROPI_RWPI,
5bcae85e
SL
295}
296
297/// LLVMRustCodeModel
298#[derive(Copy, Clone)]
299#[repr(C)]
300pub enum CodeModel {
301 Other,
302 Default,
303 JITDefault,
304 Small,
305 Kernel,
306 Medium,
307 Large,
308}
309
310/// LLVMRustDiagnosticKind
311#[derive(Copy, Clone)]
312#[repr(C)]
313pub enum DiagnosticKind {
314 Other,
315 InlineAsm,
316 StackSize,
317 DebugMetadataVersion,
318 SampleProfile,
319 OptimizationRemark,
320 OptimizationRemarkMissed,
321 OptimizationRemarkAnalysis,
322 OptimizationRemarkAnalysisFPCommute,
323 OptimizationRemarkAnalysisAliasing,
324 OptimizationRemarkOther,
325 OptimizationFailure,
326}
327
328/// LLVMRustArchiveKind
329#[derive(Copy, Clone)]
330#[repr(C)]
331pub enum ArchiveKind {
332 Other,
333 K_GNU,
334 K_MIPS64,
335 K_BSD,
336 K_COFF,
337}
338
339/// LLVMRustPassKind
340#[derive(Copy, Clone, PartialEq, Debug)]
341#[repr(C)]
342pub enum PassKind {
343 Other,
344 Function,
345 Module,
346}
347
ea8adc8c
XL
348/// LLVMRustThinLTOData
349pub enum ThinLTOData {}
350
351/// LLVMRustThinLTOBuffer
352pub enum ThinLTOBuffer {}
353
354/// LLVMRustThinLTOModule
355#[repr(C)]
356pub struct ThinLTOModule {
357 pub identifier: *const c_char,
358 pub data: *const u8,
359 pub len: usize,
360}
361
abe05a73
XL
362/// LLVMThreadLocalMode
363#[derive(Copy, Clone)]
364#[repr(C)]
365pub enum ThreadLocalMode {
366 NotThreadLocal,
367 GeneralDynamic,
368 LocalDynamic,
369 InitialExec,
370 LocalExec
371}
372
5bcae85e
SL
373// Opaque pointer types
374#[allow(missing_copy_implementations)]
375pub enum Module_opaque {}
376pub type ModuleRef = *mut Module_opaque;
377#[allow(missing_copy_implementations)]
378pub enum Context_opaque {}
379pub type ContextRef = *mut Context_opaque;
380#[allow(missing_copy_implementations)]
381pub enum Type_opaque {}
382pub type TypeRef = *mut Type_opaque;
383#[allow(missing_copy_implementations)]
384pub enum Value_opaque {}
385pub type ValueRef = *mut Value_opaque;
386#[allow(missing_copy_implementations)]
387pub enum Metadata_opaque {}
388pub type MetadataRef = *mut Metadata_opaque;
389#[allow(missing_copy_implementations)]
390pub enum BasicBlock_opaque {}
391pub type BasicBlockRef = *mut BasicBlock_opaque;
392#[allow(missing_copy_implementations)]
393pub enum Builder_opaque {}
394pub type BuilderRef = *mut Builder_opaque;
395#[allow(missing_copy_implementations)]
396pub enum ExecutionEngine_opaque {}
397pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
398#[allow(missing_copy_implementations)]
399pub enum MemoryBuffer_opaque {}
400pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
401#[allow(missing_copy_implementations)]
402pub enum PassManager_opaque {}
403pub type PassManagerRef = *mut PassManager_opaque;
404#[allow(missing_copy_implementations)]
405pub enum PassManagerBuilder_opaque {}
406pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
407#[allow(missing_copy_implementations)]
408pub enum Use_opaque {}
409pub type UseRef = *mut Use_opaque;
410#[allow(missing_copy_implementations)]
411pub enum TargetData_opaque {}
412pub type TargetDataRef = *mut TargetData_opaque;
413#[allow(missing_copy_implementations)]
414pub enum ObjectFile_opaque {}
415pub type ObjectFileRef = *mut ObjectFile_opaque;
416#[allow(missing_copy_implementations)]
417pub enum SectionIterator_opaque {}
418pub type SectionIteratorRef = *mut SectionIterator_opaque;
419#[allow(missing_copy_implementations)]
420pub enum Pass_opaque {}
421pub type PassRef = *mut Pass_opaque;
422#[allow(missing_copy_implementations)]
423pub enum TargetMachine_opaque {}
424pub type TargetMachineRef = *mut TargetMachine_opaque;
425pub enum Archive_opaque {}
426pub type ArchiveRef = *mut Archive_opaque;
427pub enum ArchiveIterator_opaque {}
428pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
429pub enum ArchiveChild_opaque {}
430pub type ArchiveChildRef = *mut ArchiveChild_opaque;
431#[allow(missing_copy_implementations)]
432pub enum Twine_opaque {}
433pub type TwineRef = *mut Twine_opaque;
434#[allow(missing_copy_implementations)]
435pub enum DiagnosticInfo_opaque {}
436pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
437#[allow(missing_copy_implementations)]
438pub enum DebugLoc_opaque {}
439pub type DebugLocRef = *mut DebugLoc_opaque;
440#[allow(missing_copy_implementations)]
441pub enum SMDiagnostic_opaque {}
442pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
443#[allow(missing_copy_implementations)]
444pub enum RustArchiveMember_opaque {}
445pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
446#[allow(missing_copy_implementations)]
447pub enum OperandBundleDef_opaque {}
448pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
449
450pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
451pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
452
476ff2be 453
5bcae85e 454pub mod debuginfo {
c30ab7b3 455 use super::MetadataRef;
5bcae85e
SL
456
457 #[allow(missing_copy_implementations)]
458 pub enum DIBuilder_opaque {}
459 pub type DIBuilderRef = *mut DIBuilder_opaque;
460
461 pub type DIDescriptor = MetadataRef;
462 pub type DIScope = DIDescriptor;
463 pub type DILocation = DIDescriptor;
464 pub type DIFile = DIScope;
465 pub type DILexicalBlock = DIScope;
466 pub type DISubprogram = DIScope;
467 pub type DINameSpace = DIScope;
468 pub type DIType = DIDescriptor;
469 pub type DIBasicType = DIType;
470 pub type DIDerivedType = DIType;
471 pub type DICompositeType = DIDerivedType;
472 pub type DIVariable = DIDescriptor;
473 pub type DIGlobalVariable = DIDescriptor;
474 pub type DIArray = DIDescriptor;
475 pub type DISubrange = DIDescriptor;
476 pub type DIEnumerator = DIDescriptor;
477 pub type DITemplateTypeParameter = DIDescriptor;
478
476ff2be
SL
479 // These values **must** match with LLVMRustDIFlags!!
480 bitflags! {
481 #[repr(C)]
ea8adc8c
XL
482 #[derive(Default)]
483 pub struct DIFlags: ::libc::uint32_t {
484 const FlagZero = 0;
485 const FlagPrivate = 1;
486 const FlagProtected = 2;
487 const FlagPublic = 3;
488 const FlagFwdDecl = (1 << 2);
489 const FlagAppleBlock = (1 << 3);
490 const FlagBlockByrefStruct = (1 << 4);
491 const FlagVirtual = (1 << 5);
492 const FlagArtificial = (1 << 6);
493 const FlagExplicit = (1 << 7);
494 const FlagPrototyped = (1 << 8);
495 const FlagObjcClassComplete = (1 << 9);
496 const FlagObjectPointer = (1 << 10);
497 const FlagVector = (1 << 11);
498 const FlagStaticMember = (1 << 12);
499 const FlagLValueReference = (1 << 13);
500 const FlagRValueReference = (1 << 14);
501 const FlagMainSubprogram = (1 << 21);
476ff2be 502 }
5bcae85e
SL
503 }
504}
505
ea8adc8c 506pub enum ModuleBuffer {}
5bcae85e
SL
507
508// Link to our native llvm bindings (things that we need to use the C++ api
509// for) and because llvm is written in C++ we need to link against libstdc++
510//
511// You'll probably notice that there is an omission of all LLVM libraries
512// from this location. This is because the set of LLVM libraries that we
513// link to is mostly defined by LLVM, and the `llvm-config` tool is used to
514// figure out the exact set of libraries. To do this, the build system
515// generates an llvmdeps.rs file next to this one which will be
516// automatically updated whenever LLVM is updated to include an up-to-date
517// set of the libraries we need to link to LLVM for.
32a655c1 518#[link(name = "rustllvm", kind = "static")] // not quite true but good enough
c30ab7b3
SL
519extern "C" {
520 // Create and destroy contexts.
5bcae85e
SL
521 pub fn LLVMContextCreate() -> ContextRef;
522 pub fn LLVMContextDispose(C: ContextRef);
c30ab7b3 523 pub fn LLVMGetMDKindIDInContext(C: ContextRef, Name: *const c_char, SLen: c_uint) -> c_uint;
5bcae85e 524
c30ab7b3
SL
525 // Create and destroy modules.
526 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: ContextRef) -> ModuleRef;
5bcae85e
SL
527 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
528 pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
529 pub fn LLVMDisposeModule(M: ModuleRef);
530
531 /// Data layout. See Module::getDataLayout.
532 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
533 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
534
5bcae85e
SL
535 /// See Module::dump.
536 pub fn LLVMDumpModule(M: ModuleRef);
537
538 /// See Module::setModuleInlineAsm.
539 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
cc61c64b 540 pub fn LLVMRustAppendModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
5bcae85e
SL
541
542 /// See llvm::LLVMTypeKind::getTypeID.
543 pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind;
544
476ff2be
SL
545 /// See llvm::Value::getContext
546 pub fn LLVMRustGetValueContext(V: ValueRef) -> ContextRef;
5bcae85e 547
c30ab7b3 548 // Operations on integer types
5bcae85e
SL
549 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
550 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
551 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
552 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
553 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
c30ab7b3 554 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint) -> TypeRef;
5bcae85e
SL
555
556 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
557
c30ab7b3 558 // Operations on real types
5bcae85e
SL
559 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
560 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
5bcae85e 561
c30ab7b3 562 // Operations on function types
5bcae85e
SL
563 pub fn LLVMFunctionType(ReturnType: TypeRef,
564 ParamTypes: *const TypeRef,
565 ParamCount: c_uint,
566 IsVarArg: Bool)
567 -> TypeRef;
5bcae85e
SL
568 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
569 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
570 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
571
c30ab7b3 572 // Operations on struct types
5bcae85e
SL
573 pub fn LLVMStructTypeInContext(C: ContextRef,
574 ElementTypes: *const TypeRef,
575 ElementCount: c_uint,
576 Packed: Bool)
577 -> TypeRef;
578 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
c30ab7b3 579 pub fn LLVMGetStructElementTypes(StructTy: TypeRef, Dest: *mut TypeRef);
5bcae85e
SL
580 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
581
c30ab7b3 582 // Operations on array, pointer, and vector types (sequence types)
5bcae85e 583 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
c30ab7b3
SL
584 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint) -> TypeRef;
585 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint) -> TypeRef;
5bcae85e
SL
586
587 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
588 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
5bcae85e
SL
589 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
590
c30ab7b3 591 // Operations on other types
5bcae85e 592 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
5bcae85e
SL
593 pub fn LLVMRustMetadataTypeInContext(C: ContextRef) -> TypeRef;
594
c30ab7b3 595 // Operations on all values
5bcae85e
SL
596 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
597 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
598 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
5bcae85e
SL
599 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
600 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
601
c30ab7b3 602 // Operations on Uses
5bcae85e
SL
603 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
604 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
605 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
5bcae85e 606
c30ab7b3 607 // Operations on Users
5bcae85e 608 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
5bcae85e 609
c30ab7b3 610 // Operations on constants of any type
5bcae85e 611 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
c30ab7b3
SL
612 pub fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
613 pub fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
614 // only for isize/vector
5bcae85e 615 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
5bcae85e
SL
616 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
617 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
5bcae85e 618
c30ab7b3 619 // Operations on metadata
041b39d2 620 pub fn LLVMMDStringInContext(C: ContextRef, Str: *const c_char, SLen: c_uint) -> ValueRef;
c30ab7b3 621 pub fn LLVMMDNodeInContext(C: ContextRef, Vals: *const ValueRef, Count: c_uint) -> ValueRef;
041b39d2 622 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef, Name: *const c_char, Val: ValueRef);
5bcae85e 623
c30ab7b3
SL
624 // Operations on scalar constants
625 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool) -> ValueRef;
32a655c1 626 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: TypeRef, Wn: c_uint, Ws: *const u64) -> ValueRef;
5bcae85e
SL
627 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
628 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
32a655c1
SL
629 pub fn LLVMRustConstInt128Get(ConstantVal: ValueRef, SExt: bool,
630 high: *mut u64, low: *mut u64) -> bool;
5bcae85e
SL
631
632
c30ab7b3 633 // Operations on composite constants
5bcae85e
SL
634 pub fn LLVMConstStringInContext(C: ContextRef,
635 Str: *const c_char,
636 Length: c_uint,
637 DontNullTerminate: Bool)
638 -> ValueRef;
639 pub fn LLVMConstStructInContext(C: ContextRef,
640 ConstantVals: *const ValueRef,
641 Count: c_uint,
642 Packed: Bool)
643 -> ValueRef;
644
645 pub fn LLVMConstArray(ElementTy: TypeRef,
646 ConstantVals: *const ValueRef,
647 Length: c_uint)
648 -> ValueRef;
c30ab7b3 649 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint) -> ValueRef;
5bcae85e 650
c30ab7b3 651 // Constant expressions
5bcae85e
SL
652 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
653 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
5bcae85e
SL
654 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
655 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
c30ab7b3 656 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
c30ab7b3
SL
657 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
658 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
c30ab7b3
SL
659 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
660 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
c30ab7b3
SL
661 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
662 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
663 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
c30ab7b3
SL
664 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
665 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
666 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
667 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
668 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
669 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
670 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
671 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
672 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
673 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
c30ab7b3 674 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
c30ab7b3 675 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
c30ab7b3
SL
676 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
677 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
678 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
679 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
680 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
681 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
682 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
c30ab7b3
SL
683 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
684 pub fn LLVMConstIntCast(ConstantVal: ValueRef, ToType: TypeRef, isSigned: Bool) -> ValueRef;
685 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
5bcae85e
SL
686 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
687 IdxList: *const c_uint,
688 NumIdx: c_uint)
689 -> ValueRef;
5bcae85e
SL
690 pub fn LLVMConstInlineAsm(Ty: TypeRef,
691 AsmString: *const c_char,
692 Constraints: *const c_char,
693 HasSideEffects: Bool,
694 IsAlignStack: Bool)
695 -> ValueRef;
5bcae85e
SL
696
697
c30ab7b3 698 // Operations on global variables, functions, and aliases (globals)
5bcae85e
SL
699 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
700 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
9e0c209e
SL
701 pub fn LLVMRustGetLinkage(Global: ValueRef) -> Linkage;
702 pub fn LLVMRustSetLinkage(Global: ValueRef, RustLinkage: Linkage);
5bcae85e
SL
703 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
704 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
476ff2be
SL
705 pub fn LLVMRustGetVisibility(Global: ValueRef) -> Visibility;
706 pub fn LLVMRustSetVisibility(Global: ValueRef, Viz: Visibility);
5bcae85e
SL
707 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
708 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
c30ab7b3 709 pub fn LLVMSetDLLStorageClass(V: ValueRef, C: DLLStorageClass);
5bcae85e
SL
710
711
c30ab7b3 712 // Operations on global variables
5bcae85e 713 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
c30ab7b3 714 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
c30ab7b3
SL
715 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
716 pub fn LLVMRustGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
5bcae85e 717 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
5bcae85e 718 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
5bcae85e
SL
719 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
720 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
c30ab7b3 721 pub fn LLVMSetInitializer(GlobalVar: ValueRef, ConstantVal: ValueRef);
5bcae85e 722 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
abe05a73 723 pub fn LLVMSetThreadLocalMode(GlobalVar: ValueRef, Mode: ThreadLocalMode);
5bcae85e
SL
724 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
725 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
726 pub fn LLVMRustGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
041b39d2 727 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
5bcae85e 728
c30ab7b3
SL
729 // Operations on functions
730 pub fn LLVMAddFunction(M: ModuleRef, Name: *const c_char, FunctionTy: TypeRef) -> ValueRef;
5bcae85e
SL
731 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
732 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
5bcae85e 733 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
5bcae85e
SL
734 pub fn LLVMRustGetOrInsertFunction(M: ModuleRef,
735 Name: *const c_char,
736 FunctionTy: TypeRef)
737 -> ValueRef;
5bcae85e 738 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
5bcae85e 739 pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
476ff2be 740 pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, attr: Attribute);
c30ab7b3
SL
741 pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef,
742 index: c_uint,
5bcae85e
SL
743 Name: *const c_char,
744 Value: *const c_char);
476ff2be 745 pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef, index: c_uint, attr: Attribute);
5bcae85e 746
c30ab7b3 747 // Operations on parameters
5bcae85e 748 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
5bcae85e 749 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
5bcae85e 750
c30ab7b3 751 // Operations on basic blocks
5bcae85e 752 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
5bcae85e 753 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
5bcae85e
SL
754 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
755 Fn: ValueRef,
756 Name: *const c_char)
757 -> BasicBlockRef;
5bcae85e
SL
758 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
759
c30ab7b3 760 // Operations on instructions
5bcae85e 761 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
32a655c1 762 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
5bcae85e 763 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
5bcae85e
SL
764 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
765
c30ab7b3 766 // Operations on call sites
5bcae85e 767 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
476ff2be 768 pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef, index: c_uint, attr: Attribute);
c30ab7b3
SL
769 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef, index: c_uint, bytes: u64);
770
c30ab7b3 771 // Operations on load/store instructions (only)
5bcae85e
SL
772 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
773
c30ab7b3 774 // Operations on phi nodes
5bcae85e
SL
775 pub fn LLVMAddIncoming(PhiNode: ValueRef,
776 IncomingValues: *const ValueRef,
777 IncomingBlocks: *const BasicBlockRef,
778 Count: c_uint);
5bcae85e 779
c30ab7b3 780 // Instruction builders
5bcae85e 781 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
c30ab7b3
SL
782 pub fn LLVMPositionBuilder(Builder: BuilderRef, Block: BasicBlockRef, Instr: ValueRef);
783 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef, Instr: ValueRef);
784 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef, Block: BasicBlockRef);
5bcae85e 785 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
5bcae85e
SL
786 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
787
c30ab7b3 788 // Metadata
5bcae85e
SL
789 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
790 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
791 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
792
c30ab7b3 793 // Terminators
5bcae85e
SL
794 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
795 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
c30ab7b3 796 pub fn LLVMBuildAggregateRet(B: BuilderRef, RetVals: *const ValueRef, N: c_uint) -> ValueRef;
5bcae85e
SL
797 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
798 pub fn LLVMBuildCondBr(B: BuilderRef,
799 If: ValueRef,
800 Then: BasicBlockRef,
801 Else: BasicBlockRef)
802 -> ValueRef;
803 pub fn LLVMBuildSwitch(B: BuilderRef,
804 V: ValueRef,
805 Else: BasicBlockRef,
806 NumCases: c_uint)
807 -> ValueRef;
c30ab7b3 808 pub fn LLVMBuildIndirectBr(B: BuilderRef, Addr: ValueRef, NumDests: c_uint) -> ValueRef;
5bcae85e
SL
809 pub fn LLVMRustBuildInvoke(B: BuilderRef,
810 Fn: ValueRef,
811 Args: *const ValueRef,
812 NumArgs: c_uint,
813 Then: BasicBlockRef,
814 Catch: BasicBlockRef,
815 Bundle: OperandBundleDefRef,
816 Name: *const c_char)
817 -> ValueRef;
818 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
819 Ty: TypeRef,
820 PersFn: ValueRef,
821 NumClauses: c_uint,
822 Name: *const c_char,
823 F: ValueRef)
824 -> ValueRef;
825 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
826 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
827
828 pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
829 ParentPad: ValueRef,
830 ArgCnt: c_uint,
831 Args: *const ValueRef,
c30ab7b3
SL
832 Name: *const c_char)
833 -> ValueRef;
5bcae85e
SL
834 pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
835 CleanupPad: ValueRef,
c30ab7b3
SL
836 UnwindBB: BasicBlockRef)
837 -> ValueRef;
5bcae85e
SL
838 pub fn LLVMRustBuildCatchPad(B: BuilderRef,
839 ParentPad: ValueRef,
840 ArgCnt: c_uint,
841 Args: *const ValueRef,
c30ab7b3
SL
842 Name: *const c_char)
843 -> ValueRef;
844 pub fn LLVMRustBuildCatchRet(B: BuilderRef, Pad: ValueRef, BB: BasicBlockRef) -> ValueRef;
5bcae85e
SL
845 pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
846 ParentPad: ValueRef,
847 BB: BasicBlockRef,
848 NumHandlers: c_uint,
c30ab7b3
SL
849 Name: *const c_char)
850 -> ValueRef;
851 pub fn LLVMRustAddHandler(CatchSwitch: ValueRef, Handler: BasicBlockRef);
8bb4bdeb 852 pub fn LLVMSetPersonalityFn(Func: ValueRef, Pers: ValueRef);
5bcae85e 853
c30ab7b3
SL
854 // Add a case to the switch instruction
855 pub fn LLVMAddCase(Switch: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef);
5bcae85e 856
c30ab7b3 857 // Add a clause to the landing pad instruction
5bcae85e
SL
858 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
859
c30ab7b3 860 // Set the cleanup on a landing pad instruction
5bcae85e
SL
861 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
862
c30ab7b3 863 // Arithmetic
5bcae85e
SL
864 pub fn LLVMBuildAdd(B: BuilderRef,
865 LHS: ValueRef,
866 RHS: ValueRef,
867 Name: *const c_char)
868 -> ValueRef;
869 pub fn LLVMBuildNSWAdd(B: BuilderRef,
870 LHS: ValueRef,
871 RHS: ValueRef,
872 Name: *const c_char)
873 -> ValueRef;
874 pub fn LLVMBuildNUWAdd(B: BuilderRef,
875 LHS: ValueRef,
876 RHS: ValueRef,
877 Name: *const c_char)
878 -> ValueRef;
879 pub fn LLVMBuildFAdd(B: BuilderRef,
880 LHS: ValueRef,
881 RHS: ValueRef,
882 Name: *const c_char)
883 -> ValueRef;
884 pub fn LLVMBuildSub(B: BuilderRef,
885 LHS: ValueRef,
886 RHS: ValueRef,
887 Name: *const c_char)
888 -> ValueRef;
889 pub fn LLVMBuildNSWSub(B: BuilderRef,
890 LHS: ValueRef,
891 RHS: ValueRef,
892 Name: *const c_char)
893 -> ValueRef;
894 pub fn LLVMBuildNUWSub(B: BuilderRef,
895 LHS: ValueRef,
896 RHS: ValueRef,
897 Name: *const c_char)
898 -> ValueRef;
899 pub fn LLVMBuildFSub(B: BuilderRef,
900 LHS: ValueRef,
901 RHS: ValueRef,
902 Name: *const c_char)
903 -> ValueRef;
904 pub fn LLVMBuildMul(B: BuilderRef,
905 LHS: ValueRef,
906 RHS: ValueRef,
907 Name: *const c_char)
908 -> ValueRef;
909 pub fn LLVMBuildNSWMul(B: BuilderRef,
910 LHS: ValueRef,
911 RHS: ValueRef,
912 Name: *const c_char)
913 -> ValueRef;
914 pub fn LLVMBuildNUWMul(B: BuilderRef,
915 LHS: ValueRef,
916 RHS: ValueRef,
917 Name: *const c_char)
918 -> ValueRef;
919 pub fn LLVMBuildFMul(B: BuilderRef,
920 LHS: ValueRef,
921 RHS: ValueRef,
922 Name: *const c_char)
923 -> ValueRef;
924 pub fn LLVMBuildUDiv(B: BuilderRef,
925 LHS: ValueRef,
926 RHS: ValueRef,
927 Name: *const c_char)
928 -> ValueRef;
929 pub fn LLVMBuildSDiv(B: BuilderRef,
930 LHS: ValueRef,
931 RHS: ValueRef,
932 Name: *const c_char)
933 -> ValueRef;
934 pub fn LLVMBuildExactSDiv(B: BuilderRef,
935 LHS: ValueRef,
936 RHS: ValueRef,
937 Name: *const c_char)
938 -> ValueRef;
939 pub fn LLVMBuildFDiv(B: BuilderRef,
940 LHS: ValueRef,
941 RHS: ValueRef,
942 Name: *const c_char)
943 -> ValueRef;
944 pub fn LLVMBuildURem(B: BuilderRef,
945 LHS: ValueRef,
946 RHS: ValueRef,
947 Name: *const c_char)
948 -> ValueRef;
949 pub fn LLVMBuildSRem(B: BuilderRef,
950 LHS: ValueRef,
951 RHS: ValueRef,
952 Name: *const c_char)
953 -> ValueRef;
954 pub fn LLVMBuildFRem(B: BuilderRef,
955 LHS: ValueRef,
956 RHS: ValueRef,
957 Name: *const c_char)
958 -> ValueRef;
959 pub fn LLVMBuildShl(B: BuilderRef,
960 LHS: ValueRef,
961 RHS: ValueRef,
962 Name: *const c_char)
963 -> ValueRef;
964 pub fn LLVMBuildLShr(B: BuilderRef,
965 LHS: ValueRef,
966 RHS: ValueRef,
967 Name: *const c_char)
968 -> ValueRef;
969 pub fn LLVMBuildAShr(B: BuilderRef,
970 LHS: ValueRef,
971 RHS: ValueRef,
972 Name: *const c_char)
973 -> ValueRef;
974 pub fn LLVMBuildAnd(B: BuilderRef,
975 LHS: ValueRef,
976 RHS: ValueRef,
977 Name: *const c_char)
978 -> ValueRef;
979 pub fn LLVMBuildOr(B: BuilderRef,
980 LHS: ValueRef,
981 RHS: ValueRef,
982 Name: *const c_char)
c30ab7b3 983 -> ValueRef;
5bcae85e
SL
984 pub fn LLVMBuildXor(B: BuilderRef,
985 LHS: ValueRef,
986 RHS: ValueRef,
987 Name: *const c_char)
988 -> ValueRef;
989 pub fn LLVMBuildBinOp(B: BuilderRef,
990 Op: Opcode,
991 LHS: ValueRef,
992 RHS: ValueRef,
993 Name: *const c_char)
994 -> ValueRef;
c30ab7b3
SL
995 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
996 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
997 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
998 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
999 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
5bcae85e
SL
1000 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: ValueRef);
1001
c30ab7b3
SL
1002 // Memory
1003 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
5bcae85e 1004 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
c30ab7b3 1005 pub fn LLVMBuildLoad(B: BuilderRef, PointerVal: ValueRef, Name: *const c_char) -> ValueRef;
5bcae85e 1006
c30ab7b3 1007 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef) -> ValueRef;
5bcae85e
SL
1008
1009 pub fn LLVMBuildGEP(B: BuilderRef,
1010 Pointer: ValueRef,
1011 Indices: *const ValueRef,
1012 NumIndices: c_uint,
1013 Name: *const c_char)
1014 -> ValueRef;
1015 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1016 Pointer: ValueRef,
1017 Indices: *const ValueRef,
1018 NumIndices: c_uint,
1019 Name: *const c_char)
1020 -> ValueRef;
1021 pub fn LLVMBuildStructGEP(B: BuilderRef,
1022 Pointer: ValueRef,
1023 Idx: c_uint,
1024 Name: *const c_char)
1025 -> ValueRef;
1026 pub fn LLVMBuildGlobalString(B: BuilderRef,
1027 Str: *const c_char,
1028 Name: *const c_char)
1029 -> ValueRef;
1030 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1031 Str: *const c_char,
1032 Name: *const c_char)
1033 -> ValueRef;
1034
c30ab7b3 1035 // Casts
5bcae85e
SL
1036 pub fn LLVMBuildTrunc(B: BuilderRef,
1037 Val: ValueRef,
1038 DestTy: TypeRef,
1039 Name: *const c_char)
1040 -> ValueRef;
1041 pub fn LLVMBuildZExt(B: BuilderRef,
1042 Val: ValueRef,
1043 DestTy: TypeRef,
1044 Name: *const c_char)
1045 -> ValueRef;
1046 pub fn LLVMBuildSExt(B: BuilderRef,
1047 Val: ValueRef,
1048 DestTy: TypeRef,
1049 Name: *const c_char)
1050 -> ValueRef;
1051 pub fn LLVMBuildFPToUI(B: BuilderRef,
1052 Val: ValueRef,
1053 DestTy: TypeRef,
1054 Name: *const c_char)
1055 -> ValueRef;
1056 pub fn LLVMBuildFPToSI(B: BuilderRef,
1057 Val: ValueRef,
1058 DestTy: TypeRef,
1059 Name: *const c_char)
1060 -> ValueRef;
1061 pub fn LLVMBuildUIToFP(B: BuilderRef,
1062 Val: ValueRef,
1063 DestTy: TypeRef,
1064 Name: *const c_char)
1065 -> ValueRef;
1066 pub fn LLVMBuildSIToFP(B: BuilderRef,
1067 Val: ValueRef,
1068 DestTy: TypeRef,
1069 Name: *const c_char)
1070 -> ValueRef;
1071 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1072 Val: ValueRef,
1073 DestTy: TypeRef,
1074 Name: *const c_char)
1075 -> ValueRef;
1076 pub fn LLVMBuildFPExt(B: BuilderRef,
1077 Val: ValueRef,
1078 DestTy: TypeRef,
1079 Name: *const c_char)
1080 -> ValueRef;
1081 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1082 Val: ValueRef,
1083 DestTy: TypeRef,
1084 Name: *const c_char)
1085 -> ValueRef;
1086 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1087 Val: ValueRef,
1088 DestTy: TypeRef,
1089 Name: *const c_char)
1090 -> ValueRef;
1091 pub fn LLVMBuildBitCast(B: BuilderRef,
1092 Val: ValueRef,
1093 DestTy: TypeRef,
1094 Name: *const c_char)
1095 -> ValueRef;
1096 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1097 Val: ValueRef,
1098 DestTy: TypeRef,
1099 Name: *const c_char)
1100 -> ValueRef;
1101 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1102 Val: ValueRef,
1103 DestTy: TypeRef,
1104 Name: *const c_char)
1105 -> ValueRef;
1106 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1107 Val: ValueRef,
1108 DestTy: TypeRef,
1109 Name: *const c_char)
1110 -> ValueRef;
1111 pub fn LLVMBuildCast(B: BuilderRef,
1112 Op: Opcode,
1113 Val: ValueRef,
1114 DestTy: TypeRef,
c30ab7b3
SL
1115 Name: *const c_char)
1116 -> ValueRef;
5bcae85e
SL
1117 pub fn LLVMBuildPointerCast(B: BuilderRef,
1118 Val: ValueRef,
1119 DestTy: TypeRef,
1120 Name: *const c_char)
1121 -> ValueRef;
8bb4bdeb
XL
1122 pub fn LLVMRustBuildIntCast(B: BuilderRef,
1123 Val: ValueRef,
1124 DestTy: TypeRef,
1125 IsSized: bool)
1126 -> ValueRef;
5bcae85e
SL
1127 pub fn LLVMBuildFPCast(B: BuilderRef,
1128 Val: ValueRef,
1129 DestTy: TypeRef,
1130 Name: *const c_char)
1131 -> ValueRef;
1132
c30ab7b3 1133 // Comparisons
5bcae85e
SL
1134 pub fn LLVMBuildICmp(B: BuilderRef,
1135 Op: c_uint,
1136 LHS: ValueRef,
1137 RHS: ValueRef,
1138 Name: *const c_char)
1139 -> ValueRef;
1140 pub fn LLVMBuildFCmp(B: BuilderRef,
1141 Op: c_uint,
1142 LHS: ValueRef,
1143 RHS: ValueRef,
1144 Name: *const c_char)
1145 -> ValueRef;
1146
c30ab7b3
SL
1147 // Miscellaneous instructions
1148 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
5bcae85e
SL
1149 pub fn LLVMRustBuildCall(B: BuilderRef,
1150 Fn: ValueRef,
1151 Args: *const ValueRef,
1152 NumArgs: c_uint,
1153 Bundle: OperandBundleDefRef,
1154 Name: *const c_char)
1155 -> ValueRef;
1156 pub fn LLVMBuildSelect(B: BuilderRef,
1157 If: ValueRef,
1158 Then: ValueRef,
1159 Else: ValueRef,
1160 Name: *const c_char)
1161 -> ValueRef;
1162 pub fn LLVMBuildVAArg(B: BuilderRef,
1163 list: ValueRef,
1164 Ty: TypeRef,
1165 Name: *const c_char)
1166 -> ValueRef;
1167 pub fn LLVMBuildExtractElement(B: BuilderRef,
1168 VecVal: ValueRef,
1169 Index: ValueRef,
1170 Name: *const c_char)
1171 -> ValueRef;
1172 pub fn LLVMBuildInsertElement(B: BuilderRef,
1173 VecVal: ValueRef,
1174 EltVal: ValueRef,
1175 Index: ValueRef,
1176 Name: *const c_char)
1177 -> ValueRef;
1178 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1179 V1: ValueRef,
1180 V2: ValueRef,
1181 Mask: ValueRef,
1182 Name: *const c_char)
1183 -> ValueRef;
1184 pub fn LLVMBuildExtractValue(B: BuilderRef,
1185 AggVal: ValueRef,
1186 Index: c_uint,
1187 Name: *const c_char)
1188 -> ValueRef;
1189 pub fn LLVMBuildInsertValue(B: BuilderRef,
1190 AggVal: ValueRef,
1191 EltVal: ValueRef,
1192 Index: c_uint,
1193 Name: *const c_char)
1194 -> ValueRef;
1195
c30ab7b3
SL
1196 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1197 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
5bcae85e
SL
1198 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1199 LHS: ValueRef,
1200 RHS: ValueRef,
1201 Name: *const c_char)
1202 -> ValueRef;
1203
c30ab7b3 1204 // Atomic Operations
5bcae85e
SL
1205 pub fn LLVMRustBuildAtomicLoad(B: BuilderRef,
1206 PointerVal: ValueRef,
1207 Name: *const c_char,
1208 Order: AtomicOrdering,
1209 Alignment: c_uint)
1210 -> ValueRef;
1211
1212 pub fn LLVMRustBuildAtomicStore(B: BuilderRef,
1213 Val: ValueRef,
1214 Ptr: ValueRef,
1215 Order: AtomicOrdering,
1216 Alignment: c_uint)
1217 -> ValueRef;
1218
1219 pub fn LLVMRustBuildAtomicCmpXchg(B: BuilderRef,
1220 LHS: ValueRef,
1221 CMP: ValueRef,
1222 RHS: ValueRef,
1223 Order: AtomicOrdering,
1224 FailureOrder: AtomicOrdering,
1225 Weak: Bool)
1226 -> ValueRef;
1227
1228 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1229 Op: AtomicRmwBinOp,
1230 LHS: ValueRef,
1231 RHS: ValueRef,
1232 Order: AtomicOrdering,
1233 SingleThreaded: Bool)
1234 -> ValueRef;
1235
1236 pub fn LLVMRustBuildAtomicFence(B: BuilderRef,
1237 Order: AtomicOrdering,
1238 Scope: SynchronizationScope);
1239
1240
c30ab7b3 1241 // Selected entries from the downcasts.
5bcae85e
SL
1242 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1243 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1244
1245 /// Writes a module to the specified path. Returns 0 on success.
1246 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1247
1248 /// Creates target data from a target layout string.
1249 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
5bcae85e 1250 /// Number of bytes clobbered when doing a Store to *T.
c30ab7b3 1251 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
5bcae85e
SL
1252
1253 /// Distance between successive elements in an array of T. Includes ABI padding.
1254 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1255
1256 /// Returns the preferred alignment of a type.
c30ab7b3 1257 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
5bcae85e 1258 /// Returns the minimum alignment of a type.
c30ab7b3 1259 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
5bcae85e
SL
1260
1261 /// Computes the byte offset of the indexed struct element for a
1262 /// target.
1263 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1264 StructTy: TypeRef,
1265 Element: c_uint)
1266 -> c_ulonglong;
1267
5bcae85e
SL
1268 /// Disposes target data.
1269 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1270
1271 /// Creates a pass manager.
1272 pub fn LLVMCreatePassManager() -> PassManagerRef;
1273
1274 /// Creates a function-by-function pass manager
c30ab7b3 1275 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef) -> PassManagerRef;
5bcae85e
SL
1276
1277 /// Disposes a pass manager.
1278 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1279
1280 /// Runs a pass manager on a module.
1281 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1282
5bcae85e
SL
1283 pub fn LLVMInitializePasses();
1284
5bcae85e
SL
1285 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1286 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
c30ab7b3 1287 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef, Value: Bool);
c30ab7b3 1288 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: PassManagerBuilderRef, Value: Bool);
c30ab7b3
SL
1289 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: PassManagerBuilderRef,
1290 threshold: c_uint);
1291 pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: PassManagerBuilderRef,
1292 PM: PassManagerRef);
1293
1294 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: PassManagerBuilderRef,
1295 PM: PassManagerRef);
1296 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: PassManagerBuilderRef,
1297 PM: PassManagerRef,
1298 Internalize: Bool,
1299 RunInliner: Bool);
ea8adc8c
XL
1300 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1301 PMB: PassManagerBuilderRef,
1302 PM: PassManagerRef) -> bool;
5bcae85e 1303
c30ab7b3 1304 // Stuff that's in rustllvm/ because it's not upstream yet.
5bcae85e
SL
1305
1306 /// Opens an object file.
1307 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1308 /// Closes an object file.
1309 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1310
1311 /// Enumerates the sections in an object file.
1312 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1313 /// Destroys a section iterator.
1314 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1315 /// Returns true if the section iterator is at the end of the section
1316 /// list:
c30ab7b3 1317 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef, SI: SectionIteratorRef) -> Bool;
5bcae85e
SL
1318 /// Moves the section iterator to point to the next section.
1319 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1320 /// Returns the current section size.
1321 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1322 /// Returns the current section contents as a string buffer.
1323 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1324
1325 /// Reads the given file and returns it as a memory buffer. Use
1326 /// LLVMDisposeMemoryBuffer() to get rid of it.
c30ab7b3 1327 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char) -> MemoryBufferRef;
476ff2be 1328
5bcae85e
SL
1329 pub fn LLVMStartMultithreaded() -> Bool;
1330
1331 /// Returns a string describing the last error caused by an LLVMRust* call.
1332 pub fn LLVMRustGetLastError() -> *const c_char;
1333
1334 /// Print the pass timings since static dtors aren't picking them up.
1335 pub fn LLVMRustPrintPassTimings();
1336
1337 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1338
1339 pub fn LLVMStructSetBody(StructTy: TypeRef,
1340 ElementTypes: *const TypeRef,
1341 ElementCount: c_uint,
1342 Packed: Bool);
1343
1344 pub fn LLVMConstNamedStruct(S: TypeRef,
1345 ConstantVals: *const ValueRef,
1346 Count: c_uint)
1347 -> ValueRef;
1348
1349 /// Enables LLVM debug output.
1350 pub fn LLVMRustSetDebug(Enabled: c_int);
1351
1352 /// Prepares inline assembly.
1353 pub fn LLVMRustInlineAsm(Ty: TypeRef,
1354 AsmString: *const c_char,
1355 Constraints: *const c_char,
1356 SideEffects: Bool,
1357 AlignStack: Bool,
1358 Dialect: AsmDialect)
1359 -> ValueRef;
1360
1361 pub fn LLVMRustDebugMetadataVersion() -> u32;
1362 pub fn LLVMRustVersionMajor() -> u32;
1363 pub fn LLVMRustVersionMinor() -> u32;
1364
c30ab7b3 1365 pub fn LLVMRustAddModuleFlag(M: ModuleRef, name: *const c_char, value: u32);
5bcae85e 1366
041b39d2
XL
1367 pub fn LLVMRustMetadataAsValue(C: ContextRef, MD: MetadataRef) -> ValueRef;
1368
5bcae85e
SL
1369 pub fn LLVMRustDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1370
1371 pub fn LLVMRustDIBuilderDispose(Builder: DIBuilderRef);
1372
1373 pub fn LLVMRustDIBuilderFinalize(Builder: DIBuilderRef);
1374
1375 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1376 Lang: c_uint,
8bb4bdeb 1377 File: DIFile,
5bcae85e
SL
1378 Producer: *const c_char,
1379 isOptimized: bool,
1380 Flags: *const c_char,
1381 RuntimeVer: c_uint,
1382 SplitName: *const c_char)
1383 -> DIDescriptor;
1384
1385 pub fn LLVMRustDIBuilderCreateFile(Builder: DIBuilderRef,
1386 Filename: *const c_char,
1387 Directory: *const c_char)
1388 -> DIFile;
1389
1390 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1391 File: DIFile,
1392 ParameterTypes: DIArray)
1393 -> DICompositeType;
1394
1395 pub fn LLVMRustDIBuilderCreateFunction(Builder: DIBuilderRef,
1396 Scope: DIDescriptor,
1397 Name: *const c_char,
1398 LinkageName: *const c_char,
1399 File: DIFile,
1400 LineNo: c_uint,
1401 Ty: DIType,
1402 isLocalToUnit: bool,
1403 isDefinition: bool,
1404 ScopeLine: c_uint,
476ff2be 1405 Flags: DIFlags,
5bcae85e
SL
1406 isOptimized: bool,
1407 Fn: ValueRef,
1408 TParam: DIArray,
1409 Decl: DIDescriptor)
1410 -> DISubprogram;
1411
1412 pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
1413 Name: *const c_char,
1414 SizeInBits: u64,
8bb4bdeb 1415 AlignInBits: u32,
5bcae85e
SL
1416 Encoding: c_uint)
1417 -> DIBasicType;
1418
1419 pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
c30ab7b3
SL
1420 PointeeTy: DIType,
1421 SizeInBits: u64,
8bb4bdeb 1422 AlignInBits: u32,
c30ab7b3
SL
1423 Name: *const c_char)
1424 -> DIDerivedType;
5bcae85e
SL
1425
1426 pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef,
1427 Scope: DIDescriptor,
1428 Name: *const c_char,
1429 File: DIFile,
1430 LineNumber: c_uint,
1431 SizeInBits: u64,
8bb4bdeb 1432 AlignInBits: u32,
476ff2be 1433 Flags: DIFlags,
5bcae85e
SL
1434 DerivedFrom: DIType,
1435 Elements: DIArray,
1436 RunTimeLang: c_uint,
1437 VTableHolder: DIType,
1438 UniqueId: *const c_char)
1439 -> DICompositeType;
1440
1441 pub fn LLVMRustDIBuilderCreateMemberType(Builder: DIBuilderRef,
1442 Scope: DIDescriptor,
1443 Name: *const c_char,
1444 File: DIFile,
1445 LineNo: c_uint,
1446 SizeInBits: u64,
8bb4bdeb 1447 AlignInBits: u32,
5bcae85e 1448 OffsetInBits: u64,
476ff2be 1449 Flags: DIFlags,
5bcae85e
SL
1450 Ty: DIType)
1451 -> DIDerivedType;
1452
1453 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1454 Scope: DIScope,
1455 File: DIFile,
1456 Line: c_uint,
1457 Col: c_uint)
1458 -> DILexicalBlock;
1459
9e0c209e
SL
1460 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: DIBuilderRef,
1461 Scope: DIScope,
1462 File: DIFile)
1463 -> DILexicalBlock;
1464
5bcae85e
SL
1465 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1466 Context: DIScope,
1467 Name: *const c_char,
1468 LinkageName: *const c_char,
1469 File: DIFile,
1470 LineNo: c_uint,
1471 Ty: DIType,
1472 isLocalToUnit: bool,
1473 Val: ValueRef,
476ff2be 1474 Decl: DIDescriptor,
8bb4bdeb 1475 AlignInBits: u32)
5bcae85e
SL
1476 -> DIGlobalVariable;
1477
1478 pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
1479 Tag: c_uint,
1480 Scope: DIDescriptor,
1481 Name: *const c_char,
1482 File: DIFile,
1483 LineNo: c_uint,
1484 Ty: DIType,
1485 AlwaysPreserve: bool,
476ff2be
SL
1486 Flags: DIFlags,
1487 ArgNo: c_uint,
8bb4bdeb 1488 AlignInBits: u32)
5bcae85e
SL
1489 -> DIVariable;
1490
1491 pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
1492 Size: u64,
8bb4bdeb 1493 AlignInBits: u32,
5bcae85e
SL
1494 Ty: DIType,
1495 Subscripts: DIArray)
1496 -> DIType;
1497
1498 pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
1499 Size: u64,
8bb4bdeb 1500 AlignInBits: u32,
5bcae85e
SL
1501 Ty: DIType,
1502 Subscripts: DIArray)
1503 -> DIType;
1504
1505 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1506 Lo: i64,
1507 Count: i64)
1508 -> DISubrange;
1509
1510 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1511 Ptr: *const DIDescriptor,
1512 Count: c_uint)
1513 -> DIArray;
1514
1515 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1516 Val: ValueRef,
1517 VarInfo: DIVariable,
1518 AddrOps: *const i64,
1519 AddrOpsCount: c_uint,
1520 DL: ValueRef,
1521 InsertAtEnd: BasicBlockRef)
1522 -> ValueRef;
1523
5bcae85e
SL
1524 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1525 Name: *const c_char,
1526 Val: u64)
1527 -> DIEnumerator;
1528
1529 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1530 Scope: DIScope,
1531 Name: *const c_char,
1532 File: DIFile,
1533 LineNumber: c_uint,
1534 SizeInBits: u64,
8bb4bdeb 1535 AlignInBits: u32,
5bcae85e
SL
1536 Elements: DIArray,
1537 ClassType: DIType)
1538 -> DIType;
1539
1540 pub fn LLVMRustDIBuilderCreateUnionType(Builder: DIBuilderRef,
1541 Scope: DIScope,
1542 Name: *const c_char,
1543 File: DIFile,
1544 LineNumber: c_uint,
1545 SizeInBits: u64,
8bb4bdeb 1546 AlignInBits: u32,
476ff2be 1547 Flags: DIFlags,
5bcae85e
SL
1548 Elements: DIArray,
1549 RunTimeLang: c_uint,
1550 UniqueId: *const c_char)
1551 -> DIType;
1552
1553 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1554
1555 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1556 Scope: DIScope,
1557 Name: *const c_char,
1558 Ty: DIType,
1559 File: DIFile,
1560 LineNo: c_uint,
1561 ColumnNo: c_uint)
1562 -> DITemplateTypeParameter;
1563
1564
1565 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1566 Scope: DIScope,
1567 Name: *const c_char,
1568 File: DIFile,
1569 LineNo: c_uint)
1570 -> DINameSpace;
1571 pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1572 CompositeType: DIType,
1573 TypeArray: DIArray);
1574
1575
1576 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: ContextRef,
1577 Line: c_uint,
1578 Column: c_uint,
1579 Scope: DIScope,
1580 InlinedAt: MetadataRef)
1581 -> ValueRef;
1582 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1583 pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
1584
1585 pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
1586 pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1587
5bcae85e
SL
1588 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
1589
1590 pub fn LLVMRustPassKind(Pass: PassRef) -> PassKind;
1591 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
1592 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
1593
c30ab7b3 1594 pub fn LLVMRustHasFeature(T: TargetMachineRef, s: *const c_char) -> bool;
5bcae85e
SL
1595
1596 pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef);
1597 pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef);
1598
1599 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1600 CPU: *const c_char,
1601 Features: *const c_char,
1602 Model: CodeModel,
1603 Reloc: RelocMode,
1604 Level: CodeGenOptLevel,
1605 UseSoftFP: bool,
1606 PositionIndependentExecutable: bool,
1607 FunctionSections: bool,
abe05a73
XL
1608 DataSections: bool,
1609 TrapUnreachable: bool,
1610 Singlethread: bool)
c30ab7b3 1611 -> TargetMachineRef;
5bcae85e 1612 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
c30ab7b3 1613 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef, PM: PassManagerRef, M: ModuleRef);
5bcae85e
SL
1614 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1615 M: ModuleRef,
1616 DisableSimplifyLibCalls: bool);
1617 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
1618 OptLevel: CodeGenOptLevel,
1619 MergeFunctions: bool,
1620 SLPVectorize: bool,
1621 LoopVectorize: bool);
c30ab7b3
SL
1622 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef,
1623 M: ModuleRef,
5bcae85e
SL
1624 DisableSimplifyLibCalls: bool);
1625 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1626 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1627 PM: PassManagerRef,
1628 M: ModuleRef,
1629 Output: *const c_char,
1630 FileType: FileType)
1631 -> LLVMRustResult;
041b39d2
XL
1632 pub fn LLVMRustPrintModule(PM: PassManagerRef,
1633 M: ModuleRef,
1634 Output: *const c_char,
1635 Demangle: extern fn(*const c_char,
1636 size_t,
1637 *mut c_char,
1638 size_t) -> size_t);
5bcae85e
SL
1639 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1640 pub fn LLVMRustPrintPasses();
1641 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
c30ab7b3
SL
1642 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef, AddLifetimes: bool);
1643 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef, bc: *const c_char, len: size_t) -> bool;
ea8adc8c 1644 pub fn LLVMRustLinkInParsedExternalBitcode(M: ModuleRef, M: ModuleRef) -> bool;
c30ab7b3 1645 pub fn LLVMRustRunRestrictionPass(M: ModuleRef, syms: *const *const c_char, len: size_t);
5bcae85e
SL
1646 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1647
1648 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1649 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
1650 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
c30ab7b3
SL
1651 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1652 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
5bcae85e
SL
1653 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
1654 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
1655 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1656
c30ab7b3 1657 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, data: *mut *const c_char) -> size_t;
5bcae85e
SL
1658
1659 pub fn LLVMRustWriteTwineToString(T: TwineRef, s: RustStringRef);
1660
1661 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
1662 Handler: DiagnosticHandler,
1663 DiagnosticContext: *mut c_void);
1664
1665 pub fn LLVMRustUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
476ff2be 1666 pass_name_out: RustStringRef,
5bcae85e 1667 function_out: *mut ValueRef,
3b2f2976
XL
1668 loc_line_out: *mut c_uint,
1669 loc_column_out: *mut c_uint,
1670 loc_filename_out: RustStringRef,
476ff2be 1671 message_out: RustStringRef);
5bcae85e
SL
1672 pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
1673 cookie_out: *mut c_uint,
1674 message_out: *mut TwineRef,
1675 instruction_out: *mut ValueRef);
1676
c30ab7b3 1677 pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
5bcae85e
SL
1678 pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
1679
c30ab7b3 1680 pub fn LLVMRustWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
5bcae85e
SL
1681
1682 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef,
1683 H: InlineAsmDiagHandler,
1684 CX: *mut c_void);
1685
1686 pub fn LLVMRustWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
1687
1688 pub fn LLVMRustWriteArchive(Dst: *const c_char,
1689 NumMembers: size_t,
1690 Members: *const RustArchiveMemberRef,
1691 WriteSymbtab: bool,
c30ab7b3
SL
1692 Kind: ArchiveKind)
1693 -> LLVMRustResult;
5bcae85e
SL
1694 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1695 Name: *const c_char,
c30ab7b3
SL
1696 Child: ArchiveChildRef)
1697 -> RustArchiveMemberRef;
5bcae85e
SL
1698 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
1699
c30ab7b3 1700 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef, TM: TargetMachineRef);
5bcae85e
SL
1701 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
1702
1703 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1704 Inputs: *const ValueRef,
1705 NumInputs: c_uint)
1706 -> OperandBundleDefRef;
1707 pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
1708
1709 pub fn LLVMRustPositionBuilderAtStart(B: BuilderRef, BB: BasicBlockRef);
1710
1711 pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
1712 pub fn LLVMRustUnsetComdat(V: ValueRef);
1713 pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
ea8adc8c
XL
1714 pub fn LLVMRustModuleBufferCreate(M: ModuleRef) -> *mut ModuleBuffer;
1715 pub fn LLVMRustModuleBufferPtr(p: *const ModuleBuffer) -> *const u8;
1716 pub fn LLVMRustModuleBufferLen(p: *const ModuleBuffer) -> usize;
1717 pub fn LLVMRustModuleBufferFree(p: *mut ModuleBuffer);
1718 pub fn LLVMRustModuleCost(M: ModuleRef) -> u64;
1719
1720 pub fn LLVMRustThinLTOAvailable() -> bool;
1721 pub fn LLVMRustWriteThinBitcodeToFile(PMR: PassManagerRef,
1722 M: ModuleRef,
1723 BC: *const c_char) -> bool;
1724 pub fn LLVMRustThinLTOBufferCreate(M: ModuleRef) -> *mut ThinLTOBuffer;
1725 pub fn LLVMRustThinLTOBufferFree(M: *mut ThinLTOBuffer);
1726 pub fn LLVMRustThinLTOBufferPtr(M: *const ThinLTOBuffer) -> *const c_char;
1727 pub fn LLVMRustThinLTOBufferLen(M: *const ThinLTOBuffer) -> size_t;
1728 pub fn LLVMRustCreateThinLTOData(
1729 Modules: *const ThinLTOModule,
1730 NumModules: c_uint,
1731 PreservedSymbols: *const *const c_char,
1732 PreservedSymbolsLen: c_uint,
1733 ) -> *mut ThinLTOData;
1734 pub fn LLVMRustPrepareThinLTORename(
1735 Data: *const ThinLTOData,
1736 Module: ModuleRef,
1737 ) -> bool;
1738 pub fn LLVMRustPrepareThinLTOResolveWeak(
1739 Data: *const ThinLTOData,
1740 Module: ModuleRef,
1741 ) -> bool;
1742 pub fn LLVMRustPrepareThinLTOInternalize(
1743 Data: *const ThinLTOData,
1744 Module: ModuleRef,
1745 ) -> bool;
1746 pub fn LLVMRustPrepareThinLTOImport(
1747 Data: *const ThinLTOData,
1748 Module: ModuleRef,
1749 ) -> bool;
1750 pub fn LLVMRustFreeThinLTOData(Data: *mut ThinLTOData);
1751 pub fn LLVMRustParseBitcodeForThinLTO(
1752 Context: ContextRef,
1753 Data: *const u8,
1754 len: usize,
1755 Identifier: *const c_char,
1756 ) -> ModuleRef;
1757 pub fn LLVMGetModuleIdentifier(M: ModuleRef, size: *mut usize) -> *const c_char;
5bcae85e 1758}