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