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