]> git.lizzy.rs Git - rust.git/blob - src/librustc_llvm/ffi.rs
Add profiling support, through the rustc -Z profile flag.
[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     pub fn LLVMRustAppendModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
511
512     /// See llvm::LLVMTypeKind::getTypeID.
513     pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind;
514
515     /// See llvm::Value::getContext
516     pub fn LLVMRustGetValueContext(V: ValueRef) -> ContextRef;
517
518     // Operations on integer types
519     pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
520     pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
521     pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
522     pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
523     pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
524     pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint) -> TypeRef;
525
526     pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
527
528     // Operations on real types
529     pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
530     pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
531
532     // Operations on function types
533     pub fn LLVMFunctionType(ReturnType: TypeRef,
534                             ParamTypes: *const TypeRef,
535                             ParamCount: c_uint,
536                             IsVarArg: Bool)
537                             -> TypeRef;
538     pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
539     pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
540     pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
541
542     // Operations on struct types
543     pub fn LLVMStructTypeInContext(C: ContextRef,
544                                    ElementTypes: *const TypeRef,
545                                    ElementCount: c_uint,
546                                    Packed: Bool)
547                                    -> TypeRef;
548     pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
549     pub fn LLVMGetStructElementTypes(StructTy: TypeRef, Dest: *mut TypeRef);
550     pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
551
552     // Operations on array, pointer, and vector types (sequence types)
553     pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
554     pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint) -> TypeRef;
555     pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint) -> TypeRef;
556
557     pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
558     pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
559     pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
560
561     // Operations on other types
562     pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
563     pub fn LLVMRustMetadataTypeInContext(C: ContextRef) -> TypeRef;
564
565     // Operations on all values
566     pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
567     pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
568     pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
569     pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
570     pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
571
572     // Operations on Uses
573     pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
574     pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
575     pub fn LLVMGetUser(U: UseRef) -> ValueRef;
576
577     // Operations on Users
578     pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
579
580     // Operations on constants of any type
581     pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
582     pub fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
583     pub fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
584     // only for isize/vector
585     pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
586     pub fn LLVMIsNull(Val: ValueRef) -> Bool;
587     pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
588
589     // Operations on metadata
590     pub fn LLVMMDStringInContext(C: ContextRef, Str: *const c_char, SLen: c_uint) -> ValueRef;
591     pub fn LLVMMDNodeInContext(C: ContextRef, Vals: *const ValueRef, Count: c_uint) -> ValueRef;
592     pub fn LLVMAddNamedMetadataOperand(M: ModuleRef, Name: *const c_char, Val: ValueRef);
593
594     // Operations on scalar constants
595     pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool) -> ValueRef;
596     pub fn LLVMConstIntOfArbitraryPrecision(IntTy: TypeRef, Wn: c_uint, Ws: *const u64) -> ValueRef;
597     pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
598     pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
599     pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
600     pub fn LLVMRustConstInt128Get(ConstantVal: ValueRef, SExt: bool,
601                                   high: *mut u64, low: *mut u64) -> bool;
602
603
604     // Operations on composite constants
605     pub fn LLVMConstStringInContext(C: ContextRef,
606                                     Str: *const c_char,
607                                     Length: c_uint,
608                                     DontNullTerminate: Bool)
609                                     -> ValueRef;
610     pub fn LLVMConstStructInContext(C: ContextRef,
611                                     ConstantVals: *const ValueRef,
612                                     Count: c_uint,
613                                     Packed: Bool)
614                                     -> ValueRef;
615
616     pub fn LLVMConstArray(ElementTy: TypeRef,
617                           ConstantVals: *const ValueRef,
618                           Length: c_uint)
619                           -> ValueRef;
620     pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint) -> ValueRef;
621
622     // Constant expressions
623     pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
624     pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
625     pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
626     pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
627     pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
628     pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
629     pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
630     pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
631     pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
632     pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
633     pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
634     pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
635     pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
636     pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
637     pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
638     pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
639     pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
640     pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
641     pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
642     pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
643     pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
644     pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
645     pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
646     pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
647     pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
648     pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
649     pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
650     pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
651     pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
652     pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
653     pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
654     pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
655     pub fn LLVMConstIntCast(ConstantVal: ValueRef, ToType: TypeRef, isSigned: Bool) -> ValueRef;
656     pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
657     pub fn LLVMConstExtractValue(AggConstant: ValueRef,
658                                  IdxList: *const c_uint,
659                                  NumIdx: c_uint)
660                                  -> ValueRef;
661     pub fn LLVMConstInlineAsm(Ty: TypeRef,
662                               AsmString: *const c_char,
663                               Constraints: *const c_char,
664                               HasSideEffects: Bool,
665                               IsAlignStack: Bool)
666                               -> ValueRef;
667
668
669     // Operations on global variables, functions, and aliases (globals)
670     pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
671     pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
672     pub fn LLVMRustGetLinkage(Global: ValueRef) -> Linkage;
673     pub fn LLVMRustSetLinkage(Global: ValueRef, RustLinkage: Linkage);
674     pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
675     pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
676     pub fn LLVMRustGetVisibility(Global: ValueRef) -> Visibility;
677     pub fn LLVMRustSetVisibility(Global: ValueRef, Viz: Visibility);
678     pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
679     pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
680     pub fn LLVMSetDLLStorageClass(V: ValueRef, C: DLLStorageClass);
681
682
683     // Operations on global variables
684     pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
685     pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
686     pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
687     pub fn LLVMRustGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
688     pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
689     pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
690     pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
691     pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
692     pub fn LLVMSetInitializer(GlobalVar: ValueRef, ConstantVal: ValueRef);
693     pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
694     pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
695     pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
696     pub fn LLVMRustGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
697
698     // Operations on functions
699     pub fn LLVMAddFunction(M: ModuleRef, Name: *const c_char, FunctionTy: TypeRef) -> ValueRef;
700     pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
701     pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
702     pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
703     pub fn LLVMRustGetOrInsertFunction(M: ModuleRef,
704                                        Name: *const c_char,
705                                        FunctionTy: TypeRef)
706                                        -> ValueRef;
707     pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
708     pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
709     pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, attr: Attribute);
710     pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef,
711                                               index: c_uint,
712                                               Name: *const c_char,
713                                               Value: *const c_char);
714     pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef, index: c_uint, attr: Attribute);
715
716     // Operations on parameters
717     pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
718     pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
719
720     // Operations on basic blocks
721     pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
722     pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
723     pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
724                                          Fn: ValueRef,
725                                          Name: *const c_char)
726                                          -> BasicBlockRef;
727     pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
728
729     // Operations on instructions
730     pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
731     pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
732     pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
733     pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
734
735     // Operations on call sites
736     pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
737     pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef, index: c_uint, attr: Attribute);
738     pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef, index: c_uint, bytes: u64);
739
740     // Operations on load/store instructions (only)
741     pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
742
743     // Operations on phi nodes
744     pub fn LLVMAddIncoming(PhiNode: ValueRef,
745                            IncomingValues: *const ValueRef,
746                            IncomingBlocks: *const BasicBlockRef,
747                            Count: c_uint);
748
749     // Instruction builders
750     pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
751     pub fn LLVMPositionBuilder(Builder: BuilderRef, Block: BasicBlockRef, Instr: ValueRef);
752     pub fn LLVMPositionBuilderBefore(Builder: BuilderRef, Instr: ValueRef);
753     pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef, Block: BasicBlockRef);
754     pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
755     pub fn LLVMDisposeBuilder(Builder: BuilderRef);
756
757     // Metadata
758     pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
759     pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
760     pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
761
762     // Terminators
763     pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
764     pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
765     pub fn LLVMBuildAggregateRet(B: BuilderRef, RetVals: *const ValueRef, N: c_uint) -> ValueRef;
766     pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
767     pub fn LLVMBuildCondBr(B: BuilderRef,
768                            If: ValueRef,
769                            Then: BasicBlockRef,
770                            Else: BasicBlockRef)
771                            -> ValueRef;
772     pub fn LLVMBuildSwitch(B: BuilderRef,
773                            V: ValueRef,
774                            Else: BasicBlockRef,
775                            NumCases: c_uint)
776                            -> ValueRef;
777     pub fn LLVMBuildIndirectBr(B: BuilderRef, Addr: ValueRef, NumDests: c_uint) -> ValueRef;
778     pub fn LLVMRustBuildInvoke(B: BuilderRef,
779                                Fn: ValueRef,
780                                Args: *const ValueRef,
781                                NumArgs: c_uint,
782                                Then: BasicBlockRef,
783                                Catch: BasicBlockRef,
784                                Bundle: OperandBundleDefRef,
785                                Name: *const c_char)
786                                -> ValueRef;
787     pub fn LLVMRustBuildLandingPad(B: BuilderRef,
788                                    Ty: TypeRef,
789                                    PersFn: ValueRef,
790                                    NumClauses: c_uint,
791                                    Name: *const c_char,
792                                    F: ValueRef)
793                                    -> ValueRef;
794     pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
795     pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
796
797     pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
798                                    ParentPad: ValueRef,
799                                    ArgCnt: c_uint,
800                                    Args: *const ValueRef,
801                                    Name: *const c_char)
802                                    -> ValueRef;
803     pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
804                                    CleanupPad: ValueRef,
805                                    UnwindBB: BasicBlockRef)
806                                    -> ValueRef;
807     pub fn LLVMRustBuildCatchPad(B: BuilderRef,
808                                  ParentPad: ValueRef,
809                                  ArgCnt: c_uint,
810                                  Args: *const ValueRef,
811                                  Name: *const c_char)
812                                  -> ValueRef;
813     pub fn LLVMRustBuildCatchRet(B: BuilderRef, Pad: ValueRef, BB: BasicBlockRef) -> ValueRef;
814     pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
815                                     ParentPad: ValueRef,
816                                     BB: BasicBlockRef,
817                                     NumHandlers: c_uint,
818                                     Name: *const c_char)
819                                     -> ValueRef;
820     pub fn LLVMRustAddHandler(CatchSwitch: ValueRef, Handler: BasicBlockRef);
821     pub fn LLVMSetPersonalityFn(Func: ValueRef, Pers: ValueRef);
822
823     // Add a case to the switch instruction
824     pub fn LLVMAddCase(Switch: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef);
825
826     // Add a clause to the landing pad instruction
827     pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
828
829     // Set the cleanup on a landing pad instruction
830     pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
831
832     // Arithmetic
833     pub fn LLVMBuildAdd(B: BuilderRef,
834                         LHS: ValueRef,
835                         RHS: ValueRef,
836                         Name: *const c_char)
837                         -> ValueRef;
838     pub fn LLVMBuildNSWAdd(B: BuilderRef,
839                            LHS: ValueRef,
840                            RHS: ValueRef,
841                            Name: *const c_char)
842                            -> ValueRef;
843     pub fn LLVMBuildNUWAdd(B: BuilderRef,
844                            LHS: ValueRef,
845                            RHS: ValueRef,
846                            Name: *const c_char)
847                            -> ValueRef;
848     pub fn LLVMBuildFAdd(B: BuilderRef,
849                          LHS: ValueRef,
850                          RHS: ValueRef,
851                          Name: *const c_char)
852                          -> ValueRef;
853     pub fn LLVMBuildSub(B: BuilderRef,
854                         LHS: ValueRef,
855                         RHS: ValueRef,
856                         Name: *const c_char)
857                         -> ValueRef;
858     pub fn LLVMBuildNSWSub(B: BuilderRef,
859                            LHS: ValueRef,
860                            RHS: ValueRef,
861                            Name: *const c_char)
862                            -> ValueRef;
863     pub fn LLVMBuildNUWSub(B: BuilderRef,
864                            LHS: ValueRef,
865                            RHS: ValueRef,
866                            Name: *const c_char)
867                            -> ValueRef;
868     pub fn LLVMBuildFSub(B: BuilderRef,
869                          LHS: ValueRef,
870                          RHS: ValueRef,
871                          Name: *const c_char)
872                          -> ValueRef;
873     pub fn LLVMBuildMul(B: BuilderRef,
874                         LHS: ValueRef,
875                         RHS: ValueRef,
876                         Name: *const c_char)
877                         -> ValueRef;
878     pub fn LLVMBuildNSWMul(B: BuilderRef,
879                            LHS: ValueRef,
880                            RHS: ValueRef,
881                            Name: *const c_char)
882                            -> ValueRef;
883     pub fn LLVMBuildNUWMul(B: BuilderRef,
884                            LHS: ValueRef,
885                            RHS: ValueRef,
886                            Name: *const c_char)
887                            -> ValueRef;
888     pub fn LLVMBuildFMul(B: BuilderRef,
889                          LHS: ValueRef,
890                          RHS: ValueRef,
891                          Name: *const c_char)
892                          -> ValueRef;
893     pub fn LLVMBuildUDiv(B: BuilderRef,
894                          LHS: ValueRef,
895                          RHS: ValueRef,
896                          Name: *const c_char)
897                          -> ValueRef;
898     pub fn LLVMBuildSDiv(B: BuilderRef,
899                          LHS: ValueRef,
900                          RHS: ValueRef,
901                          Name: *const c_char)
902                          -> ValueRef;
903     pub fn LLVMBuildExactSDiv(B: BuilderRef,
904                               LHS: ValueRef,
905                               RHS: ValueRef,
906                               Name: *const c_char)
907                               -> ValueRef;
908     pub fn LLVMBuildFDiv(B: BuilderRef,
909                          LHS: ValueRef,
910                          RHS: ValueRef,
911                          Name: *const c_char)
912                          -> ValueRef;
913     pub fn LLVMBuildURem(B: BuilderRef,
914                          LHS: ValueRef,
915                          RHS: ValueRef,
916                          Name: *const c_char)
917                          -> ValueRef;
918     pub fn LLVMBuildSRem(B: BuilderRef,
919                          LHS: ValueRef,
920                          RHS: ValueRef,
921                          Name: *const c_char)
922                          -> ValueRef;
923     pub fn LLVMBuildFRem(B: BuilderRef,
924                          LHS: ValueRef,
925                          RHS: ValueRef,
926                          Name: *const c_char)
927                          -> ValueRef;
928     pub fn LLVMBuildShl(B: BuilderRef,
929                         LHS: ValueRef,
930                         RHS: ValueRef,
931                         Name: *const c_char)
932                         -> ValueRef;
933     pub fn LLVMBuildLShr(B: BuilderRef,
934                          LHS: ValueRef,
935                          RHS: ValueRef,
936                          Name: *const c_char)
937                          -> ValueRef;
938     pub fn LLVMBuildAShr(B: BuilderRef,
939                          LHS: ValueRef,
940                          RHS: ValueRef,
941                          Name: *const c_char)
942                          -> ValueRef;
943     pub fn LLVMBuildAnd(B: BuilderRef,
944                         LHS: ValueRef,
945                         RHS: ValueRef,
946                         Name: *const c_char)
947                         -> ValueRef;
948     pub fn LLVMBuildOr(B: BuilderRef,
949                        LHS: ValueRef,
950                        RHS: ValueRef,
951                        Name: *const c_char)
952                        -> ValueRef;
953     pub fn LLVMBuildXor(B: BuilderRef,
954                         LHS: ValueRef,
955                         RHS: ValueRef,
956                         Name: *const c_char)
957                         -> ValueRef;
958     pub fn LLVMBuildBinOp(B: BuilderRef,
959                           Op: Opcode,
960                           LHS: ValueRef,
961                           RHS: ValueRef,
962                           Name: *const c_char)
963                           -> ValueRef;
964     pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
965     pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
966     pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
967     pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
968     pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
969     pub fn LLVMRustSetHasUnsafeAlgebra(Instr: ValueRef);
970
971     // Memory
972     pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
973     pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
974     pub fn LLVMBuildLoad(B: BuilderRef, PointerVal: ValueRef, Name: *const c_char) -> ValueRef;
975
976     pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef) -> ValueRef;
977
978     pub fn LLVMBuildGEP(B: BuilderRef,
979                         Pointer: ValueRef,
980                         Indices: *const ValueRef,
981                         NumIndices: c_uint,
982                         Name: *const c_char)
983                         -> ValueRef;
984     pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
985                                 Pointer: ValueRef,
986                                 Indices: *const ValueRef,
987                                 NumIndices: c_uint,
988                                 Name: *const c_char)
989                                 -> ValueRef;
990     pub fn LLVMBuildStructGEP(B: BuilderRef,
991                               Pointer: ValueRef,
992                               Idx: c_uint,
993                               Name: *const c_char)
994                               -> ValueRef;
995     pub fn LLVMBuildGlobalString(B: BuilderRef,
996                                  Str: *const c_char,
997                                  Name: *const c_char)
998                                  -> ValueRef;
999     pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1000                                     Str: *const c_char,
1001                                     Name: *const c_char)
1002                                     -> ValueRef;
1003
1004     // Casts
1005     pub fn LLVMBuildTrunc(B: BuilderRef,
1006                           Val: ValueRef,
1007                           DestTy: TypeRef,
1008                           Name: *const c_char)
1009                           -> ValueRef;
1010     pub fn LLVMBuildZExt(B: BuilderRef,
1011                          Val: ValueRef,
1012                          DestTy: TypeRef,
1013                          Name: *const c_char)
1014                          -> ValueRef;
1015     pub fn LLVMBuildSExt(B: BuilderRef,
1016                          Val: ValueRef,
1017                          DestTy: TypeRef,
1018                          Name: *const c_char)
1019                          -> ValueRef;
1020     pub fn LLVMBuildFPToUI(B: BuilderRef,
1021                            Val: ValueRef,
1022                            DestTy: TypeRef,
1023                            Name: *const c_char)
1024                            -> ValueRef;
1025     pub fn LLVMBuildFPToSI(B: BuilderRef,
1026                            Val: ValueRef,
1027                            DestTy: TypeRef,
1028                            Name: *const c_char)
1029                            -> ValueRef;
1030     pub fn LLVMBuildUIToFP(B: BuilderRef,
1031                            Val: ValueRef,
1032                            DestTy: TypeRef,
1033                            Name: *const c_char)
1034                            -> ValueRef;
1035     pub fn LLVMBuildSIToFP(B: BuilderRef,
1036                            Val: ValueRef,
1037                            DestTy: TypeRef,
1038                            Name: *const c_char)
1039                            -> ValueRef;
1040     pub fn LLVMBuildFPTrunc(B: BuilderRef,
1041                             Val: ValueRef,
1042                             DestTy: TypeRef,
1043                             Name: *const c_char)
1044                             -> ValueRef;
1045     pub fn LLVMBuildFPExt(B: BuilderRef,
1046                           Val: ValueRef,
1047                           DestTy: TypeRef,
1048                           Name: *const c_char)
1049                           -> ValueRef;
1050     pub fn LLVMBuildPtrToInt(B: BuilderRef,
1051                              Val: ValueRef,
1052                              DestTy: TypeRef,
1053                              Name: *const c_char)
1054                              -> ValueRef;
1055     pub fn LLVMBuildIntToPtr(B: BuilderRef,
1056                              Val: ValueRef,
1057                              DestTy: TypeRef,
1058                              Name: *const c_char)
1059                              -> ValueRef;
1060     pub fn LLVMBuildBitCast(B: BuilderRef,
1061                             Val: ValueRef,
1062                             DestTy: TypeRef,
1063                             Name: *const c_char)
1064                             -> ValueRef;
1065     pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1066                                   Val: ValueRef,
1067                                   DestTy: TypeRef,
1068                                   Name: *const c_char)
1069                                   -> ValueRef;
1070     pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1071                                   Val: ValueRef,
1072                                   DestTy: TypeRef,
1073                                   Name: *const c_char)
1074                                   -> ValueRef;
1075     pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1076                                    Val: ValueRef,
1077                                    DestTy: TypeRef,
1078                                    Name: *const c_char)
1079                                    -> ValueRef;
1080     pub fn LLVMBuildCast(B: BuilderRef,
1081                          Op: Opcode,
1082                          Val: ValueRef,
1083                          DestTy: TypeRef,
1084                          Name: *const c_char)
1085                          -> ValueRef;
1086     pub fn LLVMBuildPointerCast(B: BuilderRef,
1087                                 Val: ValueRef,
1088                                 DestTy: TypeRef,
1089                                 Name: *const c_char)
1090                                 -> ValueRef;
1091     pub fn LLVMRustBuildIntCast(B: BuilderRef,
1092                                 Val: ValueRef,
1093                                 DestTy: TypeRef,
1094                                 IsSized: bool)
1095                                 -> ValueRef;
1096     pub fn LLVMBuildFPCast(B: BuilderRef,
1097                            Val: ValueRef,
1098                            DestTy: TypeRef,
1099                            Name: *const c_char)
1100                            -> ValueRef;
1101
1102     // Comparisons
1103     pub fn LLVMBuildICmp(B: BuilderRef,
1104                          Op: c_uint,
1105                          LHS: ValueRef,
1106                          RHS: ValueRef,
1107                          Name: *const c_char)
1108                          -> ValueRef;
1109     pub fn LLVMBuildFCmp(B: BuilderRef,
1110                          Op: c_uint,
1111                          LHS: ValueRef,
1112                          RHS: ValueRef,
1113                          Name: *const c_char)
1114                          -> ValueRef;
1115
1116     // Miscellaneous instructions
1117     pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
1118     pub fn LLVMRustBuildCall(B: BuilderRef,
1119                              Fn: ValueRef,
1120                              Args: *const ValueRef,
1121                              NumArgs: c_uint,
1122                              Bundle: OperandBundleDefRef,
1123                              Name: *const c_char)
1124                              -> ValueRef;
1125     pub fn LLVMBuildSelect(B: BuilderRef,
1126                            If: ValueRef,
1127                            Then: ValueRef,
1128                            Else: ValueRef,
1129                            Name: *const c_char)
1130                            -> ValueRef;
1131     pub fn LLVMBuildVAArg(B: BuilderRef,
1132                           list: ValueRef,
1133                           Ty: TypeRef,
1134                           Name: *const c_char)
1135                           -> ValueRef;
1136     pub fn LLVMBuildExtractElement(B: BuilderRef,
1137                                    VecVal: ValueRef,
1138                                    Index: ValueRef,
1139                                    Name: *const c_char)
1140                                    -> ValueRef;
1141     pub fn LLVMBuildInsertElement(B: BuilderRef,
1142                                   VecVal: ValueRef,
1143                                   EltVal: ValueRef,
1144                                   Index: ValueRef,
1145                                   Name: *const c_char)
1146                                   -> ValueRef;
1147     pub fn LLVMBuildShuffleVector(B: BuilderRef,
1148                                   V1: ValueRef,
1149                                   V2: ValueRef,
1150                                   Mask: ValueRef,
1151                                   Name: *const c_char)
1152                                   -> ValueRef;
1153     pub fn LLVMBuildExtractValue(B: BuilderRef,
1154                                  AggVal: ValueRef,
1155                                  Index: c_uint,
1156                                  Name: *const c_char)
1157                                  -> ValueRef;
1158     pub fn LLVMBuildInsertValue(B: BuilderRef,
1159                                 AggVal: ValueRef,
1160                                 EltVal: ValueRef,
1161                                 Index: c_uint,
1162                                 Name: *const c_char)
1163                                 -> ValueRef;
1164
1165     pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1166     pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1167     pub fn LLVMBuildPtrDiff(B: BuilderRef,
1168                             LHS: ValueRef,
1169                             RHS: ValueRef,
1170                             Name: *const c_char)
1171                             -> ValueRef;
1172
1173     // Atomic Operations
1174     pub fn LLVMRustBuildAtomicLoad(B: BuilderRef,
1175                                    PointerVal: ValueRef,
1176                                    Name: *const c_char,
1177                                    Order: AtomicOrdering,
1178                                    Alignment: c_uint)
1179                                    -> ValueRef;
1180
1181     pub fn LLVMRustBuildAtomicStore(B: BuilderRef,
1182                                     Val: ValueRef,
1183                                     Ptr: ValueRef,
1184                                     Order: AtomicOrdering,
1185                                     Alignment: c_uint)
1186                                     -> ValueRef;
1187
1188     pub fn LLVMRustBuildAtomicCmpXchg(B: BuilderRef,
1189                                       LHS: ValueRef,
1190                                       CMP: ValueRef,
1191                                       RHS: ValueRef,
1192                                       Order: AtomicOrdering,
1193                                       FailureOrder: AtomicOrdering,
1194                                       Weak: Bool)
1195                                       -> ValueRef;
1196
1197     pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1198                               Op: AtomicRmwBinOp,
1199                               LHS: ValueRef,
1200                               RHS: ValueRef,
1201                               Order: AtomicOrdering,
1202                               SingleThreaded: Bool)
1203                               -> ValueRef;
1204
1205     pub fn LLVMRustBuildAtomicFence(B: BuilderRef,
1206                                     Order: AtomicOrdering,
1207                                     Scope: SynchronizationScope);
1208
1209
1210     // Selected entries from the downcasts.
1211     pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1212     pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1213
1214     /// Writes a module to the specified path. Returns 0 on success.
1215     pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1216
1217     /// Creates target data from a target layout string.
1218     pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1219     /// Number of bytes clobbered when doing a Store to *T.
1220     pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1221
1222     /// Distance between successive elements in an array of T. Includes ABI padding.
1223     pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1224
1225     /// Returns the preferred alignment of a type.
1226     pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1227     /// Returns the minimum alignment of a type.
1228     pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1229
1230     /// Computes the byte offset of the indexed struct element for a
1231     /// target.
1232     pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1233                                StructTy: TypeRef,
1234                                Element: c_uint)
1235                                -> c_ulonglong;
1236
1237     /// Disposes target data.
1238     pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1239
1240     /// Creates a pass manager.
1241     pub fn LLVMCreatePassManager() -> PassManagerRef;
1242
1243     /// Creates a function-by-function pass manager
1244     pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef) -> PassManagerRef;
1245
1246     /// Disposes a pass manager.
1247     pub fn LLVMDisposePassManager(PM: PassManagerRef);
1248
1249     /// Runs a pass manager on a module.
1250     pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1251
1252     pub fn LLVMInitializePasses();
1253
1254     pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1255     pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1256     pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef, Value: Bool);
1257     pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: PassManagerBuilderRef, Value: Bool);
1258     pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: PassManagerBuilderRef,
1259                                                          threshold: c_uint);
1260     pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: PassManagerBuilderRef,
1261                                                            PM: PassManagerRef);
1262
1263     pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: PassManagerBuilderRef,
1264                                                              PM: PassManagerRef);
1265     pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: PassManagerBuilderRef,
1266                                                         PM: PassManagerRef,
1267                                                         Internalize: Bool,
1268                                                         RunInliner: Bool);
1269
1270     // Stuff that's in rustllvm/ because it's not upstream yet.
1271
1272     /// Opens an object file.
1273     pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1274     /// Closes an object file.
1275     pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1276
1277     /// Enumerates the sections in an object file.
1278     pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1279     /// Destroys a section iterator.
1280     pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1281     /// Returns true if the section iterator is at the end of the section
1282     /// list:
1283     pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef, SI: SectionIteratorRef) -> Bool;
1284     /// Moves the section iterator to point to the next section.
1285     pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1286     /// Returns the current section size.
1287     pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1288     /// Returns the current section contents as a string buffer.
1289     pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1290
1291     /// Reads the given file and returns it as a memory buffer. Use
1292     /// LLVMDisposeMemoryBuffer() to get rid of it.
1293     pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char) -> MemoryBufferRef;
1294
1295     pub fn LLVMStartMultithreaded() -> Bool;
1296
1297     /// Returns a string describing the last error caused by an LLVMRust* call.
1298     pub fn LLVMRustGetLastError() -> *const c_char;
1299
1300     /// Print the pass timings since static dtors aren't picking them up.
1301     pub fn LLVMRustPrintPassTimings();
1302
1303     pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1304
1305     pub fn LLVMStructSetBody(StructTy: TypeRef,
1306                              ElementTypes: *const TypeRef,
1307                              ElementCount: c_uint,
1308                              Packed: Bool);
1309
1310     pub fn LLVMConstNamedStruct(S: TypeRef,
1311                                 ConstantVals: *const ValueRef,
1312                                 Count: c_uint)
1313                                 -> ValueRef;
1314
1315     /// Enables LLVM debug output.
1316     pub fn LLVMRustSetDebug(Enabled: c_int);
1317
1318     /// Prepares inline assembly.
1319     pub fn LLVMRustInlineAsm(Ty: TypeRef,
1320                              AsmString: *const c_char,
1321                              Constraints: *const c_char,
1322                              SideEffects: Bool,
1323                              AlignStack: Bool,
1324                              Dialect: AsmDialect)
1325                              -> ValueRef;
1326
1327     pub fn LLVMRustDebugMetadataVersion() -> u32;
1328     pub fn LLVMRustVersionMajor() -> u32;
1329     pub fn LLVMRustVersionMinor() -> u32;
1330
1331     pub fn LLVMRustAddModuleFlag(M: ModuleRef, name: *const c_char, value: u32);
1332
1333     pub fn LLVMRustMetadataAsValue(C: ContextRef, MD: MetadataRef) -> ValueRef;
1334
1335     pub fn LLVMRustDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1336
1337     pub fn LLVMRustDIBuilderDispose(Builder: DIBuilderRef);
1338
1339     pub fn LLVMRustDIBuilderFinalize(Builder: DIBuilderRef);
1340
1341     pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1342                                               Lang: c_uint,
1343                                               File: DIFile,
1344                                               Producer: *const c_char,
1345                                               isOptimized: bool,
1346                                               Flags: *const c_char,
1347                                               RuntimeVer: c_uint,
1348                                               SplitName: *const c_char)
1349                                               -> DIDescriptor;
1350
1351     pub fn LLVMRustDIBuilderCreateFile(Builder: DIBuilderRef,
1352                                        Filename: *const c_char,
1353                                        Directory: *const c_char)
1354                                        -> DIFile;
1355
1356     pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1357                                                  File: DIFile,
1358                                                  ParameterTypes: DIArray)
1359                                                  -> DICompositeType;
1360
1361     pub fn LLVMRustDIBuilderCreateFunction(Builder: DIBuilderRef,
1362                                            Scope: DIDescriptor,
1363                                            Name: *const c_char,
1364                                            LinkageName: *const c_char,
1365                                            File: DIFile,
1366                                            LineNo: c_uint,
1367                                            Ty: DIType,
1368                                            isLocalToUnit: bool,
1369                                            isDefinition: bool,
1370                                            ScopeLine: c_uint,
1371                                            Flags: DIFlags,
1372                                            isOptimized: bool,
1373                                            Fn: ValueRef,
1374                                            TParam: DIArray,
1375                                            Decl: DIDescriptor)
1376                                            -> DISubprogram;
1377
1378     pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
1379                                             Name: *const c_char,
1380                                             SizeInBits: u64,
1381                                             AlignInBits: u32,
1382                                             Encoding: c_uint)
1383                                             -> DIBasicType;
1384
1385     pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
1386                                               PointeeTy: DIType,
1387                                               SizeInBits: u64,
1388                                               AlignInBits: u32,
1389                                               Name: *const c_char)
1390                                               -> DIDerivedType;
1391
1392     pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef,
1393                                              Scope: DIDescriptor,
1394                                              Name: *const c_char,
1395                                              File: DIFile,
1396                                              LineNumber: c_uint,
1397                                              SizeInBits: u64,
1398                                              AlignInBits: u32,
1399                                              Flags: DIFlags,
1400                                              DerivedFrom: DIType,
1401                                              Elements: DIArray,
1402                                              RunTimeLang: c_uint,
1403                                              VTableHolder: DIType,
1404                                              UniqueId: *const c_char)
1405                                              -> DICompositeType;
1406
1407     pub fn LLVMRustDIBuilderCreateMemberType(Builder: DIBuilderRef,
1408                                              Scope: DIDescriptor,
1409                                              Name: *const c_char,
1410                                              File: DIFile,
1411                                              LineNo: c_uint,
1412                                              SizeInBits: u64,
1413                                              AlignInBits: u32,
1414                                              OffsetInBits: u64,
1415                                              Flags: DIFlags,
1416                                              Ty: DIType)
1417                                              -> DIDerivedType;
1418
1419     pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1420                                                Scope: DIScope,
1421                                                File: DIFile,
1422                                                Line: c_uint,
1423                                                Col: c_uint)
1424                                                -> DILexicalBlock;
1425
1426     pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: DIBuilderRef,
1427                                                    Scope: DIScope,
1428                                                    File: DIFile)
1429                                                    -> DILexicalBlock;
1430
1431     pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1432                                                  Context: DIScope,
1433                                                  Name: *const c_char,
1434                                                  LinkageName: *const c_char,
1435                                                  File: DIFile,
1436                                                  LineNo: c_uint,
1437                                                  Ty: DIType,
1438                                                  isLocalToUnit: bool,
1439                                                  Val: ValueRef,
1440                                                  Decl: DIDescriptor,
1441                                                  AlignInBits: u32)
1442                                                  -> DIGlobalVariable;
1443
1444     pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
1445                                            Tag: c_uint,
1446                                            Scope: DIDescriptor,
1447                                            Name: *const c_char,
1448                                            File: DIFile,
1449                                            LineNo: c_uint,
1450                                            Ty: DIType,
1451                                            AlwaysPreserve: bool,
1452                                            Flags: DIFlags,
1453                                            ArgNo: c_uint,
1454                                            AlignInBits: u32)
1455                                            -> DIVariable;
1456
1457     pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
1458                                             Size: u64,
1459                                             AlignInBits: u32,
1460                                             Ty: DIType,
1461                                             Subscripts: DIArray)
1462                                             -> DIType;
1463
1464     pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
1465                                              Size: u64,
1466                                              AlignInBits: u32,
1467                                              Ty: DIType,
1468                                              Subscripts: DIArray)
1469                                              -> DIType;
1470
1471     pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1472                                                 Lo: i64,
1473                                                 Count: i64)
1474                                                 -> DISubrange;
1475
1476     pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1477                                              Ptr: *const DIDescriptor,
1478                                              Count: c_uint)
1479                                              -> DIArray;
1480
1481     pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1482                                                Val: ValueRef,
1483                                                VarInfo: DIVariable,
1484                                                AddrOps: *const i64,
1485                                                AddrOpsCount: c_uint,
1486                                                DL: ValueRef,
1487                                                InsertAtEnd: BasicBlockRef)
1488                                                -> ValueRef;
1489
1490     pub fn LLVMRustDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1491                                              Name: *const c_char,
1492                                              Val: u64)
1493                                              -> DIEnumerator;
1494
1495     pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1496                                                   Scope: DIScope,
1497                                                   Name: *const c_char,
1498                                                   File: DIFile,
1499                                                   LineNumber: c_uint,
1500                                                   SizeInBits: u64,
1501                                                   AlignInBits: u32,
1502                                                   Elements: DIArray,
1503                                                   ClassType: DIType)
1504                                                   -> DIType;
1505
1506     pub fn LLVMRustDIBuilderCreateUnionType(Builder: DIBuilderRef,
1507                                             Scope: DIScope,
1508                                             Name: *const c_char,
1509                                             File: DIFile,
1510                                             LineNumber: c_uint,
1511                                             SizeInBits: u64,
1512                                             AlignInBits: u32,
1513                                             Flags: DIFlags,
1514                                             Elements: DIArray,
1515                                             RunTimeLang: c_uint,
1516                                             UniqueId: *const c_char)
1517                                             -> DIType;
1518
1519     pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1520
1521     pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1522                                                         Scope: DIScope,
1523                                                         Name: *const c_char,
1524                                                         Ty: DIType,
1525                                                         File: DIFile,
1526                                                         LineNo: c_uint,
1527                                                         ColumnNo: c_uint)
1528                                                         -> DITemplateTypeParameter;
1529
1530
1531     pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1532                                             Scope: DIScope,
1533                                             Name: *const c_char,
1534                                             File: DIFile,
1535                                             LineNo: c_uint)
1536                                             -> DINameSpace;
1537     pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1538                                                CompositeType: DIType,
1539                                                TypeArray: DIArray);
1540
1541
1542     pub fn LLVMRustDIBuilderCreateDebugLocation(Context: ContextRef,
1543                                                 Line: c_uint,
1544                                                 Column: c_uint,
1545                                                 Scope: DIScope,
1546                                                 InlinedAt: MetadataRef)
1547                                                 -> ValueRef;
1548     pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1549     pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
1550
1551     pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
1552     pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1553
1554     pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
1555
1556     pub fn LLVMRustPassKind(Pass: PassRef) -> PassKind;
1557     pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
1558     pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
1559
1560     pub fn LLVMRustHasFeature(T: TargetMachineRef, s: *const c_char) -> bool;
1561
1562     pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef);
1563     pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef);
1564
1565     pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1566                                        CPU: *const c_char,
1567                                        Features: *const c_char,
1568                                        Model: CodeModel,
1569                                        Reloc: RelocMode,
1570                                        Level: CodeGenOptLevel,
1571                                        UseSoftFP: bool,
1572                                        PositionIndependentExecutable: bool,
1573                                        FunctionSections: bool,
1574                                        DataSections: bool)
1575                                        -> TargetMachineRef;
1576     pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1577     pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef, PM: PassManagerRef, M: ModuleRef);
1578     pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1579                                          M: ModuleRef,
1580                                          DisableSimplifyLibCalls: bool);
1581     pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
1582                                                OptLevel: CodeGenOptLevel,
1583                                                MergeFunctions: bool,
1584                                                SLPVectorize: bool,
1585                                                LoopVectorize: bool);
1586     pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef,
1587                                   M: ModuleRef,
1588                                   DisableSimplifyLibCalls: bool);
1589     pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1590     pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1591                                    PM: PassManagerRef,
1592                                    M: ModuleRef,
1593                                    Output: *const c_char,
1594                                    FileType: FileType)
1595                                    -> LLVMRustResult;
1596     pub fn LLVMRustPrintModule(PM: PassManagerRef, M: ModuleRef, Output: *const c_char);
1597     pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1598     pub fn LLVMRustPrintPasses();
1599     pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1600     pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef, AddLifetimes: bool);
1601     pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef, bc: *const c_char, len: size_t) -> bool;
1602     pub fn LLVMRustRunRestrictionPass(M: ModuleRef, syms: *const *const c_char, len: size_t);
1603     pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1604
1605     pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1606     pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
1607     pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
1608     pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1609     pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1610     pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
1611     pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
1612     pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1613
1614     pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, data: *mut *const c_char) -> size_t;
1615
1616     pub fn LLVMRustWriteTwineToString(T: TwineRef, s: RustStringRef);
1617
1618     pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
1619                                            Handler: DiagnosticHandler,
1620                                            DiagnosticContext: *mut c_void);
1621
1622     pub fn LLVMRustUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
1623                                                 pass_name_out: RustStringRef,
1624                                                 function_out: *mut ValueRef,
1625                                                 debugloc_out: *mut DebugLocRef,
1626                                                 message_out: RustStringRef);
1627     pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
1628                                              cookie_out: *mut c_uint,
1629                                              message_out: *mut TwineRef,
1630                                              instruction_out: *mut ValueRef);
1631
1632     pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
1633     pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
1634
1635     pub fn LLVMRustWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
1636
1637     pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef,
1638                                                  H: InlineAsmDiagHandler,
1639                                                  CX: *mut c_void);
1640
1641     pub fn LLVMRustWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
1642
1643     pub fn LLVMRustWriteArchive(Dst: *const c_char,
1644                                 NumMembers: size_t,
1645                                 Members: *const RustArchiveMemberRef,
1646                                 WriteSymbtab: bool,
1647                                 Kind: ArchiveKind)
1648                                 -> LLVMRustResult;
1649     pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1650                                     Name: *const c_char,
1651                                     Child: ArchiveChildRef)
1652                                     -> RustArchiveMemberRef;
1653     pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
1654
1655     pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef, TM: TargetMachineRef);
1656     pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
1657
1658     pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1659                                          Inputs: *const ValueRef,
1660                                          NumInputs: c_uint)
1661                                          -> OperandBundleDefRef;
1662     pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
1663
1664     pub fn LLVMRustPositionBuilderAtStart(B: BuilderRef, BB: BasicBlockRef);
1665
1666     pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
1667     pub fn LLVMRustUnsetComdat(V: ValueRef);
1668     pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
1669 }