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