1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
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)]
15 #![allow(trivial_casts)]
17 #![crate_name = "rustc_llvm"]
18 #![unstable(feature = "rustc_private", issue = "27812")]
19 #![crate_type = "dylib"]
20 #![crate_type = "rlib"]
21 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22 html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
23 html_root_url = "https://doc.rust-lang.org/nightly/")]
24 #![cfg_attr(not(stage0), deny(warnings))]
26 #![feature(associated_consts)]
27 #![feature(box_syntax)]
29 #![feature(link_args)]
30 #![feature(staged_api)]
31 #![feature(linked_from)]
32 #![feature(concat_idents)]
35 #[macro_use] #[no_link] extern crate rustc_bitflags;
37 pub use self::OtherAttribute::*;
38 pub use self::SpecialAttribute::*;
39 pub use self::AttributeSet::*;
40 pub use self::IntPredicate::*;
41 pub use self::RealPredicate::*;
42 pub use self::TypeKind::*;
43 pub use self::AtomicBinOp::*;
44 pub use self::AtomicOrdering::*;
45 pub use self::SynchronizationScope::*;
46 pub use self::FileType::*;
47 pub use self::MetadataType::*;
48 pub use self::AsmDialect::*;
49 pub use self::CodeGenOptLevel::*;
50 pub use self::RelocMode::*;
51 pub use self::CodeGenModel::*;
52 pub use self::DiagnosticKind::*;
53 pub use self::CallConv::*;
54 pub use self::Visibility::*;
55 pub use self::DiagnosticSeverity::*;
56 pub use self::Linkage::*;
57 pub use self::DLLStorageClassTypes::*;
59 use std::ffi::CString;
60 use std::cell::RefCell;
62 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
63 use libc::{c_longlong, c_ulonglong, c_void};
64 use debuginfo::{DIBuilderRef, DIDescriptor,
65 DIFile, DILexicalBlock, DISubprogram, DIType,
66 DIBasicType, DIDerivedType, DICompositeType, DIScope,
67 DIVariable, DIGlobalVariable, DIArray, DISubrange,
68 DITemplateTypeParameter, DIEnumerator, DINameSpace};
73 pub type Opcode = u32;
74 pub type Bool = c_uint;
76 pub const True: Bool = 1 as Bool;
77 pub const False: Bool = 0 as Bool;
79 // Consts for the LLVM CallConv type, pre-cast to usize.
81 #[derive(Copy, Clone, PartialEq)]
86 X86StdcallCallConv = 64,
87 X86FastcallCallConv = 65,
92 #[derive(Copy, Clone)]
94 LLVMDefaultVisibility = 0,
96 ProtectedVisibility = 2,
99 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
100 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
101 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
102 // they've been removed in upstream LLVM commit r203866.
103 #[derive(Copy, Clone)]
106 AvailableExternallyLinkage = 1,
107 LinkOnceAnyLinkage = 2,
108 LinkOnceODRLinkage = 3,
111 AppendingLinkage = 7,
114 ExternalWeakLinkage = 12,
119 #[derive(Copy, Clone, Debug)]
120 pub enum DiagnosticSeverity {
129 #[derive(Copy, Clone)]
130 pub enum DLLStorageClassTypes {
131 DefaultStorageClass = 0,
132 DLLImportStorageClass = 1,
133 DLLExportStorageClass = 2,
137 flags Attribute : u64 {
140 const NoReturn = 1 << 2,
141 const InReg = 1 << 3,
142 const StructRet = 1 << 4,
143 const NoUnwind = 1 << 5,
144 const NoAlias = 1 << 6,
145 const ByVal = 1 << 7,
147 const ReadNone = 1 << 9,
148 const ReadOnly = 1 << 10,
149 const NoInline = 1 << 11,
150 const AlwaysInline = 1 << 12,
151 const OptimizeForSize = 1 << 13,
152 const StackProtect = 1 << 14,
153 const StackProtectReq = 1 << 15,
154 const Alignment = 1 << 16,
155 const NoCapture = 1 << 21,
156 const NoRedZone = 1 << 22,
157 const NoImplicitFloat = 1 << 23,
158 const Naked = 1 << 24,
159 const InlineHint = 1 << 25,
160 const Stack = 7 << 26,
161 const ReturnsTwice = 1 << 29,
162 const UWTable = 1 << 30,
163 const NonLazyBind = 1 << 31,
164 const OptimizeNone = 1 << 42,
170 #[derive(Copy, Clone)]
171 pub enum OtherAttribute {
172 // The following are not really exposed in
173 // the LLVM C api so instead to add these
174 // we call a wrapper function in RustWrapper
175 // that uses the C++ api.
176 SanitizeAddressAttribute = 1 << 32,
177 MinSizeAttribute = 1 << 33,
178 NoDuplicateAttribute = 1 << 34,
179 StackProtectStrongAttribute = 1 << 35,
180 SanitizeThreadAttribute = 1 << 36,
181 SanitizeMemoryAttribute = 1 << 37,
182 NoBuiltinAttribute = 1 << 38,
183 ReturnedAttribute = 1 << 39,
184 ColdAttribute = 1 << 40,
185 BuiltinAttribute = 1 << 41,
186 OptimizeNoneAttribute = 1 << 42,
187 InAllocaAttribute = 1 << 43,
188 NonNullAttribute = 1 << 44,
191 #[derive(Copy, Clone)]
192 pub enum SpecialAttribute {
193 DereferenceableAttribute(u64)
197 #[derive(Copy, Clone)]
198 pub enum AttributeSet {
203 pub trait AttrHelper {
204 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
205 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
208 impl AttrHelper for Attribute {
209 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
211 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
215 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
217 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
222 impl AttrHelper for OtherAttribute {
223 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
225 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
229 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
231 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
236 impl AttrHelper for SpecialAttribute {
237 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
239 DereferenceableAttribute(bytes) => unsafe {
240 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
245 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
247 DereferenceableAttribute(bytes) => unsafe {
248 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
254 pub struct AttrBuilder {
255 attrs: Vec<(usize, Box<AttrHelper+'static>)>
259 pub fn new() -> AttrBuilder {
265 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: usize, a: T) -> &'a mut AttrBuilder {
266 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
270 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
271 self.attrs.push((ReturnIndex as usize, box a as Box<AttrHelper+'static>));
275 pub fn apply_llfn(&self, llfn: ValueRef) {
276 for &(idx, ref attr) in &self.attrs {
277 attr.apply_llfn(idx as c_uint, llfn);
281 pub fn apply_callsite(&self, callsite: ValueRef) {
282 for &(idx, ref attr) in &self.attrs {
283 attr.apply_callsite(idx as c_uint, callsite);
288 // enum for the LLVM IntPredicate type
289 #[derive(Copy, Clone)]
290 pub enum IntPredicate {
303 // enum for the LLVM RealPredicate type
304 #[derive(Copy, Clone)]
305 pub enum RealPredicate {
306 RealPredicateFalse = 0,
321 RealPredicateTrue = 15,
324 // The LLVM TypeKind type - must stay in sync with the def of
325 // LLVMTypeKind in llvm/include/llvm-c/Core.h
326 #[derive(Copy, Clone, PartialEq, Debug)]
348 #[derive(Copy, Clone)]
349 pub enum AtomicBinOp {
364 #[derive(Copy, Clone)]
365 pub enum AtomicOrdering {
369 // Consume = 3, // Not specified yet.
373 SequentiallyConsistent = 7
377 #[derive(Copy, Clone)]
378 pub enum SynchronizationScope {
383 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
385 #[derive(Copy, Clone)]
387 AssemblyFileType = 0,
391 #[derive(Copy, Clone)]
392 pub enum MetadataType {
399 MD_invariant_load = 6,
403 MD_mem_parallel_loop_access = 10,
407 // Inline Asm Dialect
408 #[derive(Copy, Clone)]
409 pub enum AsmDialect {
414 #[derive(Copy, Clone, PartialEq)]
416 pub enum CodeGenOptLevel {
417 CodeGenLevelNone = 0,
418 CodeGenLevelLess = 1,
419 CodeGenLevelDefault = 2,
420 CodeGenLevelAggressive = 3,
423 #[derive(Copy, Clone, PartialEq)]
429 RelocDynamicNoPic = 3,
433 #[derive(Copy, Clone)]
434 pub enum CodeGenModel {
435 CodeModelDefault = 0,
436 CodeModelJITDefault = 1,
444 #[derive(Copy, Clone)]
445 pub enum DiagnosticKind {
448 DK_DebugMetadataVersion,
450 DK_OptimizationRemark,
451 DK_OptimizationRemarkMissed,
452 DK_OptimizationRemarkAnalysis,
453 DK_OptimizationFailure,
457 #[derive(Copy, Clone)]
458 pub enum ArchiveKind {
465 /// Represents the different LLVM passes Rust supports
466 #[derive(Copy, Clone, PartialEq, Debug)]
468 pub enum SupportedPassKind {
474 // Opaque pointer types
475 #[allow(missing_copy_implementations)]
476 pub enum Module_opaque {}
477 pub type ModuleRef = *mut Module_opaque;
478 #[allow(missing_copy_implementations)]
479 pub enum Context_opaque {}
480 pub type ContextRef = *mut Context_opaque;
481 #[allow(missing_copy_implementations)]
482 pub enum Type_opaque {}
483 pub type TypeRef = *mut Type_opaque;
484 #[allow(missing_copy_implementations)]
485 pub enum Value_opaque {}
486 pub type ValueRef = *mut Value_opaque;
487 #[allow(missing_copy_implementations)]
488 pub enum Metadata_opaque {}
489 pub type MetadataRef = *mut Metadata_opaque;
490 #[allow(missing_copy_implementations)]
491 pub enum BasicBlock_opaque {}
492 pub type BasicBlockRef = *mut BasicBlock_opaque;
493 #[allow(missing_copy_implementations)]
494 pub enum Builder_opaque {}
495 pub type BuilderRef = *mut Builder_opaque;
496 #[allow(missing_copy_implementations)]
497 pub enum ExecutionEngine_opaque {}
498 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
499 #[allow(missing_copy_implementations)]
500 pub enum MemoryBuffer_opaque {}
501 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
502 #[allow(missing_copy_implementations)]
503 pub enum PassManager_opaque {}
504 pub type PassManagerRef = *mut PassManager_opaque;
505 #[allow(missing_copy_implementations)]
506 pub enum PassManagerBuilder_opaque {}
507 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
508 #[allow(missing_copy_implementations)]
509 pub enum Use_opaque {}
510 pub type UseRef = *mut Use_opaque;
511 #[allow(missing_copy_implementations)]
512 pub enum TargetData_opaque {}
513 pub type TargetDataRef = *mut TargetData_opaque;
514 #[allow(missing_copy_implementations)]
515 pub enum ObjectFile_opaque {}
516 pub type ObjectFileRef = *mut ObjectFile_opaque;
517 #[allow(missing_copy_implementations)]
518 pub enum SectionIterator_opaque {}
519 pub type SectionIteratorRef = *mut SectionIterator_opaque;
520 #[allow(missing_copy_implementations)]
521 pub enum Pass_opaque {}
522 pub type PassRef = *mut Pass_opaque;
523 #[allow(missing_copy_implementations)]
524 pub enum TargetMachine_opaque {}
525 pub type TargetMachineRef = *mut TargetMachine_opaque;
526 pub enum Archive_opaque {}
527 pub type ArchiveRef = *mut Archive_opaque;
528 pub enum ArchiveIterator_opaque {}
529 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
530 pub enum ArchiveChild_opaque {}
531 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
532 #[allow(missing_copy_implementations)]
533 pub enum Twine_opaque {}
534 pub type TwineRef = *mut Twine_opaque;
535 #[allow(missing_copy_implementations)]
536 pub enum DiagnosticInfo_opaque {}
537 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
538 #[allow(missing_copy_implementations)]
539 pub enum DebugLoc_opaque {}
540 pub type DebugLocRef = *mut DebugLoc_opaque;
541 #[allow(missing_copy_implementations)]
542 pub enum SMDiagnostic_opaque {}
543 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
544 #[allow(missing_copy_implementations)]
545 pub enum RustArchiveMember_opaque {}
546 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
548 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
549 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
552 pub use self::DIDescriptorFlags::*;
553 use super::{MetadataRef};
555 #[allow(missing_copy_implementations)]
556 pub enum DIBuilder_opaque {}
557 pub type DIBuilderRef = *mut DIBuilder_opaque;
559 pub type DIDescriptor = MetadataRef;
560 pub type DIScope = DIDescriptor;
561 pub type DILocation = DIDescriptor;
562 pub type DIFile = DIScope;
563 pub type DILexicalBlock = DIScope;
564 pub type DISubprogram = DIScope;
565 pub type DINameSpace = DIScope;
566 pub type DIType = DIDescriptor;
567 pub type DIBasicType = DIType;
568 pub type DIDerivedType = DIType;
569 pub type DICompositeType = DIDerivedType;
570 pub type DIVariable = DIDescriptor;
571 pub type DIGlobalVariable = DIDescriptor;
572 pub type DIArray = DIDescriptor;
573 pub type DISubrange = DIDescriptor;
574 pub type DIEnumerator = DIDescriptor;
575 pub type DITemplateTypeParameter = DIDescriptor;
577 #[derive(Copy, Clone)]
578 pub enum DIDescriptorFlags {
579 FlagPrivate = 1 << 0,
580 FlagProtected = 1 << 1,
581 FlagFwdDecl = 1 << 2,
582 FlagAppleBlock = 1 << 3,
583 FlagBlockByrefStruct = 1 << 4,
584 FlagVirtual = 1 << 5,
585 FlagArtificial = 1 << 6,
586 FlagExplicit = 1 << 7,
587 FlagPrototyped = 1 << 8,
588 FlagObjcClassComplete = 1 << 9,
589 FlagObjectPointer = 1 << 10,
590 FlagVector = 1 << 11,
591 FlagStaticMember = 1 << 12,
592 FlagIndirectVariable = 1 << 13,
593 FlagLValueReference = 1 << 14,
594 FlagRValueReference = 1 << 15
599 // Link to our native llvm bindings (things that we need to use the C++ api
600 // for) and because llvm is written in C++ we need to link against libstdc++
602 // You'll probably notice that there is an omission of all LLVM libraries
603 // from this location. This is because the set of LLVM libraries that we
604 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
605 // figure out the exact set of libraries. To do this, the build system
606 // generates an llvmdeps.rs file next to this one which will be
607 // automatically updated whenever LLVM is updated to include an up-to-date
608 // set of the libraries we need to link to LLVM for.
609 #[link(name = "rustllvm", kind = "static")]
610 #[linked_from = "rustllvm"] // not quite true but good enough
612 /* Create and destroy contexts. */
613 pub fn LLVMContextCreate() -> ContextRef;
614 pub fn LLVMContextDispose(C: ContextRef);
615 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
620 /* Create and destroy modules. */
621 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
624 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
625 pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
626 pub fn LLVMDisposeModule(M: ModuleRef);
628 /// Data layout. See Module::getDataLayout.
629 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
630 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
632 /// Target triple. See Module::getTargetTriple.
633 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
634 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
636 /// See Module::dump.
637 pub fn LLVMDumpModule(M: ModuleRef);
639 /// See Module::setModuleInlineAsm.
640 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
642 /// See llvm::LLVMTypeKind::getTypeID.
643 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
645 /// See llvm::LLVMType::getContext.
646 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
648 /* Operations on integer types */
649 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
650 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
651 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
652 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
653 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
654 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
657 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
659 /* Operations on real types */
660 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
661 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
662 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
663 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
664 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
666 /* Operations on function types */
667 pub fn LLVMFunctionType(ReturnType: TypeRef,
668 ParamTypes: *const TypeRef,
672 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
673 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
674 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
675 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
677 /* Operations on struct types */
678 pub fn LLVMStructTypeInContext(C: ContextRef,
679 ElementTypes: *const TypeRef,
680 ElementCount: c_uint,
683 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
684 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
686 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
688 /* Operations on array, pointer, and vector types (sequence types) */
689 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
690 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
692 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
695 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
696 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
697 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
698 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
700 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
702 /* Operations on other types */
703 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
704 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
705 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
707 /* Operations on all values */
708 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
709 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
710 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
711 pub fn LLVMDumpValue(Val: ValueRef);
712 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
713 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
714 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
715 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
717 /* Operations on Uses */
718 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
719 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
720 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
721 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
723 /* Operations on Users */
724 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
725 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
726 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
728 /* Operations on constants of any type */
729 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
731 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
732 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
734 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
736 /* only for isize/vector */
737 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
738 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
739 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
740 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
741 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
743 /* Operations on metadata */
744 pub fn LLVMMDStringInContext(C: ContextRef,
748 pub fn LLVMMDNodeInContext(C: ContextRef,
749 Vals: *const ValueRef,
752 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
756 /* Operations on scalar constants */
757 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
759 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
761 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
766 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
767 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
769 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
773 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
774 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
777 /* Operations on composite constants */
778 pub fn LLVMConstStringInContext(C: ContextRef,
781 DontNullTerminate: Bool)
783 pub fn LLVMConstStructInContext(C: ContextRef,
784 ConstantVals: *const ValueRef,
789 pub fn LLVMConstArray(ElementTy: TypeRef,
790 ConstantVals: *const ValueRef,
793 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
796 /* Constant expressions */
797 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
798 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
799 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
800 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
801 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
802 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
803 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
804 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
806 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
808 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
810 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
812 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
814 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
816 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
818 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
820 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
822 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
824 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
826 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
828 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
830 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
832 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
833 RHSConstant: ValueRef)
835 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
837 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
839 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
841 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
843 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
845 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
847 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
849 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
851 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
853 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
855 pub fn LLVMConstGEP(ConstantVal: ValueRef,
856 ConstantIndices: *const ValueRef,
859 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
860 ConstantIndices: *const ValueRef,
863 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
865 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
867 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
869 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
871 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
873 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
875 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
877 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
879 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
881 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
883 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
885 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
887 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
889 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
891 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
893 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
895 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
899 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
901 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
902 ConstantIfTrue: ValueRef,
903 ConstantIfFalse: ValueRef)
905 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
906 IndexConstant: ValueRef)
908 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
909 ElementValueConstant: ValueRef,
910 IndexConstant: ValueRef)
912 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
913 VectorBConstant: ValueRef,
914 MaskConstant: ValueRef)
916 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
917 IdxList: *const c_uint,
920 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
921 ElementValueConstant: ValueRef,
922 IdxList: *const c_uint,
925 pub fn LLVMConstInlineAsm(Ty: TypeRef,
926 AsmString: *const c_char,
927 Constraints: *const c_char,
928 HasSideEffects: Bool,
931 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
935 /* Operations on global variables, functions, and aliases (globals) */
936 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
937 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
938 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
939 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
940 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
941 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
942 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
943 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
944 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
945 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
948 /* Operations on global variables */
949 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
950 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
952 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
955 AddressSpace: c_uint)
957 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
958 pub fn LLVMGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
959 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
960 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
961 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
962 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
963 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
964 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
965 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
966 ConstantVal: ValueRef);
967 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
968 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
969 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
970 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
971 pub fn LLVMGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
973 /* Operations on aliases */
974 pub fn LLVMAddAlias(M: ModuleRef,
980 /* Operations on functions */
981 pub fn LLVMAddFunction(M: ModuleRef,
985 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
986 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
987 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
988 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
989 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
990 pub fn LLVMDeleteFunction(Fn: ValueRef);
991 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
995 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
996 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
997 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
998 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
999 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
1000 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
1001 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
1002 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
1003 pub fn LLVMAddFunctionAttrStringValue(Fn: ValueRef, index: c_uint,
1004 Name: *const c_char,
1005 Value: *const c_char);
1006 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
1007 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
1008 pub fn LLVMRemoveFunctionAttr(Fn: ValueRef, val: c_ulonglong);
1010 /* Operations on parameters */
1011 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
1012 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
1013 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
1014 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
1015 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
1016 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
1017 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
1018 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
1019 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
1020 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
1021 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
1022 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
1024 /* Operations on basic blocks */
1025 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
1026 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
1027 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
1028 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
1029 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
1030 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
1031 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1032 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1033 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
1034 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
1035 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1037 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
1039 Name: *const c_char)
1041 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
1043 Name: *const c_char)
1045 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
1047 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
1048 MoveAfter: BasicBlockRef);
1050 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
1051 MoveBefore: BasicBlockRef);
1053 /* Operations on instructions */
1054 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
1055 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
1056 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
1057 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
1058 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
1059 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
1061 /* Operations on call sites */
1062 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
1063 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
1064 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
1067 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1070 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1073 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1076 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1080 /* Operations on call instructions (only) */
1081 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1082 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1084 /* Operations on load/store instructions (only) */
1085 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1086 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1088 /* Operations on phi nodes */
1089 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1090 IncomingValues: *const ValueRef,
1091 IncomingBlocks: *const BasicBlockRef,
1093 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1094 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1096 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1099 /* Instruction builders */
1100 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1101 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1102 Block: BasicBlockRef,
1104 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1106 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1107 Block: BasicBlockRef);
1108 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1109 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1110 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1111 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1113 Name: *const c_char);
1114 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1116 /* Execution engine */
1117 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef) -> ExecutionEngineRef;
1118 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1119 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1120 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1121 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1122 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1126 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1127 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1128 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1131 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1132 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1133 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1134 RetVals: *const ValueRef,
1137 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1138 pub fn LLVMBuildCondBr(B: BuilderRef,
1140 Then: BasicBlockRef,
1141 Else: BasicBlockRef)
1143 pub fn LLVMBuildSwitch(B: BuilderRef,
1145 Else: BasicBlockRef,
1148 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1152 pub fn LLVMBuildInvoke(B: BuilderRef,
1154 Args: *const ValueRef,
1156 Then: BasicBlockRef,
1157 Catch: BasicBlockRef,
1158 Name: *const c_char)
1160 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
1164 Name: *const c_char,
1167 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1168 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1170 /* Add a case to the switch instruction */
1171 pub fn LLVMAddCase(Switch: ValueRef,
1173 Dest: BasicBlockRef);
1175 /* Add a destination to the indirectbr instruction */
1176 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1178 /* Add a clause to the landing pad instruction */
1179 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1181 /* Set the cleanup on a landing pad instruction */
1182 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1185 pub fn LLVMBuildAdd(B: BuilderRef,
1188 Name: *const c_char)
1190 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1193 Name: *const c_char)
1195 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1198 Name: *const c_char)
1200 pub fn LLVMBuildFAdd(B: BuilderRef,
1203 Name: *const c_char)
1205 pub fn LLVMBuildSub(B: BuilderRef,
1208 Name: *const c_char)
1210 pub fn LLVMBuildNSWSub(B: BuilderRef,
1213 Name: *const c_char)
1215 pub fn LLVMBuildNUWSub(B: BuilderRef,
1218 Name: *const c_char)
1220 pub fn LLVMBuildFSub(B: BuilderRef,
1223 Name: *const c_char)
1225 pub fn LLVMBuildMul(B: BuilderRef,
1228 Name: *const c_char)
1230 pub fn LLVMBuildNSWMul(B: BuilderRef,
1233 Name: *const c_char)
1235 pub fn LLVMBuildNUWMul(B: BuilderRef,
1238 Name: *const c_char)
1240 pub fn LLVMBuildFMul(B: BuilderRef,
1243 Name: *const c_char)
1245 pub fn LLVMBuildUDiv(B: BuilderRef,
1248 Name: *const c_char)
1250 pub fn LLVMBuildSDiv(B: BuilderRef,
1253 Name: *const c_char)
1255 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1258 Name: *const c_char)
1260 pub fn LLVMBuildFDiv(B: BuilderRef,
1263 Name: *const c_char)
1265 pub fn LLVMBuildURem(B: BuilderRef,
1268 Name: *const c_char)
1270 pub fn LLVMBuildSRem(B: BuilderRef,
1273 Name: *const c_char)
1275 pub fn LLVMBuildFRem(B: BuilderRef,
1278 Name: *const c_char)
1280 pub fn LLVMBuildShl(B: BuilderRef,
1283 Name: *const c_char)
1285 pub fn LLVMBuildLShr(B: BuilderRef,
1288 Name: *const c_char)
1290 pub fn LLVMBuildAShr(B: BuilderRef,
1293 Name: *const c_char)
1295 pub fn LLVMBuildAnd(B: BuilderRef,
1298 Name: *const c_char)
1300 pub fn LLVMBuildOr(B: BuilderRef,
1303 Name: *const c_char)
1305 pub fn LLVMBuildXor(B: BuilderRef,
1308 Name: *const c_char)
1310 pub fn LLVMBuildBinOp(B: BuilderRef,
1314 Name: *const c_char)
1316 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1318 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1320 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1322 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1324 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1328 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1330 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1331 pub fn LLVMBuildLoad(B: BuilderRef,
1332 PointerVal: ValueRef,
1333 Name: *const c_char)
1336 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1339 pub fn LLVMBuildGEP(B: BuilderRef,
1341 Indices: *const ValueRef,
1343 Name: *const c_char)
1345 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1347 Indices: *const ValueRef,
1349 Name: *const c_char)
1351 pub fn LLVMBuildStructGEP(B: BuilderRef,
1354 Name: *const c_char)
1356 pub fn LLVMBuildGlobalString(B: BuilderRef,
1358 Name: *const c_char)
1360 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1362 Name: *const c_char)
1366 pub fn LLVMBuildTrunc(B: BuilderRef,
1369 Name: *const c_char)
1371 pub fn LLVMBuildZExt(B: BuilderRef,
1374 Name: *const c_char)
1376 pub fn LLVMBuildSExt(B: BuilderRef,
1379 Name: *const c_char)
1381 pub fn LLVMBuildFPToUI(B: BuilderRef,
1384 Name: *const c_char)
1386 pub fn LLVMBuildFPToSI(B: BuilderRef,
1389 Name: *const c_char)
1391 pub fn LLVMBuildUIToFP(B: BuilderRef,
1394 Name: *const c_char)
1396 pub fn LLVMBuildSIToFP(B: BuilderRef,
1399 Name: *const c_char)
1401 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1404 Name: *const c_char)
1406 pub fn LLVMBuildFPExt(B: BuilderRef,
1409 Name: *const c_char)
1411 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1414 Name: *const c_char)
1416 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1419 Name: *const c_char)
1421 pub fn LLVMBuildBitCast(B: BuilderRef,
1424 Name: *const c_char)
1426 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1429 Name: *const c_char)
1431 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1434 Name: *const c_char)
1436 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1439 Name: *const c_char)
1441 pub fn LLVMBuildCast(B: BuilderRef,
1445 Name: *const c_char) -> ValueRef;
1446 pub fn LLVMBuildPointerCast(B: BuilderRef,
1449 Name: *const c_char)
1451 pub fn LLVMBuildIntCast(B: BuilderRef,
1454 Name: *const c_char)
1456 pub fn LLVMBuildFPCast(B: BuilderRef,
1459 Name: *const c_char)
1463 pub fn LLVMBuildICmp(B: BuilderRef,
1467 Name: *const c_char)
1469 pub fn LLVMBuildFCmp(B: BuilderRef,
1473 Name: *const c_char)
1476 /* Miscellaneous instructions */
1477 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1479 pub fn LLVMBuildCall(B: BuilderRef,
1481 Args: *const ValueRef,
1483 Name: *const c_char)
1485 pub fn LLVMBuildSelect(B: BuilderRef,
1489 Name: *const c_char)
1491 pub fn LLVMBuildVAArg(B: BuilderRef,
1494 Name: *const c_char)
1496 pub fn LLVMBuildExtractElement(B: BuilderRef,
1499 Name: *const c_char)
1501 pub fn LLVMBuildInsertElement(B: BuilderRef,
1505 Name: *const c_char)
1507 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1511 Name: *const c_char)
1513 pub fn LLVMBuildExtractValue(B: BuilderRef,
1516 Name: *const c_char)
1518 pub fn LLVMBuildInsertValue(B: BuilderRef,
1522 Name: *const c_char)
1525 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1527 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1529 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1532 Name: *const c_char)
1535 /* Atomic Operations */
1536 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1537 PointerVal: ValueRef,
1538 Name: *const c_char,
1539 Order: AtomicOrdering,
1543 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1546 Order: AtomicOrdering,
1550 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1554 Order: AtomicOrdering,
1555 FailureOrder: AtomicOrdering)
1557 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1561 Order: AtomicOrdering,
1562 SingleThreaded: Bool)
1565 pub fn LLVMBuildAtomicFence(B: BuilderRef,
1566 Order: AtomicOrdering,
1567 Scope: SynchronizationScope);
1570 /* Selected entries from the downcasts. */
1571 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1572 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1574 /// Writes a module to the specified path. Returns 0 on success.
1575 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1577 /// Creates target data from a target layout string.
1578 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1579 /// Adds the target data to the given pass manager. The pass manager
1580 /// references the target data only weakly.
1581 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1582 /// Number of bytes clobbered when doing a Store to *T.
1583 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1586 /// Number of bytes clobbered when doing a Store to *T.
1587 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1590 /// Distance between successive elements in an array of T. Includes ABI padding.
1591 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1593 /// Returns the preferred alignment of a type.
1594 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1596 /// Returns the minimum alignment of a type.
1597 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1600 /// Computes the byte offset of the indexed struct element for a
1602 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1607 /// Returns the minimum alignment of a type when part of a call frame.
1608 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1611 /// Disposes target data.
1612 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1614 /// Creates a pass manager.
1615 pub fn LLVMCreatePassManager() -> PassManagerRef;
1617 /// Creates a function-by-function pass manager
1618 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1621 /// Disposes a pass manager.
1622 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1624 /// Runs a pass manager on a module.
1625 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1627 /// Runs the function passes on the provided function.
1628 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1631 /// Initializes all the function passes scheduled in the manager
1632 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1634 /// Finalizes all the function passes scheduled in the manager
1635 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1637 pub fn LLVMInitializePasses();
1639 /// Adds a verification pass.
1640 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1642 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1643 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1644 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1645 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1646 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1647 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1648 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1649 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1650 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1651 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1652 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1653 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1654 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1655 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1656 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1657 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1658 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1659 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1660 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1661 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1662 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1663 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1664 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1665 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1666 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1667 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1668 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1669 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1670 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1671 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1672 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1673 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1674 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1675 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1676 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1678 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1679 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1680 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1681 OptimizationLevel: c_uint);
1682 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1684 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1685 PMB: PassManagerBuilderRef,
1687 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1688 PMB: PassManagerBuilderRef,
1690 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1691 PMB: PassManagerBuilderRef,
1693 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1694 PMB: PassManagerBuilderRef,
1696 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1697 PMB: PassManagerBuilderRef,
1698 PM: PassManagerRef);
1700 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1701 PMB: PassManagerBuilderRef,
1702 PM: PassManagerRef);
1703 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1704 PMB: PassManagerBuilderRef,
1709 /// Destroys a memory buffer.
1710 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1713 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1715 /// Opens an object file.
1716 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1717 /// Closes an object file.
1718 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1720 /// Enumerates the sections in an object file.
1721 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1722 /// Destroys a section iterator.
1723 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1724 /// Returns true if the section iterator is at the end of the section
1726 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1727 SI: SectionIteratorRef)
1729 /// Moves the section iterator to point to the next section.
1730 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1731 /// Returns the current section size.
1732 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1733 /// Returns the current section contents as a string buffer.
1734 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1736 /// Reads the given file and returns it as a memory buffer. Use
1737 /// LLVMDisposeMemoryBuffer() to get rid of it.
1738 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1740 /// Borrows the contents of the memory buffer (doesn't copy it)
1741 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1742 InputDataLength: size_t,
1743 BufferName: *const c_char,
1746 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1747 InputDataLength: size_t,
1748 BufferName: *const c_char)
1751 pub fn LLVMIsMultithreaded() -> Bool;
1752 pub fn LLVMStartMultithreaded() -> Bool;
1754 /// Returns a string describing the last error caused by an LLVMRust* call.
1755 pub fn LLVMRustGetLastError() -> *const c_char;
1757 /// Print the pass timings since static dtors aren't picking them up.
1758 pub fn LLVMRustPrintPassTimings();
1760 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1762 pub fn LLVMStructSetBody(StructTy: TypeRef,
1763 ElementTypes: *const TypeRef,
1764 ElementCount: c_uint,
1767 pub fn LLVMConstNamedStruct(S: TypeRef,
1768 ConstantVals: *const ValueRef,
1772 /// Enables LLVM debug output.
1773 pub fn LLVMSetDebug(Enabled: c_int);
1775 /// Prepares inline assembly.
1776 pub fn LLVMInlineAsm(Ty: TypeRef,
1777 AsmString: *const c_char,
1778 Constraints: *const c_char,
1784 pub fn LLVMRustDebugMetadataVersion() -> u32;
1785 pub fn LLVMVersionMajor() -> u32;
1786 pub fn LLVMVersionMinor() -> u32;
1788 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1789 name: *const c_char,
1792 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1794 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1796 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1798 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1800 File: *const c_char,
1802 Producer: *const c_char,
1804 Flags: *const c_char,
1806 SplitName: *const c_char)
1809 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1810 Filename: *const c_char,
1811 Directory: *const c_char)
1814 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1816 ParameterTypes: DIArray)
1819 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1820 Scope: DIDescriptor,
1821 Name: *const c_char,
1822 LinkageName: *const c_char,
1826 isLocalToUnit: bool,
1836 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1837 Name: *const c_char,
1838 SizeInBits: c_ulonglong,
1839 AlignInBits: c_ulonglong,
1843 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1845 SizeInBits: c_ulonglong,
1846 AlignInBits: c_ulonglong,
1847 Name: *const c_char)
1850 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1851 Scope: DIDescriptor,
1852 Name: *const c_char,
1855 SizeInBits: c_ulonglong,
1856 AlignInBits: c_ulonglong,
1858 DerivedFrom: DIType,
1860 RunTimeLang: c_uint,
1861 VTableHolder: DIType,
1862 UniqueId: *const c_char)
1865 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1866 Scope: DIDescriptor,
1867 Name: *const c_char,
1870 SizeInBits: c_ulonglong,
1871 AlignInBits: c_ulonglong,
1872 OffsetInBits: c_ulonglong,
1877 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1884 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1886 Name: *const c_char,
1887 LinkageName: *const c_char,
1891 isLocalToUnit: bool,
1894 -> DIGlobalVariable;
1896 pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef,
1898 Scope: DIDescriptor,
1899 Name: *const c_char,
1903 AlwaysPreserve: bool,
1905 AddrOps: *const i64,
1906 AddrOpsCount: c_uint,
1910 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1912 AlignInBits: c_ulonglong,
1914 Subscripts: DIArray)
1917 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1919 AlignInBits: c_ulonglong,
1921 Subscripts: DIArray)
1924 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1929 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1930 Ptr: *const DIDescriptor,
1934 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1936 VarInfo: DIVariable,
1937 AddrOps: *const i64,
1938 AddrOpsCount: c_uint,
1940 InsertAtEnd: BasicBlockRef)
1943 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1945 VarInfo: DIVariable,
1946 AddrOps: *const i64,
1947 AddrOpsCount: c_uint,
1949 InsertBefore: ValueRef)
1952 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1953 Name: *const c_char,
1957 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1959 Name: *const c_char,
1962 SizeInBits: c_ulonglong,
1963 AlignInBits: c_ulonglong,
1968 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1970 Name: *const c_char,
1973 SizeInBits: c_ulonglong,
1974 AlignInBits: c_ulonglong,
1977 RunTimeLang: c_uint,
1978 UniqueId: *const c_char)
1981 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1983 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1985 Name: *const c_char,
1990 -> DITemplateTypeParameter;
1992 pub fn LLVMDIBuilderCreateOpDeref() -> i64;
1994 pub fn LLVMDIBuilderCreateOpPlus() -> i64;
1996 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1998 Name: *const c_char,
2003 pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef,
2007 InlinedAt: MetadataRef)
2010 pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
2011 CompositeType: DIType,
2012 TypeArray: DIArray);
2013 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
2014 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
2016 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
2018 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
2019 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
2021 pub fn LLVMRustPassKind(Pass: PassRef) -> SupportedPassKind;
2022 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
2023 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
2025 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
2027 Features: *const c_char,
2028 Model: CodeGenModel,
2030 Level: CodeGenOptLevel,
2032 PositionIndependentExecutable: bool,
2033 FunctionSections: bool,
2034 DataSections: bool) -> TargetMachineRef;
2035 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
2036 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
2039 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
2041 DisableSimplifyLibCalls: bool);
2042 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
2043 OptLevel: CodeGenOptLevel,
2044 MergeFunctions: bool,
2046 LoopVectorize: bool);
2047 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
2048 DisableSimplifyLibCalls: bool);
2049 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
2050 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2053 Output: *const c_char,
2054 FileType: FileType) -> bool;
2055 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2057 Output: *const c_char);
2058 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2059 pub fn LLVMRustPrintPasses();
2060 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2061 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2062 AddLifetimes: bool);
2063 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2065 len: size_t) -> bool;
2066 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2067 syms: *const *const c_char,
2069 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2071 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2072 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
2073 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
2074 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef,
2075 size: *mut size_t) -> *const c_char;
2076 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef,
2077 size: *mut size_t) -> *const c_char;
2078 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
2079 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
2080 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2082 pub fn LLVMRustSetDLLStorageClass(V: ValueRef,
2083 C: DLLStorageClassTypes);
2085 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2086 data: *mut *const c_char) -> c_int;
2088 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2090 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2091 Handler: DiagnosticHandler,
2092 DiagnosticContext: *mut c_void);
2094 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2095 pass_name_out: *mut *const c_char,
2096 function_out: *mut ValueRef,
2097 debugloc_out: *mut DebugLocRef,
2098 message_out: *mut TwineRef);
2099 pub fn LLVMUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
2100 cookie_out: *mut c_uint,
2101 message_out: *mut TwineRef,
2102 instruction_out: *mut ValueRef);
2104 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2105 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2106 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2108 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2110 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2111 H: InlineAsmDiagHandler,
2114 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2116 pub fn LLVMRustWriteArchive(Dst: *const c_char,
2118 Members: *const RustArchiveMemberRef,
2120 Kind: ArchiveKind) -> c_int;
2121 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
2122 Name: *const c_char,
2123 Child: ArchiveChildRef) -> RustArchiveMemberRef;
2124 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
2126 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef,
2127 TM: TargetMachineRef);
2128 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
2131 #[cfg(have_component_x86)]
2133 pub fn LLVMInitializeX86TargetInfo();
2134 pub fn LLVMInitializeX86Target();
2135 pub fn LLVMInitializeX86TargetMC();
2136 pub fn LLVMInitializeX86AsmPrinter();
2137 pub fn LLVMInitializeX86AsmParser();
2139 #[cfg(have_component_arm)]
2141 pub fn LLVMInitializeARMTargetInfo();
2142 pub fn LLVMInitializeARMTarget();
2143 pub fn LLVMInitializeARMTargetMC();
2144 pub fn LLVMInitializeARMAsmPrinter();
2145 pub fn LLVMInitializeARMAsmParser();
2147 #[cfg(have_component_aarch64)]
2149 pub fn LLVMInitializeAArch64TargetInfo();
2150 pub fn LLVMInitializeAArch64Target();
2151 pub fn LLVMInitializeAArch64TargetMC();
2152 pub fn LLVMInitializeAArch64AsmPrinter();
2153 pub fn LLVMInitializeAArch64AsmParser();
2155 #[cfg(have_component_mips)]
2157 pub fn LLVMInitializeMipsTargetInfo();
2158 pub fn LLVMInitializeMipsTarget();
2159 pub fn LLVMInitializeMipsTargetMC();
2160 pub fn LLVMInitializeMipsAsmPrinter();
2161 pub fn LLVMInitializeMipsAsmParser();
2163 #[cfg(have_component_powerpc)]
2165 pub fn LLVMInitializePowerPCTargetInfo();
2166 pub fn LLVMInitializePowerPCTarget();
2167 pub fn LLVMInitializePowerPCTargetMC();
2168 pub fn LLVMInitializePowerPCAsmPrinter();
2169 pub fn LLVMInitializePowerPCAsmParser();
2171 #[cfg(have_component_pnacl)]
2173 pub fn LLVMInitializePNaClTargetInfo();
2174 pub fn LLVMInitializePNaClTarget();
2175 pub fn LLVMInitializePNaClTargetMC();
2178 // LLVM requires symbols from this library, but apparently they're not printed
2179 // during llvm-config?
2181 #[link(name = "ole32")]
2184 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2186 LLVMSetInstructionCallConv(instr, cc as c_uint);
2189 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2191 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2194 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2196 LLVMSetLinkage(global, link as c_uint);
2200 pub fn SetDLLStorageClass(global: ValueRef, class: DLLStorageClassTypes) {
2202 LLVMRustSetDLLStorageClass(global, class);
2206 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2208 LLVMSetUnnamedAddr(global, unnamed as Bool);
2212 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2214 LLVMSetThreadLocal(global, is_thread_local as Bool);
2218 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2220 LLVMConstICmp(pred as c_ushort, v1, v2)
2223 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2225 LLVMConstFCmp(pred as c_ushort, v1, v2)
2229 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2231 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint,
2232 attr.bits() as uint64_t)
2236 /* Memory-managed interface to target data. */
2238 pub struct TargetData {
2239 pub lltd: TargetDataRef
2242 impl Drop for TargetData {
2243 fn drop(&mut self) {
2245 LLVMDisposeTargetData(self.lltd);
2250 pub fn mk_target_data(string_rep: &str) -> TargetData {
2251 let string_rep = CString::new(string_rep).unwrap();
2253 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2257 /* Memory-managed interface to object files. */
2259 pub struct ObjectFile {
2260 pub llof: ObjectFileRef,
2264 // This will take ownership of llmb
2265 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2267 let llof = LLVMCreateObjectFile(llmb);
2268 if llof as isize == 0 {
2269 // LLVMCreateObjectFile took ownership of llmb
2280 impl Drop for ObjectFile {
2281 fn drop(&mut self) {
2283 LLVMDisposeObjectFile(self.llof);
2288 /* Memory-managed interface to section iterators. */
2290 pub struct SectionIter {
2291 pub llsi: SectionIteratorRef
2294 impl Drop for SectionIter {
2295 fn drop(&mut self) {
2297 LLVMDisposeSectionIterator(self.llsi);
2302 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2305 llsi: LLVMGetSections(llof)
2310 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2311 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2313 assert!(index < LLVMCountParams(llfn));
2314 LLVMGetParam(llfn, index)
2318 pub fn get_params(llfn: ValueRef) -> Vec<ValueRef> {
2320 let num_params = LLVMCountParams(llfn);
2321 let mut params = Vec::with_capacity(num_params as usize);
2322 for idx in 0..num_params {
2323 params.push(LLVMGetParam(llfn, idx));
2330 #[allow(missing_copy_implementations)]
2331 pub enum RustString_opaque {}
2332 pub type RustStringRef = *mut RustString_opaque;
2333 type RustStringRepr = *mut RefCell<Vec<u8>>;
2335 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2337 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2340 let slice = slice::from_raw_parts(ptr as *const u8, size as usize);
2342 let sr = sr as RustStringRepr;
2343 (*sr).borrow_mut().extend_from_slice(slice);
2346 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2347 let mut buf = RefCell::new(Vec::new());
2348 f(&mut buf as RustStringRepr as RustStringRef);
2349 String::from_utf8(buf.into_inner()).ok()
2352 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2353 build_string(|s| LLVMWriteTwineToString(tr, s))
2354 .expect("got a non-UTF8 Twine from LLVM")
2357 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2358 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2359 .expect("got a non-UTF8 DebugLoc from LLVM")
2362 pub fn initialize_available_targets() {
2363 macro_rules! init_target(
2364 ($cfg:ident $arch:ident) => { {
2368 let f = concat_idents!(LLVMInitialize, $arch, TargetInfo);
2370 let f = concat_idents!(LLVMInitialize, $arch, Target);
2372 let f = concat_idents!(LLVMInitialize, $arch, TargetMC);
2374 let f = concat_idents!(LLVMInitialize, $arch, AsmPrinter);
2376 let f = concat_idents!(LLVMInitialize, $arch, AsmParser);
2386 init_target!(have_component_powerpc PowerPC);
2387 init_target!(have_component_mips Mips);
2388 init_target!(have_component_aarch64 AArch64);
2389 init_target!(have_component_arm ARM);
2390 init_target!(have_component_x86 X86);
2392 // PNaCl doesn't provide some of the optional target components, so we
2393 // manually initialize it here.
2394 #[cfg(have_component_pnacl)]
2397 LLVMInitializePNaClTargetInfo();
2398 LLVMInitializePNaClTarget();
2399 LLVMInitializePNaClTargetMC();
2402 #[cfg(not(have_component_pnacl))]
2407 // The module containing the native LLVM dependencies, generated by the build system
2408 // Note that this must come after the rustllvm extern declaration so that
2409 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2410 // Works to the above fix for #15460 to ensure LLVM dependencies that
2411 // are only used by rustllvm don't get stripped by the linker.
2413 include! { env!("CFG_LLVM_LINKAGE_FILE") }