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