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