]> git.lizzy.rs Git - rust.git/blob - src/librustc_llvm/lib.rs
Doc says to avoid mixing allocator instead of forbiding it
[rust.git] / src / librustc_llvm / lib.rs
1 // Copyright 2012-2014 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 #![allow(non_uppercase_statics)]
12 #![allow(non_camel_case_types)]
13 #![allow(non_snake_case)]
14 #![allow(dead_code)]
15
16 #![crate_name = "rustc_llvm"]
17 #![experimental]
18 #![license = "MIT/ASL2"]
19 #![crate_type = "dylib"]
20 #![crate_type = "rlib"]
21 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
23        html_root_url = "http://doc.rust-lang.org/")]
24
25 #![feature(globs)]
26 #![feature(link_args)]
27
28 extern crate libc;
29
30 use std::c_str::ToCStr;
31 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
32 use libc::{c_longlong, c_ulonglong};
33 use debuginfo::{DIBuilderRef, DIDescriptor,
34                 DIFile, DILexicalBlock, DISubprogram, DIType,
35                 DIBasicType, DIDerivedType, DICompositeType,
36                 DIVariable, DIGlobalVariable, DIArray, DISubrange};
37
38 pub mod archive_ro;
39
40 pub type Opcode = u32;
41 pub type Bool = c_uint;
42
43 pub static True: Bool = 1 as Bool;
44 pub static False: Bool = 0 as Bool;
45
46 // Consts for the LLVM CallConv type, pre-cast to uint.
47
48 #[deriving(PartialEq)]
49 pub enum CallConv {
50     CCallConv = 0,
51     FastCallConv = 8,
52     ColdCallConv = 9,
53     X86StdcallCallConv = 64,
54     X86FastcallCallConv = 65,
55     X86_64_Win64 = 79,
56 }
57
58 pub enum Visibility {
59     LLVMDefaultVisibility = 0,
60     HiddenVisibility = 1,
61     ProtectedVisibility = 2,
62 }
63
64 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
65 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
66 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
67 // they've been removed in upstream LLVM commit r203866.
68 pub enum Linkage {
69     ExternalLinkage = 0,
70     AvailableExternallyLinkage = 1,
71     LinkOnceAnyLinkage = 2,
72     LinkOnceODRLinkage = 3,
73     WeakAnyLinkage = 5,
74     WeakODRLinkage = 6,
75     AppendingLinkage = 7,
76     InternalLinkage = 8,
77     PrivateLinkage = 9,
78     ExternalWeakLinkage = 12,
79     CommonLinkage = 14,
80 }
81
82 #[deriving(Clone)]
83 pub enum Attribute {
84     ZExtAttribute = 1 << 0,
85     SExtAttribute = 1 << 1,
86     NoReturnAttribute = 1 << 2,
87     InRegAttribute = 1 << 3,
88     StructRetAttribute = 1 << 4,
89     NoUnwindAttribute = 1 << 5,
90     NoAliasAttribute = 1 << 6,
91     ByValAttribute = 1 << 7,
92     NestAttribute = 1 << 8,
93     ReadNoneAttribute = 1 << 9,
94     ReadOnlyAttribute = 1 << 10,
95     NoInlineAttribute = 1 << 11,
96     AlwaysInlineAttribute = 1 << 12,
97     OptimizeForSizeAttribute = 1 << 13,
98     StackProtectAttribute = 1 << 14,
99     StackProtectReqAttribute = 1 << 15,
100     AlignmentAttribute = 31 << 16,
101     NoCaptureAttribute = 1 << 21,
102     NoRedZoneAttribute = 1 << 22,
103     NoImplicitFloatAttribute = 1 << 23,
104     NakedAttribute = 1 << 24,
105     InlineHintAttribute = 1 << 25,
106     StackAttribute = 7 << 26,
107     ReturnsTwiceAttribute = 1 << 29,
108     UWTableAttribute = 1 << 30,
109     NonLazyBindAttribute = 1 << 31,
110 }
111
112 #[repr(u64)]
113 pub enum OtherAttribute {
114     // The following are not really exposed in
115     // the LLVM c api so instead to add these
116     // we call a wrapper function in RustWrapper
117     // that uses the C++ api.
118     SanitizeAddressAttribute = 1 << 32,
119     MinSizeAttribute = 1 << 33,
120     NoDuplicateAttribute = 1 << 34,
121     StackProtectStrongAttribute = 1 << 35,
122     SanitizeThreadAttribute = 1 << 36,
123     SanitizeMemoryAttribute = 1 << 37,
124     NoBuiltinAttribute = 1 << 38,
125     ReturnedAttribute = 1 << 39,
126     ColdAttribute = 1 << 40,
127     BuiltinAttribute = 1 << 41,
128     OptimizeNoneAttribute = 1 << 42,
129     InAllocaAttribute = 1 << 43,
130     NonNullAttribute = 1 << 44,
131 }
132
133 pub enum SpecialAttribute {
134     DereferenceableAttribute(u64)
135 }
136
137 #[repr(C)]
138 pub enum AttributeSet {
139     ReturnIndex = 0,
140     FunctionIndex = !0
141 }
142
143 trait AttrHelper {
144     fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
145     fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
146 }
147
148 impl AttrHelper for Attribute {
149     fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
150         unsafe {
151             LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
152         }
153     }
154
155     fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
156         unsafe {
157             LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
158         }
159     }
160 }
161
162 impl AttrHelper for OtherAttribute {
163     fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
164         unsafe {
165             LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
166         }
167     }
168
169     fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
170         unsafe {
171             LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
172         }
173     }
174 }
175
176 impl AttrHelper for SpecialAttribute {
177     fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
178         match *self {
179             DereferenceableAttribute(bytes) => unsafe {
180                 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
181             }
182         }
183     }
184
185     fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
186         match *self {
187             DereferenceableAttribute(bytes) => unsafe {
188                 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
189             }
190         }
191     }
192 }
193
194 pub struct AttrBuilder {
195     attrs: Vec<(uint, Box<AttrHelper+'static>)>
196 }
197
198 impl AttrBuilder {
199     pub fn new() -> AttrBuilder {
200         AttrBuilder {
201             attrs: Vec::new()
202         }
203     }
204
205     pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
206         self.attrs.push((idx, box a as Box<AttrHelper+'static>));
207         self
208     }
209
210     pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
211         self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
212         self
213     }
214
215     pub fn apply_llfn(&self, llfn: ValueRef) {
216         for &(idx, ref attr) in self.attrs.iter() {
217             attr.apply_llfn(idx as c_uint, llfn);
218         }
219     }
220
221     pub fn apply_callsite(&self, callsite: ValueRef) {
222         for &(idx, ref attr) in self.attrs.iter() {
223             attr.apply_callsite(idx as c_uint, callsite);
224         }
225     }
226 }
227
228 // enum for the LLVM IntPredicate type
229 pub enum IntPredicate {
230     IntEQ = 32,
231     IntNE = 33,
232     IntUGT = 34,
233     IntUGE = 35,
234     IntULT = 36,
235     IntULE = 37,
236     IntSGT = 38,
237     IntSGE = 39,
238     IntSLT = 40,
239     IntSLE = 41,
240 }
241
242 // enum for the LLVM RealPredicate type
243 pub enum RealPredicate {
244     RealPredicateFalse = 0,
245     RealOEQ = 1,
246     RealOGT = 2,
247     RealOGE = 3,
248     RealOLT = 4,
249     RealOLE = 5,
250     RealONE = 6,
251     RealORD = 7,
252     RealUNO = 8,
253     RealUEQ = 9,
254     RealUGT = 10,
255     RealUGE = 11,
256     RealULT = 12,
257     RealULE = 13,
258     RealUNE = 14,
259     RealPredicateTrue = 15,
260 }
261
262 // The LLVM TypeKind type - must stay in sync with the def of
263 // LLVMTypeKind in llvm/include/llvm-c/Core.h
264 #[deriving(PartialEq)]
265 #[repr(C)]
266 pub enum TypeKind {
267     Void      = 0,
268     Half      = 1,
269     Float     = 2,
270     Double    = 3,
271     X86_FP80  = 4,
272     FP128     = 5,
273     PPC_FP128 = 6,
274     Label     = 7,
275     Integer   = 8,
276     Function  = 9,
277     Struct    = 10,
278     Array     = 11,
279     Pointer   = 12,
280     Vector    = 13,
281     Metadata  = 14,
282     X86_MMX   = 15,
283 }
284
285 #[repr(C)]
286 pub enum AtomicBinOp {
287     Xchg = 0,
288     Add  = 1,
289     Sub  = 2,
290     And  = 3,
291     Nand = 4,
292     Or   = 5,
293     Xor  = 6,
294     Max  = 7,
295     Min  = 8,
296     UMax = 9,
297     UMin = 10,
298 }
299
300 #[repr(C)]
301 pub enum AtomicOrdering {
302     NotAtomic = 0,
303     Unordered = 1,
304     Monotonic = 2,
305     // Consume = 3,  // Not specified yet.
306     Acquire = 4,
307     Release = 5,
308     AcquireRelease = 6,
309     SequentiallyConsistent = 7
310 }
311
312 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
313 #[repr(C)]
314 pub enum FileType {
315     AssemblyFile = 0,
316     ObjectFile = 1
317 }
318
319 pub enum Metadata {
320     MD_dbg = 0,
321     MD_tbaa = 1,
322     MD_prof = 2,
323     MD_fpmath = 3,
324     MD_range = 4,
325     MD_tbaa_struct = 5
326 }
327
328 // Inline Asm Dialect
329 pub enum AsmDialect {
330     AD_ATT   = 0,
331     AD_Intel = 1
332 }
333
334 #[deriving(PartialEq, Clone)]
335 #[repr(C)]
336 pub enum CodeGenOptLevel {
337     CodeGenLevelNone = 0,
338     CodeGenLevelLess = 1,
339     CodeGenLevelDefault = 2,
340     CodeGenLevelAggressive = 3,
341 }
342
343 #[repr(C)]
344 pub enum RelocMode {
345     RelocDefault = 0,
346     RelocStatic = 1,
347     RelocPIC = 2,
348     RelocDynamicNoPic = 3,
349 }
350
351 #[repr(C)]
352 pub enum CodeGenModel {
353     CodeModelDefault = 0,
354     CodeModelJITDefault = 1,
355     CodeModelSmall = 2,
356     CodeModelKernel = 3,
357     CodeModelMedium = 4,
358     CodeModelLarge = 5,
359 }
360
361 // Opaque pointer types
362 pub enum Module_opaque {}
363 pub type ModuleRef = *mut Module_opaque;
364 pub enum Context_opaque {}
365 pub type ContextRef = *mut Context_opaque;
366 pub enum Type_opaque {}
367 pub type TypeRef = *mut Type_opaque;
368 pub enum Value_opaque {}
369 pub type ValueRef = *mut Value_opaque;
370 pub enum BasicBlock_opaque {}
371 pub type BasicBlockRef = *mut BasicBlock_opaque;
372 pub enum Builder_opaque {}
373 pub type BuilderRef = *mut Builder_opaque;
374 pub enum ExecutionEngine_opaque {}
375 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
376 pub enum MemoryBuffer_opaque {}
377 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
378 pub enum PassManager_opaque {}
379 pub type PassManagerRef = *mut PassManager_opaque;
380 pub enum PassManagerBuilder_opaque {}
381 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
382 pub enum Use_opaque {}
383 pub type UseRef = *mut Use_opaque;
384 pub enum TargetData_opaque {}
385 pub type TargetDataRef = *mut TargetData_opaque;
386 pub enum ObjectFile_opaque {}
387 pub type ObjectFileRef = *mut ObjectFile_opaque;
388 pub enum SectionIterator_opaque {}
389 pub type SectionIteratorRef = *mut SectionIterator_opaque;
390 pub enum Pass_opaque {}
391 pub type PassRef = *mut Pass_opaque;
392 pub enum TargetMachine_opaque {}
393 pub type TargetMachineRef = *mut TargetMachine_opaque;
394 pub enum Archive_opaque {}
395 pub type ArchiveRef = *mut Archive_opaque;
396
397 pub mod debuginfo {
398     use super::{ValueRef};
399
400     pub enum DIBuilder_opaque {}
401     pub type DIBuilderRef = *mut DIBuilder_opaque;
402
403     pub type DIDescriptor = ValueRef;
404     pub type DIScope = DIDescriptor;
405     pub type DILocation = DIDescriptor;
406     pub type DIFile = DIScope;
407     pub type DILexicalBlock = DIScope;
408     pub type DISubprogram = DIScope;
409     pub type DIType = DIDescriptor;
410     pub type DIBasicType = DIType;
411     pub type DIDerivedType = DIType;
412     pub type DICompositeType = DIDerivedType;
413     pub type DIVariable = DIDescriptor;
414     pub type DIGlobalVariable = DIDescriptor;
415     pub type DIArray = DIDescriptor;
416     pub type DISubrange = DIDescriptor;
417
418     pub enum DIDescriptorFlags {
419       FlagPrivate            = 1 << 0,
420       FlagProtected          = 1 << 1,
421       FlagFwdDecl            = 1 << 2,
422       FlagAppleBlock         = 1 << 3,
423       FlagBlockByrefStruct   = 1 << 4,
424       FlagVirtual            = 1 << 5,
425       FlagArtificial         = 1 << 6,
426       FlagExplicit           = 1 << 7,
427       FlagPrototyped         = 1 << 8,
428       FlagObjcClassComplete  = 1 << 9,
429       FlagObjectPointer      = 1 << 10,
430       FlagVector             = 1 << 11,
431       FlagStaticMember       = 1 << 12,
432       FlagIndirectVariable   = 1 << 13,
433       FlagLValueReference    = 1 << 14,
434       FlagRValueReference    = 1 << 15
435     }
436 }
437
438
439 // Link to our native llvm bindings (things that we need to use the C++ api
440 // for) and because llvm is written in C++ we need to link against libstdc++
441 //
442 // You'll probably notice that there is an omission of all LLVM libraries
443 // from this location. This is because the set of LLVM libraries that we
444 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
445 // figure out the exact set of libraries. To do this, the build system
446 // generates an llvmdeps.rs file next to this one which will be
447 // automatically updated whenever LLVM is updated to include an up-to-date
448 // set of the libraries we need to link to LLVM for.
449 #[link(name = "rustllvm", kind = "static")]
450 extern {
451     /* Create and destroy contexts. */
452     pub fn LLVMContextCreate() -> ContextRef;
453     pub fn LLVMContextDispose(C: ContextRef);
454     pub fn LLVMGetMDKindIDInContext(C: ContextRef,
455                                     Name: *const c_char,
456                                     SLen: c_uint)
457                                     -> c_uint;
458
459     /* Create and destroy modules. */
460     pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
461                                              C: ContextRef)
462                                              -> ModuleRef;
463     pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
464     pub fn LLVMDisposeModule(M: ModuleRef);
465
466     /** Data layout. See Module::getDataLayout. */
467     pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
468     pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
469
470     /** Target triple. See Module::getTargetTriple. */
471     pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
472     pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
473
474     /** See Module::dump. */
475     pub fn LLVMDumpModule(M: ModuleRef);
476
477     /** See Module::setModuleInlineAsm. */
478     pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
479
480     /** See llvm::LLVMTypeKind::getTypeID. */
481     pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
482
483     /** See llvm::LLVMType::getContext. */
484     pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
485
486     /* Operations on integer types */
487     pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
488     pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
489     pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
490     pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
491     pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
492     pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
493                                 -> TypeRef;
494
495     pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
496
497     /* Operations on real types */
498     pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
499     pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
500     pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
501     pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
502     pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
503
504     /* Operations on function types */
505     pub fn LLVMFunctionType(ReturnType: TypeRef,
506                             ParamTypes: *const TypeRef,
507                             ParamCount: c_uint,
508                             IsVarArg: Bool)
509                             -> TypeRef;
510     pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
511     pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
512     pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
513     pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *const TypeRef);
514
515     /* Operations on struct types */
516     pub fn LLVMStructTypeInContext(C: ContextRef,
517                                    ElementTypes: *const TypeRef,
518                                    ElementCount: c_uint,
519                                    Packed: Bool)
520                                    -> TypeRef;
521     pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
522     pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
523                                      Dest: *mut TypeRef);
524     pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
525
526     /* Operations on array, pointer, and vector types (sequence types) */
527     pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
528     pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
529                            -> TypeRef;
530     pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
531                           -> TypeRef;
532
533     pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
534     pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
535     pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
536     pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
537                                   -> *const ();
538     pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
539
540     /* Operations on other types */
541     pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
542     pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
543     pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
544
545     /* Operations on all values */
546     pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
547     pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
548     pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
549     pub fn LLVMDumpValue(Val: ValueRef);
550     pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
551     pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
552     pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
553     pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
554
555     /* Operations on Uses */
556     pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
557     pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
558     pub fn LLVMGetUser(U: UseRef) -> ValueRef;
559     pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
560
561     /* Operations on Users */
562     pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
563     pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
564     pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
565
566     /* Operations on constants of any type */
567     pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
568     /* all zeroes */
569     pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
570     pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
571                          -> ValueRef;
572     pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
573                          -> ValueRef;
574     /* only for int/vector */
575     pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
576     pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
577     pub fn LLVMIsNull(Val: ValueRef) -> Bool;
578     pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
579     pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
580
581     /* Operations on metadata */
582     pub fn LLVMMDStringInContext(C: ContextRef,
583                                  Str: *const c_char,
584                                  SLen: c_uint)
585                                  -> ValueRef;
586     pub fn LLVMMDNodeInContext(C: ContextRef,
587                                Vals: *const ValueRef,
588                                Count: c_uint)
589                                -> ValueRef;
590     pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
591                                        Str: *const c_char,
592                                        Val: ValueRef);
593
594     /* Operations on scalar constants */
595     pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
596                         -> ValueRef;
597     pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
598                                 -> ValueRef;
599     pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
600                                        Text: *const c_char,
601                                        SLen: c_uint,
602                                        Radix: u8)
603                                        -> ValueRef;
604     pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
605     pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
606                                  -> ValueRef;
607     pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
608                                         Text: *const c_char,
609                                         SLen: c_uint)
610                                         -> ValueRef;
611     pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
612     pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
613
614
615     /* Operations on composite constants */
616     pub fn LLVMConstStringInContext(C: ContextRef,
617                                     Str: *const c_char,
618                                     Length: c_uint,
619                                     DontNullTerminate: Bool)
620                                     -> ValueRef;
621     pub fn LLVMConstStructInContext(C: ContextRef,
622                                     ConstantVals: *const ValueRef,
623                                     Count: c_uint,
624                                     Packed: Bool)
625                                     -> ValueRef;
626
627     pub fn LLVMConstArray(ElementTy: TypeRef,
628                           ConstantVals: *const ValueRef,
629                           Length: c_uint)
630                           -> ValueRef;
631     pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
632                            -> ValueRef;
633
634     /* Constant expressions */
635     pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
636     pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
637     pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
638     pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
639     pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
640     pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
641     pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
642     pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
643                         -> ValueRef;
644     pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
645                            -> ValueRef;
646     pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
647                            -> ValueRef;
648     pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
649                          -> ValueRef;
650     pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
651                         -> ValueRef;
652     pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
653                            -> ValueRef;
654     pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
655                            -> ValueRef;
656     pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
657                          -> ValueRef;
658     pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
659                         -> ValueRef;
660     pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
661                            -> ValueRef;
662     pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
663                            -> ValueRef;
664     pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
665                          -> ValueRef;
666     pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
667                          -> ValueRef;
668     pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
669                          -> ValueRef;
670     pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
671                               RHSConstant: ValueRef)
672                               -> ValueRef;
673     pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
674                          -> ValueRef;
675     pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
676                          -> ValueRef;
677     pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
678                          -> ValueRef;
679     pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
680                          -> ValueRef;
681     pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
682                         -> ValueRef;
683     pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
684                        -> ValueRef;
685     pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
686                         -> ValueRef;
687     pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
688                         -> ValueRef;
689     pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
690                          -> ValueRef;
691     pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
692                          -> ValueRef;
693     pub fn LLVMConstGEP(ConstantVal: ValueRef,
694                         ConstantIndices: *const ValueRef,
695                         NumIndices: c_uint)
696                         -> ValueRef;
697     pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
698                                 ConstantIndices: *const ValueRef,
699                                 NumIndices: c_uint)
700                                 -> ValueRef;
701     pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
702                           -> ValueRef;
703     pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
704                          -> ValueRef;
705     pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
706                          -> ValueRef;
707     pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
708                             -> ValueRef;
709     pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
710                           -> ValueRef;
711     pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
712                            -> ValueRef;
713     pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
714                            -> ValueRef;
715     pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
716                            -> ValueRef;
717     pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
718                            -> ValueRef;
719     pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
720                              -> ValueRef;
721     pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
722                              -> ValueRef;
723     pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
724                             -> ValueRef;
725     pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
726                                   -> ValueRef;
727     pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
728                                   -> ValueRef;
729     pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
730                                    -> ValueRef;
731     pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
732                                 -> ValueRef;
733     pub fn LLVMConstIntCast(ConstantVal: ValueRef,
734                             ToType: TypeRef,
735                             isSigned: Bool)
736                             -> ValueRef;
737     pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
738                            -> ValueRef;
739     pub fn LLVMConstSelect(ConstantCondition: ValueRef,
740                            ConstantIfTrue: ValueRef,
741                            ConstantIfFalse: ValueRef)
742                            -> ValueRef;
743     pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
744                                    IndexConstant: ValueRef)
745                                    -> ValueRef;
746     pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
747                                   ElementValueConstant: ValueRef,
748                                   IndexConstant: ValueRef)
749                                   -> ValueRef;
750     pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
751                                   VectorBConstant: ValueRef,
752                                   MaskConstant: ValueRef)
753                                   -> ValueRef;
754     pub fn LLVMConstExtractValue(AggConstant: ValueRef,
755                                  IdxList: *const c_uint,
756                                  NumIdx: c_uint)
757                                  -> ValueRef;
758     pub fn LLVMConstInsertValue(AggConstant: ValueRef,
759                                 ElementValueConstant: ValueRef,
760                                 IdxList: *const c_uint,
761                                 NumIdx: c_uint)
762                                 -> ValueRef;
763     pub fn LLVMConstInlineAsm(Ty: TypeRef,
764                               AsmString: *const c_char,
765                               Constraints: *const c_char,
766                               HasSideEffects: Bool,
767                               IsAlignStack: Bool)
768                               -> ValueRef;
769     pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
770
771
772
773     /* Operations on global variables, functions, and aliases (globals) */
774     pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
775     pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
776     pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
777     pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
778     pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
779     pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
780     pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
781     pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
782     pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
783     pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
784
785
786     /* Operations on global variables */
787     pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
788                          -> ValueRef;
789     pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
790                                        Ty: TypeRef,
791                                        Name: *const c_char,
792                                        AddressSpace: c_uint)
793                                        -> ValueRef;
794     pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
795     pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
796     pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
797     pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
798     pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
799     pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
800     pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
801     pub fn LLVMSetInitializer(GlobalVar: ValueRef,
802                               ConstantVal: ValueRef);
803     pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
804     pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
805     pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
806     pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
807
808     /* Operations on aliases */
809     pub fn LLVMAddAlias(M: ModuleRef,
810                         Ty: TypeRef,
811                         Aliasee: ValueRef,
812                         Name: *const c_char)
813                         -> ValueRef;
814
815     /* Operations on functions */
816     pub fn LLVMAddFunction(M: ModuleRef,
817                            Name: *const c_char,
818                            FunctionTy: TypeRef)
819                            -> ValueRef;
820     pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
821     pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
822     pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
823     pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
824     pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
825     pub fn LLVMDeleteFunction(Fn: ValueRef);
826     pub fn LLVMGetOrInsertFunction(M: ModuleRef,
827                                    Name: *const c_char,
828                                    FunctionTy: TypeRef)
829                                    -> ValueRef;
830     pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
831     pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
832     pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
833     pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
834     pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
835     pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
836     pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
837     pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
838     pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
839     pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
840
841     /* Operations on parameters */
842     pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
843     pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
844     pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
845     pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
846     pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
847     pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
848     pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
849     pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
850     pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
851     pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
852     pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
853     pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
854
855     /* Operations on basic blocks */
856     pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
857     pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
858     pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
859     pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
860     pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
861     pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
862     pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
863     pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
864     pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
865     pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
866     pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
867
868     pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
869                                          Fn: ValueRef,
870                                          Name: *const c_char)
871                                          -> BasicBlockRef;
872     pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
873                                          BB: BasicBlockRef,
874                                          Name: *const c_char)
875                                          -> BasicBlockRef;
876     pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
877
878     pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
879                                    MoveAfter: BasicBlockRef);
880
881     pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
882                                     MoveBefore: BasicBlockRef);
883
884     /* Operations on instructions */
885     pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
886     pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
887     pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
888     pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
889     pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
890     pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
891
892     /* Operations on call sites */
893     pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
894     pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
895     pub fn LLVMAddInstrAttribute(Instr: ValueRef,
896                                  index: c_uint,
897                                  IA: c_uint);
898     pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
899                                     index: c_uint,
900                                     IA: c_uint);
901     pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
902                                       index: c_uint,
903                                       align: c_uint);
904     pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
905                                     index: c_uint,
906                                     Val: uint64_t);
907     pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
908                                               index: c_uint,
909                                               bytes: uint64_t);
910
911     /* Operations on call instructions (only) */
912     pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
913     pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
914
915     /* Operations on load/store instructions (only) */
916     pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
917     pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
918
919     /* Operations on phi nodes */
920     pub fn LLVMAddIncoming(PhiNode: ValueRef,
921                            IncomingValues: *const ValueRef,
922                            IncomingBlocks: *const BasicBlockRef,
923                            Count: c_uint);
924     pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
925     pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
926                                 -> ValueRef;
927     pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
928                                 -> BasicBlockRef;
929
930     /* Instruction builders */
931     pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
932     pub fn LLVMPositionBuilder(Builder: BuilderRef,
933                                Block: BasicBlockRef,
934                                Instr: ValueRef);
935     pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
936                                      Instr: ValueRef);
937     pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
938                                     Block: BasicBlockRef);
939     pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
940     pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
941     pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
942     pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
943                                          Instr: ValueRef,
944                                          Name: *const c_char);
945     pub fn LLVMDisposeBuilder(Builder: BuilderRef);
946     pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
947
948     /* Metadata */
949     pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
950     pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
951     pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
952
953     /* Terminators */
954     pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
955     pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
956     pub fn LLVMBuildAggregateRet(B: BuilderRef,
957                                  RetVals: *const ValueRef,
958                                  N: c_uint)
959                                  -> ValueRef;
960     pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
961     pub fn LLVMBuildCondBr(B: BuilderRef,
962                            If: ValueRef,
963                            Then: BasicBlockRef,
964                            Else: BasicBlockRef)
965                            -> ValueRef;
966     pub fn LLVMBuildSwitch(B: BuilderRef,
967                            V: ValueRef,
968                            Else: BasicBlockRef,
969                            NumCases: c_uint)
970                            -> ValueRef;
971     pub fn LLVMBuildIndirectBr(B: BuilderRef,
972                                Addr: ValueRef,
973                                NumDests: c_uint)
974                                -> ValueRef;
975     pub fn LLVMBuildInvoke(B: BuilderRef,
976                            Fn: ValueRef,
977                            Args: *const ValueRef,
978                            NumArgs: c_uint,
979                            Then: BasicBlockRef,
980                            Catch: BasicBlockRef,
981                            Name: *const c_char)
982                            -> ValueRef;
983     pub fn LLVMBuildLandingPad(B: BuilderRef,
984                                Ty: TypeRef,
985                                PersFn: ValueRef,
986                                NumClauses: c_uint,
987                                Name: *const c_char)
988                                -> ValueRef;
989     pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
990     pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
991
992     /* Add a case to the switch instruction */
993     pub fn LLVMAddCase(Switch: ValueRef,
994                        OnVal: ValueRef,
995                        Dest: BasicBlockRef);
996
997     /* Add a destination to the indirectbr instruction */
998     pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
999
1000     /* Add a clause to the landing pad instruction */
1001     pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1002
1003     /* Set the cleanup on a landing pad instruction */
1004     pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1005
1006     /* Arithmetic */
1007     pub fn LLVMBuildAdd(B: BuilderRef,
1008                         LHS: ValueRef,
1009                         RHS: ValueRef,
1010                         Name: *const c_char)
1011                         -> ValueRef;
1012     pub fn LLVMBuildNSWAdd(B: BuilderRef,
1013                            LHS: ValueRef,
1014                            RHS: ValueRef,
1015                            Name: *const c_char)
1016                            -> ValueRef;
1017     pub fn LLVMBuildNUWAdd(B: BuilderRef,
1018                            LHS: ValueRef,
1019                            RHS: ValueRef,
1020                            Name: *const c_char)
1021                            -> ValueRef;
1022     pub fn LLVMBuildFAdd(B: BuilderRef,
1023                          LHS: ValueRef,
1024                          RHS: ValueRef,
1025                          Name: *const c_char)
1026                          -> ValueRef;
1027     pub fn LLVMBuildSub(B: BuilderRef,
1028                         LHS: ValueRef,
1029                         RHS: ValueRef,
1030                         Name: *const c_char)
1031                         -> ValueRef;
1032     pub fn LLVMBuildNSWSub(B: BuilderRef,
1033                            LHS: ValueRef,
1034                            RHS: ValueRef,
1035                            Name: *const c_char)
1036                            -> ValueRef;
1037     pub fn LLVMBuildNUWSub(B: BuilderRef,
1038                            LHS: ValueRef,
1039                            RHS: ValueRef,
1040                            Name: *const c_char)
1041                            -> ValueRef;
1042     pub fn LLVMBuildFSub(B: BuilderRef,
1043                          LHS: ValueRef,
1044                          RHS: ValueRef,
1045                          Name: *const c_char)
1046                          -> ValueRef;
1047     pub fn LLVMBuildMul(B: BuilderRef,
1048                         LHS: ValueRef,
1049                         RHS: ValueRef,
1050                         Name: *const c_char)
1051                         -> ValueRef;
1052     pub fn LLVMBuildNSWMul(B: BuilderRef,
1053                            LHS: ValueRef,
1054                            RHS: ValueRef,
1055                            Name: *const c_char)
1056                            -> ValueRef;
1057     pub fn LLVMBuildNUWMul(B: BuilderRef,
1058                            LHS: ValueRef,
1059                            RHS: ValueRef,
1060                            Name: *const c_char)
1061                            -> ValueRef;
1062     pub fn LLVMBuildFMul(B: BuilderRef,
1063                          LHS: ValueRef,
1064                          RHS: ValueRef,
1065                          Name: *const c_char)
1066                          -> ValueRef;
1067     pub fn LLVMBuildUDiv(B: BuilderRef,
1068                          LHS: ValueRef,
1069                          RHS: ValueRef,
1070                          Name: *const c_char)
1071                          -> ValueRef;
1072     pub fn LLVMBuildSDiv(B: BuilderRef,
1073                          LHS: ValueRef,
1074                          RHS: ValueRef,
1075                          Name: *const c_char)
1076                          -> ValueRef;
1077     pub fn LLVMBuildExactSDiv(B: BuilderRef,
1078                               LHS: ValueRef,
1079                               RHS: ValueRef,
1080                               Name: *const c_char)
1081                               -> ValueRef;
1082     pub fn LLVMBuildFDiv(B: BuilderRef,
1083                          LHS: ValueRef,
1084                          RHS: ValueRef,
1085                          Name: *const c_char)
1086                          -> ValueRef;
1087     pub fn LLVMBuildURem(B: BuilderRef,
1088                          LHS: ValueRef,
1089                          RHS: ValueRef,
1090                          Name: *const c_char)
1091                          -> ValueRef;
1092     pub fn LLVMBuildSRem(B: BuilderRef,
1093                          LHS: ValueRef,
1094                          RHS: ValueRef,
1095                          Name: *const c_char)
1096                          -> ValueRef;
1097     pub fn LLVMBuildFRem(B: BuilderRef,
1098                          LHS: ValueRef,
1099                          RHS: ValueRef,
1100                          Name: *const c_char)
1101                          -> ValueRef;
1102     pub fn LLVMBuildShl(B: BuilderRef,
1103                         LHS: ValueRef,
1104                         RHS: ValueRef,
1105                         Name: *const c_char)
1106                         -> ValueRef;
1107     pub fn LLVMBuildLShr(B: BuilderRef,
1108                          LHS: ValueRef,
1109                          RHS: ValueRef,
1110                          Name: *const c_char)
1111                          -> ValueRef;
1112     pub fn LLVMBuildAShr(B: BuilderRef,
1113                          LHS: ValueRef,
1114                          RHS: ValueRef,
1115                          Name: *const c_char)
1116                          -> ValueRef;
1117     pub fn LLVMBuildAnd(B: BuilderRef,
1118                         LHS: ValueRef,
1119                         RHS: ValueRef,
1120                         Name: *const c_char)
1121                         -> ValueRef;
1122     pub fn LLVMBuildOr(B: BuilderRef,
1123                        LHS: ValueRef,
1124                        RHS: ValueRef,
1125                        Name: *const c_char)
1126                            -> ValueRef;
1127     pub fn LLVMBuildXor(B: BuilderRef,
1128                         LHS: ValueRef,
1129                         RHS: ValueRef,
1130                         Name: *const c_char)
1131                         -> ValueRef;
1132     pub fn LLVMBuildBinOp(B: BuilderRef,
1133                           Op: Opcode,
1134                           LHS: ValueRef,
1135                           RHS: ValueRef,
1136                           Name: *const c_char)
1137                           -> ValueRef;
1138     pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1139                         -> ValueRef;
1140     pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1141                            -> ValueRef;
1142     pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1143                            -> ValueRef;
1144     pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1145                          -> ValueRef;
1146     pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1147                         -> ValueRef;
1148
1149     /* Memory */
1150     pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1151                            -> ValueRef;
1152     pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1153                                 Ty: TypeRef,
1154                                 Val: ValueRef,
1155                                 Name: *const c_char)
1156                                 -> ValueRef;
1157     pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1158                            -> ValueRef;
1159     pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1160                                 Ty: TypeRef,
1161                                 Val: ValueRef,
1162                                 Name: *const c_char)
1163                                 -> ValueRef;
1164     pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1165     pub fn LLVMBuildLoad(B: BuilderRef,
1166                          PointerVal: ValueRef,
1167                          Name: *const c_char)
1168                          -> ValueRef;
1169
1170     pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1171                           -> ValueRef;
1172
1173     pub fn LLVMBuildGEP(B: BuilderRef,
1174                         Pointer: ValueRef,
1175                         Indices: *const ValueRef,
1176                         NumIndices: c_uint,
1177                         Name: *const c_char)
1178                         -> ValueRef;
1179     pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1180                                 Pointer: ValueRef,
1181                                 Indices: *const ValueRef,
1182                                 NumIndices: c_uint,
1183                                 Name: *const c_char)
1184                                 -> ValueRef;
1185     pub fn LLVMBuildStructGEP(B: BuilderRef,
1186                               Pointer: ValueRef,
1187                               Idx: c_uint,
1188                               Name: *const c_char)
1189                               -> ValueRef;
1190     pub fn LLVMBuildGlobalString(B: BuilderRef,
1191                                  Str: *const c_char,
1192                                  Name: *const c_char)
1193                                  -> ValueRef;
1194     pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1195                                     Str: *const c_char,
1196                                     Name: *const c_char)
1197                                     -> ValueRef;
1198
1199     /* Casts */
1200     pub fn LLVMBuildTrunc(B: BuilderRef,
1201                           Val: ValueRef,
1202                           DestTy: TypeRef,
1203                           Name: *const c_char)
1204                           -> ValueRef;
1205     pub fn LLVMBuildZExt(B: BuilderRef,
1206                          Val: ValueRef,
1207                          DestTy: TypeRef,
1208                          Name: *const c_char)
1209                          -> ValueRef;
1210     pub fn LLVMBuildSExt(B: BuilderRef,
1211                          Val: ValueRef,
1212                          DestTy: TypeRef,
1213                          Name: *const c_char)
1214                          -> ValueRef;
1215     pub fn LLVMBuildFPToUI(B: BuilderRef,
1216                            Val: ValueRef,
1217                            DestTy: TypeRef,
1218                            Name: *const c_char)
1219                            -> ValueRef;
1220     pub fn LLVMBuildFPToSI(B: BuilderRef,
1221                            Val: ValueRef,
1222                            DestTy: TypeRef,
1223                            Name: *const c_char)
1224                            -> ValueRef;
1225     pub fn LLVMBuildUIToFP(B: BuilderRef,
1226                            Val: ValueRef,
1227                            DestTy: TypeRef,
1228                            Name: *const c_char)
1229                            -> ValueRef;
1230     pub fn LLVMBuildSIToFP(B: BuilderRef,
1231                            Val: ValueRef,
1232                            DestTy: TypeRef,
1233                            Name: *const c_char)
1234                            -> ValueRef;
1235     pub fn LLVMBuildFPTrunc(B: BuilderRef,
1236                             Val: ValueRef,
1237                             DestTy: TypeRef,
1238                             Name: *const c_char)
1239                             -> ValueRef;
1240     pub fn LLVMBuildFPExt(B: BuilderRef,
1241                           Val: ValueRef,
1242                           DestTy: TypeRef,
1243                           Name: *const c_char)
1244                           -> ValueRef;
1245     pub fn LLVMBuildPtrToInt(B: BuilderRef,
1246                              Val: ValueRef,
1247                              DestTy: TypeRef,
1248                              Name: *const c_char)
1249                              -> ValueRef;
1250     pub fn LLVMBuildIntToPtr(B: BuilderRef,
1251                              Val: ValueRef,
1252                              DestTy: TypeRef,
1253                              Name: *const c_char)
1254                              -> ValueRef;
1255     pub fn LLVMBuildBitCast(B: BuilderRef,
1256                             Val: ValueRef,
1257                             DestTy: TypeRef,
1258                             Name: *const c_char)
1259                             -> ValueRef;
1260     pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1261                                   Val: ValueRef,
1262                                   DestTy: TypeRef,
1263                                   Name: *const c_char)
1264                                   -> ValueRef;
1265     pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1266                                   Val: ValueRef,
1267                                   DestTy: TypeRef,
1268                                   Name: *const c_char)
1269                                   -> ValueRef;
1270     pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1271                                    Val: ValueRef,
1272                                    DestTy: TypeRef,
1273                                    Name: *const c_char)
1274                                    -> ValueRef;
1275     pub fn LLVMBuildCast(B: BuilderRef,
1276                          Op: Opcode,
1277                          Val: ValueRef,
1278                          DestTy: TypeRef,
1279                          Name: *const c_char) -> ValueRef;
1280     pub fn LLVMBuildPointerCast(B: BuilderRef,
1281                                 Val: ValueRef,
1282                                 DestTy: TypeRef,
1283                                 Name: *const c_char)
1284                                 -> ValueRef;
1285     pub fn LLVMBuildIntCast(B: BuilderRef,
1286                             Val: ValueRef,
1287                             DestTy: TypeRef,
1288                             Name: *const c_char)
1289                             -> ValueRef;
1290     pub fn LLVMBuildFPCast(B: BuilderRef,
1291                            Val: ValueRef,
1292                            DestTy: TypeRef,
1293                            Name: *const c_char)
1294                            -> ValueRef;
1295
1296     /* Comparisons */
1297     pub fn LLVMBuildICmp(B: BuilderRef,
1298                          Op: c_uint,
1299                          LHS: ValueRef,
1300                          RHS: ValueRef,
1301                          Name: *const c_char)
1302                          -> ValueRef;
1303     pub fn LLVMBuildFCmp(B: BuilderRef,
1304                          Op: c_uint,
1305                          LHS: ValueRef,
1306                          RHS: ValueRef,
1307                          Name: *const c_char)
1308                          -> ValueRef;
1309
1310     /* Miscellaneous instructions */
1311     pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1312                         -> ValueRef;
1313     pub fn LLVMBuildCall(B: BuilderRef,
1314                          Fn: ValueRef,
1315                          Args: *const ValueRef,
1316                          NumArgs: c_uint,
1317                          Name: *const c_char)
1318                          -> ValueRef;
1319     pub fn LLVMBuildSelect(B: BuilderRef,
1320                            If: ValueRef,
1321                            Then: ValueRef,
1322                            Else: ValueRef,
1323                            Name: *const c_char)
1324                            -> ValueRef;
1325     pub fn LLVMBuildVAArg(B: BuilderRef,
1326                           list: ValueRef,
1327                           Ty: TypeRef,
1328                           Name: *const c_char)
1329                           -> ValueRef;
1330     pub fn LLVMBuildExtractElement(B: BuilderRef,
1331                                    VecVal: ValueRef,
1332                                    Index: ValueRef,
1333                                    Name: *const c_char)
1334                                    -> ValueRef;
1335     pub fn LLVMBuildInsertElement(B: BuilderRef,
1336                                   VecVal: ValueRef,
1337                                   EltVal: ValueRef,
1338                                   Index: ValueRef,
1339                                   Name: *const c_char)
1340                                   -> ValueRef;
1341     pub fn LLVMBuildShuffleVector(B: BuilderRef,
1342                                   V1: ValueRef,
1343                                   V2: ValueRef,
1344                                   Mask: ValueRef,
1345                                   Name: *const c_char)
1346                                   -> ValueRef;
1347     pub fn LLVMBuildExtractValue(B: BuilderRef,
1348                                  AggVal: ValueRef,
1349                                  Index: c_uint,
1350                                  Name: *const c_char)
1351                                  -> ValueRef;
1352     pub fn LLVMBuildInsertValue(B: BuilderRef,
1353                                 AggVal: ValueRef,
1354                                 EltVal: ValueRef,
1355                                 Index: c_uint,
1356                                 Name: *const c_char)
1357                                 -> ValueRef;
1358
1359     pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1360                            -> ValueRef;
1361     pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1362                               -> ValueRef;
1363     pub fn LLVMBuildPtrDiff(B: BuilderRef,
1364                             LHS: ValueRef,
1365                             RHS: ValueRef,
1366                             Name: *const c_char)
1367                             -> ValueRef;
1368
1369     /* Atomic Operations */
1370     pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1371                                PointerVal: ValueRef,
1372                                Name: *const c_char,
1373                                Order: AtomicOrdering,
1374                                Alignment: c_uint)
1375                                -> ValueRef;
1376
1377     pub fn LLVMBuildAtomicStore(B: BuilderRef,
1378                                 Val: ValueRef,
1379                                 Ptr: ValueRef,
1380                                 Order: AtomicOrdering,
1381                                 Alignment: c_uint)
1382                                 -> ValueRef;
1383
1384     pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1385                                   LHS: ValueRef,
1386                                   CMP: ValueRef,
1387                                   RHS: ValueRef,
1388                                   Order: AtomicOrdering,
1389                                   FailureOrder: AtomicOrdering)
1390                                   -> ValueRef;
1391     pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1392                               Op: AtomicBinOp,
1393                               LHS: ValueRef,
1394                               RHS: ValueRef,
1395                               Order: AtomicOrdering,
1396                               SingleThreaded: Bool)
1397                               -> ValueRef;
1398
1399     pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1400
1401
1402     /* Selected entries from the downcasts. */
1403     pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1404     pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1405
1406     /** Writes a module to the specified path. Returns 0 on success. */
1407     pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1408
1409     /** Creates target data from a target layout string. */
1410     pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1411     /// Adds the target data to the given pass manager. The pass manager
1412     /// references the target data only weakly.
1413     pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1414     /** Number of bytes clobbered when doing a Store to *T. */
1415     pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1416                                -> c_ulonglong;
1417
1418     /** Number of bytes clobbered when doing a Store to *T. */
1419     pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1420                                 -> c_ulonglong;
1421
1422     /** Distance between successive elements in an array of T.
1423     Includes ABI padding. */
1424     pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1425
1426     /** Returns the preferred alignment of a type. */
1427     pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1428                                         -> c_uint;
1429     /** Returns the minimum alignment of a type. */
1430     pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1431                                   -> c_uint;
1432
1433     /// Computes the byte offset of the indexed struct element for a
1434     /// target.
1435     pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1436                                StructTy: TypeRef,
1437                                Element: c_uint)
1438                                -> c_ulonglong;
1439
1440     /**
1441      * Returns the minimum alignment of a type when part of a call frame.
1442      */
1443     pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1444                                         -> c_uint;
1445
1446     /** Disposes target data. */
1447     pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1448
1449     /** Creates a pass manager. */
1450     pub fn LLVMCreatePassManager() -> PassManagerRef;
1451
1452     /** Creates a function-by-function pass manager */
1453     pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1454                                                   -> PassManagerRef;
1455
1456     /** Disposes a pass manager. */
1457     pub fn LLVMDisposePassManager(PM: PassManagerRef);
1458
1459     /** Runs a pass manager on a module. */
1460     pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1461
1462     /** Runs the function passes on the provided function. */
1463     pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1464                                       -> Bool;
1465
1466     /** Initializes all the function passes scheduled in the manager */
1467     pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1468
1469     /** Finalizes all the function passes scheduled in the manager */
1470     pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1471
1472     pub fn LLVMInitializePasses();
1473
1474     /** Adds a verification pass. */
1475     pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1476
1477     pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1478     pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1479     pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1480     pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1481     pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1482     pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1483     pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1484     pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1485     pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1486     pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1487     pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1488     pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1489     pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1490     pub fn LLVMAddLICMPass(PM: PassManagerRef);
1491     pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1492     pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1493     pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1494     pub fn LLVMAddGVNPass(PM: PassManagerRef);
1495     pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1496     pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1497     pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1498     pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1499     pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1500     pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1501     pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1502     pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1503     pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1504     pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1505     pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1506     pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1507     pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1508     pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1509     pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1510     pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1511     pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1512
1513     pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1514     pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1515     pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1516                                              OptimizationLevel: c_uint);
1517     pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1518                                               Value: Bool);
1519     pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1520         PMB: PassManagerBuilderRef,
1521         Value: Bool);
1522     pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1523         PMB: PassManagerBuilderRef,
1524         Value: Bool);
1525     pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1526         PMB: PassManagerBuilderRef,
1527         Value: Bool);
1528     pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1529         PMB: PassManagerBuilderRef,
1530         threshold: c_uint);
1531     pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1532         PMB: PassManagerBuilderRef,
1533         PM: PassManagerRef);
1534
1535     pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1536         PMB: PassManagerBuilderRef,
1537         PM: PassManagerRef);
1538     pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1539         PMB: PassManagerBuilderRef,
1540         PM: PassManagerRef,
1541         Internalize: Bool,
1542         RunInliner: Bool);
1543
1544     /** Destroys a memory buffer. */
1545     pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1546
1547
1548     /* Stuff that's in rustllvm/ because it's not upstream yet. */
1549
1550     /** Opens an object file. */
1551     pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1552     /** Closes an object file. */
1553     pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1554
1555     /** Enumerates the sections in an object file. */
1556     pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1557     /** Destroys a section iterator. */
1558     pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1559     /** Returns true if the section iterator is at the end of the section
1560     list: */
1561     pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1562                                       SI: SectionIteratorRef)
1563                                       -> Bool;
1564     /** Moves the section iterator to point to the next section. */
1565     pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1566     /** Returns the current section size. */
1567     pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1568     /** Returns the current section contents as a string buffer. */
1569     pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1570
1571     /** Reads the given file and returns it as a memory buffer. Use
1572     LLVMDisposeMemoryBuffer() to get rid of it. */
1573     pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1574                                                         -> MemoryBufferRef;
1575     /** Borrows the contents of the memory buffer (doesn't copy it) */
1576     pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1577                                                  InputDataLength: size_t,
1578                                                  BufferName: *const c_char,
1579                                                  RequiresNull: Bool)
1580                                                  -> MemoryBufferRef;
1581     pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1582                                                      InputDataLength: size_t,
1583                                                      BufferName: *const c_char)
1584                                                      -> MemoryBufferRef;
1585
1586     pub fn LLVMIsMultithreaded() -> Bool;
1587     pub fn LLVMStartMultithreaded() -> Bool;
1588
1589     /** Returns a string describing the last error caused by an LLVMRust*
1590     call. */
1591     pub fn LLVMRustGetLastError() -> *const c_char;
1592
1593     /// Print the pass timings since static dtors aren't picking them up.
1594     pub fn LLVMRustPrintPassTimings();
1595
1596     pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1597
1598     pub fn LLVMStructSetBody(StructTy: TypeRef,
1599                              ElementTypes: *const TypeRef,
1600                              ElementCount: c_uint,
1601                              Packed: Bool);
1602
1603     pub fn LLVMConstNamedStruct(S: TypeRef,
1604                                 ConstantVals: *const ValueRef,
1605                                 Count: c_uint)
1606                                 -> ValueRef;
1607
1608     /** Enables LLVM debug output. */
1609     pub fn LLVMSetDebug(Enabled: c_int);
1610
1611     /** Prepares inline assembly. */
1612     pub fn LLVMInlineAsm(Ty: TypeRef,
1613                          AsmString: *const c_char,
1614                          Constraints: *const c_char,
1615                          SideEffects: Bool,
1616                          AlignStack: Bool,
1617                          Dialect: c_uint)
1618                          -> ValueRef;
1619
1620     pub static LLVMRustDebugMetadataVersion: u32;
1621
1622     pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1623                                  name: *const c_char,
1624                                  value: u32);
1625
1626     pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1627
1628     pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1629
1630     pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1631
1632     pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1633                                           Lang: c_uint,
1634                                           File: *const c_char,
1635                                           Dir: *const c_char,
1636                                           Producer: *const c_char,
1637                                           isOptimized: bool,
1638                                           Flags: *const c_char,
1639                                           RuntimeVer: c_uint,
1640                                           SplitName: *const c_char);
1641
1642     pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1643                                    Filename: *const c_char,
1644                                    Directory: *const c_char)
1645                                    -> DIFile;
1646
1647     pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1648                                              File: DIFile,
1649                                              ParameterTypes: DIArray)
1650                                              -> DICompositeType;
1651
1652     pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1653                                        Scope: DIDescriptor,
1654                                        Name: *const c_char,
1655                                        LinkageName: *const c_char,
1656                                        File: DIFile,
1657                                        LineNo: c_uint,
1658                                        Ty: DIType,
1659                                        isLocalToUnit: bool,
1660                                        isDefinition: bool,
1661                                        ScopeLine: c_uint,
1662                                        Flags: c_uint,
1663                                        isOptimized: bool,
1664                                        Fn: ValueRef,
1665                                        TParam: ValueRef,
1666                                        Decl: ValueRef)
1667                                        -> DISubprogram;
1668
1669     pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1670                                         Name: *const c_char,
1671                                         SizeInBits: c_ulonglong,
1672                                         AlignInBits: c_ulonglong,
1673                                         Encoding: c_uint)
1674                                         -> DIBasicType;
1675
1676     pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1677                                           PointeeTy: DIType,
1678                                           SizeInBits: c_ulonglong,
1679                                           AlignInBits: c_ulonglong,
1680                                           Name: *const c_char)
1681                                           -> DIDerivedType;
1682
1683     pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1684                                          Scope: DIDescriptor,
1685                                          Name: *const c_char,
1686                                          File: DIFile,
1687                                          LineNumber: c_uint,
1688                                          SizeInBits: c_ulonglong,
1689                                          AlignInBits: c_ulonglong,
1690                                          Flags: c_uint,
1691                                          DerivedFrom: DIType,
1692                                          Elements: DIArray,
1693                                          RunTimeLang: c_uint,
1694                                          VTableHolder: ValueRef,
1695                                          UniqueId: *const c_char)
1696                                          -> DICompositeType;
1697
1698     pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1699                                          Scope: DIDescriptor,
1700                                          Name: *const c_char,
1701                                          File: DIFile,
1702                                          LineNo: c_uint,
1703                                          SizeInBits: c_ulonglong,
1704                                          AlignInBits: c_ulonglong,
1705                                          OffsetInBits: c_ulonglong,
1706                                          Flags: c_uint,
1707                                          Ty: DIType)
1708                                          -> DIDerivedType;
1709
1710     pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1711                                            Scope: DIDescriptor,
1712                                            File: DIFile,
1713                                            Line: c_uint,
1714                                            Col: c_uint,
1715                                            Discriminator: c_uint)
1716                                            -> DILexicalBlock;
1717
1718     pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1719                                              Context: DIDescriptor,
1720                                              Name: *const c_char,
1721                                              LinkageName: *const c_char,
1722                                              File: DIFile,
1723                                              LineNo: c_uint,
1724                                              Ty: DIType,
1725                                              isLocalToUnit: bool,
1726                                              Val: ValueRef,
1727                                              Decl: ValueRef)
1728                                              -> DIGlobalVariable;
1729
1730     pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
1731                                             Tag: c_uint,
1732                                             Scope: DIDescriptor,
1733                                             Name: *const c_char,
1734                                             File: DIFile,
1735                                             LineNo: c_uint,
1736                                             Ty: DIType,
1737                                             AlwaysPreserve: bool,
1738                                             Flags: c_uint,
1739                                             ArgNo: c_uint)
1740                                             -> DIVariable;
1741
1742     pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1743                                         Size: c_ulonglong,
1744                                         AlignInBits: c_ulonglong,
1745                                         Ty: DIType,
1746                                         Subscripts: DIArray)
1747                                         -> DIType;
1748
1749     pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1750                                          Size: c_ulonglong,
1751                                          AlignInBits: c_ulonglong,
1752                                          Ty: DIType,
1753                                          Subscripts: DIArray)
1754                                          -> DIType;
1755
1756     pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1757                                             Lo: c_longlong,
1758                                             Count: c_longlong)
1759                                             -> DISubrange;
1760
1761     pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1762                                          Ptr: *const DIDescriptor,
1763                                          Count: c_uint)
1764                                          -> DIArray;
1765
1766     pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1767                                            Val: ValueRef,
1768                                            VarInfo: DIVariable,
1769                                            InsertAtEnd: BasicBlockRef)
1770                                            -> ValueRef;
1771
1772     pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1773                                             Val: ValueRef,
1774                                             VarInfo: DIVariable,
1775                                             InsertBefore: ValueRef)
1776                                             -> ValueRef;
1777
1778     pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1779                                          Name: *const c_char,
1780                                          Val: c_ulonglong)
1781                                          -> ValueRef;
1782
1783     pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1784                                               Scope: ValueRef,
1785                                               Name: *const c_char,
1786                                               File: ValueRef,
1787                                               LineNumber: c_uint,
1788                                               SizeInBits: c_ulonglong,
1789                                               AlignInBits: c_ulonglong,
1790                                               Elements: ValueRef,
1791                                               ClassType: ValueRef)
1792                                               -> ValueRef;
1793
1794     pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1795                                         Scope: ValueRef,
1796                                         Name: *const c_char,
1797                                         File: ValueRef,
1798                                         LineNumber: c_uint,
1799                                         SizeInBits: c_ulonglong,
1800                                         AlignInBits: c_ulonglong,
1801                                         Flags: c_uint,
1802                                         Elements: ValueRef,
1803                                         RunTimeLang: c_uint,
1804                                         UniqueId: *const c_char)
1805                                         -> ValueRef;
1806
1807     pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1808
1809     pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1810                                                     Scope: ValueRef,
1811                                                     Name: *const c_char,
1812                                                     Ty: ValueRef,
1813                                                     File: ValueRef,
1814                                                     LineNo: c_uint,
1815                                                     ColumnNo: c_uint)
1816                                                     -> ValueRef;
1817
1818     pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
1819
1820     pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
1821
1822     pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
1823                                               Tag: c_uint,
1824                                               Scope: ValueRef,
1825                                               Name: *const c_char,
1826                                               File: ValueRef,
1827                                               LineNo: c_uint,
1828                                               Ty: ValueRef,
1829                                               AddrOps: *const ValueRef,
1830                                               AddrOpsCount: c_uint,
1831                                               ArgNo: c_uint)
1832                                               -> ValueRef;
1833
1834     pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1835                                         Scope: ValueRef,
1836                                         Name: *const c_char,
1837                                         File: ValueRef,
1838                                         LineNo: c_uint)
1839                                         -> ValueRef;
1840
1841     pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
1842     pub fn LLVMTypeToString(Type: TypeRef) -> *const c_char;
1843     pub fn LLVMValueToString(value_ref: ValueRef) -> *const c_char;
1844
1845     pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1846
1847     pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1848
1849     pub fn LLVMInitializeX86TargetInfo();
1850     pub fn LLVMInitializeX86Target();
1851     pub fn LLVMInitializeX86TargetMC();
1852     pub fn LLVMInitializeX86AsmPrinter();
1853     pub fn LLVMInitializeX86AsmParser();
1854     pub fn LLVMInitializeARMTargetInfo();
1855     pub fn LLVMInitializeARMTarget();
1856     pub fn LLVMInitializeARMTargetMC();
1857     pub fn LLVMInitializeARMAsmPrinter();
1858     pub fn LLVMInitializeARMAsmParser();
1859     pub fn LLVMInitializeMipsTargetInfo();
1860     pub fn LLVMInitializeMipsTarget();
1861     pub fn LLVMInitializeMipsTargetMC();
1862     pub fn LLVMInitializeMipsAsmPrinter();
1863     pub fn LLVMInitializeMipsAsmParser();
1864
1865     pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
1866     pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1867                                        CPU: *const c_char,
1868                                        Features: *const c_char,
1869                                        Model: CodeGenModel,
1870                                        Reloc: RelocMode,
1871                                        Level: CodeGenOptLevel,
1872                                        EnableSegstk: bool,
1873                                        UseSoftFP: bool,
1874                                        NoFramePointerElim: bool,
1875                                        FunctionSections: bool,
1876                                        DataSections: bool) -> TargetMachineRef;
1877     pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1878     pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1879                                      PM: PassManagerRef,
1880                                      M: ModuleRef);
1881     pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1882                                          M: ModuleRef,
1883                                          DisableSimplifyLibCalls: bool);
1884     pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
1885                                   DisableSimplifyLibCalls: bool);
1886     pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1887     pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1888                                    PM: PassManagerRef,
1889                                    M: ModuleRef,
1890                                    Output: *const c_char,
1891                                    FileType: FileType) -> bool;
1892     pub fn LLVMRustPrintModule(PM: PassManagerRef,
1893                                M: ModuleRef,
1894                                Output: *const c_char);
1895     pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1896     pub fn LLVMRustPrintPasses();
1897     pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1898     pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
1899                                        AddLifetimes: bool);
1900     pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
1901                                          bc: *const c_char,
1902                                          len: size_t) -> bool;
1903     pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
1904                                       syms: *const *const c_char,
1905                                       len: size_t);
1906     pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1907
1908     pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1909     pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
1910                                       out_len: *mut size_t) -> *const c_char;
1911     pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1912
1913     pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
1914     pub fn LLVMVersionMajor() -> c_int;
1915     pub fn LLVMVersionMinor() -> c_int;
1916
1917     pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
1918                                   data: *mut *const c_char) -> c_int;
1919 }
1920
1921 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
1922     unsafe {
1923         LLVMSetInstructionCallConv(instr, cc as c_uint);
1924     }
1925 }
1926 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
1927     unsafe {
1928         LLVMSetFunctionCallConv(fn_, cc as c_uint);
1929     }
1930 }
1931 pub fn SetLinkage(global: ValueRef, link: Linkage) {
1932     unsafe {
1933         LLVMSetLinkage(global, link as c_uint);
1934     }
1935 }
1936
1937 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
1938     unsafe {
1939         LLVMSetUnnamedAddr(global, unnamed as Bool);
1940     }
1941 }
1942
1943 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
1944     unsafe {
1945         LLVMSetThreadLocal(global, is_thread_local as Bool);
1946     }
1947 }
1948
1949 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
1950     unsafe {
1951         LLVMConstICmp(pred as c_ushort, v1, v2)
1952     }
1953 }
1954 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
1955     unsafe {
1956         LLVMConstFCmp(pred as c_ushort, v1, v2)
1957     }
1958 }
1959
1960 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
1961     unsafe {
1962         LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr as uint64_t)
1963     }
1964 }
1965
1966 /* Memory-managed interface to target data. */
1967
1968 pub struct TargetData {
1969     pub lltd: TargetDataRef
1970 }
1971
1972 impl Drop for TargetData {
1973     fn drop(&mut self) {
1974         unsafe {
1975             LLVMDisposeTargetData(self.lltd);
1976         }
1977     }
1978 }
1979
1980 pub fn mk_target_data(string_rep: &str) -> TargetData {
1981     TargetData {
1982         lltd: string_rep.with_c_str(|buf| {
1983             unsafe { LLVMCreateTargetData(buf) }
1984         })
1985     }
1986 }
1987
1988 /* Memory-managed interface to object files. */
1989
1990 pub struct ObjectFile {
1991     pub llof: ObjectFileRef,
1992 }
1993
1994 impl ObjectFile {
1995     // This will take ownership of llmb
1996     pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
1997         unsafe {
1998             let llof = LLVMCreateObjectFile(llmb);
1999             if llof as int == 0 {
2000                 // LLVMCreateObjectFile took ownership of llmb
2001                 return None
2002             }
2003
2004             Some(ObjectFile {
2005                 llof: llof,
2006             })
2007         }
2008     }
2009 }
2010
2011 impl Drop for ObjectFile {
2012     fn drop(&mut self) {
2013         unsafe {
2014             LLVMDisposeObjectFile(self.llof);
2015         }
2016     }
2017 }
2018
2019 /* Memory-managed interface to section iterators. */
2020
2021 pub struct SectionIter {
2022     pub llsi: SectionIteratorRef
2023 }
2024
2025 impl Drop for SectionIter {
2026     fn drop(&mut self) {
2027         unsafe {
2028             LLVMDisposeSectionIterator(self.llsi);
2029         }
2030     }
2031 }
2032
2033 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2034     unsafe {
2035         SectionIter {
2036             llsi: LLVMGetSections(llof)
2037         }
2038     }
2039 }
2040
2041 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2042 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2043     unsafe {
2044         assert!(index < LLVMCountParams(llfn));
2045         LLVMGetParam(llfn, index)
2046     }
2047 }
2048
2049 // FIXME #15460 - create a public function that actually calls our
2050 // static LLVM symbols. Otherwise the linker will just throw llvm
2051 // away.  We're just calling lots of stuff until we transitively get
2052 // all of LLVM. This is worse than anything.
2053 pub unsafe fn static_link_hack_this_sucks() {
2054     LLVMInitializePasses();
2055
2056     LLVMInitializeX86TargetInfo();
2057     LLVMInitializeX86Target();
2058     LLVMInitializeX86TargetMC();
2059     LLVMInitializeX86AsmPrinter();
2060     LLVMInitializeX86AsmParser();
2061
2062     LLVMInitializeARMTargetInfo();
2063     LLVMInitializeARMTarget();
2064     LLVMInitializeARMTargetMC();
2065     LLVMInitializeARMAsmPrinter();
2066     LLVMInitializeARMAsmParser();
2067
2068     LLVMInitializeMipsTargetInfo();
2069     LLVMInitializeMipsTarget();
2070     LLVMInitializeMipsTargetMC();
2071     LLVMInitializeMipsAsmPrinter();
2072     LLVMInitializeMipsAsmParser();
2073
2074     LLVMRustSetLLVMOptions(0 as c_int,
2075                                        0 as *const _);
2076
2077     LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
2078     LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
2079     LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
2080     LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
2081     LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
2082     LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
2083     LLVMPassManagerBuilderCreate();
2084     LLVMPassManagerBuilderDispose(0 as *mut _);
2085
2086     LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
2087
2088     LLVMLinkInJIT();
2089     LLVMLinkInMCJIT();
2090     LLVMLinkInInterpreter();
2091
2092     extern {
2093         fn LLVMLinkInJIT();
2094         fn LLVMLinkInMCJIT();
2095         fn LLVMLinkInInterpreter();
2096     }
2097 }
2098
2099 // The module containing the native LLVM dependencies, generated by the build system
2100 // Note that this must come after the rustllvm extern declaration so that
2101 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2102 // Works to the above fix for #15460 to ensure LLVM dependencies that
2103 // are only used by rustllvm don't get stripped by the linker.
2104 mod llvmdeps;
2105