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