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