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