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