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