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