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