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