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