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 // Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
12 #![cfg_attr(stage0, feature(custom_attribute))]
13 #![allow(non_upper_case_globals)]
14 #![allow(non_camel_case_types)]
15 #![allow(non_snake_case)]
17 #![allow(trivial_casts)]
19 #![cfg_attr(stage0, allow(improper_ctypes))]
21 #![crate_name = "rustc_llvm"]
22 #![unstable(feature = "rustc_private", issue = "27812")]
23 #![cfg_attr(stage0, staged_api)]
24 #![crate_type = "dylib"]
25 #![crate_type = "rlib"]
26 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
27 html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
28 html_root_url = "https://doc.rust-lang.org/nightly/")]
30 #![feature(associated_consts)]
31 #![feature(box_syntax)]
33 #![feature(link_args)]
34 #![feature(staged_api)]
35 #![feature(linked_from)]
36 #![feature(concat_idents)]
39 #[macro_use] #[no_link] extern crate rustc_bitflags;
41 pub use self::OtherAttribute::*;
42 pub use self::SpecialAttribute::*;
43 pub use self::AttributeSet::*;
44 pub use self::IntPredicate::*;
45 pub use self::RealPredicate::*;
46 pub use self::TypeKind::*;
47 pub use self::AtomicBinOp::*;
48 pub use self::AtomicOrdering::*;
49 pub use self::SynchronizationScope::*;
50 pub use self::FileType::*;
51 pub use self::MetadataType::*;
52 pub use self::AsmDialect::*;
53 pub use self::CodeGenOptLevel::*;
54 pub use self::RelocMode::*;
55 pub use self::CodeGenModel::*;
56 pub use self::DiagnosticKind::*;
57 pub use self::CallConv::*;
58 pub use self::Visibility::*;
59 pub use self::DiagnosticSeverity::*;
60 pub use self::Linkage::*;
61 pub use self::DLLStorageClassTypes::*;
63 use std::ffi::CString;
64 use std::cell::RefCell;
66 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
67 use libc::{c_longlong, c_ulonglong, c_void};
68 use debuginfo::{DIBuilderRef, DIDescriptor,
69 DIFile, DILexicalBlock, DISubprogram, DIType,
70 DIBasicType, DIDerivedType, DICompositeType, DIScope,
71 DIVariable, DIGlobalVariable, DIArray, DISubrange,
72 DITemplateTypeParameter, DIEnumerator, DINameSpace};
77 pub type Opcode = u32;
78 pub type Bool = c_uint;
80 pub const True: Bool = 1 as Bool;
81 pub const False: Bool = 0 as Bool;
83 // Consts for the LLVM CallConv type, pre-cast to usize.
85 #[derive(Copy, Clone, PartialEq)]
90 X86StdcallCallConv = 64,
91 X86FastcallCallConv = 65,
95 #[derive(Copy, Clone)]
97 LLVMDefaultVisibility = 0,
99 ProtectedVisibility = 2,
102 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
103 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
104 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
105 // they've been removed in upstream LLVM commit r203866.
106 #[derive(Copy, Clone)]
109 AvailableExternallyLinkage = 1,
110 LinkOnceAnyLinkage = 2,
111 LinkOnceODRLinkage = 3,
114 AppendingLinkage = 7,
117 ExternalWeakLinkage = 12,
122 #[derive(Copy, Clone, Debug)]
123 pub enum DiagnosticSeverity {
132 #[derive(Copy, Clone)]
133 pub enum DLLStorageClassTypes {
134 DefaultStorageClass = 0,
135 DLLImportStorageClass = 1,
136 DLLExportStorageClass = 2,
140 flags Attribute : u64 {
143 const NoReturn = 1 << 2,
144 const InReg = 1 << 3,
145 const StructRet = 1 << 4,
146 const NoUnwind = 1 << 5,
147 const NoAlias = 1 << 6,
148 const ByVal = 1 << 7,
150 const ReadNone = 1 << 9,
151 const ReadOnly = 1 << 10,
152 const NoInline = 1 << 11,
153 const AlwaysInline = 1 << 12,
154 const OptimizeForSize = 1 << 13,
155 const StackProtect = 1 << 14,
156 const StackProtectReq = 1 << 15,
157 const Alignment = 1 << 16,
158 const NoCapture = 1 << 21,
159 const NoRedZone = 1 << 22,
160 const NoImplicitFloat = 1 << 23,
161 const Naked = 1 << 24,
162 const InlineHint = 1 << 25,
163 const Stack = 7 << 26,
164 const ReturnsTwice = 1 << 29,
165 const UWTable = 1 << 30,
166 const NonLazyBind = 1 << 31,
167 const OptimizeNone = 1 << 42,
173 #[derive(Copy, Clone)]
174 pub enum OtherAttribute {
175 // The following are not really exposed in
176 // the LLVM C api so instead to add these
177 // we call a wrapper function in RustWrapper
178 // that uses the C++ api.
179 SanitizeAddressAttribute = 1 << 32,
180 MinSizeAttribute = 1 << 33,
181 NoDuplicateAttribute = 1 << 34,
182 StackProtectStrongAttribute = 1 << 35,
183 SanitizeThreadAttribute = 1 << 36,
184 SanitizeMemoryAttribute = 1 << 37,
185 NoBuiltinAttribute = 1 << 38,
186 ReturnedAttribute = 1 << 39,
187 ColdAttribute = 1 << 40,
188 BuiltinAttribute = 1 << 41,
189 OptimizeNoneAttribute = 1 << 42,
190 InAllocaAttribute = 1 << 43,
191 NonNullAttribute = 1 << 44,
194 #[derive(Copy, Clone)]
195 pub enum SpecialAttribute {
196 DereferenceableAttribute(u64)
200 #[derive(Copy, Clone)]
201 pub enum AttributeSet {
206 pub trait AttrHelper {
207 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
208 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
211 impl AttrHelper for Attribute {
212 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
214 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
218 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
220 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
225 impl AttrHelper for OtherAttribute {
226 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
228 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
232 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
234 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
239 impl AttrHelper for SpecialAttribute {
240 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
242 DereferenceableAttribute(bytes) => unsafe {
243 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
248 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
250 DereferenceableAttribute(bytes) => unsafe {
251 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
257 pub struct AttrBuilder {
258 attrs: Vec<(usize, Box<AttrHelper+'static>)>
262 pub fn new() -> AttrBuilder {
268 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: usize, a: T) -> &'a mut AttrBuilder {
269 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
273 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
274 self.attrs.push((ReturnIndex as usize, box a as Box<AttrHelper+'static>));
278 pub fn apply_llfn(&self, llfn: ValueRef) {
279 for &(idx, ref attr) in &self.attrs {
280 attr.apply_llfn(idx as c_uint, llfn);
284 pub fn apply_callsite(&self, callsite: ValueRef) {
285 for &(idx, ref attr) in &self.attrs {
286 attr.apply_callsite(idx as c_uint, callsite);
291 // enum for the LLVM IntPredicate type
292 #[derive(Copy, Clone)]
293 pub enum IntPredicate {
306 // enum for the LLVM RealPredicate type
307 #[derive(Copy, Clone)]
308 pub enum RealPredicate {
309 RealPredicateFalse = 0,
324 RealPredicateTrue = 15,
327 // The LLVM TypeKind type - must stay in sync with the def of
328 // LLVMTypeKind in llvm/include/llvm-c/Core.h
329 #[derive(Copy, Clone, PartialEq, Debug)]
351 #[derive(Copy, Clone)]
352 pub enum AtomicBinOp {
367 #[derive(Copy, Clone)]
368 pub enum AtomicOrdering {
372 // Consume = 3, // Not specified yet.
376 SequentiallyConsistent = 7
380 #[derive(Copy, Clone)]
381 pub enum SynchronizationScope {
386 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
388 #[derive(Copy, Clone)]
390 AssemblyFileType = 0,
394 #[derive(Copy, Clone)]
395 pub enum MetadataType {
402 MD_invariant_load = 6,
406 MD_mem_parallel_loop_access = 10,
410 // Inline Asm Dialect
411 #[derive(Copy, Clone)]
412 pub enum AsmDialect {
417 #[derive(Copy, Clone, PartialEq)]
419 pub enum CodeGenOptLevel {
420 CodeGenLevelNone = 0,
421 CodeGenLevelLess = 1,
422 CodeGenLevelDefault = 2,
423 CodeGenLevelAggressive = 3,
426 #[derive(Copy, Clone, PartialEq)]
432 RelocDynamicNoPic = 3,
436 #[derive(Copy, Clone)]
437 pub enum CodeGenModel {
438 CodeModelDefault = 0,
439 CodeModelJITDefault = 1,
447 #[derive(Copy, Clone)]
448 pub enum DiagnosticKind {
451 DK_DebugMetadataVersion,
453 DK_OptimizationRemark,
454 DK_OptimizationRemarkMissed,
455 DK_OptimizationRemarkAnalysis,
456 DK_OptimizationFailure,
460 #[derive(Copy, Clone)]
461 pub enum ArchiveKind {
468 // Opaque pointer types
469 #[allow(missing_copy_implementations)]
470 pub enum Module_opaque {}
471 pub type ModuleRef = *mut Module_opaque;
472 #[allow(missing_copy_implementations)]
473 pub enum Context_opaque {}
474 pub type ContextRef = *mut Context_opaque;
475 #[allow(missing_copy_implementations)]
476 pub enum Type_opaque {}
477 pub type TypeRef = *mut Type_opaque;
478 #[allow(missing_copy_implementations)]
479 pub enum Value_opaque {}
480 pub type ValueRef = *mut Value_opaque;
481 #[allow(missing_copy_implementations)]
482 pub enum Metadata_opaque {}
483 pub type MetadataRef = *mut Metadata_opaque;
484 #[allow(missing_copy_implementations)]
485 pub enum BasicBlock_opaque {}
486 pub type BasicBlockRef = *mut BasicBlock_opaque;
487 #[allow(missing_copy_implementations)]
488 pub enum Builder_opaque {}
489 pub type BuilderRef = *mut Builder_opaque;
490 #[allow(missing_copy_implementations)]
491 pub enum ExecutionEngine_opaque {}
492 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
493 #[allow(missing_copy_implementations)]
494 pub enum MemoryBuffer_opaque {}
495 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
496 #[allow(missing_copy_implementations)]
497 pub enum PassManager_opaque {}
498 pub type PassManagerRef = *mut PassManager_opaque;
499 #[allow(missing_copy_implementations)]
500 pub enum PassManagerBuilder_opaque {}
501 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
502 #[allow(missing_copy_implementations)]
503 pub enum Use_opaque {}
504 pub type UseRef = *mut Use_opaque;
505 #[allow(missing_copy_implementations)]
506 pub enum TargetData_opaque {}
507 pub type TargetDataRef = *mut TargetData_opaque;
508 #[allow(missing_copy_implementations)]
509 pub enum ObjectFile_opaque {}
510 pub type ObjectFileRef = *mut ObjectFile_opaque;
511 #[allow(missing_copy_implementations)]
512 pub enum SectionIterator_opaque {}
513 pub type SectionIteratorRef = *mut SectionIterator_opaque;
514 #[allow(missing_copy_implementations)]
515 pub enum Pass_opaque {}
516 pub type PassRef = *mut Pass_opaque;
517 #[allow(missing_copy_implementations)]
518 pub enum TargetMachine_opaque {}
519 pub type TargetMachineRef = *mut TargetMachine_opaque;
520 pub enum Archive_opaque {}
521 pub type ArchiveRef = *mut Archive_opaque;
522 pub enum ArchiveIterator_opaque {}
523 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
524 pub enum ArchiveChild_opaque {}
525 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
526 #[allow(missing_copy_implementations)]
527 pub enum Twine_opaque {}
528 pub type TwineRef = *mut Twine_opaque;
529 #[allow(missing_copy_implementations)]
530 pub enum DiagnosticInfo_opaque {}
531 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
532 #[allow(missing_copy_implementations)]
533 pub enum DebugLoc_opaque {}
534 pub type DebugLocRef = *mut DebugLoc_opaque;
535 #[allow(missing_copy_implementations)]
536 pub enum SMDiagnostic_opaque {}
537 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
538 #[allow(missing_copy_implementations)]
539 pub enum RustArchiveMember_opaque {}
540 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
542 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
543 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
546 pub use self::DIDescriptorFlags::*;
547 use super::{MetadataRef};
549 #[allow(missing_copy_implementations)]
550 pub enum DIBuilder_opaque {}
551 pub type DIBuilderRef = *mut DIBuilder_opaque;
553 pub type DIDescriptor = MetadataRef;
554 pub type DIScope = DIDescriptor;
555 pub type DILocation = DIDescriptor;
556 pub type DIFile = DIScope;
557 pub type DILexicalBlock = DIScope;
558 pub type DISubprogram = DIScope;
559 pub type DINameSpace = DIScope;
560 pub type DIType = DIDescriptor;
561 pub type DIBasicType = DIType;
562 pub type DIDerivedType = DIType;
563 pub type DICompositeType = DIDerivedType;
564 pub type DIVariable = DIDescriptor;
565 pub type DIGlobalVariable = DIDescriptor;
566 pub type DIArray = DIDescriptor;
567 pub type DISubrange = DIDescriptor;
568 pub type DIEnumerator = DIDescriptor;
569 pub type DITemplateTypeParameter = DIDescriptor;
571 #[derive(Copy, Clone)]
572 pub enum DIDescriptorFlags {
573 FlagPrivate = 1 << 0,
574 FlagProtected = 1 << 1,
575 FlagFwdDecl = 1 << 2,
576 FlagAppleBlock = 1 << 3,
577 FlagBlockByrefStruct = 1 << 4,
578 FlagVirtual = 1 << 5,
579 FlagArtificial = 1 << 6,
580 FlagExplicit = 1 << 7,
581 FlagPrototyped = 1 << 8,
582 FlagObjcClassComplete = 1 << 9,
583 FlagObjectPointer = 1 << 10,
584 FlagVector = 1 << 11,
585 FlagStaticMember = 1 << 12,
586 FlagIndirectVariable = 1 << 13,
587 FlagLValueReference = 1 << 14,
588 FlagRValueReference = 1 << 15
593 // Link to our native llvm bindings (things that we need to use the C++ api
594 // for) and because llvm is written in C++ we need to link against libstdc++
596 // You'll probably notice that there is an omission of all LLVM libraries
597 // from this location. This is because the set of LLVM libraries that we
598 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
599 // figure out the exact set of libraries. To do this, the build system
600 // generates an llvmdeps.rs file next to this one which will be
601 // automatically updated whenever LLVM is updated to include an up-to-date
602 // set of the libraries we need to link to LLVM for.
603 #[link(name = "rustllvm", kind = "static")]
604 #[linked_from = "rustllvm"] // not quite true but good enough
606 /* Create and destroy contexts. */
607 pub fn LLVMContextCreate() -> ContextRef;
608 pub fn LLVMContextDispose(C: ContextRef);
609 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
614 /* Create and destroy modules. */
615 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
618 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
619 pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
620 pub fn LLVMDisposeModule(M: ModuleRef);
622 /// Data layout. See Module::getDataLayout.
623 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
624 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
626 /// Target triple. See Module::getTargetTriple.
627 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
628 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
630 /// See Module::dump.
631 pub fn LLVMDumpModule(M: ModuleRef);
633 /// See Module::setModuleInlineAsm.
634 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
636 /// See llvm::LLVMTypeKind::getTypeID.
637 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
639 /// See llvm::LLVMType::getContext.
640 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
642 /* Operations on integer types */
643 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
644 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
645 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
646 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
647 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
648 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
651 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
653 /* Operations on real types */
654 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
655 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
656 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
657 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
658 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
660 /* Operations on function types */
661 pub fn LLVMFunctionType(ReturnType: TypeRef,
662 ParamTypes: *const TypeRef,
666 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
667 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
668 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
669 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
671 /* Operations on struct types */
672 pub fn LLVMStructTypeInContext(C: ContextRef,
673 ElementTypes: *const TypeRef,
674 ElementCount: c_uint,
677 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
678 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
680 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
682 /* Operations on array, pointer, and vector types (sequence types) */
683 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
684 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
686 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
689 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
690 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
691 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
692 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
694 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
696 /* Operations on other types */
697 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
698 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
699 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
701 /* Operations on all values */
702 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
703 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
704 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
705 pub fn LLVMDumpValue(Val: ValueRef);
706 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
707 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
708 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
709 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
711 /* Operations on Uses */
712 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
713 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
714 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
715 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
717 /* Operations on Users */
718 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
719 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
720 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
722 /* Operations on constants of any type */
723 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
725 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
726 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
728 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
730 /* only for isize/vector */
731 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
732 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
733 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
734 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
735 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
737 /* Operations on metadata */
738 pub fn LLVMMDStringInContext(C: ContextRef,
742 pub fn LLVMMDNodeInContext(C: ContextRef,
743 Vals: *const ValueRef,
746 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
750 /* Operations on scalar constants */
751 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
753 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
755 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
760 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
761 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
763 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
767 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
768 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
771 /* Operations on composite constants */
772 pub fn LLVMConstStringInContext(C: ContextRef,
775 DontNullTerminate: Bool)
777 pub fn LLVMConstStructInContext(C: ContextRef,
778 ConstantVals: *const ValueRef,
783 pub fn LLVMConstArray(ElementTy: TypeRef,
784 ConstantVals: *const ValueRef,
787 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
790 /* Constant expressions */
791 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
792 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
793 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
794 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
795 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
796 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
797 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
798 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
800 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
802 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
804 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
806 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
808 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
810 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
812 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
814 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
816 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
818 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
820 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
822 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
824 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
826 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
827 RHSConstant: ValueRef)
829 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
831 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
833 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
835 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
837 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
839 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
841 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
843 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
845 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
847 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
849 pub fn LLVMConstGEP(ConstantVal: ValueRef,
850 ConstantIndices: *const ValueRef,
853 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
854 ConstantIndices: *const ValueRef,
857 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
859 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
861 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
863 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
865 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
867 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
869 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
871 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
873 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
875 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
877 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
879 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
881 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
883 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
885 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
887 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
889 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
893 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
895 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
896 ConstantIfTrue: ValueRef,
897 ConstantIfFalse: ValueRef)
899 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
900 IndexConstant: ValueRef)
902 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
903 ElementValueConstant: ValueRef,
904 IndexConstant: ValueRef)
906 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
907 VectorBConstant: ValueRef,
908 MaskConstant: ValueRef)
910 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
911 IdxList: *const c_uint,
914 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
915 ElementValueConstant: ValueRef,
916 IdxList: *const c_uint,
919 pub fn LLVMConstInlineAsm(Ty: TypeRef,
920 AsmString: *const c_char,
921 Constraints: *const c_char,
922 HasSideEffects: Bool,
925 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
929 /* Operations on global variables, functions, and aliases (globals) */
930 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
931 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
932 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
933 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
934 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
935 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
936 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
937 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
938 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
939 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
942 /* Operations on global variables */
943 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
944 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
946 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
949 AddressSpace: c_uint)
951 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
952 pub fn LLVMGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
953 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
954 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
955 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
956 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
957 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
958 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
959 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
960 ConstantVal: ValueRef);
961 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
962 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
963 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
964 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
965 pub fn LLVMGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
967 /* Operations on aliases */
968 pub fn LLVMAddAlias(M: ModuleRef,
974 /* Operations on functions */
975 pub fn LLVMAddFunction(M: ModuleRef,
979 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
980 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
981 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
982 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
983 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
984 pub fn LLVMDeleteFunction(Fn: ValueRef);
985 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
989 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
990 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
991 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
992 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
993 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
994 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
995 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
996 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
997 pub fn LLVMAddFunctionAttrStringValue(Fn: ValueRef, index: c_uint,
999 Value: *const c_char);
1000 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
1001 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
1002 pub fn LLVMRemoveFunctionAttr(Fn: ValueRef, val: c_ulonglong);
1004 /* Operations on parameters */
1005 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
1006 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
1007 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
1008 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
1009 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
1010 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
1011 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
1012 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
1013 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
1014 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
1015 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
1016 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
1018 /* Operations on basic blocks */
1019 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
1020 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
1021 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
1022 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
1023 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
1024 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
1025 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1026 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1027 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
1028 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
1029 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1031 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
1033 Name: *const c_char)
1035 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
1037 Name: *const c_char)
1039 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
1041 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
1042 MoveAfter: BasicBlockRef);
1044 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
1045 MoveBefore: BasicBlockRef);
1047 /* Operations on instructions */
1048 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
1049 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
1050 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
1051 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
1052 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
1053 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
1055 /* Operations on call sites */
1056 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
1057 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
1058 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
1061 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1064 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1067 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1070 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1074 /* Operations on call instructions (only) */
1075 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1076 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1078 /* Operations on load/store instructions (only) */
1079 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1080 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1082 /* Operations on phi nodes */
1083 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1084 IncomingValues: *const ValueRef,
1085 IncomingBlocks: *const BasicBlockRef,
1087 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1088 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1090 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1093 /* Instruction builders */
1094 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1095 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1096 Block: BasicBlockRef,
1098 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1100 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1101 Block: BasicBlockRef);
1102 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1103 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1104 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1105 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1107 Name: *const c_char);
1108 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1110 /* Execution engine */
1111 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef) -> ExecutionEngineRef;
1112 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1113 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1114 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1115 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1116 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1120 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1121 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1122 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1125 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1126 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1127 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1128 RetVals: *const ValueRef,
1131 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1132 pub fn LLVMBuildCondBr(B: BuilderRef,
1134 Then: BasicBlockRef,
1135 Else: BasicBlockRef)
1137 pub fn LLVMBuildSwitch(B: BuilderRef,
1139 Else: BasicBlockRef,
1142 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1146 pub fn LLVMBuildInvoke(B: BuilderRef,
1148 Args: *const ValueRef,
1150 Then: BasicBlockRef,
1151 Catch: BasicBlockRef,
1152 Name: *const c_char)
1154 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
1158 Name: *const c_char,
1161 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1162 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1164 /* Add a case to the switch instruction */
1165 pub fn LLVMAddCase(Switch: ValueRef,
1167 Dest: BasicBlockRef);
1169 /* Add a destination to the indirectbr instruction */
1170 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1172 /* Add a clause to the landing pad instruction */
1173 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1175 /* Set the cleanup on a landing pad instruction */
1176 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1179 pub fn LLVMBuildAdd(B: BuilderRef,
1182 Name: *const c_char)
1184 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1187 Name: *const c_char)
1189 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1192 Name: *const c_char)
1194 pub fn LLVMBuildFAdd(B: BuilderRef,
1197 Name: *const c_char)
1199 pub fn LLVMBuildSub(B: BuilderRef,
1202 Name: *const c_char)
1204 pub fn LLVMBuildNSWSub(B: BuilderRef,
1207 Name: *const c_char)
1209 pub fn LLVMBuildNUWSub(B: BuilderRef,
1212 Name: *const c_char)
1214 pub fn LLVMBuildFSub(B: BuilderRef,
1217 Name: *const c_char)
1219 pub fn LLVMBuildMul(B: BuilderRef,
1222 Name: *const c_char)
1224 pub fn LLVMBuildNSWMul(B: BuilderRef,
1227 Name: *const c_char)
1229 pub fn LLVMBuildNUWMul(B: BuilderRef,
1232 Name: *const c_char)
1234 pub fn LLVMBuildFMul(B: BuilderRef,
1237 Name: *const c_char)
1239 pub fn LLVMBuildUDiv(B: BuilderRef,
1242 Name: *const c_char)
1244 pub fn LLVMBuildSDiv(B: BuilderRef,
1247 Name: *const c_char)
1249 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1252 Name: *const c_char)
1254 pub fn LLVMBuildFDiv(B: BuilderRef,
1257 Name: *const c_char)
1259 pub fn LLVMBuildURem(B: BuilderRef,
1262 Name: *const c_char)
1264 pub fn LLVMBuildSRem(B: BuilderRef,
1267 Name: *const c_char)
1269 pub fn LLVMBuildFRem(B: BuilderRef,
1272 Name: *const c_char)
1274 pub fn LLVMBuildShl(B: BuilderRef,
1277 Name: *const c_char)
1279 pub fn LLVMBuildLShr(B: BuilderRef,
1282 Name: *const c_char)
1284 pub fn LLVMBuildAShr(B: BuilderRef,
1287 Name: *const c_char)
1289 pub fn LLVMBuildAnd(B: BuilderRef,
1292 Name: *const c_char)
1294 pub fn LLVMBuildOr(B: BuilderRef,
1297 Name: *const c_char)
1299 pub fn LLVMBuildXor(B: BuilderRef,
1302 Name: *const c_char)
1304 pub fn LLVMBuildBinOp(B: BuilderRef,
1308 Name: *const c_char)
1310 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1312 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1314 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1316 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1318 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1322 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1324 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1325 pub fn LLVMBuildLoad(B: BuilderRef,
1326 PointerVal: ValueRef,
1327 Name: *const c_char)
1330 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1333 pub fn LLVMBuildGEP(B: BuilderRef,
1335 Indices: *const ValueRef,
1337 Name: *const c_char)
1339 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1341 Indices: *const ValueRef,
1343 Name: *const c_char)
1345 pub fn LLVMBuildStructGEP(B: BuilderRef,
1348 Name: *const c_char)
1350 pub fn LLVMBuildGlobalString(B: BuilderRef,
1352 Name: *const c_char)
1354 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1356 Name: *const c_char)
1360 pub fn LLVMBuildTrunc(B: BuilderRef,
1363 Name: *const c_char)
1365 pub fn LLVMBuildZExt(B: BuilderRef,
1368 Name: *const c_char)
1370 pub fn LLVMBuildSExt(B: BuilderRef,
1373 Name: *const c_char)
1375 pub fn LLVMBuildFPToUI(B: BuilderRef,
1378 Name: *const c_char)
1380 pub fn LLVMBuildFPToSI(B: BuilderRef,
1383 Name: *const c_char)
1385 pub fn LLVMBuildUIToFP(B: BuilderRef,
1388 Name: *const c_char)
1390 pub fn LLVMBuildSIToFP(B: BuilderRef,
1393 Name: *const c_char)
1395 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1398 Name: *const c_char)
1400 pub fn LLVMBuildFPExt(B: BuilderRef,
1403 Name: *const c_char)
1405 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1408 Name: *const c_char)
1410 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1413 Name: *const c_char)
1415 pub fn LLVMBuildBitCast(B: BuilderRef,
1418 Name: *const c_char)
1420 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1423 Name: *const c_char)
1425 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1428 Name: *const c_char)
1430 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1433 Name: *const c_char)
1435 pub fn LLVMBuildCast(B: BuilderRef,
1439 Name: *const c_char) -> ValueRef;
1440 pub fn LLVMBuildPointerCast(B: BuilderRef,
1443 Name: *const c_char)
1445 pub fn LLVMBuildIntCast(B: BuilderRef,
1448 Name: *const c_char)
1450 pub fn LLVMBuildFPCast(B: BuilderRef,
1453 Name: *const c_char)
1457 pub fn LLVMBuildICmp(B: BuilderRef,
1461 Name: *const c_char)
1463 pub fn LLVMBuildFCmp(B: BuilderRef,
1467 Name: *const c_char)
1470 /* Miscellaneous instructions */
1471 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1473 pub fn LLVMBuildCall(B: BuilderRef,
1475 Args: *const ValueRef,
1477 Name: *const c_char)
1479 pub fn LLVMBuildSelect(B: BuilderRef,
1483 Name: *const c_char)
1485 pub fn LLVMBuildVAArg(B: BuilderRef,
1488 Name: *const c_char)
1490 pub fn LLVMBuildExtractElement(B: BuilderRef,
1493 Name: *const c_char)
1495 pub fn LLVMBuildInsertElement(B: BuilderRef,
1499 Name: *const c_char)
1501 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1505 Name: *const c_char)
1507 pub fn LLVMBuildExtractValue(B: BuilderRef,
1510 Name: *const c_char)
1512 pub fn LLVMBuildInsertValue(B: BuilderRef,
1516 Name: *const c_char)
1519 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1521 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1523 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1526 Name: *const c_char)
1529 /* Atomic Operations */
1530 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1531 PointerVal: ValueRef,
1532 Name: *const c_char,
1533 Order: AtomicOrdering,
1537 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1540 Order: AtomicOrdering,
1544 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1548 Order: AtomicOrdering,
1549 FailureOrder: AtomicOrdering)
1551 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1555 Order: AtomicOrdering,
1556 SingleThreaded: Bool)
1559 pub fn LLVMBuildAtomicFence(B: BuilderRef,
1560 Order: AtomicOrdering,
1561 Scope: SynchronizationScope);
1564 /* Selected entries from the downcasts. */
1565 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1566 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1568 /// Writes a module to the specified path. Returns 0 on success.
1569 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1571 /// Creates target data from a target layout string.
1572 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1573 /// Adds the target data to the given pass manager. The pass manager
1574 /// references the target data only weakly.
1575 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1576 /// Number of bytes clobbered when doing a Store to *T.
1577 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1580 /// Number of bytes clobbered when doing a Store to *T.
1581 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1584 /// Distance between successive elements in an array of T. Includes ABI padding.
1585 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1587 /// Returns the preferred alignment of a type.
1588 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1590 /// Returns the minimum alignment of a type.
1591 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1594 /// Computes the byte offset of the indexed struct element for a
1596 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1601 /// Returns the minimum alignment of a type when part of a call frame.
1602 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1605 /// Disposes target data.
1606 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1608 /// Creates a pass manager.
1609 pub fn LLVMCreatePassManager() -> PassManagerRef;
1611 /// Creates a function-by-function pass manager
1612 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1615 /// Disposes a pass manager.
1616 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1618 /// Runs a pass manager on a module.
1619 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1621 /// Runs the function passes on the provided function.
1622 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1625 /// Initializes all the function passes scheduled in the manager
1626 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1628 /// Finalizes all the function passes scheduled in the manager
1629 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1631 pub fn LLVMInitializePasses();
1633 /// Adds a verification pass.
1634 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1636 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1637 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1638 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1639 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1640 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1641 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1642 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1643 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1644 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1645 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1646 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1647 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1648 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1649 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1650 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1651 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1652 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1653 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1654 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1655 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1656 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1657 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1658 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1659 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1660 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1661 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1662 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1663 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1664 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1665 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1666 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1667 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1668 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1669 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1670 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1672 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1673 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1674 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1675 OptimizationLevel: c_uint);
1676 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1678 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1679 PMB: PassManagerBuilderRef,
1681 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1682 PMB: PassManagerBuilderRef,
1684 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1685 PMB: PassManagerBuilderRef,
1687 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1688 PMB: PassManagerBuilderRef,
1690 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1691 PMB: PassManagerBuilderRef,
1692 PM: PassManagerRef);
1694 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1695 PMB: PassManagerBuilderRef,
1696 PM: PassManagerRef);
1697 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1698 PMB: PassManagerBuilderRef,
1703 /// Destroys a memory buffer.
1704 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1707 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1709 /// Opens an object file.
1710 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1711 /// Closes an object file.
1712 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1714 /// Enumerates the sections in an object file.
1715 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1716 /// Destroys a section iterator.
1717 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1718 /// Returns true if the section iterator is at the end of the section
1720 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1721 SI: SectionIteratorRef)
1723 /// Moves the section iterator to point to the next section.
1724 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1725 /// Returns the current section size.
1726 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1727 /// Returns the current section contents as a string buffer.
1728 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1730 /// Reads the given file and returns it as a memory buffer. Use
1731 /// LLVMDisposeMemoryBuffer() to get rid of it.
1732 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1734 /// Borrows the contents of the memory buffer (doesn't copy it)
1735 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1736 InputDataLength: size_t,
1737 BufferName: *const c_char,
1740 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1741 InputDataLength: size_t,
1742 BufferName: *const c_char)
1745 pub fn LLVMIsMultithreaded() -> Bool;
1746 pub fn LLVMStartMultithreaded() -> Bool;
1748 /// Returns a string describing the last error caused by an LLVMRust* call.
1749 pub fn LLVMRustGetLastError() -> *const c_char;
1751 /// Print the pass timings since static dtors aren't picking them up.
1752 pub fn LLVMRustPrintPassTimings();
1754 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1756 pub fn LLVMStructSetBody(StructTy: TypeRef,
1757 ElementTypes: *const TypeRef,
1758 ElementCount: c_uint,
1761 pub fn LLVMConstNamedStruct(S: TypeRef,
1762 ConstantVals: *const ValueRef,
1766 /// Enables LLVM debug output.
1767 pub fn LLVMSetDebug(Enabled: c_int);
1769 /// Prepares inline assembly.
1770 pub fn LLVMInlineAsm(Ty: TypeRef,
1771 AsmString: *const c_char,
1772 Constraints: *const c_char,
1778 pub fn LLVMRustDebugMetadataVersion() -> u32;
1779 pub fn LLVMVersionMajor() -> u32;
1780 pub fn LLVMVersionMinor() -> u32;
1782 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1783 name: *const c_char,
1786 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1788 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1790 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1792 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1794 File: *const c_char,
1796 Producer: *const c_char,
1798 Flags: *const c_char,
1800 SplitName: *const c_char)
1803 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1804 Filename: *const c_char,
1805 Directory: *const c_char)
1808 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1810 ParameterTypes: DIArray)
1813 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1814 Scope: DIDescriptor,
1815 Name: *const c_char,
1816 LinkageName: *const c_char,
1820 isLocalToUnit: bool,
1830 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1831 Name: *const c_char,
1832 SizeInBits: c_ulonglong,
1833 AlignInBits: c_ulonglong,
1837 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1839 SizeInBits: c_ulonglong,
1840 AlignInBits: c_ulonglong,
1841 Name: *const c_char)
1844 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1845 Scope: DIDescriptor,
1846 Name: *const c_char,
1849 SizeInBits: c_ulonglong,
1850 AlignInBits: c_ulonglong,
1852 DerivedFrom: DIType,
1854 RunTimeLang: c_uint,
1855 VTableHolder: DIType,
1856 UniqueId: *const c_char)
1859 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1860 Scope: DIDescriptor,
1861 Name: *const c_char,
1864 SizeInBits: c_ulonglong,
1865 AlignInBits: c_ulonglong,
1866 OffsetInBits: c_ulonglong,
1871 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1878 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1880 Name: *const c_char,
1881 LinkageName: *const c_char,
1885 isLocalToUnit: bool,
1888 -> DIGlobalVariable;
1890 pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef,
1892 Scope: DIDescriptor,
1893 Name: *const c_char,
1897 AlwaysPreserve: bool,
1899 AddrOps: *const i64,
1900 AddrOpsCount: c_uint,
1904 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1906 AlignInBits: c_ulonglong,
1908 Subscripts: DIArray)
1911 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1913 AlignInBits: c_ulonglong,
1915 Subscripts: DIArray)
1918 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1923 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1924 Ptr: *const DIDescriptor,
1928 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1930 VarInfo: DIVariable,
1931 AddrOps: *const i64,
1932 AddrOpsCount: c_uint,
1934 InsertAtEnd: BasicBlockRef)
1937 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1939 VarInfo: DIVariable,
1940 AddrOps: *const i64,
1941 AddrOpsCount: c_uint,
1943 InsertBefore: ValueRef)
1946 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1947 Name: *const c_char,
1951 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1953 Name: *const c_char,
1956 SizeInBits: c_ulonglong,
1957 AlignInBits: c_ulonglong,
1962 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1964 Name: *const c_char,
1967 SizeInBits: c_ulonglong,
1968 AlignInBits: c_ulonglong,
1971 RunTimeLang: c_uint,
1972 UniqueId: *const c_char)
1975 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1977 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1979 Name: *const c_char,
1984 -> DITemplateTypeParameter;
1986 pub fn LLVMDIBuilderCreateOpDeref() -> i64;
1988 pub fn LLVMDIBuilderCreateOpPlus() -> i64;
1990 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1992 Name: *const c_char,
1997 pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef,
2001 InlinedAt: MetadataRef)
2004 pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
2005 CompositeType: DIType,
2006 TypeArray: DIArray);
2007 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
2008 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
2010 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
2012 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
2013 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
2015 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
2016 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
2018 Features: *const c_char,
2019 Model: CodeGenModel,
2021 Level: CodeGenOptLevel,
2023 PositionIndependentExecutable: bool,
2024 FunctionSections: bool,
2025 DataSections: bool) -> TargetMachineRef;
2026 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
2027 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
2030 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
2032 DisableSimplifyLibCalls: bool);
2033 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
2034 OptLevel: CodeGenOptLevel,
2035 MergeFunctions: bool,
2037 LoopVectorize: bool);
2038 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
2039 DisableSimplifyLibCalls: bool);
2040 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
2041 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2044 Output: *const c_char,
2045 FileType: FileType) -> bool;
2046 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2048 Output: *const c_char);
2049 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2050 pub fn LLVMRustPrintPasses();
2051 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2052 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2053 AddLifetimes: bool);
2054 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2056 len: size_t) -> bool;
2057 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2058 syms: *const *const c_char,
2060 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2062 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2063 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
2064 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
2065 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef,
2066 size: *mut size_t) -> *const c_char;
2067 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef,
2068 size: *mut size_t) -> *const c_char;
2069 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
2070 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
2071 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2073 pub fn LLVMRustSetDLLStorageClass(V: ValueRef,
2074 C: DLLStorageClassTypes);
2076 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2077 data: *mut *const c_char) -> c_int;
2079 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2081 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2082 Handler: DiagnosticHandler,
2083 DiagnosticContext: *mut c_void);
2085 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2086 pass_name_out: *mut *const c_char,
2087 function_out: *mut ValueRef,
2088 debugloc_out: *mut DebugLocRef,
2089 message_out: *mut TwineRef);
2090 pub fn LLVMUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
2091 cookie_out: *mut c_uint,
2092 message_out: *mut TwineRef,
2093 instruction_out: *mut ValueRef);
2095 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2096 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2097 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2099 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2101 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2102 H: InlineAsmDiagHandler,
2105 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2107 pub fn LLVMRustWriteArchive(Dst: *const c_char,
2109 Members: *const RustArchiveMemberRef,
2111 Kind: ArchiveKind) -> c_int;
2112 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
2113 Name: *const c_char,
2114 Child: ArchiveChildRef) -> RustArchiveMemberRef;
2115 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
2117 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef,
2118 TM: TargetMachineRef);
2119 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
2122 #[cfg(have_component_x86)]
2124 pub fn LLVMInitializeX86TargetInfo();
2125 pub fn LLVMInitializeX86Target();
2126 pub fn LLVMInitializeX86TargetMC();
2127 pub fn LLVMInitializeX86AsmPrinter();
2128 pub fn LLVMInitializeX86AsmParser();
2130 #[cfg(have_component_arm)]
2132 pub fn LLVMInitializeARMTargetInfo();
2133 pub fn LLVMInitializeARMTarget();
2134 pub fn LLVMInitializeARMTargetMC();
2135 pub fn LLVMInitializeARMAsmPrinter();
2136 pub fn LLVMInitializeARMAsmParser();
2138 #[cfg(have_component_aarch64)]
2140 pub fn LLVMInitializeAArch64TargetInfo();
2141 pub fn LLVMInitializeAArch64Target();
2142 pub fn LLVMInitializeAArch64TargetMC();
2143 pub fn LLVMInitializeAArch64AsmPrinter();
2144 pub fn LLVMInitializeAArch64AsmParser();
2146 #[cfg(have_component_mips)]
2148 pub fn LLVMInitializeMipsTargetInfo();
2149 pub fn LLVMInitializeMipsTarget();
2150 pub fn LLVMInitializeMipsTargetMC();
2151 pub fn LLVMInitializeMipsAsmPrinter();
2152 pub fn LLVMInitializeMipsAsmParser();
2154 #[cfg(have_component_powerpc)]
2156 pub fn LLVMInitializePowerPCTargetInfo();
2157 pub fn LLVMInitializePowerPCTarget();
2158 pub fn LLVMInitializePowerPCTargetMC();
2159 pub fn LLVMInitializePowerPCAsmPrinter();
2160 pub fn LLVMInitializePowerPCAsmParser();
2162 #[cfg(have_component_pnacl)]
2164 pub fn LLVMInitializePNaClTargetInfo();
2165 pub fn LLVMInitializePNaClTarget();
2166 pub fn LLVMInitializePNaClTargetMC();
2169 // LLVM requires symbols from this library, but apparently they're not printed
2170 // during llvm-config?
2172 #[link(name = "ole32")]
2175 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2177 LLVMSetInstructionCallConv(instr, cc as c_uint);
2180 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2182 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2185 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2187 LLVMSetLinkage(global, link as c_uint);
2191 pub fn SetDLLStorageClass(global: ValueRef, class: DLLStorageClassTypes) {
2193 LLVMRustSetDLLStorageClass(global, class);
2197 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2199 LLVMSetUnnamedAddr(global, unnamed as Bool);
2203 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2205 LLVMSetThreadLocal(global, is_thread_local as Bool);
2209 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2211 LLVMConstICmp(pred as c_ushort, v1, v2)
2214 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2216 LLVMConstFCmp(pred as c_ushort, v1, v2)
2220 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2222 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint,
2223 attr.bits() as uint64_t)
2227 /* Memory-managed interface to target data. */
2229 pub struct TargetData {
2230 pub lltd: TargetDataRef
2233 impl Drop for TargetData {
2234 fn drop(&mut self) {
2236 LLVMDisposeTargetData(self.lltd);
2241 pub fn mk_target_data(string_rep: &str) -> TargetData {
2242 let string_rep = CString::new(string_rep).unwrap();
2244 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2248 /* Memory-managed interface to object files. */
2250 pub struct ObjectFile {
2251 pub llof: ObjectFileRef,
2255 // This will take ownership of llmb
2256 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2258 let llof = LLVMCreateObjectFile(llmb);
2259 if llof as isize == 0 {
2260 // LLVMCreateObjectFile took ownership of llmb
2271 impl Drop for ObjectFile {
2272 fn drop(&mut self) {
2274 LLVMDisposeObjectFile(self.llof);
2279 /* Memory-managed interface to section iterators. */
2281 pub struct SectionIter {
2282 pub llsi: SectionIteratorRef
2285 impl Drop for SectionIter {
2286 fn drop(&mut self) {
2288 LLVMDisposeSectionIterator(self.llsi);
2293 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2296 llsi: LLVMGetSections(llof)
2301 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2302 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2304 assert!(index < LLVMCountParams(llfn));
2305 LLVMGetParam(llfn, index)
2309 pub fn get_params(llfn: ValueRef) -> Vec<ValueRef> {
2311 let num_params = LLVMCountParams(llfn);
2312 let mut params = Vec::with_capacity(num_params as usize);
2313 for idx in 0..num_params {
2314 params.push(LLVMGetParam(llfn, idx));
2321 #[allow(missing_copy_implementations)]
2322 pub enum RustString_opaque {}
2323 pub type RustStringRef = *mut RustString_opaque;
2324 type RustStringRepr = *mut RefCell<Vec<u8>>;
2326 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2328 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2331 let slice = slice::from_raw_parts(ptr as *const u8, size as usize);
2333 let sr = sr as RustStringRepr;
2334 (*sr).borrow_mut().extend_from_slice(slice);
2337 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2338 let mut buf = RefCell::new(Vec::new());
2339 f(&mut buf as RustStringRepr as RustStringRef);
2340 String::from_utf8(buf.into_inner()).ok()
2343 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2344 build_string(|s| LLVMWriteTwineToString(tr, s))
2345 .expect("got a non-UTF8 Twine from LLVM")
2348 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2349 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2350 .expect("got a non-UTF8 DebugLoc from LLVM")
2353 pub fn initialize_available_targets() {
2354 macro_rules! init_target(
2355 ($cfg:ident $arch:ident) => { {
2359 let f = concat_idents!(LLVMInitialize, $arch, TargetInfo);
2361 let f = concat_idents!(LLVMInitialize, $arch, Target);
2363 let f = concat_idents!(LLVMInitialize, $arch, TargetMC);
2365 let f = concat_idents!(LLVMInitialize, $arch, AsmPrinter);
2367 let f = concat_idents!(LLVMInitialize, $arch, AsmParser);
2377 init_target!(have_component_powerpc PowerPC);
2378 init_target!(have_component_mips Mips);
2379 init_target!(have_component_aarch64 AArch64);
2380 init_target!(have_component_arm ARM);
2381 init_target!(have_component_x86 X86);
2383 // PNaCl doesn't provide some of the optional target components, so we
2384 // manually initialize it here.
2385 #[cfg(have_component_pnacl)]
2388 LLVMInitializePNaClTargetInfo();
2389 LLVMInitializePNaClTarget();
2390 LLVMInitializePNaClTargetMC();
2393 #[cfg(not(have_component_pnacl))]
2398 // The module containing the native LLVM dependencies, generated by the build system
2399 // Note that this must come after the rustllvm extern declaration so that
2400 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2401 // Works to the above fix for #15460 to ensure LLVM dependencies that
2402 // are only used by rustllvm don't get stripped by the linker.
2404 include! { env!("CFG_LLVM_LINKAGE_FILE") }