]> git.lizzy.rs Git - rust.git/blob - src/librustc/lib/llvm.rs
31050448e75520c53a2e9e0b129ea607a5f84df1
[rust.git] / src / librustc / lib / llvm.rs
1 // Copyright 2012 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 core::hashmap::HashMap;
12 use core::libc::c_uint;
13
14 pub type Opcode = u32;
15 pub type Bool = c_uint;
16
17 pub static True: Bool = 1 as Bool;
18 pub static False: Bool = 0 as Bool;
19
20 // Consts for the LLVM CallConv type, pre-cast to uint.
21
22 pub enum CallConv {
23     CCallConv = 0,
24     FastCallConv = 8,
25     ColdCallConv = 9,
26     X86StdcallCallConv = 64,
27     X86FastcallCallConv = 65,
28 }
29
30 pub enum Visibility {
31     LLVMDefaultVisibility = 0,
32     HiddenVisibility = 1,
33     ProtectedVisibility = 2,
34 }
35
36 pub enum Linkage {
37     ExternalLinkage = 0,
38     AvailableExternallyLinkage = 1,
39     LinkOnceAnyLinkage = 2,
40     LinkOnceODRLinkage = 3,
41     LinkOnceODRAutoHideLinkage = 4,
42     WeakAnyLinkage = 5,
43     WeakODRLinkage = 6,
44     AppendingLinkage = 7,
45     InternalLinkage = 8,
46     PrivateLinkage = 9,
47     DLLImportLinkage = 10,
48     DLLExportLinkage = 11,
49     ExternalWeakLinkage = 12,
50     GhostLinkage = 13,
51     CommonLinkage = 14,
52     LinkerPrivateLinkage = 15,
53     LinkerPrivateWeakLinkage = 16,
54 }
55
56 pub enum Attribute {
57     ZExtAttribute = 1,
58     SExtAttribute = 2,
59     NoReturnAttribute = 4,
60     InRegAttribute = 8,
61     StructRetAttribute = 16,
62     NoUnwindAttribute = 32,
63     NoAliasAttribute = 64,
64     ByValAttribute = 128,
65     NestAttribute = 256,
66     ReadNoneAttribute = 512,
67     ReadOnlyAttribute = 1024,
68     NoInlineAttribute = 2048,
69     AlwaysInlineAttribute = 4096,
70     OptimizeForSizeAttribute = 8192,
71     StackProtectAttribute = 16384,
72     StackProtectReqAttribute = 32768,
73     // 31 << 16
74     AlignmentAttribute = 2031616,
75     NoCaptureAttribute = 2097152,
76     NoRedZoneAttribute = 4194304,
77     NoImplicitFloatAttribute = 8388608,
78     NakedAttribute = 16777216,
79     InlineHintAttribute = 33554432,
80     // 7 << 26
81     StackAttribute = 469762048,
82     ReturnsTwiceAttribute = 536870912,
83     // 1 << 30
84     UWTableAttribute = 1073741824,
85     NonLazyBindAttribute = 2147483648,
86 }
87
88 // enum for the LLVM IntPredicate type
89 pub enum IntPredicate {
90     IntEQ = 32,
91     IntNE = 33,
92     IntUGT = 34,
93     IntUGE = 35,
94     IntULT = 36,
95     IntULE = 37,
96     IntSGT = 38,
97     IntSGE = 39,
98     IntSLT = 40,
99     IntSLE = 41,
100 }
101
102 // enum for the LLVM RealPredicate type
103 pub enum RealPredicate {
104     RealPredicateFalse = 0,
105     RealOEQ = 1,
106     RealOGT = 2,
107     RealOGE = 3,
108     RealOLT = 4,
109     RealOLE = 5,
110     RealONE = 6,
111     RealORD = 7,
112     RealUNO = 8,
113     RealUEQ = 9,
114     RealUGT = 10,
115     RealUGE = 11,
116     RealULT = 12,
117     RealULE = 13,
118     RealUNE = 14,
119     RealPredicateTrue = 15,
120 }
121
122 // The LLVM TypeKind type - must stay in sync with the def of
123 // LLVMTypeKind in llvm/include/llvm-c/Core.h
124 pub type TypeKind = u32;
125 pub static Void: TypeKind      = 0;
126 pub static Half: TypeKind      = 1;
127 pub static Float: TypeKind     = 2;
128 pub static Double: TypeKind    = 3;
129 pub static X86_FP80: TypeKind  = 4;
130 pub static FP128: TypeKind     = 5;
131 pub static PPC_FP128: TypeKind = 6;
132 pub static Label: TypeKind     = 7;
133 pub static Integer: TypeKind   = 8;
134 pub static Function: TypeKind  = 9;
135 pub static Struct: TypeKind    = 10;
136 pub static Array: TypeKind     = 11;
137 pub static Pointer: TypeKind   = 12;
138 pub static Vector: TypeKind    = 13;
139 pub static Metadata: TypeKind  = 14;
140 pub static X86_MMX: TypeKind   = 15;
141
142 pub enum AtomicBinOp {
143     Xchg = 0,
144     Add  = 1,
145     Sub  = 2,
146     And  = 3,
147     Nand = 4,
148     Or   = 5,
149     Xor  = 6,
150     Max  = 7,
151     Min  = 8,
152     UMax = 9,
153     UMin = 10,
154 }
155
156 pub enum AtomicOrdering {
157     NotAtomic = 0,
158     Unordered = 1,
159     Monotonic = 2,
160     // Consume = 3,  // Not specified yet.
161     Acquire = 4,
162     Release = 5,
163     AcquireRelease = 6,
164     SequentiallyConsistent = 7
165 }
166
167 // FIXME: Not used right now, but will be once #2334 is fixed
168 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
169 pub enum FileType {
170     AssemblyFile = 0,
171     ObjectFile = 1
172 }
173
174 pub enum Metadata {
175     MD_dbg = 0,
176     MD_tbaa = 1,
177     MD_prof = 2,
178     MD_fpmath = 3,
179     MD_range = 4,
180     MD_tbaa_struct = 5
181 }
182
183 // Inline Asm Dialect
184 pub enum AsmDialect {
185     AD_ATT   = 0,
186     AD_Intel = 1
187 }
188
189 // Opaque pointer types
190 pub enum Module_opaque {}
191 pub type ModuleRef = *Module_opaque;
192 pub enum Context_opaque {}
193 pub type ContextRef = *Context_opaque;
194 pub enum Type_opaque {}
195 pub type TypeRef = *Type_opaque;
196 pub enum Value_opaque {}
197 pub type ValueRef = *Value_opaque;
198 pub enum BasicBlock_opaque {}
199 pub type BasicBlockRef = *BasicBlock_opaque;
200 pub enum Builder_opaque {}
201 pub type BuilderRef = *Builder_opaque;
202 pub enum MemoryBuffer_opaque {}
203 pub type MemoryBufferRef = *MemoryBuffer_opaque;
204 pub enum PassManager_opaque {}
205 pub type PassManagerRef = *PassManager_opaque;
206 pub enum PassManagerBuilder_opaque {}
207 pub type PassManagerBuilderRef = *PassManagerBuilder_opaque;
208 pub enum Use_opaque {}
209 pub type UseRef = *Use_opaque;
210 pub enum TargetData_opaque {}
211 pub type TargetDataRef = *TargetData_opaque;
212 pub enum ObjectFile_opaque {}
213 pub type ObjectFileRef = *ObjectFile_opaque;
214 pub enum SectionIterator_opaque {}
215 pub type SectionIteratorRef = *SectionIterator_opaque;
216
217 pub mod llvm {
218     use super::{AtomicBinOp, AtomicOrdering, BasicBlockRef};
219     use super::{Bool, BuilderRef, ContextRef, MemoryBufferRef, ModuleRef};
220     use super::{ObjectFileRef, Opcode, PassManagerRef, PassManagerBuilderRef};
221     use super::{SectionIteratorRef, TargetDataRef, TypeKind, TypeRef, UseRef};
222     use super::{ValueRef};
223
224     use core::libc::{c_char, c_int, c_longlong, c_uint, c_ulonglong};
225
226     #[link_args = "-Lrustllvm -lrustllvm"]
227     #[link_name = "rustllvm"]
228     #[abi = "cdecl"]
229     pub extern {
230         /* Create and destroy contexts. */
231         #[fast_ffi]
232         pub unsafe fn LLVMContextCreate() -> ContextRef;
233         #[fast_ffi]
234         pub unsafe fn LLVMGetGlobalContext() -> ContextRef;
235         #[fast_ffi]
236         pub unsafe fn LLVMContextDispose(C: ContextRef);
237         #[fast_ffi]
238         pub unsafe fn LLVMGetMDKindIDInContext(C: ContextRef,
239                                            Name: *c_char,
240                                            SLen: c_uint)
241                                         -> c_uint;
242         #[fast_ffi]
243         pub unsafe fn LLVMGetMDKindID(Name: *c_char, SLen: c_uint) -> c_uint;
244
245         /* Create and destroy modules. */
246         #[fast_ffi]
247         pub unsafe fn LLVMModuleCreateWithNameInContext(ModuleID: *c_char,
248                                                     C: ContextRef)
249                                                  -> ModuleRef;
250         #[fast_ffi]
251         pub unsafe fn LLVMDisposeModule(M: ModuleRef);
252
253         /** Data layout. See Module::getDataLayout. */
254         #[fast_ffi]
255         pub unsafe fn LLVMGetDataLayout(M: ModuleRef) -> *c_char;
256         #[fast_ffi]
257         pub unsafe fn LLVMSetDataLayout(M: ModuleRef, Triple: *c_char);
258
259         /** Target triple. See Module::getTargetTriple. */
260         #[fast_ffi]
261         pub unsafe fn LLVMGetTarget(M: ModuleRef) -> *c_char;
262         #[fast_ffi]
263         pub unsafe fn LLVMSetTarget(M: ModuleRef, Triple: *c_char);
264
265         /** See Module::dump. */
266         #[fast_ffi]
267         pub unsafe fn LLVMDumpModule(M: ModuleRef);
268
269         /** See Module::setModuleInlineAsm. */
270         #[fast_ffi]
271         pub unsafe fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *c_char);
272
273         /** See llvm::LLVMTypeKind::getTypeID. */
274         pub unsafe fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
275
276         /** See llvm::LLVMType::getContext. */
277         #[fast_ffi]
278         pub unsafe fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
279
280         /* Operations on integer types */
281         #[fast_ffi]
282         pub unsafe fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
283         #[fast_ffi]
284         pub unsafe fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
285         #[fast_ffi]
286         pub unsafe fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
287         #[fast_ffi]
288         pub unsafe fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
289         #[fast_ffi]
290         pub unsafe fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
291         #[fast_ffi]
292         pub unsafe fn LLVMIntTypeInContext(C: ContextRef,
293                                            NumBits: c_uint) -> TypeRef;
294
295         #[fast_ffi]
296         pub unsafe fn LLVMInt1Type() -> TypeRef;
297         #[fast_ffi]
298         pub unsafe fn LLVMInt8Type() -> TypeRef;
299         #[fast_ffi]
300         pub unsafe fn LLVMInt16Type() -> TypeRef;
301         #[fast_ffi]
302         pub unsafe fn LLVMInt32Type() -> TypeRef;
303         #[fast_ffi]
304         pub unsafe fn LLVMInt64Type() -> TypeRef;
305         #[fast_ffi]
306         pub unsafe fn LLVMIntType(NumBits: c_uint) -> TypeRef;
307         #[fast_ffi]
308         pub unsafe fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
309
310         /* Operations on real types */
311         #[fast_ffi]
312         pub unsafe fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
313         #[fast_ffi]
314         pub unsafe fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
315         #[fast_ffi]
316         pub unsafe fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
317         #[fast_ffi]
318         pub unsafe fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
319         #[fast_ffi]
320         pub unsafe fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
321
322         #[fast_ffi]
323         pub unsafe fn LLVMFloatType() -> TypeRef;
324         #[fast_ffi]
325         pub unsafe fn LLVMDoubleType() -> TypeRef;
326         #[fast_ffi]
327         pub unsafe fn LLVMX86FP80Type() -> TypeRef;
328         #[fast_ffi]
329         pub unsafe fn LLVMFP128Type() -> TypeRef;
330         #[fast_ffi]
331         pub unsafe fn LLVMPPCFP128Type() -> TypeRef;
332
333         /* Operations on function types */
334         #[fast_ffi]
335         pub unsafe fn LLVMFunctionType(ReturnType: TypeRef,
336                                        ParamTypes: *TypeRef,
337                                        ParamCount: c_uint,
338                                        IsVarArg: Bool)
339                                     -> TypeRef;
340         #[fast_ffi]
341         pub unsafe fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
342         #[fast_ffi]
343         pub unsafe fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
344         #[fast_ffi]
345         pub unsafe fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
346         #[fast_ffi]
347         pub unsafe fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *TypeRef);
348
349         /* Operations on struct types */
350         #[fast_ffi]
351         pub unsafe fn LLVMStructTypeInContext(C: ContextRef,
352                                               ElementTypes: *TypeRef,
353                                               ElementCount: c_uint,
354                                               Packed: Bool) -> TypeRef;
355         #[fast_ffi]
356         pub unsafe fn LLVMStructType(ElementTypes: *TypeRef,
357                                      ElementCount: c_uint,
358                                      Packed: Bool)
359                                   -> TypeRef;
360         #[fast_ffi]
361         pub unsafe fn LLVMCountStructElementTypes(StructTy: TypeRef)
362                                                -> c_uint;
363         #[fast_ffi]
364         pub unsafe fn LLVMGetStructElementTypes(StructTy: TypeRef,
365                                             Dest: *mut TypeRef);
366         #[fast_ffi]
367         pub unsafe fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
368
369         /* Operations on array, pointer, and vector types (sequence types) */
370         #[fast_ffi]
371         pub unsafe fn LLVMArrayType(ElementType: TypeRef,
372                          ElementCount: c_uint) -> TypeRef;
373         #[fast_ffi]
374         pub unsafe fn LLVMPointerType(ElementType: TypeRef,
375                            AddressSpace: c_uint) -> TypeRef;
376         #[fast_ffi]
377         pub unsafe fn LLVMVectorType(ElementType: TypeRef,
378                           ElementCount: c_uint) -> TypeRef;
379
380         #[fast_ffi]
381         pub unsafe fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
382         #[fast_ffi]
383         pub unsafe fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
384         #[fast_ffi]
385         pub unsafe fn LLVMGetPointerAddressSpace(PointerTy: TypeRef)
386                                               -> c_uint;
387         #[fast_ffi]
388         pub unsafe fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
389
390         /* Operations on other types */
391         #[fast_ffi]
392         pub unsafe fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
393         #[fast_ffi]
394         pub unsafe fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
395         #[fast_ffi]
396         pub unsafe fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
397
398         #[fast_ffi]
399         pub unsafe fn LLVMVoidType() -> TypeRef;
400         #[fast_ffi]
401         pub unsafe fn LLVMLabelType() -> TypeRef;
402         #[fast_ffi]
403         pub unsafe fn LLVMMetadataType() -> TypeRef;
404
405         /* Operations on all values */
406         #[fast_ffi]
407         pub unsafe fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
408         #[fast_ffi]
409         pub unsafe fn LLVMGetValueName(Val: ValueRef) -> *c_char;
410         #[fast_ffi]
411         pub unsafe fn LLVMSetValueName(Val: ValueRef, Name: *c_char);
412         #[fast_ffi]
413         pub unsafe fn LLVMDumpValue(Val: ValueRef);
414         #[fast_ffi]
415         pub unsafe fn LLVMReplaceAllUsesWith(OldVal: ValueRef,
416                                              NewVal: ValueRef);
417         #[fast_ffi]
418         pub unsafe fn LLVMHasMetadata(Val: ValueRef) -> c_int;
419         #[fast_ffi]
420         pub unsafe fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint)
421                                    -> ValueRef;
422         #[fast_ffi]
423         pub unsafe fn LLVMSetMetadata(Val: ValueRef,
424                                       KindID: c_uint,
425                                       Node: ValueRef);
426
427         /* Operations on Uses */
428         #[fast_ffi]
429         pub unsafe fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
430         #[fast_ffi]
431         pub unsafe fn LLVMGetNextUse(U: UseRef) -> UseRef;
432         #[fast_ffi]
433         pub unsafe fn LLVMGetUser(U: UseRef) -> ValueRef;
434         #[fast_ffi]
435         pub unsafe fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
436
437         /* Operations on Users */
438         #[fast_ffi]
439         pub unsafe fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
440         #[fast_ffi]
441         pub unsafe fn LLVMGetOperand(Val: ValueRef, Index: c_uint)
442                                   -> ValueRef;
443         #[fast_ffi]
444         pub unsafe fn LLVMSetOperand(Val: ValueRef,
445                                      Index: c_uint,
446                                      Op: ValueRef);
447
448         /* Operations on constants of any type */
449         #[fast_ffi]
450         pub unsafe fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
451         /* all zeroes */
452         #[fast_ffi]
453         pub unsafe fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
454         /* only for int/vector */
455         #[fast_ffi]
456         pub unsafe fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
457         #[fast_ffi]
458         pub unsafe fn LLVMIsConstant(Val: ValueRef) -> Bool;
459         #[fast_ffi]
460         pub unsafe fn LLVMIsNull(Val: ValueRef) -> Bool;
461         #[fast_ffi]
462         pub unsafe fn LLVMIsUndef(Val: ValueRef) -> Bool;
463         #[fast_ffi]
464         pub unsafe fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
465
466         /* Operations on metadata */
467         #[fast_ffi]
468         pub unsafe fn LLVMMDStringInContext(C: ContextRef,
469                                         Str: *c_char,
470                                         SLen: c_uint)
471                                      -> ValueRef;
472         #[fast_ffi]
473         pub unsafe fn LLVMMDString(Str: *c_char, SLen: c_uint) -> ValueRef;
474         #[fast_ffi]
475         pub unsafe fn LLVMMDNodeInContext(C: ContextRef,
476                                       Vals: *ValueRef,
477                                       Count: c_uint)
478                                    -> ValueRef;
479         #[fast_ffi]
480         pub unsafe fn LLVMMDNode(Vals: *ValueRef, Count: c_uint) -> ValueRef;
481         #[fast_ffi]
482         pub unsafe fn LLVMAddNamedMetadataOperand(M: ModuleRef, Str: *c_char,
483                                        Val: ValueRef);
484
485         /* Operations on scalar constants */
486         #[fast_ffi]
487         pub unsafe fn LLVMConstInt(IntTy: TypeRef,
488                                N: c_ulonglong,
489                                SignExtend: Bool)
490                             -> ValueRef;
491         #[fast_ffi]
492         pub unsafe fn LLVMConstIntOfString(IntTy: TypeRef,
493                                        Text: *c_char,
494                                        Radix: u8)
495                                     -> ValueRef;
496         #[fast_ffi]
497         pub unsafe fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
498                                                   Text: *c_char,
499                                                   SLen: c_uint,
500                                                   Radix: u8)
501                                                -> ValueRef;
502         #[fast_ffi]
503         pub unsafe fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
504         #[fast_ffi]
505         pub unsafe fn LLVMConstRealOfString(RealTy: TypeRef,
506                                         Text: *c_char)
507                                      -> ValueRef;
508         #[fast_ffi]
509         pub unsafe fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
510                                                    Text: *c_char,
511                                                    SLen: c_uint)
512                                                 -> ValueRef;
513         #[fast_ffi]
514         pub unsafe fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef)
515                                             -> c_ulonglong;
516         #[fast_ffi]
517         pub unsafe fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef)
518                                             -> c_longlong;
519
520
521         /* Operations on composite constants */
522         #[fast_ffi]
523         pub unsafe fn LLVMConstStringInContext(C: ContextRef,
524                                            Str: *c_char,
525                                            Length: c_uint,
526                                            DontNullTerminate: Bool)
527                                         -> ValueRef;
528         #[fast_ffi]
529         pub unsafe fn LLVMConstStructInContext(C: ContextRef,
530                                                ConstantVals: *ValueRef,
531                                                Count: c_uint,
532                                                Packed: Bool) -> ValueRef;
533
534         #[fast_ffi]
535         pub unsafe fn LLVMConstString(Str: *c_char,
536                                       Length: c_uint,
537                                       DontNullTerminate: Bool)
538                                    -> ValueRef;
539         #[fast_ffi]
540         pub unsafe fn LLVMConstArray(ElementTy: TypeRef,
541                                      ConstantVals: *ValueRef,
542                                      Length: c_uint)
543                                   -> ValueRef;
544         #[fast_ffi]
545         pub unsafe fn LLVMConstStruct(ConstantVals: *ValueRef,
546                                       Count: c_uint,
547                                       Packed: Bool) -> ValueRef;
548         #[fast_ffi]
549         pub unsafe fn LLVMConstVector(ScalarConstantVals: *ValueRef,
550                                       Size: c_uint) -> ValueRef;
551
552         /* Constant expressions */
553         #[fast_ffi]
554         pub unsafe fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
555         #[fast_ffi]
556         pub unsafe fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
557         #[fast_ffi]
558         pub unsafe fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
559         #[fast_ffi]
560         pub unsafe fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
561         #[fast_ffi]
562         pub unsafe fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
563         #[fast_ffi]
564         pub unsafe fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
565         #[fast_ffi]
566         pub unsafe fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
567         #[fast_ffi]
568         pub unsafe fn LLVMConstAdd(LHSConstant: ValueRef,
569                                    RHSConstant: ValueRef)
570                                 -> ValueRef;
571         #[fast_ffi]
572         pub unsafe fn LLVMConstNSWAdd(LHSConstant: ValueRef,
573                                   RHSConstant: ValueRef)
574                                -> ValueRef;
575         #[fast_ffi]
576         pub unsafe fn LLVMConstNUWAdd(LHSConstant: ValueRef,
577                                   RHSConstant: ValueRef)
578                                -> ValueRef;
579         #[fast_ffi]
580         pub unsafe fn LLVMConstFAdd(LHSConstant: ValueRef,
581                                 RHSConstant: ValueRef)
582                              -> ValueRef;
583         #[fast_ffi]
584         pub unsafe fn LLVMConstSub(LHSConstant: ValueRef,
585                                    RHSConstant: ValueRef)
586                                 -> ValueRef;
587         #[fast_ffi]
588         pub unsafe fn LLVMConstNSWSub(LHSConstant: ValueRef,
589                                       RHSConstant: ValueRef)
590                                    -> ValueRef;
591         #[fast_ffi]
592         pub unsafe fn LLVMConstNUWSub(LHSConstant: ValueRef,
593                                       RHSConstant: ValueRef)
594                                    -> ValueRef;
595         #[fast_ffi]
596         pub unsafe fn LLVMConstFSub(LHSConstant: ValueRef,
597                                     RHSConstant: ValueRef)
598                                  -> ValueRef;
599         #[fast_ffi]
600         pub unsafe fn LLVMConstMul(LHSConstant: ValueRef,
601                                RHSConstant: ValueRef)
602                             -> ValueRef;
603         #[fast_ffi]
604         pub unsafe fn LLVMConstNSWMul(LHSConstant: ValueRef,
605                                   RHSConstant: ValueRef)
606                                -> ValueRef;
607         #[fast_ffi]
608         pub unsafe fn LLVMConstNUWMul(LHSConstant: ValueRef,
609                                   RHSConstant: ValueRef)
610                                -> ValueRef;
611         #[fast_ffi]
612         pub unsafe fn LLVMConstFMul(LHSConstant: ValueRef,
613                                 RHSConstant: ValueRef)
614                              -> ValueRef;
615         #[fast_ffi]
616         pub unsafe fn LLVMConstUDiv(LHSConstant: ValueRef,
617                                 RHSConstant: ValueRef)
618                              -> ValueRef;
619         #[fast_ffi]
620         pub unsafe fn LLVMConstSDiv(LHSConstant: ValueRef,
621                                 RHSConstant: ValueRef)
622                              -> ValueRef;
623         #[fast_ffi]
624         pub unsafe fn LLVMConstExactSDiv(LHSConstant: ValueRef,
625                                      RHSConstant: ValueRef)
626                                   -> ValueRef;
627         #[fast_ffi]
628         pub unsafe fn LLVMConstFDiv(LHSConstant: ValueRef,
629                                 RHSConstant: ValueRef)
630                              -> ValueRef;
631         #[fast_ffi]
632         pub unsafe fn LLVMConstURem(LHSConstant: ValueRef,
633                                 RHSConstant: ValueRef)
634                              -> ValueRef;
635         #[fast_ffi]
636         pub unsafe fn LLVMConstSRem(LHSConstant: ValueRef,
637                                 RHSConstant: ValueRef)
638                              -> ValueRef;
639         #[fast_ffi]
640         pub unsafe fn LLVMConstFRem(LHSConstant: ValueRef,
641                                 RHSConstant: ValueRef)
642                              -> ValueRef;
643         #[fast_ffi]
644         pub unsafe fn LLVMConstAnd(LHSConstant: ValueRef,
645                                RHSConstant: ValueRef)
646                             -> ValueRef;
647         #[fast_ffi]
648         pub unsafe fn LLVMConstOr(LHSConstant: ValueRef,
649                               RHSConstant: ValueRef)
650                            -> ValueRef;
651         #[fast_ffi]
652         pub unsafe fn LLVMConstXor(LHSConstant: ValueRef,
653                                RHSConstant: ValueRef)
654                             -> ValueRef;
655         #[fast_ffi]
656         pub unsafe fn LLVMConstShl(LHSConstant: ValueRef,
657                                RHSConstant: ValueRef)
658                             -> ValueRef;
659         #[fast_ffi]
660         pub unsafe fn LLVMConstLShr(LHSConstant: ValueRef,
661                                     RHSConstant: ValueRef) -> ValueRef;
662         #[fast_ffi]
663         pub unsafe fn LLVMConstAShr(LHSConstant: ValueRef,
664                                     RHSConstant: ValueRef) -> ValueRef;
665         #[fast_ffi]
666         pub unsafe fn LLVMConstGEP(ConstantVal: ValueRef,
667                         ConstantIndices: *ValueRef,
668                         NumIndices: c_uint) -> ValueRef;
669         #[fast_ffi]
670         pub unsafe fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
671                                        ConstantIndices: *ValueRef,
672                                        NumIndices: c_uint)
673                                     -> ValueRef;
674         #[fast_ffi]
675         pub unsafe fn LLVMConstTrunc(ConstantVal: ValueRef,
676                                  ToType: TypeRef)
677                               -> ValueRef;
678         #[fast_ffi]
679         pub unsafe fn LLVMConstSExt(ConstantVal: ValueRef,
680                                 ToType: TypeRef)
681                              -> ValueRef;
682         #[fast_ffi]
683         pub unsafe fn LLVMConstZExt(ConstantVal: ValueRef,
684                                 ToType: TypeRef)
685                              -> ValueRef;
686         #[fast_ffi]
687         pub unsafe fn LLVMConstFPTrunc(ConstantVal: ValueRef,
688                                    ToType: TypeRef)
689                                 -> ValueRef;
690         #[fast_ffi]
691         pub unsafe fn LLVMConstFPExt(ConstantVal: ValueRef,
692                                  ToType: TypeRef)
693                               -> ValueRef;
694         #[fast_ffi]
695         pub unsafe fn LLVMConstUIToFP(ConstantVal: ValueRef,
696                                   ToType: TypeRef)
697                                -> ValueRef;
698         #[fast_ffi]
699         pub unsafe fn LLVMConstSIToFP(ConstantVal: ValueRef,
700                                   ToType: TypeRef)
701                                -> ValueRef;
702         #[fast_ffi]
703         pub unsafe fn LLVMConstFPToUI(ConstantVal: ValueRef,
704                                   ToType: TypeRef)
705                                -> ValueRef;
706         #[fast_ffi]
707         pub unsafe fn LLVMConstFPToSI(ConstantVal: ValueRef,
708                                   ToType: TypeRef)
709                                -> ValueRef;
710         #[fast_ffi]
711         pub unsafe fn LLVMConstPtrToInt(ConstantVal: ValueRef,
712                                     ToType: TypeRef)
713                                  -> ValueRef;
714         #[fast_ffi]
715         pub unsafe fn LLVMConstIntToPtr(ConstantVal: ValueRef,
716                                     ToType: TypeRef)
717                                  -> ValueRef;
718         #[fast_ffi]
719         pub unsafe fn LLVMConstBitCast(ConstantVal: ValueRef,
720                                    ToType: TypeRef)
721                                 -> ValueRef;
722         #[fast_ffi]
723         pub unsafe fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef,
724                                          ToType: TypeRef)
725                                       -> ValueRef;
726         #[fast_ffi]
727         pub unsafe fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef,
728                                          ToType: TypeRef)
729                                       -> ValueRef;
730         #[fast_ffi]
731         pub unsafe fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef,
732                                           ToType: TypeRef)
733                                        -> ValueRef;
734         #[fast_ffi]
735         pub unsafe fn LLVMConstPointerCast(ConstantVal: ValueRef,
736                                        ToType: TypeRef)
737                                     -> ValueRef;
738         #[fast_ffi]
739         pub unsafe fn LLVMConstIntCast(ConstantVal: ValueRef,
740                                        ToType: TypeRef,
741                                        isSigned: Bool)
742                                     -> ValueRef;
743         #[fast_ffi]
744         pub unsafe fn LLVMConstFPCast(ConstantVal: ValueRef,
745                                   ToType: TypeRef)
746                                -> ValueRef;
747         #[fast_ffi]
748         pub unsafe fn LLVMConstSelect(ConstantCondition: ValueRef,
749                                       ConstantIfTrue: ValueRef,
750                                       ConstantIfFalse: ValueRef)
751                                    -> ValueRef;
752         #[fast_ffi]
753         pub unsafe fn LLVMConstExtractElement(VectorConstant: ValueRef,
754                                    IndexConstant: ValueRef) -> ValueRef;
755         #[fast_ffi]
756         pub unsafe fn LLVMConstInsertElement(VectorConstant: ValueRef,
757                                   ElementValueConstant: ValueRef,
758                                   IndexConstant: ValueRef) -> ValueRef;
759         #[fast_ffi]
760         pub unsafe fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
761                                   VectorBConstant: ValueRef,
762                                   MaskConstant: ValueRef) -> ValueRef;
763         #[fast_ffi]
764         pub unsafe fn LLVMConstExtractValue(AggConstant: ValueRef,
765                                             IdxList: *c_uint,
766                                             NumIdx: c_uint) -> ValueRef;
767         #[fast_ffi]
768         pub unsafe fn LLVMConstInsertValue(AggConstant: ValueRef,
769                                            ElementValueConstant: ValueRef,
770                                            IdxList: *c_uint,
771                                            NumIdx: c_uint)
772                                         -> ValueRef;
773         #[fast_ffi]
774         pub unsafe fn LLVMConstInlineAsm(Ty: TypeRef, AsmString: *c_char,
775                               Constraints: *c_char, HasSideEffects: Bool,
776                               IsAlignStack: Bool) -> ValueRef;
777         #[fast_ffi]
778         pub unsafe fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef)
779                                     -> ValueRef;
780
781
782
783         /* Operations on global variables, functions, and aliases (globals) */
784         #[fast_ffi]
785         pub unsafe fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
786         #[fast_ffi]
787         pub unsafe fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
788         #[fast_ffi]
789         pub unsafe fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
790         #[fast_ffi]
791         pub unsafe fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
792         #[fast_ffi]
793         pub unsafe fn LLVMGetSection(Global: ValueRef) -> *c_char;
794         #[fast_ffi]
795         pub unsafe fn LLVMSetSection(Global: ValueRef, Section: *c_char);
796         #[fast_ffi]
797         pub unsafe fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
798         #[fast_ffi]
799         pub unsafe fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
800         #[fast_ffi]
801         pub unsafe fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
802         #[fast_ffi]
803         pub unsafe fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
804
805
806         /* Operations on global variables */
807         #[fast_ffi]
808         pub unsafe fn LLVMAddGlobal(M: ModuleRef,
809                                 Ty: TypeRef,
810                                 Name: *c_char)
811                              -> ValueRef;
812         #[fast_ffi]
813         pub unsafe fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
814                                               Ty: TypeRef,
815                                               Name: *c_char,
816                                               AddressSpace: c_uint)
817                                            -> ValueRef;
818         #[fast_ffi]
819         pub unsafe fn LLVMGetNamedGlobal(M: ModuleRef, Name: *c_char)
820                                       -> ValueRef;
821         #[fast_ffi]
822         pub unsafe fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
823         #[fast_ffi]
824         pub unsafe fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
825         #[fast_ffi]
826         pub unsafe fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
827         #[fast_ffi]
828         pub unsafe fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
829         #[fast_ffi]
830         pub unsafe fn LLVMDeleteGlobal(GlobalVar: ValueRef);
831         #[fast_ffi]
832         pub unsafe fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
833         #[fast_ffi]
834         pub unsafe fn LLVMSetInitializer(GlobalVar: ValueRef,
835                                          ConstantVal: ValueRef);
836         #[fast_ffi]
837         pub unsafe fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
838         #[fast_ffi]
839         pub unsafe fn LLVMSetThreadLocal(GlobalVar: ValueRef,
840                                          IsThreadLocal: Bool);
841         #[fast_ffi]
842         pub unsafe fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
843         #[fast_ffi]
844         pub unsafe fn LLVMSetGlobalConstant(GlobalVar: ValueRef,
845                                             IsConstant: Bool);
846
847         /* Operations on aliases */
848         #[fast_ffi]
849         pub unsafe fn LLVMAddAlias(M: ModuleRef,
850                                    Ty: TypeRef,
851                                    Aliasee: ValueRef,
852                                    Name: *c_char)
853                                 -> ValueRef;
854
855         /* Operations on functions */
856         #[fast_ffi]
857         pub unsafe fn LLVMAddFunction(M: ModuleRef,
858                                   Name: *c_char,
859                                   FunctionTy: TypeRef)
860                                -> ValueRef;
861         #[fast_ffi]
862         pub unsafe fn LLVMGetNamedFunction(M: ModuleRef,
863                                            Name: *c_char) -> ValueRef;
864         #[fast_ffi]
865         pub unsafe fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
866         #[fast_ffi]
867         pub unsafe fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
868         #[fast_ffi]
869         pub unsafe fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
870         #[fast_ffi]
871         pub unsafe fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
872         #[fast_ffi]
873         pub unsafe fn LLVMDeleteFunction(Fn: ValueRef);
874         #[fast_ffi]
875         pub unsafe fn LLVMGetOrInsertFunction(M: ModuleRef, Name: *c_char,
876                                    FunctionTy: TypeRef) -> ValueRef;
877         #[fast_ffi]
878         pub unsafe fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
879         #[fast_ffi]
880         pub unsafe fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
881         #[fast_ffi]
882         pub unsafe fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
883         #[fast_ffi]
884         pub unsafe fn LLVMGetGC(Fn: ValueRef) -> *c_char;
885         #[fast_ffi]
886         pub unsafe fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
887         #[fast_ffi]
888         pub unsafe fn LLVMAddFunctionAttr(Fn: ValueRef,
889                                           PA: c_uint,
890                                           HighPA: c_uint);
891         #[fast_ffi]
892         pub unsafe fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
893         #[fast_ffi]
894         pub unsafe fn LLVMRemoveFunctionAttr(Fn: ValueRef,
895                                              PA: c_ulonglong,
896                                              HighPA: c_ulonglong);
897
898         /* Operations on parameters */
899         #[fast_ffi]
900         pub unsafe fn LLVMCountParams(Fn: ValueRef) -> c_uint;
901         #[fast_ffi]
902         pub unsafe fn LLVMGetParams(Fn: ValueRef, Params: *ValueRef);
903         #[fast_ffi]
904         pub unsafe fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
905         #[fast_ffi]
906         pub unsafe fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
907         #[fast_ffi]
908         pub unsafe fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
909         #[fast_ffi]
910         pub unsafe fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
911         #[fast_ffi]
912         pub unsafe fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
913         #[fast_ffi]
914         pub unsafe fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
915         #[fast_ffi]
916         pub unsafe fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
917         #[fast_ffi]
918         pub unsafe fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
919         #[fast_ffi]
920         pub unsafe fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
921         #[fast_ffi]
922         pub unsafe fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
923
924         /* Operations on basic blocks */
925         #[fast_ffi]
926         pub unsafe fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
927         #[fast_ffi]
928         pub unsafe fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
929         #[fast_ffi]
930         pub unsafe fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
931         #[fast_ffi]
932         pub unsafe fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
933         #[fast_ffi]
934         pub unsafe fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
935         #[fast_ffi]
936         pub unsafe fn LLVMGetBasicBlocks(Fn: ValueRef,
937                                          BasicBlocks: *ValueRef);
938         #[fast_ffi]
939         pub unsafe fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
940         #[fast_ffi]
941         pub unsafe fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
942         #[fast_ffi]
943         pub unsafe fn LLVMGetNextBasicBlock(BB: BasicBlockRef)
944                                          -> BasicBlockRef;
945         #[fast_ffi]
946         pub unsafe fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef)
947                                              -> BasicBlockRef;
948         #[fast_ffi]
949         pub unsafe fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
950
951         #[fast_ffi]
952         pub unsafe fn LLVMAppendBasicBlockInContext(C: ContextRef,
953                                                     Fn: ValueRef,
954                                                     Name: *c_char)
955                                                  -> BasicBlockRef;
956         #[fast_ffi]
957         pub unsafe fn LLVMInsertBasicBlockInContext(C: ContextRef,
958                                                     BB: BasicBlockRef,
959                                                     Name: *c_char)
960                                                  -> BasicBlockRef;
961
962         #[fast_ffi]
963         pub unsafe fn LLVMAppendBasicBlock(Fn: ValueRef,
964                                        Name: *c_char)
965                                     -> BasicBlockRef;
966         #[fast_ffi]
967         pub unsafe fn LLVMInsertBasicBlock(InsertBeforeBB: BasicBlockRef,
968                                        Name: *c_char)
969                                     -> BasicBlockRef;
970         #[fast_ffi]
971         pub unsafe fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
972
973         /* Operations on instructions */
974         #[fast_ffi]
975         pub unsafe fn LLVMGetInstructionParent(Inst: ValueRef)
976                                             -> BasicBlockRef;
977         #[fast_ffi]
978         pub unsafe fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
979         #[fast_ffi]
980         pub unsafe fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
981         #[fast_ffi]
982         pub unsafe fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
983         #[fast_ffi]
984         pub unsafe fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
985
986         /* Operations on call sites */
987         #[fast_ffi]
988         pub unsafe fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
989         #[fast_ffi]
990         pub unsafe fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
991         #[fast_ffi]
992         pub unsafe fn LLVMAddInstrAttribute(Instr: ValueRef,
993                                             index: c_uint,
994                                             IA: c_uint);
995         #[fast_ffi]
996         pub unsafe fn LLVMRemoveInstrAttribute(Instr: ValueRef,
997                                                index: c_uint,
998                                                IA: c_uint);
999         #[fast_ffi]
1000         pub unsafe fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1001                                                  index: c_uint,
1002                                                  align: c_uint);
1003
1004         /* Operations on call instructions (only) */
1005         #[fast_ffi]
1006         pub unsafe fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1007         #[fast_ffi]
1008         pub unsafe fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1009
1010         /* Operations on phi nodes */
1011         #[fast_ffi]
1012         pub unsafe fn LLVMAddIncoming(PhiNode: ValueRef,
1013                                       IncomingValues: *ValueRef,
1014                                       IncomingBlocks: *BasicBlockRef,
1015                                       Count: c_uint);
1016         #[fast_ffi]
1017         pub unsafe fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1018         #[fast_ffi]
1019         pub unsafe fn LLVMGetIncomingValue(PhiNode: ValueRef,
1020                                        Index: c_uint)
1021                                     -> ValueRef;
1022         #[fast_ffi]
1023         pub unsafe fn LLVMGetIncomingBlock(PhiNode: ValueRef,
1024                                 Index: c_uint) -> BasicBlockRef;
1025
1026         /* Instruction builders */
1027         #[fast_ffi]
1028         pub unsafe fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1029         #[fast_ffi]
1030         pub unsafe fn LLVMCreateBuilder() -> BuilderRef;
1031         #[fast_ffi]
1032         pub unsafe fn LLVMPositionBuilder(Builder: BuilderRef,
1033                                           Block: BasicBlockRef,
1034                                           Instr: ValueRef);
1035         #[fast_ffi]
1036         pub unsafe fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1037                                                 Instr: ValueRef);
1038         #[fast_ffi]
1039         pub unsafe fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1040                                                Block: BasicBlockRef);
1041         #[fast_ffi]
1042         pub unsafe fn LLVMGetInsertBlock(Builder: BuilderRef)
1043                                       -> BasicBlockRef;
1044         #[fast_ffi]
1045         pub unsafe fn LLVMClearInsertionPosition(Builder: BuilderRef);
1046         #[fast_ffi]
1047         pub unsafe fn LLVMInsertIntoBuilder(Builder: BuilderRef,
1048                                             Instr: ValueRef);
1049         #[fast_ffi]
1050         pub unsafe fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1051                                                 Instr: ValueRef,
1052                                                 Name: *c_char);
1053         #[fast_ffi]
1054         pub unsafe fn LLVMDisposeBuilder(Builder: BuilderRef);
1055
1056         /* Metadata */
1057         #[fast_ffi]
1058         pub unsafe fn LLVMSetCurrentDebugLocation(Builder: BuilderRef,
1059                                                   L: ValueRef);
1060         #[fast_ffi]
1061         pub unsafe fn LLVMGetCurrentDebugLocation(Builder: BuilderRef)
1062                                                -> ValueRef;
1063         #[fast_ffi]
1064         pub unsafe fn LLVMSetInstDebugLocation(Builder: BuilderRef,
1065                                                Inst: ValueRef);
1066
1067         /* Terminators */
1068         #[fast_ffi]
1069         pub unsafe fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1070         #[fast_ffi]
1071         pub unsafe fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1072         #[fast_ffi]
1073         pub unsafe fn LLVMBuildAggregateRet(B: BuilderRef, RetVals: *ValueRef,
1074                                  N: c_uint) -> ValueRef;
1075         #[fast_ffi]
1076         pub unsafe fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef)
1077                                -> ValueRef;
1078         #[fast_ffi]
1079         pub unsafe fn LLVMBuildCondBr(B: BuilderRef,
1080                                   If: ValueRef,
1081                                   Then: BasicBlockRef,
1082                                   Else: BasicBlockRef)
1083                                -> ValueRef;
1084         #[fast_ffi]
1085         pub unsafe fn LLVMBuildSwitch(B: BuilderRef, V: ValueRef,
1086                                       Else: BasicBlockRef, NumCases: c_uint)
1087                                    -> ValueRef;
1088         #[fast_ffi]
1089         pub unsafe fn LLVMBuildIndirectBr(B: BuilderRef, Addr: ValueRef,
1090                                NumDests: c_uint) -> ValueRef;
1091         #[fast_ffi]
1092         pub unsafe fn LLVMBuildInvoke(B: BuilderRef,
1093                                       Fn: ValueRef,
1094                                       Args: *ValueRef,
1095                                       NumArgs: c_uint,
1096                                       Then: BasicBlockRef,
1097                                       Catch: BasicBlockRef,
1098                                       Name: *c_char) -> ValueRef;
1099         #[fast_ffi]
1100         pub unsafe fn LLVMBuildLandingPad(B: BuilderRef,
1101                                       Ty: TypeRef,
1102                                       PersFn: ValueRef,
1103                                       NumClauses: c_uint,
1104                                       Name: *c_char)
1105                                    -> ValueRef;
1106         #[fast_ffi]
1107         pub unsafe fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef)
1108                                    -> ValueRef;
1109         #[fast_ffi]
1110         pub unsafe fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1111
1112         /* Add a case to the switch instruction */
1113         #[fast_ffi]
1114         pub unsafe fn LLVMAddCase(Switch: ValueRef,
1115                               OnVal: ValueRef,
1116                               Dest: BasicBlockRef);
1117
1118         /* Add a destination to the indirectbr instruction */
1119         #[fast_ffi]
1120         pub unsafe fn LLVMAddDestination(IndirectBr: ValueRef,
1121                                          Dest: BasicBlockRef);
1122
1123         /* Add a clause to the landing pad instruction */
1124         #[fast_ffi]
1125         pub unsafe fn LLVMAddClause(LandingPad: ValueRef,
1126                                     ClauseVal: ValueRef);
1127
1128         /* Set the cleanup on a landing pad instruction */
1129         #[fast_ffi]
1130         pub unsafe fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1131
1132         /* Arithmetic */
1133         #[fast_ffi]
1134         pub unsafe fn LLVMBuildAdd(B: BuilderRef,
1135                                    LHS: ValueRef,
1136                                    RHS: ValueRef,
1137                                    Name: *c_char)
1138                                 -> ValueRef;
1139         #[fast_ffi]
1140         pub unsafe fn LLVMBuildNSWAdd(B: BuilderRef,
1141                                       LHS: ValueRef,
1142                                       RHS: ValueRef,
1143                                       Name: *c_char)
1144                                    -> ValueRef;
1145         #[fast_ffi]
1146         pub unsafe fn LLVMBuildNUWAdd(B: BuilderRef,
1147                                       LHS: ValueRef,
1148                                       RHS: ValueRef,
1149                                       Name: *c_char)
1150                                    -> ValueRef;
1151         #[fast_ffi]
1152         pub unsafe fn LLVMBuildFAdd(B: BuilderRef,
1153                                     LHS: ValueRef,
1154                                     RHS: ValueRef,
1155                                     Name: *c_char)
1156                                  -> ValueRef;
1157         #[fast_ffi]
1158         pub unsafe fn LLVMBuildSub(B: BuilderRef,
1159                                    LHS: ValueRef,
1160                                    RHS: ValueRef,
1161                                    Name: *c_char)
1162                                 -> ValueRef;
1163         #[fast_ffi]
1164         pub unsafe fn LLVMBuildNSWSub(B: BuilderRef,
1165                                       LHS: ValueRef,
1166                                       RHS: ValueRef,
1167                                       Name: *c_char)
1168                                    -> ValueRef;
1169         #[fast_ffi]
1170         pub unsafe fn LLVMBuildNUWSub(B: BuilderRef,
1171                                       LHS: ValueRef,
1172                                       RHS: ValueRef,
1173                                       Name: *c_char)
1174                                    -> ValueRef;
1175         #[fast_ffi]
1176         pub unsafe fn LLVMBuildFSub(B: BuilderRef,
1177                                     LHS: ValueRef,
1178                                     RHS: ValueRef,
1179                                     Name: *c_char)
1180                                  -> ValueRef;
1181         #[fast_ffi]
1182         pub unsafe fn LLVMBuildMul(B: BuilderRef,
1183                                    LHS: ValueRef,
1184                                    RHS: ValueRef,
1185                                    Name: *c_char)
1186                                 -> ValueRef;
1187         #[fast_ffi]
1188         pub unsafe fn LLVMBuildNSWMul(B: BuilderRef,
1189                                       LHS: ValueRef,
1190                                       RHS: ValueRef,
1191                                       Name: *c_char)
1192                                    -> ValueRef;
1193         #[fast_ffi]
1194         pub unsafe fn LLVMBuildNUWMul(B: BuilderRef,
1195                                       LHS: ValueRef,
1196                                       RHS: ValueRef,
1197                                       Name: *c_char)
1198                                    -> ValueRef;
1199         #[fast_ffi]
1200         pub unsafe fn LLVMBuildFMul(B: BuilderRef,
1201                                     LHS: ValueRef,
1202                                     RHS: ValueRef,
1203                                     Name: *c_char)
1204                                  -> ValueRef;
1205         #[fast_ffi]
1206         pub unsafe fn LLVMBuildUDiv(B: BuilderRef,
1207                                     LHS: ValueRef,
1208                                     RHS: ValueRef,
1209                                     Name: *c_char)
1210                                  -> ValueRef;
1211         #[fast_ffi]
1212         pub unsafe fn LLVMBuildSDiv(B: BuilderRef,
1213                                     LHS: ValueRef,
1214                                     RHS: ValueRef,
1215                                     Name: *c_char)
1216                                  -> ValueRef;
1217         #[fast_ffi]
1218         pub unsafe fn LLVMBuildExactSDiv(B: BuilderRef,
1219                                          LHS: ValueRef,
1220                                          RHS: ValueRef,
1221                                          Name: *c_char)
1222                                       -> ValueRef;
1223         #[fast_ffi]
1224         pub unsafe fn LLVMBuildFDiv(B: BuilderRef,
1225                                     LHS: ValueRef,
1226                                     RHS: ValueRef,
1227                                     Name: *c_char)
1228                                  -> ValueRef;
1229         #[fast_ffi]
1230         pub unsafe fn LLVMBuildURem(B: BuilderRef,
1231                                     LHS: ValueRef,
1232                                     RHS: ValueRef,
1233                                     Name: *c_char)
1234                                  -> ValueRef;
1235         #[fast_ffi]
1236         pub unsafe fn LLVMBuildSRem(B: BuilderRef,
1237                                     LHS: ValueRef,
1238                                     RHS: ValueRef,
1239                                     Name: *c_char)
1240                                  -> ValueRef;
1241         #[fast_ffi]
1242         pub unsafe fn LLVMBuildFRem(B: BuilderRef,
1243                                     LHS: ValueRef,
1244                                     RHS: ValueRef,
1245                                     Name: *c_char)
1246                                  -> ValueRef;
1247         #[fast_ffi]
1248         pub unsafe fn LLVMBuildShl(B: BuilderRef,
1249                                    LHS: ValueRef,
1250                                    RHS: ValueRef,
1251                                    Name: *c_char)
1252                                 -> ValueRef;
1253         #[fast_ffi]
1254         pub unsafe fn LLVMBuildLShr(B: BuilderRef,
1255                                     LHS: ValueRef,
1256                                     RHS: ValueRef,
1257                                     Name: *c_char)
1258                                  -> ValueRef;
1259         #[fast_ffi]
1260         pub unsafe fn LLVMBuildAShr(B: BuilderRef,
1261                                     LHS: ValueRef,
1262                                     RHS: ValueRef,
1263                                     Name: *c_char)
1264                                  -> ValueRef;
1265         #[fast_ffi]
1266         pub unsafe fn LLVMBuildAnd(B: BuilderRef,
1267                                    LHS: ValueRef,
1268                                    RHS: ValueRef,
1269                                    Name: *c_char)
1270                                 -> ValueRef;
1271         #[fast_ffi]
1272         pub unsafe fn LLVMBuildOr(B: BuilderRef,
1273                                   LHS: ValueRef,
1274                                   RHS: ValueRef,
1275                                   Name: *c_char)
1276                                -> ValueRef;
1277         #[fast_ffi]
1278         pub unsafe fn LLVMBuildXor(B: BuilderRef,
1279                                    LHS: ValueRef,
1280                                    RHS: ValueRef,
1281                                    Name: *c_char)
1282                                 -> ValueRef;
1283         #[fast_ffi]
1284         pub unsafe fn LLVMBuildBinOp(B: BuilderRef,
1285                                  Op: Opcode,
1286                                  LHS: ValueRef,
1287                                  RHS: ValueRef,
1288                                  Name: *c_char)
1289                               -> ValueRef;
1290         #[fast_ffi]
1291         pub unsafe fn LLVMBuildNeg(B: BuilderRef,
1292                                V: ValueRef,
1293                                Name: *c_char)
1294                             -> ValueRef;
1295         #[fast_ffi]
1296         pub unsafe fn LLVMBuildNSWNeg(B: BuilderRef,
1297                                   V: ValueRef,
1298                                   Name: *c_char)
1299                                -> ValueRef;
1300         #[fast_ffi]
1301         pub unsafe fn LLVMBuildNUWNeg(B: BuilderRef,
1302                                   V: ValueRef,
1303                                   Name: *c_char)
1304                                -> ValueRef;
1305         #[fast_ffi]
1306         pub unsafe fn LLVMBuildFNeg(B: BuilderRef,
1307                                 V: ValueRef,
1308                                 Name: *c_char)
1309                              -> ValueRef;
1310         #[fast_ffi]
1311         pub unsafe fn LLVMBuildNot(B: BuilderRef,
1312                                V: ValueRef,
1313                                Name: *c_char)
1314                             -> ValueRef;
1315
1316         /* Memory */
1317         #[fast_ffi]
1318         pub unsafe fn LLVMBuildMalloc(B: BuilderRef,
1319                                       Ty: TypeRef,
1320                                       Name: *c_char)
1321                                    -> ValueRef;
1322         #[fast_ffi]
1323         pub unsafe fn LLVMBuildArrayMalloc(B: BuilderRef,
1324                                            Ty: TypeRef,
1325                                            Val: ValueRef,
1326                                            Name: *c_char) -> ValueRef;
1327         #[fast_ffi]
1328         pub unsafe fn LLVMBuildAlloca(B: BuilderRef,
1329                                   Ty: TypeRef,
1330                                   Name: *c_char)
1331                                -> ValueRef;
1332         #[fast_ffi]
1333         pub unsafe fn LLVMBuildArrayAlloca(B: BuilderRef,
1334                                            Ty: TypeRef,
1335                                            Val: ValueRef,
1336                                            Name: *c_char) -> ValueRef;
1337         #[fast_ffi]
1338         pub unsafe fn LLVMBuildFree(B: BuilderRef,
1339                                     PointerVal: ValueRef) -> ValueRef;
1340         #[fast_ffi]
1341         pub unsafe fn LLVMBuildLoad(B: BuilderRef,
1342                                 PointerVal: ValueRef,
1343                                 Name: *c_char)
1344                              -> ValueRef;
1345         #[fast_ffi]
1346         pub unsafe fn LLVMBuildStore(B: BuilderRef,
1347                                      Val: ValueRef,
1348                                      Ptr: ValueRef) -> ValueRef;
1349         #[fast_ffi]
1350         pub unsafe fn LLVMBuildGEP(B: BuilderRef,
1351                                Pointer: ValueRef,
1352                                Indices: *ValueRef,
1353                                NumIndices: c_uint,
1354                                Name: *c_char)
1355                             -> ValueRef;
1356         #[fast_ffi]
1357         pub unsafe fn LLVMBuildInBoundsGEP(B: BuilderRef, Pointer: ValueRef,
1358                                 Indices: *ValueRef, NumIndices: c_uint,
1359                                 Name: *c_char)
1360            -> ValueRef;
1361         #[fast_ffi]
1362         pub unsafe fn LLVMBuildStructGEP(B: BuilderRef,
1363                                      Pointer: ValueRef,
1364                                      Idx: c_uint,
1365                                      Name: *c_char)
1366                                   -> ValueRef;
1367         #[fast_ffi]
1368         pub unsafe fn LLVMBuildGlobalString(B: BuilderRef,
1369                                         Str: *c_char,
1370                                         Name: *c_char)
1371                                      -> ValueRef;
1372         #[fast_ffi]
1373         pub unsafe fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1374                                            Str: *c_char,
1375                                            Name: *c_char)
1376                                         -> ValueRef;
1377
1378         /* Casts */
1379         #[fast_ffi]
1380         pub unsafe fn LLVMBuildTrunc(B: BuilderRef,
1381                                      Val: ValueRef,
1382                                      DestTy: TypeRef,
1383                                      Name: *c_char) -> ValueRef;
1384         #[fast_ffi]
1385         pub unsafe fn LLVMBuildZExt(B: BuilderRef,
1386                                     Val: ValueRef,
1387                                     DestTy: TypeRef,
1388                                     Name: *c_char)
1389                                  -> ValueRef;
1390         #[fast_ffi]
1391         pub unsafe fn LLVMBuildSExt(B: BuilderRef,
1392                                     Val: ValueRef,
1393                                     DestTy: TypeRef,
1394                                     Name: *c_char)
1395                                  -> ValueRef;
1396         #[fast_ffi]
1397         pub unsafe fn LLVMBuildFPToUI(B: BuilderRef,
1398                                       Val: ValueRef,
1399                                       DestTy: TypeRef,
1400                                       Name: *c_char) -> ValueRef;
1401         #[fast_ffi]
1402         pub unsafe fn LLVMBuildFPToSI(B: BuilderRef,
1403                                       Val: ValueRef,
1404                                       DestTy: TypeRef,
1405                                       Name: *c_char) -> ValueRef;
1406         #[fast_ffi]
1407         pub unsafe fn LLVMBuildUIToFP(B: BuilderRef,
1408                                       Val: ValueRef,
1409                                       DestTy: TypeRef,
1410                                       Name: *c_char) -> ValueRef;
1411         #[fast_ffi]
1412         pub unsafe fn LLVMBuildSIToFP(B: BuilderRef,
1413                                       Val: ValueRef,
1414                                       DestTy: TypeRef,
1415                                       Name: *c_char) -> ValueRef;
1416         #[fast_ffi]
1417         pub unsafe fn LLVMBuildFPTrunc(B: BuilderRef,
1418                                        Val: ValueRef,
1419                                        DestTy: TypeRef,
1420                                        Name: *c_char) -> ValueRef;
1421         #[fast_ffi]
1422         pub unsafe fn LLVMBuildFPExt(B: BuilderRef,
1423                                      Val: ValueRef,
1424                                      DestTy: TypeRef,
1425                                      Name: *c_char) -> ValueRef;
1426         #[fast_ffi]
1427         pub unsafe fn LLVMBuildPtrToInt(B: BuilderRef,
1428                                         Val: ValueRef,
1429                                         DestTy: TypeRef,
1430                                         Name: *c_char) -> ValueRef;
1431         #[fast_ffi]
1432         pub unsafe fn LLVMBuildIntToPtr(B: BuilderRef,
1433                                         Val: ValueRef,
1434                                         DestTy: TypeRef,
1435                                         Name: *c_char) -> ValueRef;
1436         #[fast_ffi]
1437         pub unsafe fn LLVMBuildBitCast(B: BuilderRef,
1438                                        Val: ValueRef,
1439                                        DestTy: TypeRef,
1440                                        Name: *c_char) -> ValueRef;
1441         #[fast_ffi]
1442         pub unsafe fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1443                                          Val: ValueRef,
1444                                          DestTy: TypeRef,
1445                                          Name: *c_char)
1446                                       -> ValueRef;
1447         #[fast_ffi]
1448         pub unsafe fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1449                                          Val: ValueRef,
1450                                          DestTy: TypeRef,
1451                                          Name: *c_char)
1452                                       -> ValueRef;
1453         #[fast_ffi]
1454         pub unsafe fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1455                                           Val: ValueRef,
1456                                           DestTy: TypeRef,
1457                                           Name: *c_char)
1458                                        -> ValueRef;
1459         #[fast_ffi]
1460         pub unsafe fn LLVMBuildCast(B: BuilderRef, Op: Opcode, Val: ValueRef,
1461                          DestTy: TypeRef, Name: *c_char) -> ValueRef;
1462         #[fast_ffi]
1463         pub unsafe fn LLVMBuildPointerCast(B: BuilderRef,
1464                                        Val: ValueRef,
1465                                        DestTy: TypeRef,
1466                                        Name: *c_char)
1467                                     -> ValueRef;
1468         #[fast_ffi]
1469         pub unsafe fn LLVMBuildIntCast(B: BuilderRef,
1470                                        Val: ValueRef,
1471                                        DestTy: TypeRef,
1472                                        Name: *c_char) -> ValueRef;
1473         #[fast_ffi]
1474         pub unsafe fn LLVMBuildFPCast(B: BuilderRef,
1475                                       Val: ValueRef,
1476                                       DestTy: TypeRef,
1477                                       Name: *c_char) -> ValueRef;
1478
1479         /* Comparisons */
1480         #[fast_ffi]
1481         pub unsafe fn LLVMBuildICmp(B: BuilderRef, Op: c_uint, LHS: ValueRef,
1482                          RHS: ValueRef, Name: *c_char) -> ValueRef;
1483         #[fast_ffi]
1484         pub unsafe fn LLVMBuildFCmp(B: BuilderRef, Op: c_uint, LHS: ValueRef,
1485                          RHS: ValueRef, Name: *c_char) -> ValueRef;
1486
1487         /* Miscellaneous instructions */
1488         #[fast_ffi]
1489         pub unsafe fn LLVMBuildPhi(B: BuilderRef,
1490                                    Ty: TypeRef,
1491                                    Name: *c_char)
1492                                 -> ValueRef;
1493         #[fast_ffi]
1494         pub unsafe fn LLVMBuildCall(B: BuilderRef,
1495                                     Fn: ValueRef,
1496                                     Args: *ValueRef,
1497                                     NumArgs: c_uint,
1498                                     Name: *c_char)
1499                                  -> ValueRef;
1500         #[fast_ffi]
1501         pub unsafe fn LLVMBuildSelect(B: BuilderRef,
1502                                       If: ValueRef,
1503                                       Then: ValueRef,
1504                                       Else: ValueRef,
1505                                       Name: *c_char)
1506                                    -> ValueRef;
1507         #[fast_ffi]
1508         pub unsafe fn LLVMBuildVAArg(B: BuilderRef,
1509                                      list: ValueRef,
1510                                      Ty: TypeRef,
1511                                      Name: *c_char)
1512                                   -> ValueRef;
1513         #[fast_ffi]
1514         pub unsafe fn LLVMBuildExtractElement(B: BuilderRef,
1515                                           VecVal: ValueRef,
1516                                           Index: ValueRef,
1517                                           Name: *c_char)
1518                                        -> ValueRef;
1519         #[fast_ffi]
1520         pub unsafe fn LLVMBuildInsertElement(B: BuilderRef,
1521                                          VecVal: ValueRef,
1522                                          EltVal: ValueRef,
1523                                          Index: ValueRef,
1524                                          Name: *c_char)
1525                                       -> ValueRef;
1526         #[fast_ffi]
1527         pub unsafe fn LLVMBuildShuffleVector(B: BuilderRef,
1528                                          V1: ValueRef,
1529                                          V2: ValueRef,
1530                                          Mask: ValueRef,
1531                                          Name: *c_char)
1532                                       -> ValueRef;
1533         #[fast_ffi]
1534         pub unsafe fn LLVMBuildExtractValue(B: BuilderRef,
1535                                         AggVal: ValueRef,
1536                                         Index: c_uint,
1537                                         Name: *c_char)
1538                                      -> ValueRef;
1539         #[fast_ffi]
1540         pub unsafe fn LLVMBuildInsertValue(B: BuilderRef,
1541                                        AggVal: ValueRef,
1542                                        EltVal: ValueRef,
1543                                        Index: c_uint,
1544                                        Name: *c_char)
1545                                     -> ValueRef;
1546
1547         #[fast_ffi]
1548         pub unsafe fn LLVMBuildIsNull(B: BuilderRef,
1549                                       Val: ValueRef,
1550                                       Name: *c_char)
1551                                    -> ValueRef;
1552         #[fast_ffi]
1553         pub unsafe fn LLVMBuildIsNotNull(B: BuilderRef,
1554                                          Val: ValueRef,
1555                                          Name: *c_char)
1556                                       -> ValueRef;
1557         #[fast_ffi]
1558         pub unsafe fn LLVMBuildPtrDiff(B: BuilderRef,
1559                                        LHS: ValueRef,
1560                                        RHS: ValueRef,
1561                                        Name: *c_char) -> ValueRef;
1562
1563         /* Atomic Operations */
1564         pub unsafe fn LLVMBuildAtomicCmpXchg(B: BuilderRef, LHS: ValueRef,
1565                                   CMP: ValueRef, RHS: ValueRef,
1566                                   ++Order: AtomicOrdering) -> ValueRef;
1567         pub unsafe fn LLVMBuildAtomicRMW(B: BuilderRef, ++Op: AtomicBinOp,
1568                               LHS: ValueRef, RHS: ValueRef,
1569                               ++Order: AtomicOrdering) -> ValueRef;
1570
1571         /* Selected entries from the downcasts. */
1572         #[fast_ffi]
1573         pub unsafe fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1574
1575         /** Writes a module to the specified path. Returns 0 on success. */
1576         #[fast_ffi]
1577         pub unsafe fn LLVMWriteBitcodeToFile(M: ModuleRef,
1578                                              Path: *c_char) -> c_int;
1579
1580         /** Creates target data from a target layout string. */
1581         #[fast_ffi]
1582         pub unsafe fn LLVMCreateTargetData(StringRep: *c_char)
1583                                         -> TargetDataRef;
1584         /** Adds the target data to the given pass manager. The pass manager
1585             references the target data only weakly. */
1586         #[fast_ffi]
1587         pub unsafe fn LLVMAddTargetData(TD: TargetDataRef,
1588                                         PM: PassManagerRef);
1589         /** Number of bytes clobbered when doing a Store to *T. */
1590         #[fast_ffi]
1591         pub unsafe fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1592             -> c_ulonglong;
1593
1594         /** Number of bytes clobbered when doing a Store to *T. */
1595         #[fast_ffi]
1596         pub unsafe fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1597             -> c_ulonglong;
1598
1599         /** Distance between successive elements in an array of T.
1600         Includes ABI padding. */
1601         #[fast_ffi]
1602         pub unsafe fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef)
1603                                      -> c_uint;
1604
1605         /** Returns the preferred alignment of a type. */
1606         #[fast_ffi]
1607         pub unsafe fn LLVMPreferredAlignmentOfType(TD: TargetDataRef,
1608                                         Ty: TypeRef) -> c_uint;
1609         /** Returns the minimum alignment of a type. */
1610         #[fast_ffi]
1611         pub unsafe fn LLVMABIAlignmentOfType(TD: TargetDataRef,
1612                                   Ty: TypeRef) -> c_uint;
1613         /**
1614          * Returns the minimum alignment of a type when part of a call frame.
1615          */
1616         #[fast_ffi]
1617         pub unsafe fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef,
1618                                                    Ty: TypeRef)
1619                                                 -> c_uint;
1620
1621         /** Disposes target data. */
1622         #[fast_ffi]
1623         pub unsafe fn LLVMDisposeTargetData(TD: TargetDataRef);
1624
1625         /** Creates a pass manager. */
1626         #[fast_ffi]
1627         pub unsafe fn LLVMCreatePassManager() -> PassManagerRef;
1628         /** Disposes a pass manager. */
1629         #[fast_ffi]
1630         pub unsafe fn LLVMDisposePassManager(PM: PassManagerRef);
1631         /** Runs a pass manager on a module. */
1632         #[fast_ffi]
1633         pub unsafe fn LLVMRunPassManager(PM: PassManagerRef,
1634                                          M: ModuleRef) -> Bool;
1635
1636         /** Adds a verification pass. */
1637         #[fast_ffi]
1638         pub unsafe fn LLVMAddVerifierPass(PM: PassManagerRef);
1639
1640         #[fast_ffi]
1641         pub unsafe fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1642         #[fast_ffi]
1643         pub unsafe fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1644         #[fast_ffi]
1645         pub unsafe fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1646         #[fast_ffi]
1647         pub unsafe fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1648         #[fast_ffi]
1649         pub unsafe fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1650         #[fast_ffi]
1651         pub unsafe fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1652         #[fast_ffi]
1653         pub unsafe fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1654         #[fast_ffi]
1655         pub unsafe fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1656         #[fast_ffi]
1657         pub unsafe fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1658         #[fast_ffi]
1659         pub unsafe fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1660         #[fast_ffi]
1661         pub unsafe fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1662         #[fast_ffi]
1663         pub unsafe fn LLVMAddReassociatePass(PM: PassManagerRef);
1664         #[fast_ffi]
1665         pub unsafe fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1666         #[fast_ffi]
1667         pub unsafe fn LLVMAddLICMPass(PM: PassManagerRef);
1668         #[fast_ffi]
1669         pub unsafe fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1670         #[fast_ffi]
1671         pub unsafe fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1672         #[fast_ffi]
1673         pub unsafe fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1674         #[fast_ffi]
1675         pub unsafe fn LLVMAddGVNPass(PM: PassManagerRef);
1676         #[fast_ffi]
1677         pub unsafe fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1678         #[fast_ffi]
1679         pub unsafe fn LLVMAddSCCPPass(PM: PassManagerRef);
1680         #[fast_ffi]
1681         pub unsafe fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1682         #[fast_ffi]
1683         pub unsafe fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1684         #[fast_ffi]
1685         pub unsafe fn LLVMAddConstantMergePass(PM: PassManagerRef);
1686         #[fast_ffi]
1687         pub unsafe fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1688         #[fast_ffi]
1689         pub unsafe fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1690         #[fast_ffi]
1691         pub unsafe fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1692         #[fast_ffi]
1693         pub unsafe fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1694         #[fast_ffi]
1695         pub unsafe fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1696         #[fast_ffi]
1697         pub unsafe fn LLVMAddCorrelatedValuePropagationPass(PM:
1698                                                             PassManagerRef);
1699         #[fast_ffi]
1700         pub unsafe fn LLVMAddPruneEHPass(PM: PassManagerRef);
1701         #[fast_ffi]
1702         pub unsafe fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1703         #[fast_ffi]
1704         pub unsafe fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1705         #[fast_ffi]
1706         pub unsafe fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1707         #[fast_ffi]
1708         pub unsafe fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1709         #[fast_ffi]
1710         pub unsafe fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1711
1712         #[fast_ffi]
1713         pub unsafe fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1714         #[fast_ffi]
1715         pub unsafe fn LLVMPassManagerBuilderDispose(PMB:
1716                                                     PassManagerBuilderRef);
1717         #[fast_ffi]
1718         pub unsafe fn LLVMPassManagerBuilderSetOptLevel(
1719             PMB: PassManagerBuilderRef, OptimizationLevel: c_uint);
1720         #[fast_ffi]
1721         pub unsafe fn LLVMPassManagerBuilderSetSizeLevel(
1722             PMB: PassManagerBuilderRef, Value: Bool);
1723         #[fast_ffi]
1724         pub unsafe fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1725             PMB: PassManagerBuilderRef, Value: Bool);
1726         #[fast_ffi]
1727         pub unsafe fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1728             PMB: PassManagerBuilderRef, Value: Bool);
1729         #[fast_ffi]
1730         pub unsafe fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls
1731             (PMB: PassManagerBuilderRef, Value: Bool);
1732         #[fast_ffi]
1733         pub unsafe fn LLVMPassManagerBuilderUseInlinerWithThreshold
1734             (PMB: PassManagerBuilderRef, threshold: c_uint);
1735         #[fast_ffi]
1736         pub unsafe fn LLVMPassManagerBuilderPopulateModulePassManager
1737             (PMB: PassManagerBuilderRef, PM: PassManagerRef);
1738
1739         #[fast_ffi]
1740         pub unsafe fn LLVMPassManagerBuilderPopulateFunctionPassManager
1741             (PMB: PassManagerBuilderRef, PM: PassManagerRef);
1742
1743         /** Destroys a memory buffer. */
1744         #[fast_ffi]
1745         pub unsafe fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1746
1747
1748         /* Stuff that's in rustllvm/ because it's not upstream yet. */
1749
1750         /** Opens an object file. */
1751         #[fast_ffi]
1752         pub unsafe fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef)
1753                                         -> ObjectFileRef;
1754         /** Closes an object file. */
1755         #[fast_ffi]
1756         pub unsafe fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1757
1758         /** Enumerates the sections in an object file. */
1759         #[fast_ffi]
1760         pub unsafe fn LLVMGetSections(ObjFile: ObjectFileRef)
1761                                    -> SectionIteratorRef;
1762         /** Destroys a section iterator. */
1763         #[fast_ffi]
1764         pub unsafe fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1765         /** Returns true if the section iterator is at the end of the section
1766             list: */
1767         #[fast_ffi]
1768         pub unsafe fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1769                                       SI: SectionIteratorRef) -> Bool;
1770         /** Moves the section iterator to point to the next section. */
1771         #[fast_ffi]
1772         pub unsafe fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1773         /** Returns the current section name. */
1774         #[fast_ffi]
1775         pub unsafe fn LLVMGetSectionName(SI: SectionIteratorRef) -> *c_char;
1776         /** Returns the current section size. */
1777         #[fast_ffi]
1778         pub unsafe fn LLVMGetSectionSize(SI: SectionIteratorRef)
1779                                       -> c_ulonglong;
1780         /** Returns the current section contents as a string buffer. */
1781         #[fast_ffi]
1782         pub unsafe fn LLVMGetSectionContents(SI: SectionIteratorRef)
1783                                           -> *c_char;
1784
1785         /** Reads the given file and returns it as a memory buffer. Use
1786             LLVMDisposeMemoryBuffer() to get rid of it. */
1787         #[fast_ffi]
1788         pub unsafe fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1789                 Path: *c_char)
1790              -> MemoryBufferRef;
1791
1792         #[fast_ffi]
1793         pub unsafe fn LLVMRustWriteOutputFile(PM: PassManagerRef,
1794                                               M: ModuleRef,
1795                                               Triple: *c_char,
1796                                               Feature: *c_char,
1797                                               Output: *c_char,
1798                                               // FIXME: When #2334 is fixed,
1799                                               // change c_uint to FileType
1800                                               FileType: c_uint,
1801                                               OptLevel: c_int,
1802                                               EnableSegmentedStacks: bool)
1803                                            -> bool;
1804
1805         /** Returns a string describing the last error caused by an LLVMRust*
1806             call. */
1807         #[fast_ffi]
1808         pub unsafe fn LLVMRustGetLastError() -> *c_char;
1809
1810         /** Prepare the JIT. Returns a memory manager that can load crates. */
1811         #[fast_ffi]
1812         pub unsafe fn LLVMRustPrepareJIT(__morestack: *()) -> *();
1813
1814         /** Load a crate into the memory manager. */
1815         #[fast_ffi]
1816         pub unsafe fn LLVMRustLoadCrate(MM: *(),
1817                                         Filename: *c_char)
1818                                      -> bool;
1819
1820         /** Execute the JIT engine. */
1821         #[fast_ffi]
1822         pub unsafe fn LLVMRustExecuteJIT(MM: *(),
1823                               PM: PassManagerRef,
1824                               M: ModuleRef,
1825                               OptLevel: c_int,
1826                               EnableSegmentedStacks: bool) -> *();
1827
1828         /** Parses the bitcode in the given memory buffer. */
1829         #[fast_ffi]
1830         pub unsafe fn LLVMRustParseBitcode(MemBuf: MemoryBufferRef)
1831                                         -> ModuleRef;
1832
1833         /** Parses LLVM asm in the given file */
1834         #[fast_ffi]
1835         pub unsafe fn LLVMRustParseAssemblyFile(Filename: *c_char)
1836                                              -> ModuleRef;
1837
1838         #[fast_ffi]
1839         pub unsafe fn LLVMRustAddPrintModulePass(PM: PassManagerRef,
1840                                                  M: ModuleRef,
1841                                                  Output: *c_char);
1842
1843         /** Turn on LLVM pass-timing. */
1844         #[fast_ffi]
1845         pub unsafe fn LLVMRustEnableTimePasses();
1846
1847         /// Print the pass timings since static dtors aren't picking them up.
1848         #[fast_ffi]
1849         pub unsafe fn LLVMRustPrintPassTimings();
1850
1851         #[fast_ffi]
1852         pub unsafe fn LLVMStructCreateNamed(C: ContextRef, Name: *c_char)
1853                                          -> TypeRef;
1854
1855         #[fast_ffi]
1856         pub unsafe fn LLVMStructSetBody(StructTy: TypeRef,
1857                                         ElementTypes: *TypeRef,
1858                                         ElementCount: c_uint,
1859                                         Packed: Bool);
1860
1861         #[fast_ffi]
1862         pub unsafe fn LLVMConstNamedStruct(S: TypeRef,
1863                                            ConstantVals: *ValueRef,
1864                                            Count: c_uint)
1865                                         -> ValueRef;
1866
1867         /** Enables LLVM debug output. */
1868         #[fast_ffi]
1869         pub unsafe fn LLVMSetDebug(Enabled: c_int);
1870
1871         /** Prepares inline assembly. */
1872         #[fast_ffi]
1873         pub unsafe fn LLVMInlineAsm(Ty: TypeRef, AsmString: *c_char,
1874                                     Constraints: *c_char, SideEffects: Bool,
1875                                     AlignStack: Bool, Dialect: c_uint)
1876                                  -> ValueRef;
1877     }
1878 }
1879
1880 pub fn SetInstructionCallConv(Instr: ValueRef, CC: CallConv) {
1881     unsafe {
1882         llvm::LLVMSetInstructionCallConv(Instr, CC as c_uint);
1883     }
1884 }
1885 pub fn SetFunctionCallConv(Fn: ValueRef, CC: CallConv) {
1886     unsafe {
1887         llvm::LLVMSetFunctionCallConv(Fn, CC as c_uint);
1888     }
1889 }
1890 pub fn SetLinkage(Global: ValueRef, Link: Linkage) {
1891     unsafe {
1892         llvm::LLVMSetLinkage(Global, Link as c_uint);
1893     }
1894 }
1895
1896 /* Memory-managed object interface to type handles. */
1897
1898 pub struct TypeNames {
1899     type_names: @mut HashMap<TypeRef, @str>,
1900     named_types: @mut HashMap<@str, TypeRef>
1901 }
1902
1903 pub fn associate_type(tn: @TypeNames, s: @str, t: TypeRef) {
1904     assert!(tn.type_names.insert(t, s));
1905     assert!(tn.named_types.insert(s, t));
1906 }
1907
1908 pub fn type_has_name(tn: @TypeNames, t: TypeRef) -> Option<@str> {
1909     return tn.type_names.find(&t).map_consume(|x| *x);
1910 }
1911
1912 pub fn name_has_type(tn: @TypeNames, s: @str) -> Option<TypeRef> {
1913     return tn.named_types.find(&s).map_consume(|x| *x);
1914 }
1915
1916 pub fn mk_type_names() -> @TypeNames {
1917     @TypeNames {
1918         type_names: @mut HashMap::new(),
1919         named_types: @mut HashMap::new()
1920     }
1921 }
1922
1923 pub fn type_to_str(names: @TypeNames, ty: TypeRef) -> @str {
1924     return type_to_str_inner(names, [], ty);
1925 }
1926
1927 pub fn type_to_str_inner(names: @TypeNames, outer0: &[TypeRef], ty: TypeRef)
1928                       -> @str {
1929     unsafe {
1930         match type_has_name(names, ty) {
1931           option::Some(n) => return n,
1932           _ => {}
1933         }
1934
1935         let outer = vec::append_one(outer0.to_vec(), ty);
1936
1937         let kind = llvm::LLVMGetTypeKind(ty);
1938
1939         fn tys_str(names: @TypeNames, outer: &[TypeRef],
1940                    tys: ~[TypeRef]) -> @str {
1941             let mut s = ~"";
1942             let mut first: bool = true;
1943             for tys.each |t| {
1944                 if first { first = false; } else { s += ~", "; }
1945                 s += type_to_str_inner(names, outer, *t).to_owned();
1946             }
1947             // [Note at-str] FIXME #2543: Could rewrite this without the copy,
1948             // but need better @str support.
1949             return s.to_managed();
1950         }
1951
1952         match kind {
1953           Void => return @"Void",
1954           Half => return @"Half",
1955           Float => return @"Float",
1956           Double => return @"Double",
1957           X86_FP80 => return @"X86_FP80",
1958           FP128 => return @"FP128",
1959           PPC_FP128 => return @"PPC_FP128",
1960           Label => return @"Label",
1961           Integer => {
1962             // See [Note at-str]
1963             return fmt!("i%d", llvm::LLVMGetIntTypeWidth(ty)
1964                         as int).to_managed();
1965           }
1966           Function => {
1967             let out_ty: TypeRef = llvm::LLVMGetReturnType(ty);
1968             let n_args = llvm::LLVMCountParamTypes(ty) as uint;
1969             let args = vec::from_elem(n_args, 0 as TypeRef);
1970             unsafe {
1971                 llvm::LLVMGetParamTypes(ty, vec::raw::to_ptr(args));
1972             }
1973             // See [Note at-str]
1974             return fmt!("fn(%s) -> %s",
1975                         tys_str(names, outer, args),
1976                         type_to_str_inner(names, outer, out_ty)).to_managed();
1977           }
1978           Struct => {
1979             let elts = struct_tys(ty);
1980             // See [Note at-str]
1981             return fmt!("{%s}", tys_str(names, outer, elts)).to_managed();
1982           }
1983           Array => {
1984             let el_ty = llvm::LLVMGetElementType(ty);
1985             // See [Note at-str]
1986             return fmt!("[%s@ x %u", type_to_str_inner(names, outer, el_ty),
1987                 llvm::LLVMGetArrayLength(ty) as uint).to_managed();
1988           }
1989           Pointer => {
1990             let mut i = 0;
1991             for outer0.each |tout| {
1992                 i += 1;
1993                 if *tout as int == ty as int {
1994                     let n = outer0.len() - i;
1995                     // See [Note at-str]
1996                     return fmt!("*\\%d", n as int).to_managed();
1997                 }
1998             }
1999             let addrstr = {
2000                 let addrspace = llvm::LLVMGetPointerAddressSpace(ty) as uint;
2001                 if addrspace == 0 {
2002                     ~""
2003                 } else {
2004                     fmt!("addrspace(%u)", addrspace)
2005                 }
2006             };
2007             // See [Note at-str]
2008             return fmt!("%s*%s", addrstr, type_to_str_inner(names,
2009                         outer,
2010                         llvm::LLVMGetElementType(ty))).to_managed();
2011           }
2012           Vector => return @"Vector",
2013           Metadata => return @"Metadata",
2014           X86_MMX => return @"X86_MMAX",
2015           _ => fail!()
2016         }
2017     }
2018 }
2019
2020 pub fn float_width(llt: TypeRef) -> uint {
2021     unsafe {
2022         return match llvm::LLVMGetTypeKind(llt) as int {
2023               1 => 32u,
2024               2 => 64u,
2025               3 => 80u,
2026               4 | 5 => 128u,
2027               _ => fail!(~"llvm_float_width called on a non-float type")
2028             };
2029     }
2030 }
2031
2032 pub fn fn_ty_param_tys(fn_ty: TypeRef) -> ~[TypeRef] {
2033     unsafe {
2034         let args = vec::from_elem(llvm::LLVMCountParamTypes(fn_ty) as uint,
2035                                  0 as TypeRef);
2036         llvm::LLVMGetParamTypes(fn_ty, vec::raw::to_ptr(args));
2037         return args;
2038     }
2039 }
2040
2041 pub fn struct_tys(struct_ty: TypeRef) -> ~[TypeRef] {
2042     unsafe {
2043         let n_elts = llvm::LLVMCountStructElementTypes(struct_ty) as uint;
2044         if n_elts == 0 {
2045             return ~[];
2046         }
2047         let mut elts = vec::from_elem(n_elts, ptr::null());
2048         llvm::LLVMGetStructElementTypes(
2049             struct_ty, ptr::to_mut_unsafe_ptr(&mut elts[0]));
2050         return elts;
2051     }
2052 }
2053
2054
2055 /* Memory-managed interface to target data. */
2056
2057 pub struct target_data_res {
2058     TD: TargetDataRef,
2059 }
2060
2061 impl Drop for target_data_res {
2062     fn finalize(&self) {
2063         unsafe {
2064             llvm::LLVMDisposeTargetData(self.TD);
2065         }
2066     }
2067 }
2068
2069 pub fn target_data_res(TD: TargetDataRef) -> target_data_res {
2070     target_data_res {
2071         TD: TD
2072     }
2073 }
2074
2075 pub struct TargetData {
2076     lltd: TargetDataRef,
2077     dtor: @target_data_res
2078 }
2079
2080 pub fn mk_target_data(string_rep: &str) -> TargetData {
2081     let lltd =
2082         str::as_c_str(string_rep, |buf| unsafe {
2083             llvm::LLVMCreateTargetData(buf)
2084         });
2085
2086     TargetData {
2087         lltd: lltd,
2088         dtor: @target_data_res(lltd)
2089     }
2090 }
2091
2092 /* Memory-managed interface to pass managers. */
2093
2094 pub struct pass_manager_res {
2095     PM: PassManagerRef,
2096 }
2097
2098 impl Drop for pass_manager_res {
2099     fn finalize(&self) {
2100         unsafe {
2101             llvm::LLVMDisposePassManager(self.PM);
2102         }
2103     }
2104 }
2105
2106 pub fn pass_manager_res(PM: PassManagerRef) -> pass_manager_res {
2107     pass_manager_res {
2108         PM: PM
2109     }
2110 }
2111
2112 pub struct PassManager {
2113     llpm: PassManagerRef,
2114     dtor: @pass_manager_res
2115 }
2116
2117 pub fn mk_pass_manager() -> PassManager {
2118     unsafe {
2119         let llpm = llvm::LLVMCreatePassManager();
2120
2121         PassManager {
2122             llpm: llpm,
2123             dtor: @pass_manager_res(llpm)
2124         }
2125     }
2126 }
2127
2128 /* Memory-managed interface to object files. */
2129
2130 pub struct object_file_res {
2131     ObjectFile: ObjectFileRef,
2132 }
2133
2134 impl Drop for object_file_res {
2135     fn finalize(&self) {
2136         unsafe {
2137             llvm::LLVMDisposeObjectFile(self.ObjectFile);
2138         }
2139     }
2140 }
2141
2142 pub fn object_file_res(ObjFile: ObjectFileRef) -> object_file_res {
2143     object_file_res {
2144         ObjectFile: ObjFile
2145     }
2146 }
2147
2148 pub struct ObjectFile {
2149     llof: ObjectFileRef,
2150     dtor: @object_file_res
2151 }
2152
2153 pub fn mk_object_file(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2154     unsafe {
2155         let llof = llvm::LLVMCreateObjectFile(llmb);
2156         if llof as int == 0 { return option::None::<ObjectFile>; }
2157
2158         option::Some(ObjectFile {
2159             llof: llof,
2160             dtor: @object_file_res(llof)
2161         })
2162     }
2163 }
2164
2165 /* Memory-managed interface to section iterators. */
2166
2167 pub struct section_iter_res {
2168     SI: SectionIteratorRef,
2169 }
2170
2171 impl Drop for section_iter_res {
2172     fn finalize(&self) {
2173         unsafe {
2174             llvm::LLVMDisposeSectionIterator(self.SI);
2175         }
2176     }
2177 }
2178
2179 pub fn section_iter_res(SI: SectionIteratorRef) -> section_iter_res {
2180     section_iter_res {
2181         SI: SI
2182     }
2183 }
2184
2185 pub struct SectionIter {
2186     llsi: SectionIteratorRef,
2187     dtor: @section_iter_res
2188 }
2189
2190 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2191     unsafe {
2192         let llsi = llvm::LLVMGetSections(llof);
2193         SectionIter {
2194             llsi: llsi,
2195             dtor: @section_iter_res(llsi)
2196         }
2197     }
2198 }
2199
2200 //
2201 // Local Variables:
2202 // mode: rust
2203 // fill-column: 78;
2204 // indent-tabs-mode: nil
2205 // c-basic-offset: 4
2206 // buffer-file-coding-system: utf-8-unix
2207 // End:
2208 //