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