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 #![license = "MIT/ASL2"]
19 #![crate_type = "dylib"]
20 #![crate_type = "rlib"]
21 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22 html_favicon_url = "http://www.rust-lang.org/favicon.ico",
23 html_root_url = "http://doc.rust-lang.org/nightly/")]
26 #![feature(link_args)]
30 pub use self::OtherAttribute::*;
31 pub use self::SpecialAttribute::*;
32 pub use self::AttributeSet::*;
33 pub use self::IntPredicate::*;
34 pub use self::RealPredicate::*;
35 pub use self::TypeKind::*;
36 pub use self::AtomicBinOp::*;
37 pub use self::AtomicOrdering::*;
38 pub use self::FileType::*;
39 pub use self::MetadataType::*;
40 pub use self::AsmDialect::*;
41 pub use self::CodeGenOptLevel::*;
42 pub use self::RelocMode::*;
43 pub use self::CodeGenModel::*;
44 pub use self::DiagnosticKind::*;
45 pub use self::CallConv::*;
46 pub use self::Visibility::*;
47 pub use self::DiagnosticSeverity::*;
48 pub use self::Linkage::*;
50 use std::c_str::ToCStr;
51 use std::cell::RefCell;
53 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
54 use libc::{c_longlong, c_ulonglong, c_void};
55 use debuginfo::{DIBuilderRef, DIDescriptor,
56 DIFile, DILexicalBlock, DISubprogram, DIType,
57 DIBasicType, DIDerivedType, DICompositeType,
58 DIVariable, DIGlobalVariable, DIArray, DISubrange};
63 pub type Opcode = u32;
64 pub type Bool = c_uint;
66 pub const True: Bool = 1 as Bool;
67 pub const False: Bool = 0 as Bool;
69 // Consts for the LLVM CallConv type, pre-cast to uint.
71 #[deriving(PartialEq)]
76 X86StdcallCallConv = 64,
77 X86FastcallCallConv = 65,
82 LLVMDefaultVisibility = 0,
84 ProtectedVisibility = 2,
87 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
88 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
89 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
90 // they've been removed in upstream LLVM commit r203866.
93 AvailableExternallyLinkage = 1,
94 LinkOnceAnyLinkage = 2,
95 LinkOnceODRLinkage = 3,
101 ExternalWeakLinkage = 12,
107 pub enum DiagnosticSeverity {
115 flags Attribute : u32 {
116 const ZExtAttribute = 1 << 0,
117 const SExtAttribute = 1 << 1,
118 const NoReturnAttribute = 1 << 2,
119 const InRegAttribute = 1 << 3,
120 const StructRetAttribute = 1 << 4,
121 const NoUnwindAttribute = 1 << 5,
122 const NoAliasAttribute = 1 << 6,
123 const ByValAttribute = 1 << 7,
124 const NestAttribute = 1 << 8,
125 const ReadNoneAttribute = 1 << 9,
126 const ReadOnlyAttribute = 1 << 10,
127 const NoInlineAttribute = 1 << 11,
128 const AlwaysInlineAttribute = 1 << 12,
129 const OptimizeForSizeAttribute = 1 << 13,
130 const StackProtectAttribute = 1 << 14,
131 const StackProtectReqAttribute = 1 << 15,
132 const AlignmentAttribute = 31 << 16,
133 const NoCaptureAttribute = 1 << 21,
134 const NoRedZoneAttribute = 1 << 22,
135 const NoImplicitFloatAttribute = 1 << 23,
136 const NakedAttribute = 1 << 24,
137 const InlineHintAttribute = 1 << 25,
138 const StackAttribute = 7 << 26,
139 const ReturnsTwiceAttribute = 1 << 29,
140 const UWTableAttribute = 1 << 30,
141 const NonLazyBindAttribute = 1 << 31,
146 pub enum OtherAttribute {
147 // The following are not really exposed in
148 // the LLVM c api so instead to add these
149 // we call a wrapper function in RustWrapper
150 // that uses the C++ api.
151 SanitizeAddressAttribute = 1 << 32,
152 MinSizeAttribute = 1 << 33,
153 NoDuplicateAttribute = 1 << 34,
154 StackProtectStrongAttribute = 1 << 35,
155 SanitizeThreadAttribute = 1 << 36,
156 SanitizeMemoryAttribute = 1 << 37,
157 NoBuiltinAttribute = 1 << 38,
158 ReturnedAttribute = 1 << 39,
159 ColdAttribute = 1 << 40,
160 BuiltinAttribute = 1 << 41,
161 OptimizeNoneAttribute = 1 << 42,
162 InAllocaAttribute = 1 << 43,
163 NonNullAttribute = 1 << 44,
166 pub enum SpecialAttribute {
167 DereferenceableAttribute(u64)
171 pub enum AttributeSet {
176 pub trait AttrHelper {
177 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
178 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
181 impl AttrHelper for Attribute {
182 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
184 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
188 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
190 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
195 impl AttrHelper for OtherAttribute {
196 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
198 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
202 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
204 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
209 impl AttrHelper for SpecialAttribute {
210 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
212 DereferenceableAttribute(bytes) => unsafe {
213 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
218 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
220 DereferenceableAttribute(bytes) => unsafe {
221 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
227 pub struct AttrBuilder {
228 attrs: Vec<(uint, Box<AttrHelper+'static>)>
232 pub fn new() -> AttrBuilder {
238 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
239 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
243 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
244 self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
248 pub fn apply_llfn(&self, llfn: ValueRef) {
249 for &(idx, ref attr) in self.attrs.iter() {
250 attr.apply_llfn(idx as c_uint, llfn);
254 pub fn apply_callsite(&self, callsite: ValueRef) {
255 for &(idx, ref attr) in self.attrs.iter() {
256 attr.apply_callsite(idx as c_uint, callsite);
261 // enum for the LLVM IntPredicate type
262 pub enum IntPredicate {
275 // enum for the LLVM RealPredicate type
276 pub enum RealPredicate {
277 RealPredicateFalse = 0,
292 RealPredicateTrue = 15,
295 // The LLVM TypeKind type - must stay in sync with the def of
296 // LLVMTypeKind in llvm/include/llvm-c/Core.h
297 #[deriving(PartialEq)]
319 pub enum AtomicBinOp {
334 pub enum AtomicOrdering {
338 // Consume = 3, // Not specified yet.
342 SequentiallyConsistent = 7
345 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
348 AssemblyFileType = 0,
352 pub enum MetadataType {
361 // Inline Asm Dialect
362 pub enum AsmDialect {
367 #[deriving(PartialEq, Clone)]
369 pub enum CodeGenOptLevel {
370 CodeGenLevelNone = 0,
371 CodeGenLevelLess = 1,
372 CodeGenLevelDefault = 2,
373 CodeGenLevelAggressive = 3,
376 #[deriving(PartialEq)]
382 RelocDynamicNoPic = 3,
386 pub enum CodeGenModel {
387 CodeModelDefault = 0,
388 CodeModelJITDefault = 1,
396 pub enum DiagnosticKind {
399 DK_DebugMetadataVersion,
401 DK_OptimizationRemark,
402 DK_OptimizationRemarkMissed,
403 DK_OptimizationRemarkAnalysis,
404 DK_OptimizationFailure,
407 // Opaque pointer types
408 pub enum Module_opaque {}
409 pub type ModuleRef = *mut Module_opaque;
410 pub enum Context_opaque {}
411 pub type ContextRef = *mut Context_opaque;
412 pub enum Type_opaque {}
413 pub type TypeRef = *mut Type_opaque;
414 pub enum Value_opaque {}
415 pub type ValueRef = *mut Value_opaque;
416 pub enum BasicBlock_opaque {}
417 pub type BasicBlockRef = *mut BasicBlock_opaque;
418 pub enum Builder_opaque {}
419 pub type BuilderRef = *mut Builder_opaque;
420 pub enum ExecutionEngine_opaque {}
421 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
422 pub enum MemoryBuffer_opaque {}
423 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
424 pub enum PassManager_opaque {}
425 pub type PassManagerRef = *mut PassManager_opaque;
426 pub enum PassManagerBuilder_opaque {}
427 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
428 pub enum Use_opaque {}
429 pub type UseRef = *mut Use_opaque;
430 pub enum TargetData_opaque {}
431 pub type TargetDataRef = *mut TargetData_opaque;
432 pub enum ObjectFile_opaque {}
433 pub type ObjectFileRef = *mut ObjectFile_opaque;
434 pub enum SectionIterator_opaque {}
435 pub type SectionIteratorRef = *mut SectionIterator_opaque;
436 pub enum Pass_opaque {}
437 pub type PassRef = *mut Pass_opaque;
438 pub enum TargetMachine_opaque {}
439 pub type TargetMachineRef = *mut TargetMachine_opaque;
440 pub enum Archive_opaque {}
441 pub type ArchiveRef = *mut Archive_opaque;
442 pub enum Twine_opaque {}
443 pub type TwineRef = *mut Twine_opaque;
444 pub enum DiagnosticInfo_opaque {}
445 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
446 pub enum DebugLoc_opaque {}
447 pub type DebugLocRef = *mut DebugLoc_opaque;
448 pub enum SMDiagnostic_opaque {}
449 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
451 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
452 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
455 pub use self::DIDescriptorFlags::*;
456 use super::{ValueRef};
458 pub enum DIBuilder_opaque {}
459 pub type DIBuilderRef = *mut DIBuilder_opaque;
461 pub type DIDescriptor = ValueRef;
462 pub type DIScope = DIDescriptor;
463 pub type DILocation = DIDescriptor;
464 pub type DIFile = DIScope;
465 pub type DILexicalBlock = DIScope;
466 pub type DISubprogram = DIScope;
467 pub type DIType = DIDescriptor;
468 pub type DIBasicType = DIType;
469 pub type DIDerivedType = DIType;
470 pub type DICompositeType = DIDerivedType;
471 pub type DIVariable = DIDescriptor;
472 pub type DIGlobalVariable = DIDescriptor;
473 pub type DIArray = DIDescriptor;
474 pub type DISubrange = DIDescriptor;
476 pub enum DIDescriptorFlags {
477 FlagPrivate = 1 << 0,
478 FlagProtected = 1 << 1,
479 FlagFwdDecl = 1 << 2,
480 FlagAppleBlock = 1 << 3,
481 FlagBlockByrefStruct = 1 << 4,
482 FlagVirtual = 1 << 5,
483 FlagArtificial = 1 << 6,
484 FlagExplicit = 1 << 7,
485 FlagPrototyped = 1 << 8,
486 FlagObjcClassComplete = 1 << 9,
487 FlagObjectPointer = 1 << 10,
488 FlagVector = 1 << 11,
489 FlagStaticMember = 1 << 12,
490 FlagIndirectVariable = 1 << 13,
491 FlagLValueReference = 1 << 14,
492 FlagRValueReference = 1 << 15
497 // Link to our native llvm bindings (things that we need to use the C++ api
498 // for) and because llvm is written in C++ we need to link against libstdc++
500 // You'll probably notice that there is an omission of all LLVM libraries
501 // from this location. This is because the set of LLVM libraries that we
502 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
503 // figure out the exact set of libraries. To do this, the build system
504 // generates an llvmdeps.rs file next to this one which will be
505 // automatically updated whenever LLVM is updated to include an up-to-date
506 // set of the libraries we need to link to LLVM for.
507 #[link(name = "rustllvm", kind = "static")]
509 /* Create and destroy contexts. */
510 pub fn LLVMContextCreate() -> ContextRef;
511 pub fn LLVMContextDispose(C: ContextRef);
512 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
517 /* Create and destroy modules. */
518 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
521 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
522 pub fn LLVMDisposeModule(M: ModuleRef);
524 /// Data layout. See Module::getDataLayout.
525 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
526 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
528 /// Target triple. See Module::getTargetTriple.
529 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
530 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
532 /// See Module::dump.
533 pub fn LLVMDumpModule(M: ModuleRef);
535 /// See Module::setModuleInlineAsm.
536 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
538 /// See llvm::LLVMTypeKind::getTypeID.
539 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
541 /// See llvm::LLVMType::getContext.
542 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
544 /* Operations on integer types */
545 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
546 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
547 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
548 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
549 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
550 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
553 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
555 /* Operations on real types */
556 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
557 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
558 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
559 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
560 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
562 /* Operations on function types */
563 pub fn LLVMFunctionType(ReturnType: TypeRef,
564 ParamTypes: *const TypeRef,
568 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
569 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
570 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
571 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
573 /* Operations on struct types */
574 pub fn LLVMStructTypeInContext(C: ContextRef,
575 ElementTypes: *const TypeRef,
576 ElementCount: c_uint,
579 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
580 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
582 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
584 /* Operations on array, pointer, and vector types (sequence types) */
585 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
586 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
588 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
591 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
592 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
593 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
594 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
596 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
598 /* Operations on other types */
599 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
600 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
601 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
603 /* Operations on all values */
604 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
605 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
606 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
607 pub fn LLVMDumpValue(Val: ValueRef);
608 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
609 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
610 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
611 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
613 /* Operations on Uses */
614 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
615 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
616 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
617 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
619 /* Operations on Users */
620 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
621 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
622 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
624 /* Operations on constants of any type */
625 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
627 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
628 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
630 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
632 /* only for int/vector */
633 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
634 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
635 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
636 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
637 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
639 /* Operations on metadata */
640 pub fn LLVMMDStringInContext(C: ContextRef,
644 pub fn LLVMMDNodeInContext(C: ContextRef,
645 Vals: *const ValueRef,
648 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
652 /* Operations on scalar constants */
653 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
655 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
657 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
662 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
663 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
665 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
669 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
670 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
673 /* Operations on composite constants */
674 pub fn LLVMConstStringInContext(C: ContextRef,
677 DontNullTerminate: Bool)
679 pub fn LLVMConstStructInContext(C: ContextRef,
680 ConstantVals: *const ValueRef,
685 pub fn LLVMConstArray(ElementTy: TypeRef,
686 ConstantVals: *const ValueRef,
689 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
692 /* Constant expressions */
693 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
694 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
695 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
696 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
697 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
698 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
699 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
700 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
702 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
704 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
706 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
708 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
710 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
712 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
714 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
716 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
718 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
720 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
722 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
724 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
726 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
728 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
729 RHSConstant: ValueRef)
731 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
733 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
735 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
737 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
739 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
741 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
743 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
745 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
747 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
749 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
751 pub fn LLVMConstGEP(ConstantVal: ValueRef,
752 ConstantIndices: *const ValueRef,
755 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
756 ConstantIndices: *const ValueRef,
759 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
761 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
763 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
765 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
767 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
769 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
771 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
773 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
775 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
777 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
779 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
781 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
783 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
785 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
787 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
789 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
791 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
795 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
797 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
798 ConstantIfTrue: ValueRef,
799 ConstantIfFalse: ValueRef)
801 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
802 IndexConstant: ValueRef)
804 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
805 ElementValueConstant: ValueRef,
806 IndexConstant: ValueRef)
808 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
809 VectorBConstant: ValueRef,
810 MaskConstant: ValueRef)
812 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
813 IdxList: *const c_uint,
816 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
817 ElementValueConstant: ValueRef,
818 IdxList: *const c_uint,
821 pub fn LLVMConstInlineAsm(Ty: TypeRef,
822 AsmString: *const c_char,
823 Constraints: *const c_char,
824 HasSideEffects: Bool,
827 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
831 /* Operations on global variables, functions, and aliases (globals) */
832 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
833 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
834 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
835 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
836 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
837 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
838 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
839 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
840 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
841 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
844 /* Operations on global variables */
845 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
847 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
850 AddressSpace: c_uint)
852 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
853 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
854 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
855 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
856 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
857 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
858 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
859 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
860 ConstantVal: ValueRef);
861 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
862 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
863 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
864 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
866 /* Operations on aliases */
867 pub fn LLVMAddAlias(M: ModuleRef,
873 /* Operations on functions */
874 pub fn LLVMAddFunction(M: ModuleRef,
878 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
879 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
880 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
881 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
882 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
883 pub fn LLVMDeleteFunction(Fn: ValueRef);
884 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
888 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
889 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
890 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
891 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
892 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
893 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
894 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
895 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
896 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
897 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
899 /* Operations on parameters */
900 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
901 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
902 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
903 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
904 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
905 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
906 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
907 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
908 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
909 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
910 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
911 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
913 /* Operations on basic blocks */
914 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
915 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
916 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
917 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
918 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
919 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
920 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
921 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
922 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
923 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
924 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
926 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
930 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
934 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
936 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
937 MoveAfter: BasicBlockRef);
939 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
940 MoveBefore: BasicBlockRef);
942 /* Operations on instructions */
943 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
944 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
945 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
946 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
947 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
948 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
950 /* Operations on call sites */
951 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
952 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
953 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
956 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
959 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
962 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
965 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
969 /* Operations on call instructions (only) */
970 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
971 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
973 /* Operations on load/store instructions (only) */
974 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
975 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
977 /* Operations on phi nodes */
978 pub fn LLVMAddIncoming(PhiNode: ValueRef,
979 IncomingValues: *const ValueRef,
980 IncomingBlocks: *const BasicBlockRef,
982 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
983 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
985 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
988 /* Instruction builders */
989 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
990 pub fn LLVMPositionBuilder(Builder: BuilderRef,
991 Block: BasicBlockRef,
993 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
995 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
996 Block: BasicBlockRef);
997 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
998 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
999 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1000 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1002 Name: *const c_char);
1003 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1004 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1007 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1008 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1009 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1012 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1013 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1014 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1015 RetVals: *const ValueRef,
1018 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1019 pub fn LLVMBuildCondBr(B: BuilderRef,
1021 Then: BasicBlockRef,
1022 Else: BasicBlockRef)
1024 pub fn LLVMBuildSwitch(B: BuilderRef,
1026 Else: BasicBlockRef,
1029 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1033 pub fn LLVMBuildInvoke(B: BuilderRef,
1035 Args: *const ValueRef,
1037 Then: BasicBlockRef,
1038 Catch: BasicBlockRef,
1039 Name: *const c_char)
1041 pub fn LLVMBuildLandingPad(B: BuilderRef,
1045 Name: *const c_char)
1047 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1048 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1050 /* Add a case to the switch instruction */
1051 pub fn LLVMAddCase(Switch: ValueRef,
1053 Dest: BasicBlockRef);
1055 /* Add a destination to the indirectbr instruction */
1056 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1058 /* Add a clause to the landing pad instruction */
1059 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1061 /* Set the cleanup on a landing pad instruction */
1062 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1065 pub fn LLVMBuildAdd(B: BuilderRef,
1068 Name: *const c_char)
1070 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1073 Name: *const c_char)
1075 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1078 Name: *const c_char)
1080 pub fn LLVMBuildFAdd(B: BuilderRef,
1083 Name: *const c_char)
1085 pub fn LLVMBuildSub(B: BuilderRef,
1088 Name: *const c_char)
1090 pub fn LLVMBuildNSWSub(B: BuilderRef,
1093 Name: *const c_char)
1095 pub fn LLVMBuildNUWSub(B: BuilderRef,
1098 Name: *const c_char)
1100 pub fn LLVMBuildFSub(B: BuilderRef,
1103 Name: *const c_char)
1105 pub fn LLVMBuildMul(B: BuilderRef,
1108 Name: *const c_char)
1110 pub fn LLVMBuildNSWMul(B: BuilderRef,
1113 Name: *const c_char)
1115 pub fn LLVMBuildNUWMul(B: BuilderRef,
1118 Name: *const c_char)
1120 pub fn LLVMBuildFMul(B: BuilderRef,
1123 Name: *const c_char)
1125 pub fn LLVMBuildUDiv(B: BuilderRef,
1128 Name: *const c_char)
1130 pub fn LLVMBuildSDiv(B: BuilderRef,
1133 Name: *const c_char)
1135 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1138 Name: *const c_char)
1140 pub fn LLVMBuildFDiv(B: BuilderRef,
1143 Name: *const c_char)
1145 pub fn LLVMBuildURem(B: BuilderRef,
1148 Name: *const c_char)
1150 pub fn LLVMBuildSRem(B: BuilderRef,
1153 Name: *const c_char)
1155 pub fn LLVMBuildFRem(B: BuilderRef,
1158 Name: *const c_char)
1160 pub fn LLVMBuildShl(B: BuilderRef,
1163 Name: *const c_char)
1165 pub fn LLVMBuildLShr(B: BuilderRef,
1168 Name: *const c_char)
1170 pub fn LLVMBuildAShr(B: BuilderRef,
1173 Name: *const c_char)
1175 pub fn LLVMBuildAnd(B: BuilderRef,
1178 Name: *const c_char)
1180 pub fn LLVMBuildOr(B: BuilderRef,
1183 Name: *const c_char)
1185 pub fn LLVMBuildXor(B: BuilderRef,
1188 Name: *const c_char)
1190 pub fn LLVMBuildBinOp(B: BuilderRef,
1194 Name: *const c_char)
1196 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1198 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1200 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1202 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1204 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1208 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1210 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1213 Name: *const c_char)
1215 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1217 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1220 Name: *const c_char)
1222 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1223 pub fn LLVMBuildLoad(B: BuilderRef,
1224 PointerVal: ValueRef,
1225 Name: *const c_char)
1228 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1231 pub fn LLVMBuildGEP(B: BuilderRef,
1233 Indices: *const ValueRef,
1235 Name: *const c_char)
1237 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1239 Indices: *const ValueRef,
1241 Name: *const c_char)
1243 pub fn LLVMBuildStructGEP(B: BuilderRef,
1246 Name: *const c_char)
1248 pub fn LLVMBuildGlobalString(B: BuilderRef,
1250 Name: *const c_char)
1252 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1254 Name: *const c_char)
1258 pub fn LLVMBuildTrunc(B: BuilderRef,
1261 Name: *const c_char)
1263 pub fn LLVMBuildZExt(B: BuilderRef,
1266 Name: *const c_char)
1268 pub fn LLVMBuildSExt(B: BuilderRef,
1271 Name: *const c_char)
1273 pub fn LLVMBuildFPToUI(B: BuilderRef,
1276 Name: *const c_char)
1278 pub fn LLVMBuildFPToSI(B: BuilderRef,
1281 Name: *const c_char)
1283 pub fn LLVMBuildUIToFP(B: BuilderRef,
1286 Name: *const c_char)
1288 pub fn LLVMBuildSIToFP(B: BuilderRef,
1291 Name: *const c_char)
1293 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1296 Name: *const c_char)
1298 pub fn LLVMBuildFPExt(B: BuilderRef,
1301 Name: *const c_char)
1303 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1306 Name: *const c_char)
1308 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1311 Name: *const c_char)
1313 pub fn LLVMBuildBitCast(B: BuilderRef,
1316 Name: *const c_char)
1318 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1321 Name: *const c_char)
1323 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1326 Name: *const c_char)
1328 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1331 Name: *const c_char)
1333 pub fn LLVMBuildCast(B: BuilderRef,
1337 Name: *const c_char) -> ValueRef;
1338 pub fn LLVMBuildPointerCast(B: BuilderRef,
1341 Name: *const c_char)
1343 pub fn LLVMBuildIntCast(B: BuilderRef,
1346 Name: *const c_char)
1348 pub fn LLVMBuildFPCast(B: BuilderRef,
1351 Name: *const c_char)
1355 pub fn LLVMBuildICmp(B: BuilderRef,
1359 Name: *const c_char)
1361 pub fn LLVMBuildFCmp(B: BuilderRef,
1365 Name: *const c_char)
1368 /* Miscellaneous instructions */
1369 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1371 pub fn LLVMBuildCall(B: BuilderRef,
1373 Args: *const ValueRef,
1375 Name: *const c_char)
1377 pub fn LLVMBuildSelect(B: BuilderRef,
1381 Name: *const c_char)
1383 pub fn LLVMBuildVAArg(B: BuilderRef,
1386 Name: *const c_char)
1388 pub fn LLVMBuildExtractElement(B: BuilderRef,
1391 Name: *const c_char)
1393 pub fn LLVMBuildInsertElement(B: BuilderRef,
1397 Name: *const c_char)
1399 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1403 Name: *const c_char)
1405 pub fn LLVMBuildExtractValue(B: BuilderRef,
1408 Name: *const c_char)
1410 pub fn LLVMBuildInsertValue(B: BuilderRef,
1414 Name: *const c_char)
1417 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1419 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1421 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1424 Name: *const c_char)
1427 /* Atomic Operations */
1428 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1429 PointerVal: ValueRef,
1430 Name: *const c_char,
1431 Order: AtomicOrdering,
1435 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1438 Order: AtomicOrdering,
1442 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1446 Order: AtomicOrdering,
1447 FailureOrder: AtomicOrdering)
1449 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1453 Order: AtomicOrdering,
1454 SingleThreaded: Bool)
1457 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1460 /* Selected entries from the downcasts. */
1461 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1462 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1464 /// Writes a module to the specified path. Returns 0 on success.
1465 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1467 /// Creates target data from a target layout string.
1468 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1469 /// Adds the target data to the given pass manager. The pass manager
1470 /// references the target data only weakly.
1471 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1472 /// Number of bytes clobbered when doing a Store to *T.
1473 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1476 /// Number of bytes clobbered when doing a Store to *T.
1477 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1480 /// Distance between successive elements in an array of T. Includes ABI padding.
1481 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1483 /// Returns the preferred alignment of a type.
1484 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1486 /// Returns the minimum alignment of a type.
1487 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1490 /// Computes the byte offset of the indexed struct element for a
1492 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1497 /// Returns the minimum alignment of a type when part of a call frame.
1498 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1501 /// Disposes target data.
1502 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1504 /// Creates a pass manager.
1505 pub fn LLVMCreatePassManager() -> PassManagerRef;
1507 /// Creates a function-by-function pass manager
1508 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1511 /// Disposes a pass manager.
1512 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1514 /// Runs a pass manager on a module.
1515 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1517 /// Runs the function passes on the provided function.
1518 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1521 /// Initializes all the function passes scheduled in the manager
1522 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1524 /// Finalizes all the function passes scheduled in the manager
1525 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1527 pub fn LLVMInitializePasses();
1529 /// Adds a verification pass.
1530 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1532 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1533 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1534 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1535 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1536 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1537 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1538 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1539 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1540 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1541 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1542 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1543 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1544 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1545 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1546 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1547 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1548 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1549 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1550 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1551 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1552 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1553 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1554 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1555 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1556 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1557 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1558 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1559 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1560 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1561 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1562 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1563 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1564 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1565 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1566 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1568 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1569 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1570 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1571 OptimizationLevel: c_uint);
1572 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1574 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1575 PMB: PassManagerBuilderRef,
1577 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1578 PMB: PassManagerBuilderRef,
1580 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1581 PMB: PassManagerBuilderRef,
1583 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1584 PMB: PassManagerBuilderRef,
1586 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1587 PMB: PassManagerBuilderRef,
1588 PM: PassManagerRef);
1590 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1591 PMB: PassManagerBuilderRef,
1592 PM: PassManagerRef);
1593 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1594 PMB: PassManagerBuilderRef,
1599 /// Destroys a memory buffer.
1600 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1603 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1605 /// Opens an object file.
1606 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1607 /// Closes an object file.
1608 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1610 /// Enumerates the sections in an object file.
1611 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1612 /// Destroys a section iterator.
1613 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1614 /// Returns true if the section iterator is at the end of the section
1616 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1617 SI: SectionIteratorRef)
1619 /// Moves the section iterator to point to the next section.
1620 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1621 /// Returns the current section size.
1622 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1623 /// Returns the current section contents as a string buffer.
1624 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1626 /// Reads the given file and returns it as a memory buffer. Use
1627 /// LLVMDisposeMemoryBuffer() to get rid of it.
1628 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1630 /// Borrows the contents of the memory buffer (doesn't copy it)
1631 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1632 InputDataLength: size_t,
1633 BufferName: *const c_char,
1636 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1637 InputDataLength: size_t,
1638 BufferName: *const c_char)
1641 pub fn LLVMIsMultithreaded() -> Bool;
1642 pub fn LLVMStartMultithreaded() -> Bool;
1644 /// Returns a string describing the last error caused by an LLVMRust* call.
1645 pub fn LLVMRustGetLastError() -> *const c_char;
1647 /// Print the pass timings since static dtors aren't picking them up.
1648 pub fn LLVMRustPrintPassTimings();
1650 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1652 pub fn LLVMStructSetBody(StructTy: TypeRef,
1653 ElementTypes: *const TypeRef,
1654 ElementCount: c_uint,
1657 pub fn LLVMConstNamedStruct(S: TypeRef,
1658 ConstantVals: *const ValueRef,
1662 /// Enables LLVM debug output.
1663 pub fn LLVMSetDebug(Enabled: c_int);
1665 /// Prepares inline assembly.
1666 pub fn LLVMInlineAsm(Ty: TypeRef,
1667 AsmString: *const c_char,
1668 Constraints: *const c_char,
1674 pub static LLVMRustDebugMetadataVersion: u32;
1676 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1677 name: *const c_char,
1680 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1682 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1684 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1686 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1688 File: *const c_char,
1690 Producer: *const c_char,
1692 Flags: *const c_char,
1694 SplitName: *const c_char);
1696 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1697 Filename: *const c_char,
1698 Directory: *const c_char)
1701 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1703 ParameterTypes: DIArray)
1706 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1707 Scope: DIDescriptor,
1708 Name: *const c_char,
1709 LinkageName: *const c_char,
1713 isLocalToUnit: bool,
1723 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1724 Name: *const c_char,
1725 SizeInBits: c_ulonglong,
1726 AlignInBits: c_ulonglong,
1730 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1732 SizeInBits: c_ulonglong,
1733 AlignInBits: c_ulonglong,
1734 Name: *const c_char)
1737 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1738 Scope: DIDescriptor,
1739 Name: *const c_char,
1742 SizeInBits: c_ulonglong,
1743 AlignInBits: c_ulonglong,
1745 DerivedFrom: DIType,
1747 RunTimeLang: c_uint,
1748 VTableHolder: ValueRef,
1749 UniqueId: *const c_char)
1752 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1753 Scope: DIDescriptor,
1754 Name: *const c_char,
1757 SizeInBits: c_ulonglong,
1758 AlignInBits: c_ulonglong,
1759 OffsetInBits: c_ulonglong,
1764 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1765 Scope: DIDescriptor,
1771 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1772 Context: DIDescriptor,
1773 Name: *const c_char,
1774 LinkageName: *const c_char,
1778 isLocalToUnit: bool,
1781 -> DIGlobalVariable;
1783 pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
1785 Scope: DIDescriptor,
1786 Name: *const c_char,
1790 AlwaysPreserve: bool,
1795 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1797 AlignInBits: c_ulonglong,
1799 Subscripts: DIArray)
1802 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1804 AlignInBits: c_ulonglong,
1806 Subscripts: DIArray)
1809 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1814 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1815 Ptr: *const DIDescriptor,
1819 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1821 VarInfo: DIVariable,
1822 InsertAtEnd: BasicBlockRef)
1825 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1827 VarInfo: DIVariable,
1828 InsertBefore: ValueRef)
1831 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1832 Name: *const c_char,
1836 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1838 Name: *const c_char,
1841 SizeInBits: c_ulonglong,
1842 AlignInBits: c_ulonglong,
1844 ClassType: ValueRef)
1847 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1849 Name: *const c_char,
1852 SizeInBits: c_ulonglong,
1853 AlignInBits: c_ulonglong,
1856 RunTimeLang: c_uint,
1857 UniqueId: *const c_char)
1860 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1862 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1864 Name: *const c_char,
1871 pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
1873 pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
1875 pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
1878 Name: *const c_char,
1882 AddrOps: *const ValueRef,
1883 AddrOpsCount: c_uint,
1887 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1889 Name: *const c_char,
1894 pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
1895 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1896 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1898 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1900 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1902 pub fn LLVMInitializeX86TargetInfo();
1903 pub fn LLVMInitializeX86Target();
1904 pub fn LLVMInitializeX86TargetMC();
1905 pub fn LLVMInitializeX86AsmPrinter();
1906 pub fn LLVMInitializeX86AsmParser();
1907 pub fn LLVMInitializeARMTargetInfo();
1908 pub fn LLVMInitializeARMTarget();
1909 pub fn LLVMInitializeARMTargetMC();
1910 pub fn LLVMInitializeARMAsmPrinter();
1911 pub fn LLVMInitializeARMAsmParser();
1912 pub fn LLVMInitializeMipsTargetInfo();
1913 pub fn LLVMInitializeMipsTarget();
1914 pub fn LLVMInitializeMipsTargetMC();
1915 pub fn LLVMInitializeMipsAsmPrinter();
1916 pub fn LLVMInitializeMipsAsmParser();
1918 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
1919 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1921 Features: *const c_char,
1922 Model: CodeGenModel,
1924 Level: CodeGenOptLevel,
1927 NoFramePointerElim: bool,
1928 PositionIndependentExecutable: bool,
1929 FunctionSections: bool,
1930 DataSections: bool) -> TargetMachineRef;
1931 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1932 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1935 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1937 DisableSimplifyLibCalls: bool);
1938 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
1939 DisableSimplifyLibCalls: bool);
1940 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1941 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1944 Output: *const c_char,
1945 FileType: FileType) -> bool;
1946 pub fn LLVMRustPrintModule(PM: PassManagerRef,
1948 Output: *const c_char);
1949 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1950 pub fn LLVMRustPrintPasses();
1951 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1952 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
1953 AddLifetimes: bool);
1954 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
1956 len: size_t) -> bool;
1957 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
1958 syms: *const *const c_char,
1960 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1962 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1963 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
1964 out_len: *mut size_t) -> *const c_char;
1965 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1967 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
1968 pub fn LLVMVersionMajor() -> c_int;
1969 pub fn LLVMVersionMinor() -> c_int;
1971 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
1972 data: *mut *const c_char) -> c_int;
1974 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
1976 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
1977 Handler: DiagnosticHandler,
1978 DiagnosticContext: *mut c_void);
1980 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
1981 pass_name_out: *mut *const c_char,
1982 function_out: *mut ValueRef,
1983 debugloc_out: *mut DebugLocRef,
1984 message_out: *mut TwineRef);
1986 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
1987 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
1988 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
1990 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
1992 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
1993 H: InlineAsmDiagHandler,
1996 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
1999 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2001 LLVMSetInstructionCallConv(instr, cc as c_uint);
2004 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2006 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2009 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2011 LLVMSetLinkage(global, link as c_uint);
2015 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2017 LLVMSetUnnamedAddr(global, unnamed as Bool);
2021 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2023 LLVMSetThreadLocal(global, is_thread_local as Bool);
2027 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2029 LLVMConstICmp(pred as c_ushort, v1, v2)
2032 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2034 LLVMConstFCmp(pred as c_ushort, v1, v2)
2038 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2040 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
2044 /* Memory-managed interface to target data. */
2046 pub struct TargetData {
2047 pub lltd: TargetDataRef
2050 impl Drop for TargetData {
2051 fn drop(&mut self) {
2053 LLVMDisposeTargetData(self.lltd);
2058 pub fn mk_target_data(string_rep: &str) -> TargetData {
2060 lltd: string_rep.with_c_str(|buf| {
2061 unsafe { LLVMCreateTargetData(buf) }
2066 /* Memory-managed interface to object files. */
2068 pub struct ObjectFile {
2069 pub llof: ObjectFileRef,
2073 // This will take ownership of llmb
2074 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2076 let llof = LLVMCreateObjectFile(llmb);
2077 if llof as int == 0 {
2078 // LLVMCreateObjectFile took ownership of llmb
2089 impl Drop for ObjectFile {
2090 fn drop(&mut self) {
2092 LLVMDisposeObjectFile(self.llof);
2097 /* Memory-managed interface to section iterators. */
2099 pub struct SectionIter {
2100 pub llsi: SectionIteratorRef
2103 impl Drop for SectionIter {
2104 fn drop(&mut self) {
2106 LLVMDisposeSectionIterator(self.llsi);
2111 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2114 llsi: LLVMGetSections(llof)
2119 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2120 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2122 assert!(index < LLVMCountParams(llfn));
2123 LLVMGetParam(llfn, index)
2127 pub enum RustString_opaque {}
2128 pub type RustStringRef = *mut RustString_opaque;
2129 type RustStringRepr = *mut RefCell<Vec<u8>>;
2131 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2133 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2136 let slice: &[u8] = mem::transmute(raw::Slice {
2137 data: ptr as *const u8,
2141 let sr: RustStringRepr = mem::transmute(sr);
2142 (*sr).borrow_mut().push_all(slice);
2145 pub fn build_string(f: |RustStringRef|) -> Option<String> {
2146 let mut buf = RefCell::new(Vec::new());
2147 f(&mut buf as RustStringRepr as RustStringRef);
2148 String::from_utf8(buf.into_inner()).ok()
2151 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2152 build_string(|s| LLVMWriteTwineToString(tr, s))
2153 .expect("got a non-UTF8 Twine from LLVM")
2156 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2157 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2158 .expect("got a non-UTF8 DebugLoc from LLVM")
2161 // FIXME #15460 - create a public function that actually calls our
2162 // static LLVM symbols. Otherwise the linker will just throw llvm
2163 // away. We're just calling lots of stuff until we transitively get
2164 // all of LLVM. This is worse than anything.
2165 pub unsafe fn static_link_hack_this_sucks() {
2166 LLVMInitializePasses();
2168 LLVMInitializeX86TargetInfo();
2169 LLVMInitializeX86Target();
2170 LLVMInitializeX86TargetMC();
2171 LLVMInitializeX86AsmPrinter();
2172 LLVMInitializeX86AsmParser();
2174 LLVMInitializeARMTargetInfo();
2175 LLVMInitializeARMTarget();
2176 LLVMInitializeARMTargetMC();
2177 LLVMInitializeARMAsmPrinter();
2178 LLVMInitializeARMAsmParser();
2180 LLVMInitializeMipsTargetInfo();
2181 LLVMInitializeMipsTarget();
2182 LLVMInitializeMipsTargetMC();
2183 LLVMInitializeMipsAsmPrinter();
2184 LLVMInitializeMipsAsmParser();
2186 LLVMRustSetLLVMOptions(0 as c_int,
2189 LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
2190 LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
2191 LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
2192 LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
2193 LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
2194 LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
2195 LLVMPassManagerBuilderCreate();
2196 LLVMPassManagerBuilderDispose(0 as *mut _);
2198 LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
2201 LLVMLinkInInterpreter();
2204 fn LLVMLinkInMCJIT();
2205 fn LLVMLinkInInterpreter();
2209 // The module containing the native LLVM dependencies, generated by the build system
2210 // Note that this must come after the rustllvm extern declaration so that
2211 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2212 // Works to the above fix for #15460 to ensure LLVM dependencies that
2213 // are only used by rustllvm don't get stripped by the linker.