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