]> git.lizzy.rs Git - rust.git/blob - src/librustc_llvm/ffi.rs
50c68d5e75eef18602b86d622119474339ade5a8
[rust.git] / src / librustc_llvm / ffi.rs
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use debuginfo::{DIBuilderRef, DIDescriptor,
12                 DIFile, DILexicalBlock, DISubprogram, DIType,
13                 DIBasicType, DIDerivedType, DICompositeType, DIScope,
14                 DIVariable, DIGlobalVariable, DIArray, DISubrange,
15                 DITemplateTypeParameter, DIEnumerator, DINameSpace};
16
17 use libc::{c_uint, c_int, size_t, c_char};
18 use libc::{c_longlong, c_ulonglong, c_void};
19
20 use RustStringRef;
21
22 pub type Opcode = u32;
23 pub type Bool = c_uint;
24
25 pub const True: Bool = 1 as Bool;
26 pub const False: Bool = 0 as Bool;
27
28 #[derive(Copy, Clone, PartialEq)]
29 #[repr(C)]
30 pub enum LLVMRustResult {
31     Success,
32     Failure,
33 }
34 // Consts for the LLVM CallConv type, pre-cast to usize.
35
36 /// LLVM CallingConv::ID. Should we wrap this?
37 #[derive(Copy, Clone, PartialEq)]
38 #[repr(C)]
39 pub enum CallConv {
40     CCallConv = 0,
41     FastCallConv = 8,
42     ColdCallConv = 9,
43     X86StdcallCallConv = 64,
44     X86FastcallCallConv = 65,
45     X86_64_SysV = 78,
46     X86_64_Win64 = 79,
47     X86_VectorCall = 80
48 }
49
50 /// LLVMRustLinkage
51 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
52 #[repr(C)]
53 pub enum Linkage {
54     ExternalLinkage = 0,
55     AvailableExternallyLinkage = 1,
56     LinkOnceAnyLinkage = 2,
57     LinkOnceODRLinkage = 3,
58     WeakAnyLinkage = 4,
59     WeakODRLinkage = 5,
60     AppendingLinkage = 6,
61     InternalLinkage = 7,
62     PrivateLinkage = 8,
63     ExternalWeakLinkage = 9,
64     CommonLinkage = 10,
65 }
66
67 /// LLVMDiagnosticSeverity
68 #[derive(Copy, Clone, Debug)]
69 #[repr(C)]
70 pub enum DiagnosticSeverity {
71     Error = 0,
72     Warning = 1,
73     Remark = 2,
74     Note = 3,
75 }
76
77 /// LLVMDLLStorageClass
78 #[derive(Copy, Clone)]
79 #[repr(C)]
80 pub enum DLLStorageClass {
81   Default   = 0,
82   DllImport = 1, /* Function to be imported from DLL. */
83   DllExport = 2, /* Function to be accessible from DLL. */
84 }
85
86 bitflags! {
87     #[derive(Default, Debug)]
88     flags Attribute : u64 {
89         const ZExt            = 1 << 0,
90         const SExt            = 1 << 1,
91         const NoReturn        = 1 << 2,
92         const InReg           = 1 << 3,
93         const StructRet       = 1 << 4,
94         const NoUnwind        = 1 << 5,
95         const NoAlias         = 1 << 6,
96         const ByVal           = 1 << 7,
97         const Nest            = 1 << 8,
98         const ReadNone        = 1 << 9,
99         const ReadOnly        = 1 << 10,
100         const NoInline        = 1 << 11,
101         const AlwaysInline    = 1 << 12,
102         const OptimizeForSize = 1 << 13,
103         const StackProtect    = 1 << 14,
104         const StackProtectReq = 1 << 15,
105         const NoCapture       = 1 << 21,
106         const NoRedZone       = 1 << 22,
107         const NoImplicitFloat = 1 << 23,
108         const Naked           = 1 << 24,
109         const InlineHint      = 1 << 25,
110         const ReturnsTwice    = 1 << 29,
111         const UWTable         = 1 << 30,
112         const NonLazyBind     = 1 << 31,
113
114         // Some of these are missing from the LLVM C API, the rest are
115         // present, but commented out, and preceded by the following warning:
116         // FIXME: These attributes are currently not included in the C API as
117         // a temporary measure until the API/ABI impact to the C API is understood
118         // and the path forward agreed upon.
119         const SanitizeAddress = 1 << 32,
120         const MinSize         = 1 << 33,
121         const NoDuplicate     = 1 << 34,
122         const StackProtectStrong = 1 << 35,
123         const SanitizeThread  = 1 << 36,
124         const SanitizeMemory  = 1 << 37,
125         const NoBuiltin       = 1 << 38,
126         const Returned        = 1 << 39,
127         const Cold            = 1 << 40,
128         const Builtin         = 1 << 41,
129         const OptimizeNone    = 1 << 42,
130         const InAlloca        = 1 << 43,
131         const NonNull         = 1 << 44,
132         const JumpTable       = 1 << 45,
133         const Convergent      = 1 << 46,
134         const SafeStack       = 1 << 47,
135         const NoRecurse       = 1 << 48,
136         const InaccessibleMemOnly         = 1 << 49,
137         const InaccessibleMemOrArgMemOnly = 1 << 50,
138     }
139 }
140
141 /// LLVMIntPredicate
142 #[derive(Copy, Clone)]
143 #[repr(C)]
144 pub enum IntPredicate {
145     IntEQ = 32,
146     IntNE = 33,
147     IntUGT = 34,
148     IntUGE = 35,
149     IntULT = 36,
150     IntULE = 37,
151     IntSGT = 38,
152     IntSGE = 39,
153     IntSLT = 40,
154     IntSLE = 41,
155 }
156
157 /// LLVMRealPredicate
158 #[derive(Copy, Clone)]
159 #[repr(C)]
160 pub enum RealPredicate {
161     RealPredicateFalse = 0,
162     RealOEQ = 1,
163     RealOGT = 2,
164     RealOGE = 3,
165     RealOLT = 4,
166     RealOLE = 5,
167     RealONE = 6,
168     RealORD = 7,
169     RealUNO = 8,
170     RealUEQ = 9,
171     RealUGT = 10,
172     RealUGE = 11,
173     RealULT = 12,
174     RealULE = 13,
175     RealUNE = 14,
176     RealPredicateTrue = 15,
177 }
178
179 /// LLVMTypeKind
180 #[derive(Copy, Clone, PartialEq, Debug)]
181 #[repr(C)]
182 pub enum TypeKind {
183     Void      = 0,
184     Half      = 1,
185     Float     = 2,
186     Double    = 3,
187     X86_FP80  = 4,
188     FP128     = 5,
189     PPC_FP128 = 6,
190     Label     = 7,
191     Integer   = 8,
192     Function  = 9,
193     Struct    = 10,
194     Array     = 11,
195     Pointer   = 12,
196     Vector    = 13,
197     Metadata  = 14,
198     X86_MMX   = 15,
199     Token     = 16,
200 }
201
202 /// LLVMAtomicRmwBinOp
203 #[derive(Copy, Clone)]
204 #[repr(C)]
205 pub enum AtomicRmwBinOp {
206     AtomicXchg = 0,
207     AtomicAdd  = 1,
208     AtomicSub  = 2,
209     AtomicAnd  = 3,
210     AtomicNand = 4,
211     AtomicOr   = 5,
212     AtomicXor  = 6,
213     AtomicMax  = 7,
214     AtomicMin  = 8,
215     AtomicUMax = 9,
216     AtomicUMin = 10,
217 }
218
219 /// LLVMAtomicOrdering
220 #[derive(Copy, Clone)]
221 #[repr(C)]
222 pub enum AtomicOrdering {
223     NotAtomic = 0,
224     Unordered = 1,
225     Monotonic = 2,
226     // Consume = 3,  // Not specified yet.
227     Acquire = 4,
228     Release = 5,
229     AcquireRelease = 6,
230     SequentiallyConsistent = 7
231 }
232
233 /// LLVMRustSynchronizationScope
234 #[derive(Copy, Clone)]
235 #[repr(C)]
236 pub enum SynchronizationScope {
237     Other,
238     SingleThread,
239     CrossThread,
240 }
241
242 /// LLVMRustFileType
243 #[derive(Copy, Clone)]
244 #[repr(C)]
245 pub enum FileType {
246     Other,
247     AssemblyFile,
248     ObjectFile,
249 }
250
251 /// LLVMMetadataType
252 #[derive(Copy, Clone)]
253 #[repr(C)]
254 pub enum MetadataType {
255     MD_dbg = 0,
256     MD_tbaa = 1,
257     MD_prof = 2,
258     MD_fpmath = 3,
259     MD_range = 4,
260     MD_tbaa_struct = 5,
261     MD_invariant_load = 6,
262     MD_alias_scope = 7,
263     MD_noalias = 8,
264     MD_nontemporal = 9,
265     MD_mem_parallel_loop_access = 10,
266     MD_nonnull = 11,
267 }
268
269 /// LLVMRustAsmDialect
270 #[derive(Copy, Clone)]
271 #[repr(C)]
272 pub enum AsmDialect {
273     Other,
274     Att,
275     Intel,
276 }
277
278 /// LLVMRustCodeGenOptLevel
279 #[derive(Copy, Clone, PartialEq)]
280 #[repr(C)]
281 pub enum CodeGenOptLevel {
282     Other,
283     None,
284     Less,
285     Default,
286     Aggressive,
287 }
288
289 /// LLVMRelocMode
290 #[derive(Copy, Clone, PartialEq)]
291 #[repr(C)]
292 pub enum RelocMode {
293     Default = 0,
294     Static = 1,
295     PIC = 2,
296     DynamicNoPic = 3,
297 }
298
299 /// LLVMRustCodeModel
300 #[derive(Copy, Clone)]
301 #[repr(C)]
302 pub enum CodeModel {
303     Other,
304     Default,
305     JITDefault,
306     Small,
307     Kernel,
308     Medium,
309     Large,
310 }
311
312 /// LLVMRustDiagnosticKind
313 #[derive(Copy, Clone)]
314 #[repr(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 }
329
330 /// LLVMRustArchiveKind
331 #[derive(Copy, Clone)]
332 #[repr(C)]
333 pub enum ArchiveKind {
334     Other,
335     K_GNU,
336     K_MIPS64,
337     K_BSD,
338     K_COFF,
339 }
340
341 /// LLVMRustPassKind
342 #[derive(Copy, Clone, PartialEq, Debug)]
343 #[repr(C)]
344 pub enum PassKind {
345     Other,
346     Function,
347     Module,
348 }
349
350 // Opaque pointer types
351 #[allow(missing_copy_implementations)]
352 pub enum Module_opaque {}
353 pub type ModuleRef = *mut Module_opaque;
354 #[allow(missing_copy_implementations)]
355 pub enum Context_opaque {}
356 pub type ContextRef = *mut Context_opaque;
357 #[allow(missing_copy_implementations)]
358 pub enum Type_opaque {}
359 pub type TypeRef = *mut Type_opaque;
360 #[allow(missing_copy_implementations)]
361 pub enum Value_opaque {}
362 pub type ValueRef = *mut Value_opaque;
363 #[allow(missing_copy_implementations)]
364 pub enum Metadata_opaque {}
365 pub type MetadataRef = *mut Metadata_opaque;
366 #[allow(missing_copy_implementations)]
367 pub enum BasicBlock_opaque {}
368 pub type BasicBlockRef = *mut BasicBlock_opaque;
369 #[allow(missing_copy_implementations)]
370 pub enum Builder_opaque {}
371 pub type BuilderRef = *mut Builder_opaque;
372 #[allow(missing_copy_implementations)]
373 pub enum ExecutionEngine_opaque {}
374 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
375 #[allow(missing_copy_implementations)]
376 pub enum MemoryBuffer_opaque {}
377 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
378 #[allow(missing_copy_implementations)]
379 pub enum PassManager_opaque {}
380 pub type PassManagerRef = *mut PassManager_opaque;
381 #[allow(missing_copy_implementations)]
382 pub enum PassManagerBuilder_opaque {}
383 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
384 #[allow(missing_copy_implementations)]
385 pub enum Use_opaque {}
386 pub type UseRef = *mut Use_opaque;
387 #[allow(missing_copy_implementations)]
388 pub enum TargetData_opaque {}
389 pub type TargetDataRef = *mut TargetData_opaque;
390 #[allow(missing_copy_implementations)]
391 pub enum ObjectFile_opaque {}
392 pub type ObjectFileRef = *mut ObjectFile_opaque;
393 #[allow(missing_copy_implementations)]
394 pub enum SectionIterator_opaque {}
395 pub type SectionIteratorRef = *mut SectionIterator_opaque;
396 #[allow(missing_copy_implementations)]
397 pub enum Pass_opaque {}
398 pub type PassRef = *mut Pass_opaque;
399 #[allow(missing_copy_implementations)]
400 pub enum TargetMachine_opaque {}
401 pub type TargetMachineRef = *mut TargetMachine_opaque;
402 pub enum Archive_opaque {}
403 pub type ArchiveRef = *mut Archive_opaque;
404 pub enum ArchiveIterator_opaque {}
405 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
406 pub enum ArchiveChild_opaque {}
407 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
408 #[allow(missing_copy_implementations)]
409 pub enum Twine_opaque {}
410 pub type TwineRef = *mut Twine_opaque;
411 #[allow(missing_copy_implementations)]
412 pub enum DiagnosticInfo_opaque {}
413 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
414 #[allow(missing_copy_implementations)]
415 pub enum DebugLoc_opaque {}
416 pub type DebugLocRef = *mut DebugLoc_opaque;
417 #[allow(missing_copy_implementations)]
418 pub enum SMDiagnostic_opaque {}
419 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
420 #[allow(missing_copy_implementations)]
421 pub enum RustArchiveMember_opaque {}
422 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
423 #[allow(missing_copy_implementations)]
424 pub enum OperandBundleDef_opaque {}
425 pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
426
427 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
428 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
429
430 pub mod debuginfo {
431     pub use self::DIDescriptorFlags::*;
432     use super::{MetadataRef};
433
434     #[allow(missing_copy_implementations)]
435     pub enum DIBuilder_opaque {}
436     pub type DIBuilderRef = *mut DIBuilder_opaque;
437
438     pub type DIDescriptor = MetadataRef;
439     pub type DIScope = DIDescriptor;
440     pub type DILocation = DIDescriptor;
441     pub type DIFile = DIScope;
442     pub type DILexicalBlock = DIScope;
443     pub type DISubprogram = DIScope;
444     pub type DINameSpace = DIScope;
445     pub type DIType = DIDescriptor;
446     pub type DIBasicType = DIType;
447     pub type DIDerivedType = DIType;
448     pub type DICompositeType = DIDerivedType;
449     pub type DIVariable = DIDescriptor;
450     pub type DIGlobalVariable = DIDescriptor;
451     pub type DIArray = DIDescriptor;
452     pub type DISubrange = DIDescriptor;
453     pub type DIEnumerator = DIDescriptor;
454     pub type DITemplateTypeParameter = DIDescriptor;
455
456     #[derive(Copy, Clone)]
457     pub enum DIDescriptorFlags {
458       FlagPrivate            = 1 << 0,
459       FlagProtected          = 1 << 1,
460       FlagFwdDecl            = 1 << 2,
461       FlagAppleBlock         = 1 << 3,
462       FlagBlockByrefStruct   = 1 << 4,
463       FlagVirtual            = 1 << 5,
464       FlagArtificial         = 1 << 6,
465       FlagExplicit           = 1 << 7,
466       FlagPrototyped         = 1 << 8,
467       FlagObjcClassComplete  = 1 << 9,
468       FlagObjectPointer      = 1 << 10,
469       FlagVector             = 1 << 11,
470       FlagStaticMember       = 1 << 12,
471       FlagIndirectVariable   = 1 << 13,
472       FlagLValueReference    = 1 << 14,
473       FlagRValueReference    = 1 << 15
474     }
475 }
476
477
478 // Link to our native llvm bindings (things that we need to use the C++ api
479 // for) and because llvm is written in C++ we need to link against libstdc++
480 //
481 // You'll probably notice that there is an omission of all LLVM libraries
482 // from this location. This is because the set of LLVM libraries that we
483 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
484 // figure out the exact set of libraries. To do this, the build system
485 // generates an llvmdeps.rs file next to this one which will be
486 // automatically updated whenever LLVM is updated to include an up-to-date
487 // set of the libraries we need to link to LLVM for.
488 #[link(name = "rustllvm", kind = "static")]
489 #[cfg(not(cargobuild))]
490 extern {}
491
492 #[linked_from = "rustllvm"] // not quite true but good enough
493 extern {
494     /* Create and destroy contexts. */
495     pub fn LLVMContextCreate() -> ContextRef;
496     pub fn LLVMContextDispose(C: ContextRef);
497     pub fn LLVMGetMDKindIDInContext(C: ContextRef,
498                                     Name: *const c_char,
499                                     SLen: c_uint)
500                                     -> c_uint;
501
502     /* Create and destroy modules. */
503     pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
504                                              C: ContextRef)
505                                              -> ModuleRef;
506     pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
507     pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
508     pub fn LLVMDisposeModule(M: ModuleRef);
509
510     /// Data layout. See Module::getDataLayout.
511     pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
512     pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
513
514     /// Target triple. See Module::getTargetTriple.
515     pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
516     pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
517
518     /// See Module::dump.
519     pub fn LLVMDumpModule(M: ModuleRef);
520
521     /// See Module::setModuleInlineAsm.
522     pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
523
524     /// See llvm::LLVMTypeKind::getTypeID.
525     pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind;
526
527     /// See llvm::LLVMType::getContext.
528     pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
529
530     /* Operations on integer types */
531     pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
532     pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
533     pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
534     pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
535     pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
536     pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
537                                 -> TypeRef;
538
539     pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
540
541     /* Operations on real types */
542     pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
543     pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
544     pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
545     pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
546     pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
547
548     /* Operations on function types */
549     pub fn LLVMFunctionType(ReturnType: TypeRef,
550                             ParamTypes: *const TypeRef,
551                             ParamCount: c_uint,
552                             IsVarArg: Bool)
553                             -> TypeRef;
554     pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
555     pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
556     pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
557     pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
558
559     /* Operations on struct types */
560     pub fn LLVMStructTypeInContext(C: ContextRef,
561                                    ElementTypes: *const TypeRef,
562                                    ElementCount: c_uint,
563                                    Packed: Bool)
564                                    -> TypeRef;
565     pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
566     pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
567                                      Dest: *mut TypeRef);
568     pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
569
570     /* Operations on array, pointer, and vector types (sequence types) */
571     pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
572     pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
573                            -> TypeRef;
574     pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
575                           -> TypeRef;
576
577     pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
578     pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
579     pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
580     pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
581                                   -> *const c_void;
582     pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
583
584     /* Operations on other types */
585     pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
586     pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
587     pub fn LLVMRustMetadataTypeInContext(C: ContextRef) -> TypeRef;
588
589     /* Operations on all values */
590     pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
591     pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
592     pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
593     pub fn LLVMDumpValue(Val: ValueRef);
594     pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
595     pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
596
597     /* Operations on Uses */
598     pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
599     pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
600     pub fn LLVMGetUser(U: UseRef) -> ValueRef;
601     pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
602
603     /* Operations on Users */
604     pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
605     pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
606     pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
607
608     /* Operations on constants of any type */
609     pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
610     /* all zeroes */
611     pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
612     pub fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef)
613                          -> ValueRef;
614     pub fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef)
615                          -> ValueRef;
616     /* only for isize/vector */
617     pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
618     pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
619     pub fn LLVMIsNull(Val: ValueRef) -> Bool;
620     pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
621     pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
622
623     /* Operations on metadata */
624     pub fn LLVMMDStringInContext(C: ContextRef,
625                                  Str: *const c_char,
626                                  SLen: c_uint)
627                                  -> ValueRef;
628     pub fn LLVMMDNodeInContext(C: ContextRef,
629                                Vals: *const ValueRef,
630                                Count: c_uint)
631                                -> ValueRef;
632     pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
633                                        Str: *const c_char,
634                                        Val: ValueRef);
635
636     /* Operations on scalar constants */
637     pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
638                         -> ValueRef;
639     pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
640                                 -> ValueRef;
641     pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
642                                        Text: *const c_char,
643                                        SLen: c_uint,
644                                        Radix: u8)
645                                        -> ValueRef;
646     pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
647     pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
648                                  -> ValueRef;
649     pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
650                                         Text: *const c_char,
651                                         SLen: c_uint)
652                                         -> ValueRef;
653     pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
654     pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
655
656
657     /* Operations on composite constants */
658     pub fn LLVMConstStringInContext(C: ContextRef,
659                                     Str: *const c_char,
660                                     Length: c_uint,
661                                     DontNullTerminate: Bool)
662                                     -> ValueRef;
663     pub fn LLVMConstStructInContext(C: ContextRef,
664                                     ConstantVals: *const ValueRef,
665                                     Count: c_uint,
666                                     Packed: Bool)
667                                     -> ValueRef;
668
669     pub fn LLVMConstArray(ElementTy: TypeRef,
670                           ConstantVals: *const ValueRef,
671                           Length: c_uint)
672                           -> ValueRef;
673     pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
674                            -> ValueRef;
675
676     /* Constant expressions */
677     pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
678     pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
679     pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
680     pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
681     pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
682     pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
683     pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
684     pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
685                         -> ValueRef;
686     pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
687                            -> ValueRef;
688     pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
689                            -> ValueRef;
690     pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
691                          -> ValueRef;
692     pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
693                         -> ValueRef;
694     pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
695                            -> ValueRef;
696     pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
697                            -> ValueRef;
698     pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
699                          -> ValueRef;
700     pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
701                         -> ValueRef;
702     pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
703                            -> ValueRef;
704     pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
705                            -> ValueRef;
706     pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
707                          -> ValueRef;
708     pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
709                          -> ValueRef;
710     pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
711                          -> ValueRef;
712     pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
713                               RHSConstant: ValueRef)
714                               -> ValueRef;
715     pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
716                          -> ValueRef;
717     pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
718                          -> ValueRef;
719     pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
720                          -> ValueRef;
721     pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
722                          -> ValueRef;
723     pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
724                         -> ValueRef;
725     pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
726                        -> ValueRef;
727     pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
728                         -> ValueRef;
729     pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
730                         -> ValueRef;
731     pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
732                          -> ValueRef;
733     pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
734                          -> ValueRef;
735     pub fn LLVMConstGEP(ConstantVal: ValueRef,
736                         ConstantIndices: *const ValueRef,
737                         NumIndices: c_uint)
738                         -> ValueRef;
739     pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
740                                 ConstantIndices: *const ValueRef,
741                                 NumIndices: c_uint)
742                                 -> ValueRef;
743     pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
744                           -> ValueRef;
745     pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
746                          -> ValueRef;
747     pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
748                          -> ValueRef;
749     pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
750                             -> ValueRef;
751     pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
752                           -> ValueRef;
753     pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
754                            -> ValueRef;
755     pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
756                            -> ValueRef;
757     pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
758                            -> ValueRef;
759     pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
760                            -> ValueRef;
761     pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
762                              -> ValueRef;
763     pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
764                              -> ValueRef;
765     pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
766                             -> ValueRef;
767     pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
768                                   -> ValueRef;
769     pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
770                                   -> ValueRef;
771     pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
772                                    -> ValueRef;
773     pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
774                                 -> ValueRef;
775     pub fn LLVMConstIntCast(ConstantVal: ValueRef,
776                             ToType: TypeRef,
777                             isSigned: Bool)
778                             -> ValueRef;
779     pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
780                            -> ValueRef;
781     pub fn LLVMConstSelect(ConstantCondition: ValueRef,
782                            ConstantIfTrue: ValueRef,
783                            ConstantIfFalse: ValueRef)
784                            -> ValueRef;
785     pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
786                                    IndexConstant: ValueRef)
787                                    -> ValueRef;
788     pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
789                                   ElementValueConstant: ValueRef,
790                                   IndexConstant: ValueRef)
791                                   -> ValueRef;
792     pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
793                                   VectorBConstant: ValueRef,
794                                   MaskConstant: ValueRef)
795                                   -> ValueRef;
796     pub fn LLVMConstExtractValue(AggConstant: ValueRef,
797                                  IdxList: *const c_uint,
798                                  NumIdx: c_uint)
799                                  -> ValueRef;
800     pub fn LLVMConstInsertValue(AggConstant: ValueRef,
801                                 ElementValueConstant: ValueRef,
802                                 IdxList: *const c_uint,
803                                 NumIdx: c_uint)
804                                 -> ValueRef;
805     pub fn LLVMConstInlineAsm(Ty: TypeRef,
806                               AsmString: *const c_char,
807                               Constraints: *const c_char,
808                               HasSideEffects: Bool,
809                               IsAlignStack: Bool)
810                               -> ValueRef;
811     pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
812
813
814
815     /* Operations on global variables, functions, and aliases (globals) */
816     pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
817     pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
818     pub fn LLVMRustGetLinkage(Global: ValueRef) -> Linkage;
819     pub fn LLVMRustSetLinkage(Global: ValueRef, RustLinkage: Linkage);
820     pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
821     pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
822     pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
823     pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
824     pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
825     pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
826     pub fn LLVMSetDLLStorageClass(V: ValueRef,
827                                   C: DLLStorageClass);
828
829
830     /* Operations on global variables */
831     pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
832     pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
833                          -> ValueRef;
834     pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
835                                        Ty: TypeRef,
836                                        Name: *const c_char,
837                                        AddressSpace: c_uint)
838                                        -> ValueRef;
839     pub fn LLVMGetNamedGlobal(M: ModuleRef,
840                               Name: *const c_char)
841                               -> ValueRef;
842     pub fn LLVMRustGetOrInsertGlobal(M: ModuleRef,
843                                      Name: *const c_char,
844                                      T: TypeRef)
845                                      -> ValueRef;
846     pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
847     pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
848     pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
849     pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
850     pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
851     pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
852     pub fn LLVMSetInitializer(GlobalVar: ValueRef,
853                               ConstantVal: ValueRef);
854     pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
855     pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
856     pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
857     pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
858     pub fn LLVMRustGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
859
860     /* Operations on aliases */
861     pub fn LLVMAddAlias(M: ModuleRef,
862                         Ty: TypeRef,
863                         Aliasee: ValueRef,
864                         Name: *const c_char)
865                         -> ValueRef;
866
867     /* Operations on functions */
868     pub fn LLVMAddFunction(M: ModuleRef,
869                            Name: *const c_char,
870                            FunctionTy: TypeRef)
871                            -> ValueRef;
872     pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
873     pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
874     pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
875     pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
876     pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
877     pub fn LLVMDeleteFunction(Fn: ValueRef);
878     pub fn LLVMRustGetOrInsertFunction(M: ModuleRef,
879                                        Name: *const c_char,
880                                        FunctionTy: TypeRef)
881                                        -> ValueRef;
882     pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
883     pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
884     pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
885     pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
886     pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
887     pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
888     pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: u64);
889     pub fn LLVMRustAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
890     pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef, index: c_uint,
891                                               Name: *const c_char,
892                                               Value: *const c_char);
893     pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef,
894                                             index: c_uint,
895                                             attr: u64);
896     pub fn LLVMRustRemoveFunctionAttrString(Fn: ValueRef,
897                                             index: c_uint,
898                                             Name: *const c_char);
899     pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_uint;
900     pub fn LLVMRemoveFunctionAttr(Fn: ValueRef, val: c_uint);
901
902     /* Operations on parameters */
903     pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
904     pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
905     pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
906     pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
907     pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
908     pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
909     pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
910     pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
911     pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
912     pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
913     pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
914     pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
915
916     /* Operations on basic blocks */
917     pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
918     pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
919     pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
920     pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
921     pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
922     pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
923     pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
924     pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
925     pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
926     pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
927     pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
928
929     pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
930                                          Fn: ValueRef,
931                                          Name: *const c_char)
932                                          -> BasicBlockRef;
933     pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
934                                          BB: BasicBlockRef,
935                                          Name: *const c_char)
936                                          -> BasicBlockRef;
937     pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
938
939     pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
940                                    MoveAfter: BasicBlockRef);
941
942     pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
943                                     MoveBefore: BasicBlockRef);
944
945     /* Operations on instructions */
946     pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
947     pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
948     pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
949     pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
950     pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
951     pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
952
953     /* Operations on call sites */
954     pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
955     pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
956     pub fn LLVMAddInstrAttribute(Instr: ValueRef,
957                                  index: c_uint,
958                                  IA: c_uint);
959     pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
960                                     index: c_uint,
961                                     IA: c_uint);
962     pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
963                                       index: c_uint,
964                                       align: c_uint);
965     pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef,
966                                     index: c_uint,
967                                     Val: u64);
968     pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef,
969                                                   index: c_uint,
970                                                   bytes: u64);
971
972     /* Operations on call instructions (only) */
973     pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
974     pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
975
976     /* Operations on load/store instructions (only) */
977     pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
978     pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
979
980     /* Operations on phi nodes */
981     pub fn LLVMAddIncoming(PhiNode: ValueRef,
982                            IncomingValues: *const ValueRef,
983                            IncomingBlocks: *const BasicBlockRef,
984                            Count: c_uint);
985     pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
986     pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
987                                 -> ValueRef;
988     pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
989                                 -> BasicBlockRef;
990
991     /* Instruction builders */
992     pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
993     pub fn LLVMPositionBuilder(Builder: BuilderRef,
994                                Block: BasicBlockRef,
995                                Instr: ValueRef);
996     pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
997                                      Instr: ValueRef);
998     pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
999                                     Block: BasicBlockRef);
1000     pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1001     pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1002     pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1003     pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1004                                          Instr: ValueRef,
1005                                          Name: *const c_char);
1006     pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1007
1008     /* Metadata */
1009     pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1010     pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1011     pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1012
1013     /* Terminators */
1014     pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1015     pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1016     pub fn LLVMBuildAggregateRet(B: BuilderRef,
1017                                  RetVals: *const ValueRef,
1018                                  N: c_uint)
1019                                  -> ValueRef;
1020     pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1021     pub fn LLVMBuildCondBr(B: BuilderRef,
1022                            If: ValueRef,
1023                            Then: BasicBlockRef,
1024                            Else: BasicBlockRef)
1025                            -> ValueRef;
1026     pub fn LLVMBuildSwitch(B: BuilderRef,
1027                            V: ValueRef,
1028                            Else: BasicBlockRef,
1029                            NumCases: c_uint)
1030                            -> ValueRef;
1031     pub fn LLVMBuildIndirectBr(B: BuilderRef,
1032                                Addr: ValueRef,
1033                                NumDests: c_uint)
1034                                -> ValueRef;
1035     pub fn LLVMRustBuildInvoke(B: BuilderRef,
1036                                Fn: ValueRef,
1037                                Args: *const ValueRef,
1038                                NumArgs: c_uint,
1039                                Then: BasicBlockRef,
1040                                Catch: BasicBlockRef,
1041                                Bundle: OperandBundleDefRef,
1042                                Name: *const c_char)
1043                                -> ValueRef;
1044     pub fn LLVMRustBuildLandingPad(B: BuilderRef,
1045                                    Ty: TypeRef,
1046                                    PersFn: ValueRef,
1047                                    NumClauses: c_uint,
1048                                    Name: *const c_char,
1049                                    F: ValueRef)
1050                                    -> ValueRef;
1051     pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1052     pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1053
1054     pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
1055                                    ParentPad: ValueRef,
1056                                    ArgCnt: c_uint,
1057                                    Args: *const ValueRef,
1058                                    Name: *const c_char) -> ValueRef;
1059     pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
1060                                    CleanupPad: ValueRef,
1061                                    UnwindBB: BasicBlockRef) -> ValueRef;
1062     pub fn LLVMRustBuildCatchPad(B: BuilderRef,
1063                                  ParentPad: ValueRef,
1064                                  ArgCnt: c_uint,
1065                                  Args: *const ValueRef,
1066                                  Name: *const c_char) -> ValueRef;
1067     pub fn LLVMRustBuildCatchRet(B: BuilderRef,
1068                                  Pad: ValueRef,
1069                                  BB: BasicBlockRef) -> ValueRef;
1070     pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
1071                                     ParentPad: ValueRef,
1072                                     BB: BasicBlockRef,
1073                                     NumHandlers: c_uint,
1074                                     Name: *const c_char) -> ValueRef;
1075     pub fn LLVMRustAddHandler(CatchSwitch: ValueRef,
1076                               Handler: BasicBlockRef);
1077     pub fn LLVMRustSetPersonalityFn(B: BuilderRef, Pers: ValueRef);
1078
1079     /* Add a case to the switch instruction */
1080     pub fn LLVMAddCase(Switch: ValueRef,
1081                        OnVal: ValueRef,
1082                        Dest: BasicBlockRef);
1083
1084     /* Add a destination to the indirectbr instruction */
1085     pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1086
1087     /* Add a clause to the landing pad instruction */
1088     pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1089
1090     /* Set the cleanup on a landing pad instruction */
1091     pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1092
1093     /* Arithmetic */
1094     pub fn LLVMBuildAdd(B: BuilderRef,
1095                         LHS: ValueRef,
1096                         RHS: ValueRef,
1097                         Name: *const c_char)
1098                         -> ValueRef;
1099     pub fn LLVMBuildNSWAdd(B: BuilderRef,
1100                            LHS: ValueRef,
1101                            RHS: ValueRef,
1102                            Name: *const c_char)
1103                            -> ValueRef;
1104     pub fn LLVMBuildNUWAdd(B: BuilderRef,
1105                            LHS: ValueRef,
1106                            RHS: ValueRef,
1107                            Name: *const c_char)
1108                            -> ValueRef;
1109     pub fn LLVMBuildFAdd(B: BuilderRef,
1110                          LHS: ValueRef,
1111                          RHS: ValueRef,
1112                          Name: *const c_char)
1113                          -> ValueRef;
1114     pub fn LLVMBuildSub(B: BuilderRef,
1115                         LHS: ValueRef,
1116                         RHS: ValueRef,
1117                         Name: *const c_char)
1118                         -> ValueRef;
1119     pub fn LLVMBuildNSWSub(B: BuilderRef,
1120                            LHS: ValueRef,
1121                            RHS: ValueRef,
1122                            Name: *const c_char)
1123                            -> ValueRef;
1124     pub fn LLVMBuildNUWSub(B: BuilderRef,
1125                            LHS: ValueRef,
1126                            RHS: ValueRef,
1127                            Name: *const c_char)
1128                            -> ValueRef;
1129     pub fn LLVMBuildFSub(B: BuilderRef,
1130                          LHS: ValueRef,
1131                          RHS: ValueRef,
1132                          Name: *const c_char)
1133                          -> ValueRef;
1134     pub fn LLVMBuildMul(B: BuilderRef,
1135                         LHS: ValueRef,
1136                         RHS: ValueRef,
1137                         Name: *const c_char)
1138                         -> ValueRef;
1139     pub fn LLVMBuildNSWMul(B: BuilderRef,
1140                            LHS: ValueRef,
1141                            RHS: ValueRef,
1142                            Name: *const c_char)
1143                            -> ValueRef;
1144     pub fn LLVMBuildNUWMul(B: BuilderRef,
1145                            LHS: ValueRef,
1146                            RHS: ValueRef,
1147                            Name: *const c_char)
1148                            -> ValueRef;
1149     pub fn LLVMBuildFMul(B: BuilderRef,
1150                          LHS: ValueRef,
1151                          RHS: ValueRef,
1152                          Name: *const c_char)
1153                          -> ValueRef;
1154     pub fn LLVMBuildUDiv(B: BuilderRef,
1155                          LHS: ValueRef,
1156                          RHS: ValueRef,
1157                          Name: *const c_char)
1158                          -> ValueRef;
1159     pub fn LLVMBuildSDiv(B: BuilderRef,
1160                          LHS: ValueRef,
1161                          RHS: ValueRef,
1162                          Name: *const c_char)
1163                          -> ValueRef;
1164     pub fn LLVMBuildExactSDiv(B: BuilderRef,
1165                               LHS: ValueRef,
1166                               RHS: ValueRef,
1167                               Name: *const c_char)
1168                               -> ValueRef;
1169     pub fn LLVMBuildFDiv(B: BuilderRef,
1170                          LHS: ValueRef,
1171                          RHS: ValueRef,
1172                          Name: *const c_char)
1173                          -> ValueRef;
1174     pub fn LLVMBuildURem(B: BuilderRef,
1175                          LHS: ValueRef,
1176                          RHS: ValueRef,
1177                          Name: *const c_char)
1178                          -> ValueRef;
1179     pub fn LLVMBuildSRem(B: BuilderRef,
1180                          LHS: ValueRef,
1181                          RHS: ValueRef,
1182                          Name: *const c_char)
1183                          -> ValueRef;
1184     pub fn LLVMBuildFRem(B: BuilderRef,
1185                          LHS: ValueRef,
1186                          RHS: ValueRef,
1187                          Name: *const c_char)
1188                          -> ValueRef;
1189     pub fn LLVMBuildShl(B: BuilderRef,
1190                         LHS: ValueRef,
1191                         RHS: ValueRef,
1192                         Name: *const c_char)
1193                         -> ValueRef;
1194     pub fn LLVMBuildLShr(B: BuilderRef,
1195                          LHS: ValueRef,
1196                          RHS: ValueRef,
1197                          Name: *const c_char)
1198                          -> ValueRef;
1199     pub fn LLVMBuildAShr(B: BuilderRef,
1200                          LHS: ValueRef,
1201                          RHS: ValueRef,
1202                          Name: *const c_char)
1203                          -> ValueRef;
1204     pub fn LLVMBuildAnd(B: BuilderRef,
1205                         LHS: ValueRef,
1206                         RHS: ValueRef,
1207                         Name: *const c_char)
1208                         -> ValueRef;
1209     pub fn LLVMBuildOr(B: BuilderRef,
1210                        LHS: ValueRef,
1211                        RHS: ValueRef,
1212                        Name: *const c_char)
1213                            -> ValueRef;
1214     pub fn LLVMBuildXor(B: BuilderRef,
1215                         LHS: ValueRef,
1216                         RHS: ValueRef,
1217                         Name: *const c_char)
1218                         -> ValueRef;
1219     pub fn LLVMBuildBinOp(B: BuilderRef,
1220                           Op: Opcode,
1221                           LHS: ValueRef,
1222                           RHS: ValueRef,
1223                           Name: *const c_char)
1224                           -> ValueRef;
1225     pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1226                         -> ValueRef;
1227     pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1228                            -> ValueRef;
1229     pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1230                            -> ValueRef;
1231     pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1232                          -> ValueRef;
1233     pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1234                         -> ValueRef;
1235     pub fn LLVMRustSetHasUnsafeAlgebra(Instr: ValueRef);
1236
1237     /* Memory */
1238     pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1239                            -> ValueRef;
1240     pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1241     pub fn LLVMBuildLoad(B: BuilderRef,
1242                          PointerVal: ValueRef,
1243                          Name: *const c_char)
1244                          -> ValueRef;
1245
1246     pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1247                           -> ValueRef;
1248
1249     pub fn LLVMBuildGEP(B: BuilderRef,
1250                         Pointer: ValueRef,
1251                         Indices: *const ValueRef,
1252                         NumIndices: c_uint,
1253                         Name: *const c_char)
1254                         -> ValueRef;
1255     pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1256                                 Pointer: ValueRef,
1257                                 Indices: *const ValueRef,
1258                                 NumIndices: c_uint,
1259                                 Name: *const c_char)
1260                                 -> ValueRef;
1261     pub fn LLVMBuildStructGEP(B: BuilderRef,
1262                               Pointer: ValueRef,
1263                               Idx: c_uint,
1264                               Name: *const c_char)
1265                               -> ValueRef;
1266     pub fn LLVMBuildGlobalString(B: BuilderRef,
1267                                  Str: *const c_char,
1268                                  Name: *const c_char)
1269                                  -> ValueRef;
1270     pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1271                                     Str: *const c_char,
1272                                     Name: *const c_char)
1273                                     -> ValueRef;
1274
1275     /* Casts */
1276     pub fn LLVMBuildTrunc(B: BuilderRef,
1277                           Val: ValueRef,
1278                           DestTy: TypeRef,
1279                           Name: *const c_char)
1280                           -> ValueRef;
1281     pub fn LLVMBuildZExt(B: BuilderRef,
1282                          Val: ValueRef,
1283                          DestTy: TypeRef,
1284                          Name: *const c_char)
1285                          -> ValueRef;
1286     pub fn LLVMBuildSExt(B: BuilderRef,
1287                          Val: ValueRef,
1288                          DestTy: TypeRef,
1289                          Name: *const c_char)
1290                          -> ValueRef;
1291     pub fn LLVMBuildFPToUI(B: BuilderRef,
1292                            Val: ValueRef,
1293                            DestTy: TypeRef,
1294                            Name: *const c_char)
1295                            -> ValueRef;
1296     pub fn LLVMBuildFPToSI(B: BuilderRef,
1297                            Val: ValueRef,
1298                            DestTy: TypeRef,
1299                            Name: *const c_char)
1300                            -> ValueRef;
1301     pub fn LLVMBuildUIToFP(B: BuilderRef,
1302                            Val: ValueRef,
1303                            DestTy: TypeRef,
1304                            Name: *const c_char)
1305                            -> ValueRef;
1306     pub fn LLVMBuildSIToFP(B: BuilderRef,
1307                            Val: ValueRef,
1308                            DestTy: TypeRef,
1309                            Name: *const c_char)
1310                            -> ValueRef;
1311     pub fn LLVMBuildFPTrunc(B: BuilderRef,
1312                             Val: ValueRef,
1313                             DestTy: TypeRef,
1314                             Name: *const c_char)
1315                             -> ValueRef;
1316     pub fn LLVMBuildFPExt(B: BuilderRef,
1317                           Val: ValueRef,
1318                           DestTy: TypeRef,
1319                           Name: *const c_char)
1320                           -> ValueRef;
1321     pub fn LLVMBuildPtrToInt(B: BuilderRef,
1322                              Val: ValueRef,
1323                              DestTy: TypeRef,
1324                              Name: *const c_char)
1325                              -> ValueRef;
1326     pub fn LLVMBuildIntToPtr(B: BuilderRef,
1327                              Val: ValueRef,
1328                              DestTy: TypeRef,
1329                              Name: *const c_char)
1330                              -> ValueRef;
1331     pub fn LLVMBuildBitCast(B: BuilderRef,
1332                             Val: ValueRef,
1333                             DestTy: TypeRef,
1334                             Name: *const c_char)
1335                             -> ValueRef;
1336     pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1337                                   Val: ValueRef,
1338                                   DestTy: TypeRef,
1339                                   Name: *const c_char)
1340                                   -> ValueRef;
1341     pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1342                                   Val: ValueRef,
1343                                   DestTy: TypeRef,
1344                                   Name: *const c_char)
1345                                   -> ValueRef;
1346     pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1347                                    Val: ValueRef,
1348                                    DestTy: TypeRef,
1349                                    Name: *const c_char)
1350                                    -> ValueRef;
1351     pub fn LLVMBuildCast(B: BuilderRef,
1352                          Op: Opcode,
1353                          Val: ValueRef,
1354                          DestTy: TypeRef,
1355                          Name: *const c_char) -> ValueRef;
1356     pub fn LLVMBuildPointerCast(B: BuilderRef,
1357                                 Val: ValueRef,
1358                                 DestTy: TypeRef,
1359                                 Name: *const c_char)
1360                                 -> ValueRef;
1361     pub fn LLVMBuildIntCast(B: BuilderRef,
1362                             Val: ValueRef,
1363                             DestTy: TypeRef,
1364                             Name: *const c_char)
1365                             -> ValueRef;
1366     pub fn LLVMBuildFPCast(B: BuilderRef,
1367                            Val: ValueRef,
1368                            DestTy: TypeRef,
1369                            Name: *const c_char)
1370                            -> ValueRef;
1371
1372     /* Comparisons */
1373     pub fn LLVMBuildICmp(B: BuilderRef,
1374                          Op: c_uint,
1375                          LHS: ValueRef,
1376                          RHS: ValueRef,
1377                          Name: *const c_char)
1378                          -> ValueRef;
1379     pub fn LLVMBuildFCmp(B: BuilderRef,
1380                          Op: c_uint,
1381                          LHS: ValueRef,
1382                          RHS: ValueRef,
1383                          Name: *const c_char)
1384                          -> ValueRef;
1385
1386     /* Miscellaneous instructions */
1387     pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1388                         -> ValueRef;
1389     pub fn LLVMRustBuildCall(B: BuilderRef,
1390                              Fn: ValueRef,
1391                              Args: *const ValueRef,
1392                              NumArgs: c_uint,
1393                              Bundle: OperandBundleDefRef,
1394                              Name: *const c_char)
1395                              -> ValueRef;
1396     pub fn LLVMBuildSelect(B: BuilderRef,
1397                            If: ValueRef,
1398                            Then: ValueRef,
1399                            Else: ValueRef,
1400                            Name: *const c_char)
1401                            -> ValueRef;
1402     pub fn LLVMBuildVAArg(B: BuilderRef,
1403                           list: ValueRef,
1404                           Ty: TypeRef,
1405                           Name: *const c_char)
1406                           -> ValueRef;
1407     pub fn LLVMBuildExtractElement(B: BuilderRef,
1408                                    VecVal: ValueRef,
1409                                    Index: ValueRef,
1410                                    Name: *const c_char)
1411                                    -> ValueRef;
1412     pub fn LLVMBuildInsertElement(B: BuilderRef,
1413                                   VecVal: ValueRef,
1414                                   EltVal: ValueRef,
1415                                   Index: ValueRef,
1416                                   Name: *const c_char)
1417                                   -> ValueRef;
1418     pub fn LLVMBuildShuffleVector(B: BuilderRef,
1419                                   V1: ValueRef,
1420                                   V2: ValueRef,
1421                                   Mask: ValueRef,
1422                                   Name: *const c_char)
1423                                   -> ValueRef;
1424     pub fn LLVMBuildExtractValue(B: BuilderRef,
1425                                  AggVal: ValueRef,
1426                                  Index: c_uint,
1427                                  Name: *const c_char)
1428                                  -> ValueRef;
1429     pub fn LLVMBuildInsertValue(B: BuilderRef,
1430                                 AggVal: ValueRef,
1431                                 EltVal: ValueRef,
1432                                 Index: c_uint,
1433                                 Name: *const c_char)
1434                                 -> ValueRef;
1435
1436     pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1437                            -> ValueRef;
1438     pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1439                               -> ValueRef;
1440     pub fn LLVMBuildPtrDiff(B: BuilderRef,
1441                             LHS: ValueRef,
1442                             RHS: ValueRef,
1443                             Name: *const c_char)
1444                             -> ValueRef;
1445
1446     /* Atomic Operations */
1447     pub fn LLVMRustBuildAtomicLoad(B: BuilderRef,
1448                                    PointerVal: ValueRef,
1449                                    Name: *const c_char,
1450                                    Order: AtomicOrdering,
1451                                    Alignment: c_uint)
1452                                    -> ValueRef;
1453
1454     pub fn LLVMRustBuildAtomicStore(B: BuilderRef,
1455                                     Val: ValueRef,
1456                                     Ptr: ValueRef,
1457                                     Order: AtomicOrdering,
1458                                     Alignment: c_uint)
1459                                     -> ValueRef;
1460
1461     pub fn LLVMRustBuildAtomicCmpXchg(B: BuilderRef,
1462                                       LHS: ValueRef,
1463                                       CMP: ValueRef,
1464                                       RHS: ValueRef,
1465                                       Order: AtomicOrdering,
1466                                       FailureOrder: AtomicOrdering,
1467                                       Weak: Bool)
1468                                       -> ValueRef;
1469
1470     pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1471                               Op: AtomicRmwBinOp,
1472                               LHS: ValueRef,
1473                               RHS: ValueRef,
1474                               Order: AtomicOrdering,
1475                               SingleThreaded: Bool)
1476                               -> ValueRef;
1477
1478     pub fn LLVMRustBuildAtomicFence(B: BuilderRef,
1479                                     Order: AtomicOrdering,
1480                                     Scope: SynchronizationScope);
1481
1482
1483     /* Selected entries from the downcasts. */
1484     pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1485     pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1486
1487     /// Writes a module to the specified path. Returns 0 on success.
1488     pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1489
1490     /// Creates target data from a target layout string.
1491     pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1492     /// Number of bytes clobbered when doing a Store to *T.
1493     pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1494                                -> c_ulonglong;
1495
1496     /// Number of bytes clobbered when doing a Store to *T.
1497     pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1498                                 -> c_ulonglong;
1499
1500     /// Distance between successive elements in an array of T. Includes ABI padding.
1501     pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1502
1503     /// Returns the preferred alignment of a type.
1504     pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1505                                         -> c_uint;
1506     /// Returns the minimum alignment of a type.
1507     pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1508                                   -> c_uint;
1509
1510     /// Computes the byte offset of the indexed struct element for a
1511     /// target.
1512     pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1513                                StructTy: TypeRef,
1514                                Element: c_uint)
1515                                -> c_ulonglong;
1516
1517     /// Returns the minimum alignment of a type when part of a call frame.
1518     pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1519                                         -> c_uint;
1520
1521     /// Disposes target data.
1522     pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1523
1524     /// Creates a pass manager.
1525     pub fn LLVMCreatePassManager() -> PassManagerRef;
1526
1527     /// Creates a function-by-function pass manager
1528     pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1529                                                   -> PassManagerRef;
1530
1531     /// Disposes a pass manager.
1532     pub fn LLVMDisposePassManager(PM: PassManagerRef);
1533
1534     /// Runs a pass manager on a module.
1535     pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1536
1537     /// Runs the function passes on the provided function.
1538     pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1539                                       -> Bool;
1540
1541     /// Initializes all the function passes scheduled in the manager
1542     pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1543
1544     /// Finalizes all the function passes scheduled in the manager
1545     pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1546
1547     pub fn LLVMInitializePasses();
1548
1549     /// Adds a verification pass.
1550     pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1551
1552     pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1553     pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1554     pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1555     pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1556     pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1557     pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1558     pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1559     pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1560     pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1561     pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1562     pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1563     pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1564     pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1565     pub fn LLVMAddLICMPass(PM: PassManagerRef);
1566     pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1567     pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1568     pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1569     pub fn LLVMAddGVNPass(PM: PassManagerRef);
1570     pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1571     pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1572     pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1573     pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1574     pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1575     pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1576     pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1577     pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1578     pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1579     pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1580     pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1581     pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1582     pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1583     pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1584     pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1585     pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1586     pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1587
1588     pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1589     pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1590     pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1591                                              OptimizationLevel: c_uint);
1592     pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1593                                               Value: Bool);
1594     pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1595         PMB: PassManagerBuilderRef,
1596         Value: Bool);
1597     pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1598         PMB: PassManagerBuilderRef,
1599         Value: Bool);
1600     pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1601         PMB: PassManagerBuilderRef,
1602         Value: Bool);
1603     pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1604         PMB: PassManagerBuilderRef,
1605         threshold: c_uint);
1606     pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1607         PMB: PassManagerBuilderRef,
1608         PM: PassManagerRef);
1609
1610     pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1611         PMB: PassManagerBuilderRef,
1612         PM: PassManagerRef);
1613     pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1614         PMB: PassManagerBuilderRef,
1615         PM: PassManagerRef,
1616         Internalize: Bool,
1617         RunInliner: Bool);
1618
1619     /// Destroys a memory buffer.
1620     pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1621
1622
1623     /* Stuff that's in rustllvm/ because it's not upstream yet. */
1624
1625     /// Opens an object file.
1626     pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1627     /// Closes an object file.
1628     pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1629
1630     /// Enumerates the sections in an object file.
1631     pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1632     /// Destroys a section iterator.
1633     pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1634     /// Returns true if the section iterator is at the end of the section
1635     /// list:
1636     pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1637                                       SI: SectionIteratorRef)
1638                                       -> Bool;
1639     /// Moves the section iterator to point to the next section.
1640     pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1641     /// Returns the current section size.
1642     pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1643     /// Returns the current section contents as a string buffer.
1644     pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1645
1646     /// Reads the given file and returns it as a memory buffer. Use
1647     /// LLVMDisposeMemoryBuffer() to get rid of it.
1648     pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1649                                                         -> MemoryBufferRef;
1650     /// Borrows the contents of the memory buffer (doesn't copy it)
1651     pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1652                                                  InputDataLength: size_t,
1653                                                  BufferName: *const c_char,
1654                                                  RequiresNull: Bool)
1655                                                  -> MemoryBufferRef;
1656     pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1657                                                      InputDataLength: size_t,
1658                                                      BufferName: *const c_char)
1659                                                      -> MemoryBufferRef;
1660
1661     pub fn LLVMIsMultithreaded() -> Bool;
1662     pub fn LLVMStartMultithreaded() -> Bool;
1663
1664     /// Returns a string describing the last error caused by an LLVMRust* call.
1665     pub fn LLVMRustGetLastError() -> *const c_char;
1666
1667     /// Print the pass timings since static dtors aren't picking them up.
1668     pub fn LLVMRustPrintPassTimings();
1669
1670     pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1671
1672     pub fn LLVMStructSetBody(StructTy: TypeRef,
1673                              ElementTypes: *const TypeRef,
1674                              ElementCount: c_uint,
1675                              Packed: Bool);
1676
1677     pub fn LLVMConstNamedStruct(S: TypeRef,
1678                                 ConstantVals: *const ValueRef,
1679                                 Count: c_uint)
1680                                 -> ValueRef;
1681
1682     /// Enables LLVM debug output.
1683     pub fn LLVMRustSetDebug(Enabled: c_int);
1684
1685     /// Prepares inline assembly.
1686     pub fn LLVMRustInlineAsm(Ty: TypeRef,
1687                              AsmString: *const c_char,
1688                              Constraints: *const c_char,
1689                              SideEffects: Bool,
1690                              AlignStack: Bool,
1691                              Dialect: AsmDialect)
1692                              -> ValueRef;
1693
1694     pub fn LLVMRustDebugMetadataVersion() -> u32;
1695     pub fn LLVMRustVersionMajor() -> u32;
1696     pub fn LLVMRustVersionMinor() -> u32;
1697
1698     pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1699                                  name: *const c_char,
1700                                  value: u32);
1701
1702     pub fn LLVMRustDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1703
1704     pub fn LLVMRustDIBuilderDispose(Builder: DIBuilderRef);
1705
1706     pub fn LLVMRustDIBuilderFinalize(Builder: DIBuilderRef);
1707
1708     pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1709                                               Lang: c_uint,
1710                                               File: *const c_char,
1711                                               Dir: *const c_char,
1712                                               Producer: *const c_char,
1713                                               isOptimized: bool,
1714                                               Flags: *const c_char,
1715                                               RuntimeVer: c_uint,
1716                                               SplitName: *const c_char)
1717                                               -> DIDescriptor;
1718
1719     pub fn LLVMRustDIBuilderCreateFile(Builder: DIBuilderRef,
1720                                        Filename: *const c_char,
1721                                        Directory: *const c_char)
1722                                        -> DIFile;
1723
1724     pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1725                                                  File: DIFile,
1726                                                  ParameterTypes: DIArray)
1727                                                  -> DICompositeType;
1728
1729     pub fn LLVMRustDIBuilderCreateFunction(Builder: DIBuilderRef,
1730                                            Scope: DIDescriptor,
1731                                            Name: *const c_char,
1732                                            LinkageName: *const c_char,
1733                                            File: DIFile,
1734                                            LineNo: c_uint,
1735                                            Ty: DIType,
1736                                            isLocalToUnit: bool,
1737                                            isDefinition: bool,
1738                                            ScopeLine: c_uint,
1739                                            Flags: c_uint,
1740                                            isOptimized: bool,
1741                                            Fn: ValueRef,
1742                                            TParam: DIArray,
1743                                            Decl: DIDescriptor)
1744                                            -> DISubprogram;
1745
1746     pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
1747                                             Name: *const c_char,
1748                                             SizeInBits: u64,
1749                                             AlignInBits: u64,
1750                                             Encoding: c_uint)
1751                                             -> DIBasicType;
1752
1753     pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
1754                                           PointeeTy: DIType,
1755                                           SizeInBits: u64,
1756                                           AlignInBits: u64,
1757                                           Name: *const c_char)
1758                                           -> DIDerivedType;
1759
1760     pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef,
1761                                              Scope: DIDescriptor,
1762                                              Name: *const c_char,
1763                                              File: DIFile,
1764                                              LineNumber: c_uint,
1765                                              SizeInBits: u64,
1766                                              AlignInBits: u64,
1767                                              Flags: c_uint,
1768                                              DerivedFrom: DIType,
1769                                              Elements: DIArray,
1770                                              RunTimeLang: c_uint,
1771                                              VTableHolder: DIType,
1772                                              UniqueId: *const c_char)
1773                                              -> DICompositeType;
1774
1775     pub fn LLVMRustDIBuilderCreateMemberType(Builder: DIBuilderRef,
1776                                              Scope: DIDescriptor,
1777                                              Name: *const c_char,
1778                                              File: DIFile,
1779                                              LineNo: c_uint,
1780                                              SizeInBits: u64,
1781                                              AlignInBits: u64,
1782                                              OffsetInBits: u64,
1783                                              Flags: c_uint,
1784                                              Ty: DIType)
1785                                              -> DIDerivedType;
1786
1787     pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1788                                                Scope: DIScope,
1789                                                File: DIFile,
1790                                                Line: c_uint,
1791                                                Col: c_uint)
1792                                                -> DILexicalBlock;
1793
1794     pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: DIBuilderRef,
1795                                                    Scope: DIScope,
1796                                                    File: DIFile)
1797                                                    -> DILexicalBlock;
1798
1799     pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1800                                                  Context: DIScope,
1801                                                  Name: *const c_char,
1802                                                  LinkageName: *const c_char,
1803                                                  File: DIFile,
1804                                                  LineNo: c_uint,
1805                                                  Ty: DIType,
1806                                                  isLocalToUnit: bool,
1807                                                  Val: ValueRef,
1808                                                  Decl: DIDescriptor)
1809                                                  -> DIGlobalVariable;
1810
1811     pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
1812                                            Tag: c_uint,
1813                                            Scope: DIDescriptor,
1814                                            Name: *const c_char,
1815                                            File: DIFile,
1816                                            LineNo: c_uint,
1817                                            Ty: DIType,
1818                                            AlwaysPreserve: bool,
1819                                            Flags: c_uint,
1820                                            AddrOps: *const i64,
1821                                            AddrOpsCount: c_uint,
1822                                            ArgNo: c_uint)
1823                                            -> DIVariable;
1824
1825     pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
1826                                             Size: u64,
1827                                             AlignInBits: u64,
1828                                             Ty: DIType,
1829                                             Subscripts: DIArray)
1830                                             -> DIType;
1831
1832     pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
1833                                              Size: u64,
1834                                              AlignInBits: u64,
1835                                              Ty: DIType,
1836                                              Subscripts: DIArray)
1837                                              -> DIType;
1838
1839     pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1840                                                 Lo: i64,
1841                                                 Count: i64)
1842                                                 -> DISubrange;
1843
1844     pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1845                                              Ptr: *const DIDescriptor,
1846                                              Count: c_uint)
1847                                              -> DIArray;
1848
1849     pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1850                                                Val: ValueRef,
1851                                                VarInfo: DIVariable,
1852                                                AddrOps: *const i64,
1853                                                AddrOpsCount: c_uint,
1854                                                DL: ValueRef,
1855                                                InsertAtEnd: BasicBlockRef)
1856                                                -> ValueRef;
1857
1858     pub fn LLVMRustDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1859                                                 Val: ValueRef,
1860                                                 VarInfo: DIVariable,
1861                                                 AddrOps: *const i64,
1862                                                 AddrOpsCount: c_uint,
1863                                                 DL: ValueRef,
1864                                                 InsertBefore: ValueRef)
1865                                                 -> ValueRef;
1866
1867     pub fn LLVMRustDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1868                                              Name: *const c_char,
1869                                              Val: u64)
1870                                              -> DIEnumerator;
1871
1872     pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1873                                                   Scope: DIScope,
1874                                                   Name: *const c_char,
1875                                                   File: DIFile,
1876                                                   LineNumber: c_uint,
1877                                                   SizeInBits: u64,
1878                                                   AlignInBits: u64,
1879                                                   Elements: DIArray,
1880                                                   ClassType: DIType)
1881                                                   -> DIType;
1882
1883     pub fn LLVMRustDIBuilderCreateUnionType(Builder: DIBuilderRef,
1884                                             Scope: DIScope,
1885                                             Name: *const c_char,
1886                                             File: DIFile,
1887                                             LineNumber: c_uint,
1888                                             SizeInBits: u64,
1889                                             AlignInBits: u64,
1890                                             Flags: c_uint,
1891                                             Elements: DIArray,
1892                                             RunTimeLang: c_uint,
1893                                             UniqueId: *const c_char)
1894                                             -> DIType;
1895
1896     pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1897
1898     pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1899                                                         Scope: DIScope,
1900                                                         Name: *const c_char,
1901                                                         Ty: DIType,
1902                                                         File: DIFile,
1903                                                         LineNo: c_uint,
1904                                                         ColumnNo: c_uint)
1905                                                         -> DITemplateTypeParameter;
1906
1907
1908     pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1909                                             Scope: DIScope,
1910                                             Name: *const c_char,
1911                                             File: DIFile,
1912                                             LineNo: c_uint)
1913                                             -> DINameSpace;
1914     pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1915                                                CompositeType: DIType,
1916                                                TypeArray: DIArray);
1917
1918
1919     pub fn LLVMRustDIBuilderCreateDebugLocation(Context: ContextRef,
1920                                                 Line: c_uint,
1921                                                 Column: c_uint,
1922                                                 Scope: DIScope,
1923                                                 InlinedAt: MetadataRef)
1924                                                 -> ValueRef;
1925     pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1926     pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
1927
1928     pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
1929     pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1930
1931     pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1932
1933     pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1934     pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
1935
1936     pub fn LLVMRustPassKind(Pass: PassRef) -> PassKind;
1937     pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
1938     pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
1939
1940     pub fn LLVMRustHasFeature(T: TargetMachineRef,
1941                               s: *const c_char) -> bool;
1942
1943     pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef);
1944     pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef);
1945
1946     pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1947                                        CPU: *const c_char,
1948                                        Features: *const c_char,
1949                                        Model: CodeModel,
1950                                        Reloc: RelocMode,
1951                                        Level: CodeGenOptLevel,
1952                                        UseSoftFP: bool,
1953                                        PositionIndependentExecutable: bool,
1954                                        FunctionSections: bool,
1955                                        DataSections: bool) -> TargetMachineRef;
1956     pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1957     pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1958                                      PM: PassManagerRef,
1959                                      M: ModuleRef);
1960     pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1961                                          M: ModuleRef,
1962                                          DisableSimplifyLibCalls: bool);
1963     pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
1964                                                OptLevel: CodeGenOptLevel,
1965                                                MergeFunctions: bool,
1966                                                SLPVectorize: bool,
1967                                                LoopVectorize: bool);
1968     pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
1969                                   DisableSimplifyLibCalls: bool);
1970     pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1971     pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1972                                    PM: PassManagerRef,
1973                                    M: ModuleRef,
1974                                    Output: *const c_char,
1975                                    FileType: FileType)
1976                                    -> LLVMRustResult;
1977     pub fn LLVMRustPrintModule(PM: PassManagerRef,
1978                                M: ModuleRef,
1979                                Output: *const c_char);
1980     pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1981     pub fn LLVMRustPrintPasses();
1982     pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1983     pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
1984                                        AddLifetimes: bool);
1985     pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
1986                                          bc: *const c_char,
1987                                          len: size_t) -> bool;
1988     pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
1989                                       syms: *const *const c_char,
1990                                       len: size_t);
1991     pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1992
1993     pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1994     pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
1995     pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
1996     pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef,
1997                                     size: *mut size_t) -> *const c_char;
1998     pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef,
1999                                     size: *mut size_t) -> *const c_char;
2000     pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
2001     pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
2002     pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2003
2004     pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2005                                   data: *mut *const c_char) -> size_t;
2006
2007     pub fn LLVMRustWriteTwineToString(T: TwineRef, s: RustStringRef);
2008
2009     pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2010                                            Handler: DiagnosticHandler,
2011                                            DiagnosticContext: *mut c_void);
2012
2013     pub fn LLVMRustUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2014                                                 pass_name_out: *mut *const c_char,
2015                                                 function_out: *mut ValueRef,
2016                                                 debugloc_out: *mut DebugLocRef,
2017                                                 message_out: *mut TwineRef);
2018     pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
2019                                              cookie_out: *mut c_uint,
2020                                              message_out: *mut TwineRef,
2021                                              instruction_out: *mut ValueRef);
2022
2023     pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef,
2024                                                s: RustStringRef);
2025     pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2026     pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2027
2028     pub fn LLVMRustWriteDebugLocToString(C: ContextRef,
2029                                          DL: DebugLocRef,
2030                                          s: RustStringRef);
2031
2032     pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef,
2033                                                  H: InlineAsmDiagHandler,
2034                                                  CX: *mut c_void);
2035
2036     pub fn LLVMRustWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2037
2038     pub fn LLVMRustWriteArchive(Dst: *const c_char,
2039                                 NumMembers: size_t,
2040                                 Members: *const RustArchiveMemberRef,
2041                                 WriteSymbtab: bool,
2042                                 Kind: ArchiveKind) ->
2043                                 LLVMRustResult;
2044     pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
2045                                     Name: *const c_char,
2046                                     Child: ArchiveChildRef) -> RustArchiveMemberRef;
2047     pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
2048
2049     pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef,
2050                                                   TM: TargetMachineRef);
2051     pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
2052
2053     pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
2054                                          Inputs: *const ValueRef,
2055                                          NumInputs: c_uint)
2056                                          -> OperandBundleDefRef;
2057     pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
2058
2059     pub fn LLVMRustPositionBuilderAtStart(B: BuilderRef, BB: BasicBlockRef);
2060
2061     pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
2062     pub fn LLVMRustUnsetComdat(V: ValueRef);
2063     pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
2064 }
2065
2066
2067 // LLVM requires symbols from this library, but apparently they're not printed
2068 // during llvm-config?
2069 #[cfg(windows)]
2070 #[link(name = "ole32")]
2071 extern {}