1 // Copyright 2012-2014 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.
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.
11 #![allow(non_upper_case_globals)]
12 #![allow(non_camel_case_types)]
13 #![allow(non_snake_case)]
16 #![crate_name = "rustc_llvm"]
18 #![crate_type = "dylib"]
19 #![crate_type = "rlib"]
20 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
21 html_favicon_url = "http://www.rust-lang.org/favicon.ico",
22 html_root_url = "http://doc.rust-lang.org/nightly/")]
25 #![feature(link_args)]
29 pub use self::OtherAttribute::*;
30 pub use self::SpecialAttribute::*;
31 pub use self::AttributeSet::*;
32 pub use self::IntPredicate::*;
33 pub use self::RealPredicate::*;
34 pub use self::TypeKind::*;
35 pub use self::AtomicBinOp::*;
36 pub use self::AtomicOrdering::*;
37 pub use self::FileType::*;
38 pub use self::MetadataType::*;
39 pub use self::AsmDialect::*;
40 pub use self::CodeGenOptLevel::*;
41 pub use self::RelocMode::*;
42 pub use self::CodeGenModel::*;
43 pub use self::DiagnosticKind::*;
44 pub use self::CallConv::*;
45 pub use self::Visibility::*;
46 pub use self::DiagnosticSeverity::*;
47 pub use self::Linkage::*;
49 use std::c_str::ToCStr;
50 use std::cell::RefCell;
52 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
53 use libc::{c_longlong, c_ulonglong, c_void};
54 use debuginfo::{DIBuilderRef, DIDescriptor,
55 DIFile, DILexicalBlock, DISubprogram, DIType,
56 DIBasicType, DIDerivedType, DICompositeType,
57 DIVariable, DIGlobalVariable, DIArray, DISubrange};
62 pub type Opcode = u32;
63 pub type Bool = c_uint;
65 pub const True: Bool = 1 as Bool;
66 pub const False: Bool = 0 as Bool;
68 // Consts for the LLVM CallConv type, pre-cast to uint.
70 #[deriving(PartialEq)]
75 X86StdcallCallConv = 64,
76 X86FastcallCallConv = 65,
81 LLVMDefaultVisibility = 0,
83 ProtectedVisibility = 2,
86 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
87 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
88 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
89 // they've been removed in upstream LLVM commit r203866.
92 AvailableExternallyLinkage = 1,
93 LinkOnceAnyLinkage = 2,
94 LinkOnceODRLinkage = 3,
100 ExternalWeakLinkage = 12,
106 pub enum DiagnosticSeverity {
114 flags Attribute : u32 {
115 const ZExtAttribute = 1 << 0,
116 const SExtAttribute = 1 << 1,
117 const NoReturnAttribute = 1 << 2,
118 const InRegAttribute = 1 << 3,
119 const StructRetAttribute = 1 << 4,
120 const NoUnwindAttribute = 1 << 5,
121 const NoAliasAttribute = 1 << 6,
122 const ByValAttribute = 1 << 7,
123 const NestAttribute = 1 << 8,
124 const ReadNoneAttribute = 1 << 9,
125 const ReadOnlyAttribute = 1 << 10,
126 const NoInlineAttribute = 1 << 11,
127 const AlwaysInlineAttribute = 1 << 12,
128 const OptimizeForSizeAttribute = 1 << 13,
129 const StackProtectAttribute = 1 << 14,
130 const StackProtectReqAttribute = 1 << 15,
131 const AlignmentAttribute = 31 << 16,
132 const NoCaptureAttribute = 1 << 21,
133 const NoRedZoneAttribute = 1 << 22,
134 const NoImplicitFloatAttribute = 1 << 23,
135 const NakedAttribute = 1 << 24,
136 const InlineHintAttribute = 1 << 25,
137 const StackAttribute = 7 << 26,
138 const ReturnsTwiceAttribute = 1 << 29,
139 const UWTableAttribute = 1 << 30,
140 const NonLazyBindAttribute = 1 << 31,
145 pub enum OtherAttribute {
146 // The following are not really exposed in
147 // the LLVM c api so instead to add these
148 // we call a wrapper function in RustWrapper
149 // that uses the C++ api.
150 SanitizeAddressAttribute = 1 << 32,
151 MinSizeAttribute = 1 << 33,
152 NoDuplicateAttribute = 1 << 34,
153 StackProtectStrongAttribute = 1 << 35,
154 SanitizeThreadAttribute = 1 << 36,
155 SanitizeMemoryAttribute = 1 << 37,
156 NoBuiltinAttribute = 1 << 38,
157 ReturnedAttribute = 1 << 39,
158 ColdAttribute = 1 << 40,
159 BuiltinAttribute = 1 << 41,
160 OptimizeNoneAttribute = 1 << 42,
161 InAllocaAttribute = 1 << 43,
162 NonNullAttribute = 1 << 44,
165 pub enum SpecialAttribute {
166 DereferenceableAttribute(u64)
170 pub enum AttributeSet {
175 pub trait AttrHelper {
176 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
177 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
180 impl AttrHelper for Attribute {
181 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
183 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
187 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
189 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
194 impl AttrHelper for OtherAttribute {
195 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
197 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
201 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
203 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
208 impl AttrHelper for SpecialAttribute {
209 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
211 DereferenceableAttribute(bytes) => unsafe {
212 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
217 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
219 DereferenceableAttribute(bytes) => unsafe {
220 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
226 pub struct AttrBuilder {
227 attrs: Vec<(uint, Box<AttrHelper+'static>)>
231 pub fn new() -> AttrBuilder {
237 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
238 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
242 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
243 self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
247 pub fn apply_llfn(&self, llfn: ValueRef) {
248 for &(idx, ref attr) in self.attrs.iter() {
249 attr.apply_llfn(idx as c_uint, llfn);
253 pub fn apply_callsite(&self, callsite: ValueRef) {
254 for &(idx, ref attr) in self.attrs.iter() {
255 attr.apply_callsite(idx as c_uint, callsite);
260 // enum for the LLVM IntPredicate type
261 pub enum IntPredicate {
274 // enum for the LLVM RealPredicate type
275 pub enum RealPredicate {
276 RealPredicateFalse = 0,
291 RealPredicateTrue = 15,
294 // The LLVM TypeKind type - must stay in sync with the def of
295 // LLVMTypeKind in llvm/include/llvm-c/Core.h
296 #[deriving(PartialEq)]
318 pub enum AtomicBinOp {
333 pub enum AtomicOrdering {
337 // Consume = 3, // Not specified yet.
341 SequentiallyConsistent = 7
344 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
347 AssemblyFileType = 0,
351 pub enum MetadataType {
360 // Inline Asm Dialect
361 pub enum AsmDialect {
366 #[deriving(PartialEq, Clone)]
368 pub enum CodeGenOptLevel {
369 CodeGenLevelNone = 0,
370 CodeGenLevelLess = 1,
371 CodeGenLevelDefault = 2,
372 CodeGenLevelAggressive = 3,
375 #[deriving(PartialEq)]
381 RelocDynamicNoPic = 3,
385 pub enum CodeGenModel {
386 CodeModelDefault = 0,
387 CodeModelJITDefault = 1,
395 pub enum DiagnosticKind {
398 DK_DebugMetadataVersion,
400 DK_OptimizationRemark,
401 DK_OptimizationRemarkMissed,
402 DK_OptimizationRemarkAnalysis,
403 DK_OptimizationFailure,
406 // Opaque pointer types
407 pub enum Module_opaque {}
408 pub type ModuleRef = *mut Module_opaque;
409 pub enum Context_opaque {}
410 pub type ContextRef = *mut Context_opaque;
411 pub enum Type_opaque {}
412 pub type TypeRef = *mut Type_opaque;
413 pub enum Value_opaque {}
414 pub type ValueRef = *mut Value_opaque;
415 pub enum BasicBlock_opaque {}
416 pub type BasicBlockRef = *mut BasicBlock_opaque;
417 pub enum Builder_opaque {}
418 pub type BuilderRef = *mut Builder_opaque;
419 pub enum ExecutionEngine_opaque {}
420 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
421 pub enum MemoryBuffer_opaque {}
422 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
423 pub enum PassManager_opaque {}
424 pub type PassManagerRef = *mut PassManager_opaque;
425 pub enum PassManagerBuilder_opaque {}
426 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
427 pub enum Use_opaque {}
428 pub type UseRef = *mut Use_opaque;
429 pub enum TargetData_opaque {}
430 pub type TargetDataRef = *mut TargetData_opaque;
431 pub enum ObjectFile_opaque {}
432 pub type ObjectFileRef = *mut ObjectFile_opaque;
433 pub enum SectionIterator_opaque {}
434 pub type SectionIteratorRef = *mut SectionIterator_opaque;
435 pub enum Pass_opaque {}
436 pub type PassRef = *mut Pass_opaque;
437 pub enum TargetMachine_opaque {}
438 pub type TargetMachineRef = *mut TargetMachine_opaque;
439 pub enum Archive_opaque {}
440 pub type ArchiveRef = *mut Archive_opaque;
441 pub enum Twine_opaque {}
442 pub type TwineRef = *mut Twine_opaque;
443 pub enum DiagnosticInfo_opaque {}
444 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
445 pub enum DebugLoc_opaque {}
446 pub type DebugLocRef = *mut DebugLoc_opaque;
447 pub enum SMDiagnostic_opaque {}
448 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
450 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
451 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
454 pub use self::DIDescriptorFlags::*;
455 use super::{ValueRef};
457 pub enum DIBuilder_opaque {}
458 pub type DIBuilderRef = *mut DIBuilder_opaque;
460 pub type DIDescriptor = ValueRef;
461 pub type DIScope = DIDescriptor;
462 pub type DILocation = DIDescriptor;
463 pub type DIFile = DIScope;
464 pub type DILexicalBlock = DIScope;
465 pub type DISubprogram = DIScope;
466 pub type DIType = DIDescriptor;
467 pub type DIBasicType = DIType;
468 pub type DIDerivedType = DIType;
469 pub type DICompositeType = DIDerivedType;
470 pub type DIVariable = DIDescriptor;
471 pub type DIGlobalVariable = DIDescriptor;
472 pub type DIArray = DIDescriptor;
473 pub type DISubrange = DIDescriptor;
475 pub enum DIDescriptorFlags {
476 FlagPrivate = 1 << 0,
477 FlagProtected = 1 << 1,
478 FlagFwdDecl = 1 << 2,
479 FlagAppleBlock = 1 << 3,
480 FlagBlockByrefStruct = 1 << 4,
481 FlagVirtual = 1 << 5,
482 FlagArtificial = 1 << 6,
483 FlagExplicit = 1 << 7,
484 FlagPrototyped = 1 << 8,
485 FlagObjcClassComplete = 1 << 9,
486 FlagObjectPointer = 1 << 10,
487 FlagVector = 1 << 11,
488 FlagStaticMember = 1 << 12,
489 FlagIndirectVariable = 1 << 13,
490 FlagLValueReference = 1 << 14,
491 FlagRValueReference = 1 << 15
496 // Link to our native llvm bindings (things that we need to use the C++ api
497 // for) and because llvm is written in C++ we need to link against libstdc++
499 // You'll probably notice that there is an omission of all LLVM libraries
500 // from this location. This is because the set of LLVM libraries that we
501 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
502 // figure out the exact set of libraries. To do this, the build system
503 // generates an llvmdeps.rs file next to this one which will be
504 // automatically updated whenever LLVM is updated to include an up-to-date
505 // set of the libraries we need to link to LLVM for.
506 #[link(name = "rustllvm", kind = "static")]
508 /* Create and destroy contexts. */
509 pub fn LLVMContextCreate() -> ContextRef;
510 pub fn LLVMContextDispose(C: ContextRef);
511 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
516 /* Create and destroy modules. */
517 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
520 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
521 pub fn LLVMDisposeModule(M: ModuleRef);
523 /// Data layout. See Module::getDataLayout.
524 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
525 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
527 /// Target triple. See Module::getTargetTriple.
528 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
529 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
531 /// See Module::dump.
532 pub fn LLVMDumpModule(M: ModuleRef);
534 /// See Module::setModuleInlineAsm.
535 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
537 /// See llvm::LLVMTypeKind::getTypeID.
538 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
540 /// See llvm::LLVMType::getContext.
541 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
543 /* Operations on integer types */
544 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
545 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
546 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
547 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
548 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
549 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
552 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
554 /* Operations on real types */
555 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
556 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
557 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
558 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
559 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
561 /* Operations on function types */
562 pub fn LLVMFunctionType(ReturnType: TypeRef,
563 ParamTypes: *const TypeRef,
567 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
568 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
569 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
570 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
572 /* Operations on struct types */
573 pub fn LLVMStructTypeInContext(C: ContextRef,
574 ElementTypes: *const TypeRef,
575 ElementCount: c_uint,
578 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
579 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
581 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
583 /* Operations on array, pointer, and vector types (sequence types) */
584 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
585 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
587 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
590 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
591 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
592 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
593 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
595 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
597 /* Operations on other types */
598 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
599 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
600 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
602 /* Operations on all values */
603 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
604 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
605 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
606 pub fn LLVMDumpValue(Val: ValueRef);
607 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
608 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
609 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
610 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
612 /* Operations on Uses */
613 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
614 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
615 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
616 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
618 /* Operations on Users */
619 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
620 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
621 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
623 /* Operations on constants of any type */
624 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
626 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
627 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
629 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
631 /* only for int/vector */
632 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
633 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
634 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
635 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
636 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
638 /* Operations on metadata */
639 pub fn LLVMMDStringInContext(C: ContextRef,
643 pub fn LLVMMDNodeInContext(C: ContextRef,
644 Vals: *const ValueRef,
647 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
651 /* Operations on scalar constants */
652 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
654 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
656 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
661 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
662 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
664 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
668 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
669 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
672 /* Operations on composite constants */
673 pub fn LLVMConstStringInContext(C: ContextRef,
676 DontNullTerminate: Bool)
678 pub fn LLVMConstStructInContext(C: ContextRef,
679 ConstantVals: *const ValueRef,
684 pub fn LLVMConstArray(ElementTy: TypeRef,
685 ConstantVals: *const ValueRef,
688 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
691 /* Constant expressions */
692 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
693 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
694 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
695 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
696 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
697 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
698 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
699 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
701 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
703 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
705 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
707 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
709 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
711 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
713 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
715 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
717 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
719 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
721 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
723 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
725 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
727 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
728 RHSConstant: ValueRef)
730 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
732 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
734 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
736 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
738 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
740 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
742 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
744 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
746 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
748 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
750 pub fn LLVMConstGEP(ConstantVal: ValueRef,
751 ConstantIndices: *const ValueRef,
754 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
755 ConstantIndices: *const ValueRef,
758 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
760 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
762 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
764 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
766 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
768 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
770 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
772 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
774 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
776 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
778 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
780 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
782 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
784 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
786 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
788 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
790 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
794 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
796 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
797 ConstantIfTrue: ValueRef,
798 ConstantIfFalse: ValueRef)
800 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
801 IndexConstant: ValueRef)
803 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
804 ElementValueConstant: ValueRef,
805 IndexConstant: ValueRef)
807 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
808 VectorBConstant: ValueRef,
809 MaskConstant: ValueRef)
811 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
812 IdxList: *const c_uint,
815 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
816 ElementValueConstant: ValueRef,
817 IdxList: *const c_uint,
820 pub fn LLVMConstInlineAsm(Ty: TypeRef,
821 AsmString: *const c_char,
822 Constraints: *const c_char,
823 HasSideEffects: Bool,
826 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
830 /* Operations on global variables, functions, and aliases (globals) */
831 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
832 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
833 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
834 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
835 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
836 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
837 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
838 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
839 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
840 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
843 /* Operations on global variables */
844 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
846 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
849 AddressSpace: c_uint)
851 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
852 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
853 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
854 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
855 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
856 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
857 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
858 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
859 ConstantVal: ValueRef);
860 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
861 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
862 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
863 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
865 /* Operations on aliases */
866 pub fn LLVMAddAlias(M: ModuleRef,
872 /* Operations on functions */
873 pub fn LLVMAddFunction(M: ModuleRef,
877 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
878 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
879 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
880 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
881 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
882 pub fn LLVMDeleteFunction(Fn: ValueRef);
883 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
887 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
888 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
889 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
890 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
891 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
892 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
893 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
894 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
895 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
896 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
898 /* Operations on parameters */
899 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
900 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
901 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
902 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
903 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
904 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
905 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
906 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
907 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
908 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
909 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
910 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
912 /* Operations on basic blocks */
913 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
914 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
915 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
916 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
917 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
918 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
919 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
920 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
921 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
922 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
923 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
925 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
929 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
933 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
935 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
936 MoveAfter: BasicBlockRef);
938 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
939 MoveBefore: BasicBlockRef);
941 /* Operations on instructions */
942 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
943 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
944 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
945 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
946 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
947 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
949 /* Operations on call sites */
950 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
951 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
952 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
955 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
958 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
961 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
964 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
968 /* Operations on call instructions (only) */
969 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
970 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
972 /* Operations on load/store instructions (only) */
973 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
974 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
976 /* Operations on phi nodes */
977 pub fn LLVMAddIncoming(PhiNode: ValueRef,
978 IncomingValues: *const ValueRef,
979 IncomingBlocks: *const BasicBlockRef,
981 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
982 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
984 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
987 /* Instruction builders */
988 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
989 pub fn LLVMPositionBuilder(Builder: BuilderRef,
990 Block: BasicBlockRef,
992 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
994 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
995 Block: BasicBlockRef);
996 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
997 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
998 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
999 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1001 Name: *const c_char);
1002 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1003 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1006 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1007 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1008 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1011 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1012 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1013 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1014 RetVals: *const ValueRef,
1017 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1018 pub fn LLVMBuildCondBr(B: BuilderRef,
1020 Then: BasicBlockRef,
1021 Else: BasicBlockRef)
1023 pub fn LLVMBuildSwitch(B: BuilderRef,
1025 Else: BasicBlockRef,
1028 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1032 pub fn LLVMBuildInvoke(B: BuilderRef,
1034 Args: *const ValueRef,
1036 Then: BasicBlockRef,
1037 Catch: BasicBlockRef,
1038 Name: *const c_char)
1040 pub fn LLVMBuildLandingPad(B: BuilderRef,
1044 Name: *const c_char)
1046 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1047 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1049 /* Add a case to the switch instruction */
1050 pub fn LLVMAddCase(Switch: ValueRef,
1052 Dest: BasicBlockRef);
1054 /* Add a destination to the indirectbr instruction */
1055 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1057 /* Add a clause to the landing pad instruction */
1058 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1060 /* Set the cleanup on a landing pad instruction */
1061 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1064 pub fn LLVMBuildAdd(B: BuilderRef,
1067 Name: *const c_char)
1069 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1072 Name: *const c_char)
1074 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1077 Name: *const c_char)
1079 pub fn LLVMBuildFAdd(B: BuilderRef,
1082 Name: *const c_char)
1084 pub fn LLVMBuildSub(B: BuilderRef,
1087 Name: *const c_char)
1089 pub fn LLVMBuildNSWSub(B: BuilderRef,
1092 Name: *const c_char)
1094 pub fn LLVMBuildNUWSub(B: BuilderRef,
1097 Name: *const c_char)
1099 pub fn LLVMBuildFSub(B: BuilderRef,
1102 Name: *const c_char)
1104 pub fn LLVMBuildMul(B: BuilderRef,
1107 Name: *const c_char)
1109 pub fn LLVMBuildNSWMul(B: BuilderRef,
1112 Name: *const c_char)
1114 pub fn LLVMBuildNUWMul(B: BuilderRef,
1117 Name: *const c_char)
1119 pub fn LLVMBuildFMul(B: BuilderRef,
1122 Name: *const c_char)
1124 pub fn LLVMBuildUDiv(B: BuilderRef,
1127 Name: *const c_char)
1129 pub fn LLVMBuildSDiv(B: BuilderRef,
1132 Name: *const c_char)
1134 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1137 Name: *const c_char)
1139 pub fn LLVMBuildFDiv(B: BuilderRef,
1142 Name: *const c_char)
1144 pub fn LLVMBuildURem(B: BuilderRef,
1147 Name: *const c_char)
1149 pub fn LLVMBuildSRem(B: BuilderRef,
1152 Name: *const c_char)
1154 pub fn LLVMBuildFRem(B: BuilderRef,
1157 Name: *const c_char)
1159 pub fn LLVMBuildShl(B: BuilderRef,
1162 Name: *const c_char)
1164 pub fn LLVMBuildLShr(B: BuilderRef,
1167 Name: *const c_char)
1169 pub fn LLVMBuildAShr(B: BuilderRef,
1172 Name: *const c_char)
1174 pub fn LLVMBuildAnd(B: BuilderRef,
1177 Name: *const c_char)
1179 pub fn LLVMBuildOr(B: BuilderRef,
1182 Name: *const c_char)
1184 pub fn LLVMBuildXor(B: BuilderRef,
1187 Name: *const c_char)
1189 pub fn LLVMBuildBinOp(B: BuilderRef,
1193 Name: *const c_char)
1195 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1197 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1199 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1201 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1203 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1207 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1209 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1212 Name: *const c_char)
1214 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1216 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1219 Name: *const c_char)
1221 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1222 pub fn LLVMBuildLoad(B: BuilderRef,
1223 PointerVal: ValueRef,
1224 Name: *const c_char)
1227 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1230 pub fn LLVMBuildGEP(B: BuilderRef,
1232 Indices: *const ValueRef,
1234 Name: *const c_char)
1236 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1238 Indices: *const ValueRef,
1240 Name: *const c_char)
1242 pub fn LLVMBuildStructGEP(B: BuilderRef,
1245 Name: *const c_char)
1247 pub fn LLVMBuildGlobalString(B: BuilderRef,
1249 Name: *const c_char)
1251 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1253 Name: *const c_char)
1257 pub fn LLVMBuildTrunc(B: BuilderRef,
1260 Name: *const c_char)
1262 pub fn LLVMBuildZExt(B: BuilderRef,
1265 Name: *const c_char)
1267 pub fn LLVMBuildSExt(B: BuilderRef,
1270 Name: *const c_char)
1272 pub fn LLVMBuildFPToUI(B: BuilderRef,
1275 Name: *const c_char)
1277 pub fn LLVMBuildFPToSI(B: BuilderRef,
1280 Name: *const c_char)
1282 pub fn LLVMBuildUIToFP(B: BuilderRef,
1285 Name: *const c_char)
1287 pub fn LLVMBuildSIToFP(B: BuilderRef,
1290 Name: *const c_char)
1292 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1295 Name: *const c_char)
1297 pub fn LLVMBuildFPExt(B: BuilderRef,
1300 Name: *const c_char)
1302 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1305 Name: *const c_char)
1307 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1310 Name: *const c_char)
1312 pub fn LLVMBuildBitCast(B: BuilderRef,
1315 Name: *const c_char)
1317 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1320 Name: *const c_char)
1322 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1325 Name: *const c_char)
1327 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1330 Name: *const c_char)
1332 pub fn LLVMBuildCast(B: BuilderRef,
1336 Name: *const c_char) -> ValueRef;
1337 pub fn LLVMBuildPointerCast(B: BuilderRef,
1340 Name: *const c_char)
1342 pub fn LLVMBuildIntCast(B: BuilderRef,
1345 Name: *const c_char)
1347 pub fn LLVMBuildFPCast(B: BuilderRef,
1350 Name: *const c_char)
1354 pub fn LLVMBuildICmp(B: BuilderRef,
1358 Name: *const c_char)
1360 pub fn LLVMBuildFCmp(B: BuilderRef,
1364 Name: *const c_char)
1367 /* Miscellaneous instructions */
1368 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1370 pub fn LLVMBuildCall(B: BuilderRef,
1372 Args: *const ValueRef,
1374 Name: *const c_char)
1376 pub fn LLVMBuildSelect(B: BuilderRef,
1380 Name: *const c_char)
1382 pub fn LLVMBuildVAArg(B: BuilderRef,
1385 Name: *const c_char)
1387 pub fn LLVMBuildExtractElement(B: BuilderRef,
1390 Name: *const c_char)
1392 pub fn LLVMBuildInsertElement(B: BuilderRef,
1396 Name: *const c_char)
1398 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1402 Name: *const c_char)
1404 pub fn LLVMBuildExtractValue(B: BuilderRef,
1407 Name: *const c_char)
1409 pub fn LLVMBuildInsertValue(B: BuilderRef,
1413 Name: *const c_char)
1416 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1418 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1420 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1423 Name: *const c_char)
1426 /* Atomic Operations */
1427 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1428 PointerVal: ValueRef,
1429 Name: *const c_char,
1430 Order: AtomicOrdering,
1434 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1437 Order: AtomicOrdering,
1441 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1445 Order: AtomicOrdering,
1446 FailureOrder: AtomicOrdering)
1448 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1452 Order: AtomicOrdering,
1453 SingleThreaded: Bool)
1456 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1459 /* Selected entries from the downcasts. */
1460 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1461 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1463 /// Writes a module to the specified path. Returns 0 on success.
1464 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1466 /// Creates target data from a target layout string.
1467 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1468 /// Adds the target data to the given pass manager. The pass manager
1469 /// references the target data only weakly.
1470 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1471 /// Number of bytes clobbered when doing a Store to *T.
1472 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1475 /// Number of bytes clobbered when doing a Store to *T.
1476 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1479 /// Distance between successive elements in an array of T. Includes ABI padding.
1480 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1482 /// Returns the preferred alignment of a type.
1483 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1485 /// Returns the minimum alignment of a type.
1486 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1489 /// Computes the byte offset of the indexed struct element for a
1491 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1496 /// Returns the minimum alignment of a type when part of a call frame.
1497 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1500 /// Disposes target data.
1501 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1503 /// Creates a pass manager.
1504 pub fn LLVMCreatePassManager() -> PassManagerRef;
1506 /// Creates a function-by-function pass manager
1507 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1510 /// Disposes a pass manager.
1511 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1513 /// Runs a pass manager on a module.
1514 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1516 /// Runs the function passes on the provided function.
1517 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1520 /// Initializes all the function passes scheduled in the manager
1521 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1523 /// Finalizes all the function passes scheduled in the manager
1524 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1526 pub fn LLVMInitializePasses();
1528 /// Adds a verification pass.
1529 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1531 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1532 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1533 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1534 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1535 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1536 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1537 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1538 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1539 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1540 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1541 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1542 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1543 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1544 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1545 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1546 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1547 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1548 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1549 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1550 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1551 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1552 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1553 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1554 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1555 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1556 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1557 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1558 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1559 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1560 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1561 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1562 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1563 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1564 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1565 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1567 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1568 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1569 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1570 OptimizationLevel: c_uint);
1571 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1573 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1574 PMB: PassManagerBuilderRef,
1576 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1577 PMB: PassManagerBuilderRef,
1579 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1580 PMB: PassManagerBuilderRef,
1582 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1583 PMB: PassManagerBuilderRef,
1585 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1586 PMB: PassManagerBuilderRef,
1587 PM: PassManagerRef);
1589 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1590 PMB: PassManagerBuilderRef,
1591 PM: PassManagerRef);
1592 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1593 PMB: PassManagerBuilderRef,
1598 /// Destroys a memory buffer.
1599 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1602 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1604 /// Opens an object file.
1605 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1606 /// Closes an object file.
1607 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1609 /// Enumerates the sections in an object file.
1610 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1611 /// Destroys a section iterator.
1612 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1613 /// Returns true if the section iterator is at the end of the section
1615 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1616 SI: SectionIteratorRef)
1618 /// Moves the section iterator to point to the next section.
1619 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1620 /// Returns the current section size.
1621 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1622 /// Returns the current section contents as a string buffer.
1623 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1625 /// Reads the given file and returns it as a memory buffer. Use
1626 /// LLVMDisposeMemoryBuffer() to get rid of it.
1627 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1629 /// Borrows the contents of the memory buffer (doesn't copy it)
1630 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1631 InputDataLength: size_t,
1632 BufferName: *const c_char,
1635 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1636 InputDataLength: size_t,
1637 BufferName: *const c_char)
1640 pub fn LLVMIsMultithreaded() -> Bool;
1641 pub fn LLVMStartMultithreaded() -> Bool;
1643 /// Returns a string describing the last error caused by an LLVMRust* call.
1644 pub fn LLVMRustGetLastError() -> *const c_char;
1646 /// Print the pass timings since static dtors aren't picking them up.
1647 pub fn LLVMRustPrintPassTimings();
1649 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1651 pub fn LLVMStructSetBody(StructTy: TypeRef,
1652 ElementTypes: *const TypeRef,
1653 ElementCount: c_uint,
1656 pub fn LLVMConstNamedStruct(S: TypeRef,
1657 ConstantVals: *const ValueRef,
1661 /// Enables LLVM debug output.
1662 pub fn LLVMSetDebug(Enabled: c_int);
1664 /// Prepares inline assembly.
1665 pub fn LLVMInlineAsm(Ty: TypeRef,
1666 AsmString: *const c_char,
1667 Constraints: *const c_char,
1673 pub static LLVMRustDebugMetadataVersion: u32;
1675 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1676 name: *const c_char,
1679 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1681 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1683 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1685 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1687 File: *const c_char,
1689 Producer: *const c_char,
1691 Flags: *const c_char,
1693 SplitName: *const c_char);
1695 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1696 Filename: *const c_char,
1697 Directory: *const c_char)
1700 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1702 ParameterTypes: DIArray)
1705 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1706 Scope: DIDescriptor,
1707 Name: *const c_char,
1708 LinkageName: *const c_char,
1712 isLocalToUnit: bool,
1722 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1723 Name: *const c_char,
1724 SizeInBits: c_ulonglong,
1725 AlignInBits: c_ulonglong,
1729 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1731 SizeInBits: c_ulonglong,
1732 AlignInBits: c_ulonglong,
1733 Name: *const c_char)
1736 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1737 Scope: DIDescriptor,
1738 Name: *const c_char,
1741 SizeInBits: c_ulonglong,
1742 AlignInBits: c_ulonglong,
1744 DerivedFrom: DIType,
1746 RunTimeLang: c_uint,
1747 VTableHolder: ValueRef,
1748 UniqueId: *const c_char)
1751 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1752 Scope: DIDescriptor,
1753 Name: *const c_char,
1756 SizeInBits: c_ulonglong,
1757 AlignInBits: c_ulonglong,
1758 OffsetInBits: c_ulonglong,
1763 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1764 Scope: DIDescriptor,
1770 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1771 Context: DIDescriptor,
1772 Name: *const c_char,
1773 LinkageName: *const c_char,
1777 isLocalToUnit: bool,
1780 -> DIGlobalVariable;
1782 pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
1784 Scope: DIDescriptor,
1785 Name: *const c_char,
1789 AlwaysPreserve: bool,
1794 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1796 AlignInBits: c_ulonglong,
1798 Subscripts: DIArray)
1801 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1803 AlignInBits: c_ulonglong,
1805 Subscripts: DIArray)
1808 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1813 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1814 Ptr: *const DIDescriptor,
1818 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1820 VarInfo: DIVariable,
1821 InsertAtEnd: BasicBlockRef)
1824 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1826 VarInfo: DIVariable,
1827 InsertBefore: ValueRef)
1830 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1831 Name: *const c_char,
1835 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1837 Name: *const c_char,
1840 SizeInBits: c_ulonglong,
1841 AlignInBits: c_ulonglong,
1843 ClassType: ValueRef)
1846 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1848 Name: *const c_char,
1851 SizeInBits: c_ulonglong,
1852 AlignInBits: c_ulonglong,
1855 RunTimeLang: c_uint,
1856 UniqueId: *const c_char)
1859 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1861 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1863 Name: *const c_char,
1870 pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
1872 pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
1874 pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
1877 Name: *const c_char,
1881 AddrOps: *const ValueRef,
1882 AddrOpsCount: c_uint,
1886 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1888 Name: *const c_char,
1893 pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
1894 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1895 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1897 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1899 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1901 pub fn LLVMInitializeX86TargetInfo();
1902 pub fn LLVMInitializeX86Target();
1903 pub fn LLVMInitializeX86TargetMC();
1904 pub fn LLVMInitializeX86AsmPrinter();
1905 pub fn LLVMInitializeX86AsmParser();
1906 pub fn LLVMInitializeARMTargetInfo();
1907 pub fn LLVMInitializeARMTarget();
1908 pub fn LLVMInitializeARMTargetMC();
1909 pub fn LLVMInitializeARMAsmPrinter();
1910 pub fn LLVMInitializeARMAsmParser();
1911 pub fn LLVMInitializeMipsTargetInfo();
1912 pub fn LLVMInitializeMipsTarget();
1913 pub fn LLVMInitializeMipsTargetMC();
1914 pub fn LLVMInitializeMipsAsmPrinter();
1915 pub fn LLVMInitializeMipsAsmParser();
1917 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
1918 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1920 Features: *const c_char,
1921 Model: CodeGenModel,
1923 Level: CodeGenOptLevel,
1926 NoFramePointerElim: bool,
1927 PositionIndependentExecutable: bool,
1928 FunctionSections: bool,
1929 DataSections: bool) -> TargetMachineRef;
1930 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1931 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1934 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1936 DisableSimplifyLibCalls: bool);
1937 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
1938 DisableSimplifyLibCalls: bool);
1939 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1940 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1943 Output: *const c_char,
1944 FileType: FileType) -> bool;
1945 pub fn LLVMRustPrintModule(PM: PassManagerRef,
1947 Output: *const c_char);
1948 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1949 pub fn LLVMRustPrintPasses();
1950 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1951 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
1952 AddLifetimes: bool);
1953 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
1955 len: size_t) -> bool;
1956 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
1957 syms: *const *const c_char,
1959 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1961 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1962 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
1963 out_len: *mut size_t) -> *const c_char;
1964 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1966 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
1967 pub fn LLVMVersionMajor() -> c_int;
1968 pub fn LLVMVersionMinor() -> c_int;
1970 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
1971 data: *mut *const c_char) -> c_int;
1973 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
1975 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
1976 Handler: DiagnosticHandler,
1977 DiagnosticContext: *mut c_void);
1979 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
1980 pass_name_out: *mut *const c_char,
1981 function_out: *mut ValueRef,
1982 debugloc_out: *mut DebugLocRef,
1983 message_out: *mut TwineRef);
1985 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
1986 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
1987 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
1989 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
1991 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
1992 H: InlineAsmDiagHandler,
1995 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
1998 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2000 LLVMSetInstructionCallConv(instr, cc as c_uint);
2003 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2005 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2008 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2010 LLVMSetLinkage(global, link as c_uint);
2014 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2016 LLVMSetUnnamedAddr(global, unnamed as Bool);
2020 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2022 LLVMSetThreadLocal(global, is_thread_local as Bool);
2026 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2028 LLVMConstICmp(pred as c_ushort, v1, v2)
2031 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2033 LLVMConstFCmp(pred as c_ushort, v1, v2)
2037 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2039 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
2043 /* Memory-managed interface to target data. */
2045 pub struct TargetData {
2046 pub lltd: TargetDataRef
2049 impl Drop for TargetData {
2050 fn drop(&mut self) {
2052 LLVMDisposeTargetData(self.lltd);
2057 pub fn mk_target_data(string_rep: &str) -> TargetData {
2059 lltd: string_rep.with_c_str(|buf| {
2060 unsafe { LLVMCreateTargetData(buf) }
2065 /* Memory-managed interface to object files. */
2067 pub struct ObjectFile {
2068 pub llof: ObjectFileRef,
2072 // This will take ownership of llmb
2073 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2075 let llof = LLVMCreateObjectFile(llmb);
2076 if llof as int == 0 {
2077 // LLVMCreateObjectFile took ownership of llmb
2088 impl Drop for ObjectFile {
2089 fn drop(&mut self) {
2091 LLVMDisposeObjectFile(self.llof);
2096 /* Memory-managed interface to section iterators. */
2098 pub struct SectionIter {
2099 pub llsi: SectionIteratorRef
2102 impl Drop for SectionIter {
2103 fn drop(&mut self) {
2105 LLVMDisposeSectionIterator(self.llsi);
2110 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2113 llsi: LLVMGetSections(llof)
2118 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2119 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2121 assert!(index < LLVMCountParams(llfn));
2122 LLVMGetParam(llfn, index)
2126 pub enum RustString_opaque {}
2127 pub type RustStringRef = *mut RustString_opaque;
2128 type RustStringRepr = *mut RefCell<Vec<u8>>;
2130 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2132 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2135 let slice: &[u8] = mem::transmute(raw::Slice {
2136 data: ptr as *const u8,
2140 let sr: RustStringRepr = mem::transmute(sr);
2141 (*sr).borrow_mut().push_all(slice);
2144 pub fn build_string(f: |RustStringRef|) -> Option<String> {
2145 let mut buf = RefCell::new(Vec::new());
2146 f(&mut buf as RustStringRepr as RustStringRef);
2147 String::from_utf8(buf.into_inner()).ok()
2150 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2151 build_string(|s| LLVMWriteTwineToString(tr, s))
2152 .expect("got a non-UTF8 Twine from LLVM")
2155 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2156 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2157 .expect("got a non-UTF8 DebugLoc from LLVM")
2160 // FIXME #15460 - create a public function that actually calls our
2161 // static LLVM symbols. Otherwise the linker will just throw llvm
2162 // away. We're just calling lots of stuff until we transitively get
2163 // all of LLVM. This is worse than anything.
2164 pub unsafe fn static_link_hack_this_sucks() {
2165 LLVMInitializePasses();
2167 LLVMInitializeX86TargetInfo();
2168 LLVMInitializeX86Target();
2169 LLVMInitializeX86TargetMC();
2170 LLVMInitializeX86AsmPrinter();
2171 LLVMInitializeX86AsmParser();
2173 LLVMInitializeARMTargetInfo();
2174 LLVMInitializeARMTarget();
2175 LLVMInitializeARMTargetMC();
2176 LLVMInitializeARMAsmPrinter();
2177 LLVMInitializeARMAsmParser();
2179 LLVMInitializeMipsTargetInfo();
2180 LLVMInitializeMipsTarget();
2181 LLVMInitializeMipsTargetMC();
2182 LLVMInitializeMipsAsmPrinter();
2183 LLVMInitializeMipsAsmParser();
2185 LLVMRustSetLLVMOptions(0 as c_int,
2188 LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
2189 LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
2190 LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
2191 LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
2192 LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
2193 LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
2194 LLVMPassManagerBuilderCreate();
2195 LLVMPassManagerBuilderDispose(0 as *mut _);
2197 LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
2200 LLVMLinkInInterpreter();
2203 fn LLVMLinkInMCJIT();
2204 fn LLVMLinkInInterpreter();
2208 // The module containing the native LLVM dependencies, generated by the build system
2209 // Note that this must come after the rustllvm extern declaration so that
2210 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2211 // Works to the above fix for #15460 to ensure LLVM dependencies that
2212 // are only used by rustllvm don't get stripped by the linker.
2214 include!(env!("CFG_LLVM_LINKAGE_FILE"))