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 #![crate_name = "rustc_llvm"]
20 #![unstable(feature = "rustc_private")]
22 #![crate_type = "dylib"]
23 #![crate_type = "rlib"]
24 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
25 html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
26 html_root_url = "http://doc.rust-lang.org/nightly/")]
28 #![feature(associated_consts)]
29 #![feature(box_syntax)]
31 #![feature(link_args)]
32 #![feature(staged_api)]
33 #![feature(vec_push_all)]
34 #![cfg_attr(not(stage0), feature(linked_from))]
37 #[macro_use] #[no_link] extern crate rustc_bitflags;
39 pub use self::OtherAttribute::*;
40 pub use self::SpecialAttribute::*;
41 pub use self::AttributeSet::*;
42 pub use self::IntPredicate::*;
43 pub use self::RealPredicate::*;
44 pub use self::TypeKind::*;
45 pub use self::AtomicBinOp::*;
46 pub use self::AtomicOrdering::*;
47 pub use self::SynchronizationScope::*;
48 pub use self::FileType::*;
49 pub use self::MetadataType::*;
50 pub use self::AsmDialect::*;
51 pub use self::CodeGenOptLevel::*;
52 pub use self::RelocMode::*;
53 pub use self::CodeGenModel::*;
54 pub use self::DiagnosticKind::*;
55 pub use self::CallConv::*;
56 pub use self::Visibility::*;
57 pub use self::DiagnosticSeverity::*;
58 pub use self::Linkage::*;
59 pub use self::DLLStorageClassTypes::*;
61 use std::ffi::CString;
62 use std::cell::RefCell;
63 use std::{slice, mem};
64 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
65 use libc::{c_longlong, c_ulonglong, c_void};
66 use debuginfo::{DIBuilderRef, DIDescriptor,
67 DIFile, DILexicalBlock, DISubprogram, DIType,
68 DIBasicType, DIDerivedType, DICompositeType, DIScope,
69 DIVariable, DIGlobalVariable, DIArray, DISubrange,
70 DITemplateTypeParameter, DIEnumerator, DINameSpace};
75 pub type Opcode = u32;
76 pub type Bool = c_uint;
78 pub const True: Bool = 1 as Bool;
79 pub const False: Bool = 0 as Bool;
81 // Consts for the LLVM CallConv type, pre-cast to usize.
83 #[derive(Copy, Clone, PartialEq)]
88 X86StdcallCallConv = 64,
89 X86FastcallCallConv = 65,
93 #[derive(Copy, Clone)]
95 LLVMDefaultVisibility = 0,
97 ProtectedVisibility = 2,
100 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
101 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
102 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
103 // they've been removed in upstream LLVM commit r203866.
104 #[derive(Copy, Clone)]
107 AvailableExternallyLinkage = 1,
108 LinkOnceAnyLinkage = 2,
109 LinkOnceODRLinkage = 3,
112 AppendingLinkage = 7,
115 ExternalWeakLinkage = 12,
120 #[derive(Copy, Clone, Debug)]
121 pub enum DiagnosticSeverity {
130 #[derive(Copy, Clone)]
131 pub enum DLLStorageClassTypes {
132 DefaultStorageClass = 0,
133 DLLImportStorageClass = 1,
134 DLLExportStorageClass = 2,
138 flags Attribute : u64 {
141 const NoReturn = 1 << 2,
142 const InReg = 1 << 3,
143 const StructRet = 1 << 4,
144 const NoUnwind = 1 << 5,
145 const NoAlias = 1 << 6,
146 const ByVal = 1 << 7,
148 const ReadNone = 1 << 9,
149 const ReadOnly = 1 << 10,
150 const NoInline = 1 << 11,
151 const AlwaysInline = 1 << 12,
152 const OptimizeForSize = 1 << 13,
153 const StackProtect = 1 << 14,
154 const StackProtectReq = 1 << 15,
155 const Alignment = 1 << 16,
156 const NoCapture = 1 << 21,
157 const NoRedZone = 1 << 22,
158 const NoImplicitFloat = 1 << 23,
159 const Naked = 1 << 24,
160 const InlineHint = 1 << 25,
161 const Stack = 7 << 26,
162 const ReturnsTwice = 1 << 29,
163 const UWTable = 1 << 30,
164 const NonLazyBind = 1 << 31,
165 const OptimizeNone = 1 << 42,
171 #[derive(Copy, Clone)]
172 pub enum OtherAttribute {
173 // The following are not really exposed in
174 // the LLVM C api so instead to add these
175 // we call a wrapper function in RustWrapper
176 // that uses the C++ api.
177 SanitizeAddressAttribute = 1 << 32,
178 MinSizeAttribute = 1 << 33,
179 NoDuplicateAttribute = 1 << 34,
180 StackProtectStrongAttribute = 1 << 35,
181 SanitizeThreadAttribute = 1 << 36,
182 SanitizeMemoryAttribute = 1 << 37,
183 NoBuiltinAttribute = 1 << 38,
184 ReturnedAttribute = 1 << 39,
185 ColdAttribute = 1 << 40,
186 BuiltinAttribute = 1 << 41,
187 OptimizeNoneAttribute = 1 << 42,
188 InAllocaAttribute = 1 << 43,
189 NonNullAttribute = 1 << 44,
192 #[derive(Copy, Clone)]
193 pub enum SpecialAttribute {
194 DereferenceableAttribute(u64)
198 #[derive(Copy, Clone)]
199 pub enum AttributeSet {
204 pub trait AttrHelper {
205 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
206 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
209 impl AttrHelper for Attribute {
210 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
212 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
216 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
218 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
223 impl AttrHelper for OtherAttribute {
224 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
226 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
230 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
232 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
237 impl AttrHelper for SpecialAttribute {
238 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
240 DereferenceableAttribute(bytes) => unsafe {
241 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
246 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
248 DereferenceableAttribute(bytes) => unsafe {
249 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
255 pub struct AttrBuilder {
256 attrs: Vec<(usize, Box<AttrHelper+'static>)>
260 pub fn new() -> AttrBuilder {
266 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: usize, a: T) -> &'a mut AttrBuilder {
267 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
271 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
272 self.attrs.push((ReturnIndex as usize, box a as Box<AttrHelper+'static>));
276 pub fn apply_llfn(&self, llfn: ValueRef) {
277 for &(idx, ref attr) in &self.attrs {
278 attr.apply_llfn(idx as c_uint, llfn);
282 pub fn apply_callsite(&self, callsite: ValueRef) {
283 for &(idx, ref attr) in &self.attrs {
284 attr.apply_callsite(idx as c_uint, callsite);
289 // enum for the LLVM IntPredicate type
290 #[derive(Copy, Clone)]
291 pub enum IntPredicate {
304 // enum for the LLVM RealPredicate type
305 #[derive(Copy, Clone)]
306 pub enum RealPredicate {
307 RealPredicateFalse = 0,
322 RealPredicateTrue = 15,
325 // The LLVM TypeKind type - must stay in sync with the def of
326 // LLVMTypeKind in llvm/include/llvm-c/Core.h
327 #[derive(Copy, Clone, PartialEq, Debug)]
349 #[derive(Copy, Clone)]
350 pub enum AtomicBinOp {
365 #[derive(Copy, Clone)]
366 pub enum AtomicOrdering {
370 // Consume = 3, // Not specified yet.
374 SequentiallyConsistent = 7
378 #[derive(Copy, Clone)]
379 pub enum SynchronizationScope {
384 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
386 #[derive(Copy, Clone)]
388 AssemblyFileType = 0,
392 #[derive(Copy, Clone)]
393 pub enum MetadataType {
400 MD_invariant_load = 6,
404 MD_mem_parallel_loop_access = 10,
408 // Inline Asm Dialect
409 #[derive(Copy, Clone)]
410 pub enum AsmDialect {
415 #[derive(Copy, Clone, PartialEq)]
417 pub enum CodeGenOptLevel {
418 CodeGenLevelNone = 0,
419 CodeGenLevelLess = 1,
420 CodeGenLevelDefault = 2,
421 CodeGenLevelAggressive = 3,
424 #[derive(Copy, Clone, PartialEq)]
430 RelocDynamicNoPic = 3,
434 #[derive(Copy, Clone)]
435 pub enum CodeGenModel {
436 CodeModelDefault = 0,
437 CodeModelJITDefault = 1,
445 #[derive(Copy, Clone)]
446 pub enum DiagnosticKind {
449 DK_DebugMetadataVersion,
451 DK_OptimizationRemark,
452 DK_OptimizationRemarkMissed,
453 DK_OptimizationRemarkAnalysis,
454 DK_OptimizationFailure,
458 #[derive(Copy, Clone)]
459 pub enum ArchiveKind {
466 // Opaque pointer types
467 #[allow(missing_copy_implementations)]
468 pub enum Module_opaque {}
469 pub type ModuleRef = *mut Module_opaque;
470 #[allow(missing_copy_implementations)]
471 pub enum Context_opaque {}
472 pub type ContextRef = *mut Context_opaque;
473 #[allow(missing_copy_implementations)]
474 pub enum Type_opaque {}
475 pub type TypeRef = *mut Type_opaque;
476 #[allow(missing_copy_implementations)]
477 pub enum Value_opaque {}
478 pub type ValueRef = *mut Value_opaque;
479 #[allow(missing_copy_implementations)]
480 pub enum Metadata_opaque {}
481 pub type MetadataRef = *mut Metadata_opaque;
482 #[allow(missing_copy_implementations)]
483 pub enum BasicBlock_opaque {}
484 pub type BasicBlockRef = *mut BasicBlock_opaque;
485 #[allow(missing_copy_implementations)]
486 pub enum Builder_opaque {}
487 pub type BuilderRef = *mut Builder_opaque;
488 #[allow(missing_copy_implementations)]
489 pub enum ExecutionEngine_opaque {}
490 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
491 #[allow(missing_copy_implementations)]
492 pub enum MemoryBuffer_opaque {}
493 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
494 #[allow(missing_copy_implementations)]
495 pub enum PassManager_opaque {}
496 pub type PassManagerRef = *mut PassManager_opaque;
497 #[allow(missing_copy_implementations)]
498 pub enum PassManagerBuilder_opaque {}
499 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
500 #[allow(missing_copy_implementations)]
501 pub enum Use_opaque {}
502 pub type UseRef = *mut Use_opaque;
503 #[allow(missing_copy_implementations)]
504 pub enum TargetData_opaque {}
505 pub type TargetDataRef = *mut TargetData_opaque;
506 #[allow(missing_copy_implementations)]
507 pub enum ObjectFile_opaque {}
508 pub type ObjectFileRef = *mut ObjectFile_opaque;
509 #[allow(missing_copy_implementations)]
510 pub enum SectionIterator_opaque {}
511 pub type SectionIteratorRef = *mut SectionIterator_opaque;
512 #[allow(missing_copy_implementations)]
513 pub enum Pass_opaque {}
514 pub type PassRef = *mut Pass_opaque;
515 #[allow(missing_copy_implementations)]
516 pub enum TargetMachine_opaque {}
517 pub type TargetMachineRef = *mut TargetMachine_opaque;
518 pub enum Archive_opaque {}
519 pub type ArchiveRef = *mut Archive_opaque;
520 pub enum ArchiveIterator_opaque {}
521 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
522 pub enum ArchiveChild_opaque {}
523 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
524 #[allow(missing_copy_implementations)]
525 pub enum Twine_opaque {}
526 pub type TwineRef = *mut Twine_opaque;
527 #[allow(missing_copy_implementations)]
528 pub enum DiagnosticInfo_opaque {}
529 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
530 #[allow(missing_copy_implementations)]
531 pub enum DebugLoc_opaque {}
532 pub type DebugLocRef = *mut DebugLoc_opaque;
533 #[allow(missing_copy_implementations)]
534 pub enum SMDiagnostic_opaque {}
535 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
536 #[allow(missing_copy_implementations)]
537 pub enum RustArchiveMember_opaque {}
538 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
540 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
541 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
544 pub use self::DIDescriptorFlags::*;
545 use super::{MetadataRef};
547 #[allow(missing_copy_implementations)]
548 pub enum DIBuilder_opaque {}
549 pub type DIBuilderRef = *mut DIBuilder_opaque;
551 pub type DIDescriptor = MetadataRef;
552 pub type DIScope = DIDescriptor;
553 pub type DILocation = DIDescriptor;
554 pub type DIFile = DIScope;
555 pub type DILexicalBlock = DIScope;
556 pub type DISubprogram = DIScope;
557 pub type DINameSpace = DIScope;
558 pub type DIType = DIDescriptor;
559 pub type DIBasicType = DIType;
560 pub type DIDerivedType = DIType;
561 pub type DICompositeType = DIDerivedType;
562 pub type DIVariable = DIDescriptor;
563 pub type DIGlobalVariable = DIDescriptor;
564 pub type DIArray = DIDescriptor;
565 pub type DISubrange = DIDescriptor;
566 pub type DIEnumerator = DIDescriptor;
567 pub type DITemplateTypeParameter = DIDescriptor;
569 #[derive(Copy, Clone)]
570 pub enum DIDescriptorFlags {
571 FlagPrivate = 1 << 0,
572 FlagProtected = 1 << 1,
573 FlagFwdDecl = 1 << 2,
574 FlagAppleBlock = 1 << 3,
575 FlagBlockByrefStruct = 1 << 4,
576 FlagVirtual = 1 << 5,
577 FlagArtificial = 1 << 6,
578 FlagExplicit = 1 << 7,
579 FlagPrototyped = 1 << 8,
580 FlagObjcClassComplete = 1 << 9,
581 FlagObjectPointer = 1 << 10,
582 FlagVector = 1 << 11,
583 FlagStaticMember = 1 << 12,
584 FlagIndirectVariable = 1 << 13,
585 FlagLValueReference = 1 << 14,
586 FlagRValueReference = 1 << 15
591 // Link to our native llvm bindings (things that we need to use the C++ api
592 // for) and because llvm is written in C++ we need to link against libstdc++
594 // You'll probably notice that there is an omission of all LLVM libraries
595 // from this location. This is because the set of LLVM libraries that we
596 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
597 // figure out the exact set of libraries. To do this, the build system
598 // generates an llvmdeps.rs file next to this one which will be
599 // automatically updated whenever LLVM is updated to include an up-to-date
600 // set of the libraries we need to link to LLVM for.
601 #[link(name = "rustllvm", kind = "static")]
602 #[cfg_attr(not(stage0), linked_from = "rustllvm")] // not quite true but good enough
604 /* Create and destroy contexts. */
605 pub fn LLVMContextCreate() -> ContextRef;
606 pub fn LLVMContextDispose(C: ContextRef);
607 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
612 /* Create and destroy modules. */
613 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
616 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
617 pub fn LLVMDisposeModule(M: ModuleRef);
619 /// Data layout. See Module::getDataLayout.
620 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
621 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
623 /// Target triple. See Module::getTargetTriple.
624 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
625 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
627 /// See Module::dump.
628 pub fn LLVMDumpModule(M: ModuleRef);
630 /// See Module::setModuleInlineAsm.
631 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
633 /// See llvm::LLVMTypeKind::getTypeID.
634 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
636 /// See llvm::LLVMType::getContext.
637 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
639 /* Operations on integer types */
640 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
641 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
642 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
643 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
644 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
645 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
648 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
650 /* Operations on real types */
651 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
652 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
653 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
654 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
655 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
657 /* Operations on function types */
658 pub fn LLVMFunctionType(ReturnType: TypeRef,
659 ParamTypes: *const TypeRef,
663 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
664 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
665 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
666 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
668 /* Operations on struct types */
669 pub fn LLVMStructTypeInContext(C: ContextRef,
670 ElementTypes: *const TypeRef,
671 ElementCount: c_uint,
674 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
675 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
677 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
679 /* Operations on array, pointer, and vector types (sequence types) */
680 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
681 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
683 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
686 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
687 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
688 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
689 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
691 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
693 /* Operations on other types */
694 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
695 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
696 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
698 /* Operations on all values */
699 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
700 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
701 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
702 pub fn LLVMDumpValue(Val: ValueRef);
703 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
704 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
705 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
706 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
708 /* Operations on Uses */
709 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
710 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
711 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
712 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
714 /* Operations on Users */
715 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
716 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
717 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
719 /* Operations on constants of any type */
720 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
722 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
723 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
725 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
727 /* only for isize/vector */
728 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
729 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
730 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
731 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
732 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
734 /* Operations on metadata */
735 pub fn LLVMMDStringInContext(C: ContextRef,
739 pub fn LLVMMDNodeInContext(C: ContextRef,
740 Vals: *const ValueRef,
743 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
747 /* Operations on scalar constants */
748 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
750 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
752 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
757 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
758 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
760 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
764 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
765 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
768 /* Operations on composite constants */
769 pub fn LLVMConstStringInContext(C: ContextRef,
772 DontNullTerminate: Bool)
774 pub fn LLVMConstStructInContext(C: ContextRef,
775 ConstantVals: *const ValueRef,
780 pub fn LLVMConstArray(ElementTy: TypeRef,
781 ConstantVals: *const ValueRef,
784 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
787 /* Constant expressions */
788 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
789 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
790 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
791 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
792 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
793 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
794 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
795 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
797 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
799 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
801 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
803 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
805 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
807 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
809 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
811 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
813 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
815 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
817 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
819 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
821 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
823 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
824 RHSConstant: ValueRef)
826 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
828 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
830 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
832 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
834 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
836 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
838 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
840 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
842 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
844 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
846 pub fn LLVMConstGEP(ConstantVal: ValueRef,
847 ConstantIndices: *const ValueRef,
850 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
851 ConstantIndices: *const ValueRef,
854 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
856 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
858 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
860 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
862 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
864 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
866 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
868 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
870 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
872 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
874 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
876 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
878 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
880 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
882 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
884 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
886 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
890 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
892 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
893 ConstantIfTrue: ValueRef,
894 ConstantIfFalse: ValueRef)
896 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
897 IndexConstant: ValueRef)
899 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
900 ElementValueConstant: ValueRef,
901 IndexConstant: ValueRef)
903 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
904 VectorBConstant: ValueRef,
905 MaskConstant: ValueRef)
907 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
908 IdxList: *const c_uint,
911 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
912 ElementValueConstant: ValueRef,
913 IdxList: *const c_uint,
916 pub fn LLVMConstInlineAsm(Ty: TypeRef,
917 AsmString: *const c_char,
918 Constraints: *const c_char,
919 HasSideEffects: Bool,
922 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
926 /* Operations on global variables, functions, and aliases (globals) */
927 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
928 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
929 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
930 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
931 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
932 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
933 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
934 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
935 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
936 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
939 /* Operations on global variables */
940 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
941 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
943 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
946 AddressSpace: c_uint)
948 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
949 pub fn LLVMGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
950 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
951 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
952 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
953 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
954 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
955 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
956 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
957 ConstantVal: ValueRef);
958 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
959 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
960 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
961 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
962 pub fn LLVMGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
964 /* Operations on aliases */
965 pub fn LLVMAddAlias(M: ModuleRef,
971 /* Operations on functions */
972 pub fn LLVMAddFunction(M: ModuleRef,
976 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
977 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
978 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
979 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
980 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
981 pub fn LLVMDeleteFunction(Fn: ValueRef);
982 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
986 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
987 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
988 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
989 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
990 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
991 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
992 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
993 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
994 pub fn LLVMAddFunctionAttrStringValue(Fn: ValueRef, index: c_uint,
996 Value: *const c_char);
997 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
998 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
999 pub fn LLVMRemoveFunctionAttr(Fn: ValueRef, val: c_ulonglong);
1001 /* Operations on parameters */
1002 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
1003 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
1004 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
1005 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
1006 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
1007 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
1008 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
1009 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
1010 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
1011 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
1012 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
1013 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
1015 /* Operations on basic blocks */
1016 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
1017 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
1018 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
1019 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
1020 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
1021 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
1022 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1023 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1024 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
1025 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
1026 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1028 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
1030 Name: *const c_char)
1032 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
1034 Name: *const c_char)
1036 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
1038 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
1039 MoveAfter: BasicBlockRef);
1041 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
1042 MoveBefore: BasicBlockRef);
1044 /* Operations on instructions */
1045 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
1046 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
1047 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
1048 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
1049 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
1050 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
1052 /* Operations on call sites */
1053 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
1054 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
1055 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
1058 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1061 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1064 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1067 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1071 /* Operations on call instructions (only) */
1072 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1073 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1075 /* Operations on load/store instructions (only) */
1076 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1077 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1079 /* Operations on phi nodes */
1080 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1081 IncomingValues: *const ValueRef,
1082 IncomingBlocks: *const BasicBlockRef,
1084 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1085 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1087 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1090 /* Instruction builders */
1091 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1092 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1093 Block: BasicBlockRef,
1095 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1097 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1098 Block: BasicBlockRef);
1099 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1100 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1101 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1102 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1104 Name: *const c_char);
1105 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1107 /* Execution engine */
1108 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef) -> ExecutionEngineRef;
1109 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1110 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1111 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1112 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1113 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1117 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1118 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1119 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1122 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1123 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1124 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1125 RetVals: *const ValueRef,
1128 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1129 pub fn LLVMBuildCondBr(B: BuilderRef,
1131 Then: BasicBlockRef,
1132 Else: BasicBlockRef)
1134 pub fn LLVMBuildSwitch(B: BuilderRef,
1136 Else: BasicBlockRef,
1139 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1143 pub fn LLVMBuildInvoke(B: BuilderRef,
1145 Args: *const ValueRef,
1147 Then: BasicBlockRef,
1148 Catch: BasicBlockRef,
1149 Name: *const c_char)
1151 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
1155 Name: *const c_char,
1158 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1159 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1161 /* Add a case to the switch instruction */
1162 pub fn LLVMAddCase(Switch: ValueRef,
1164 Dest: BasicBlockRef);
1166 /* Add a destination to the indirectbr instruction */
1167 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1169 /* Add a clause to the landing pad instruction */
1170 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1172 /* Set the cleanup on a landing pad instruction */
1173 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1176 pub fn LLVMBuildAdd(B: BuilderRef,
1179 Name: *const c_char)
1181 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1184 Name: *const c_char)
1186 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1189 Name: *const c_char)
1191 pub fn LLVMBuildFAdd(B: BuilderRef,
1194 Name: *const c_char)
1196 pub fn LLVMBuildSub(B: BuilderRef,
1199 Name: *const c_char)
1201 pub fn LLVMBuildNSWSub(B: BuilderRef,
1204 Name: *const c_char)
1206 pub fn LLVMBuildNUWSub(B: BuilderRef,
1209 Name: *const c_char)
1211 pub fn LLVMBuildFSub(B: BuilderRef,
1214 Name: *const c_char)
1216 pub fn LLVMBuildMul(B: BuilderRef,
1219 Name: *const c_char)
1221 pub fn LLVMBuildNSWMul(B: BuilderRef,
1224 Name: *const c_char)
1226 pub fn LLVMBuildNUWMul(B: BuilderRef,
1229 Name: *const c_char)
1231 pub fn LLVMBuildFMul(B: BuilderRef,
1234 Name: *const c_char)
1236 pub fn LLVMBuildUDiv(B: BuilderRef,
1239 Name: *const c_char)
1241 pub fn LLVMBuildSDiv(B: BuilderRef,
1244 Name: *const c_char)
1246 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1249 Name: *const c_char)
1251 pub fn LLVMBuildFDiv(B: BuilderRef,
1254 Name: *const c_char)
1256 pub fn LLVMBuildURem(B: BuilderRef,
1259 Name: *const c_char)
1261 pub fn LLVMBuildSRem(B: BuilderRef,
1264 Name: *const c_char)
1266 pub fn LLVMBuildFRem(B: BuilderRef,
1269 Name: *const c_char)
1271 pub fn LLVMBuildShl(B: BuilderRef,
1274 Name: *const c_char)
1276 pub fn LLVMBuildLShr(B: BuilderRef,
1279 Name: *const c_char)
1281 pub fn LLVMBuildAShr(B: BuilderRef,
1284 Name: *const c_char)
1286 pub fn LLVMBuildAnd(B: BuilderRef,
1289 Name: *const c_char)
1291 pub fn LLVMBuildOr(B: BuilderRef,
1294 Name: *const c_char)
1296 pub fn LLVMBuildXor(B: BuilderRef,
1299 Name: *const c_char)
1301 pub fn LLVMBuildBinOp(B: BuilderRef,
1305 Name: *const c_char)
1307 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1309 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1311 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1313 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1315 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1319 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1321 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1322 pub fn LLVMBuildLoad(B: BuilderRef,
1323 PointerVal: ValueRef,
1324 Name: *const c_char)
1327 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1330 pub fn LLVMBuildGEP(B: BuilderRef,
1332 Indices: *const ValueRef,
1334 Name: *const c_char)
1336 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1338 Indices: *const ValueRef,
1340 Name: *const c_char)
1342 pub fn LLVMBuildStructGEP(B: BuilderRef,
1345 Name: *const c_char)
1347 pub fn LLVMBuildGlobalString(B: BuilderRef,
1349 Name: *const c_char)
1351 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1353 Name: *const c_char)
1357 pub fn LLVMBuildTrunc(B: BuilderRef,
1360 Name: *const c_char)
1362 pub fn LLVMBuildZExt(B: BuilderRef,
1365 Name: *const c_char)
1367 pub fn LLVMBuildSExt(B: BuilderRef,
1370 Name: *const c_char)
1372 pub fn LLVMBuildFPToUI(B: BuilderRef,
1375 Name: *const c_char)
1377 pub fn LLVMBuildFPToSI(B: BuilderRef,
1380 Name: *const c_char)
1382 pub fn LLVMBuildUIToFP(B: BuilderRef,
1385 Name: *const c_char)
1387 pub fn LLVMBuildSIToFP(B: BuilderRef,
1390 Name: *const c_char)
1392 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1395 Name: *const c_char)
1397 pub fn LLVMBuildFPExt(B: BuilderRef,
1400 Name: *const c_char)
1402 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1405 Name: *const c_char)
1407 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1410 Name: *const c_char)
1412 pub fn LLVMBuildBitCast(B: BuilderRef,
1415 Name: *const c_char)
1417 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1420 Name: *const c_char)
1422 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1425 Name: *const c_char)
1427 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1430 Name: *const c_char)
1432 pub fn LLVMBuildCast(B: BuilderRef,
1436 Name: *const c_char) -> ValueRef;
1437 pub fn LLVMBuildPointerCast(B: BuilderRef,
1440 Name: *const c_char)
1442 pub fn LLVMBuildIntCast(B: BuilderRef,
1445 Name: *const c_char)
1447 pub fn LLVMBuildFPCast(B: BuilderRef,
1450 Name: *const c_char)
1454 pub fn LLVMBuildICmp(B: BuilderRef,
1458 Name: *const c_char)
1460 pub fn LLVMBuildFCmp(B: BuilderRef,
1464 Name: *const c_char)
1467 /* Miscellaneous instructions */
1468 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1470 pub fn LLVMBuildCall(B: BuilderRef,
1472 Args: *const ValueRef,
1474 Name: *const c_char)
1476 pub fn LLVMBuildSelect(B: BuilderRef,
1480 Name: *const c_char)
1482 pub fn LLVMBuildVAArg(B: BuilderRef,
1485 Name: *const c_char)
1487 pub fn LLVMBuildExtractElement(B: BuilderRef,
1490 Name: *const c_char)
1492 pub fn LLVMBuildInsertElement(B: BuilderRef,
1496 Name: *const c_char)
1498 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1502 Name: *const c_char)
1504 pub fn LLVMBuildExtractValue(B: BuilderRef,
1507 Name: *const c_char)
1509 pub fn LLVMBuildInsertValue(B: BuilderRef,
1513 Name: *const c_char)
1516 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1518 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1520 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1523 Name: *const c_char)
1526 /* Atomic Operations */
1527 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1528 PointerVal: ValueRef,
1529 Name: *const c_char,
1530 Order: AtomicOrdering,
1534 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1537 Order: AtomicOrdering,
1541 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1545 Order: AtomicOrdering,
1546 FailureOrder: AtomicOrdering)
1548 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1552 Order: AtomicOrdering,
1553 SingleThreaded: Bool)
1556 pub fn LLVMBuildAtomicFence(B: BuilderRef,
1557 Order: AtomicOrdering,
1558 Scope: SynchronizationScope);
1561 /* Selected entries from the downcasts. */
1562 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1563 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1565 /// Writes a module to the specified path. Returns 0 on success.
1566 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1568 /// Creates target data from a target layout string.
1569 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1570 /// Adds the target data to the given pass manager. The pass manager
1571 /// references the target data only weakly.
1572 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1573 /// Number of bytes clobbered when doing a Store to *T.
1574 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1577 /// Number of bytes clobbered when doing a Store to *T.
1578 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1581 /// Distance between successive elements in an array of T. Includes ABI padding.
1582 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1584 /// Returns the preferred alignment of a type.
1585 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1587 /// Returns the minimum alignment of a type.
1588 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1591 /// Computes the byte offset of the indexed struct element for a
1593 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1598 /// Returns the minimum alignment of a type when part of a call frame.
1599 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1602 /// Disposes target data.
1603 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1605 /// Creates a pass manager.
1606 pub fn LLVMCreatePassManager() -> PassManagerRef;
1608 /// Creates a function-by-function pass manager
1609 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1612 /// Disposes a pass manager.
1613 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1615 /// Runs a pass manager on a module.
1616 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1618 /// Runs the function passes on the provided function.
1619 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1622 /// Initializes all the function passes scheduled in the manager
1623 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1625 /// Finalizes all the function passes scheduled in the manager
1626 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1628 pub fn LLVMInitializePasses();
1630 /// Adds a verification pass.
1631 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1633 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1634 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1635 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1636 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1637 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1638 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1639 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1640 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1641 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1642 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1643 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1644 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1645 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1646 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1647 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1648 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1649 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1650 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1651 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1652 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1653 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1654 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1655 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1656 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1657 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1658 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1659 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1660 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1661 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1662 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1663 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1664 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1665 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1666 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1667 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1669 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1670 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1671 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1672 OptimizationLevel: c_uint);
1673 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1675 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1676 PMB: PassManagerBuilderRef,
1678 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1679 PMB: PassManagerBuilderRef,
1681 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1682 PMB: PassManagerBuilderRef,
1684 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1685 PMB: PassManagerBuilderRef,
1687 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1688 PMB: PassManagerBuilderRef,
1689 PM: PassManagerRef);
1691 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1692 PMB: PassManagerBuilderRef,
1693 PM: PassManagerRef);
1694 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1695 PMB: PassManagerBuilderRef,
1700 /// Destroys a memory buffer.
1701 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1704 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1706 /// Opens an object file.
1707 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1708 /// Closes an object file.
1709 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1711 /// Enumerates the sections in an object file.
1712 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1713 /// Destroys a section iterator.
1714 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1715 /// Returns true if the section iterator is at the end of the section
1717 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1718 SI: SectionIteratorRef)
1720 /// Moves the section iterator to point to the next section.
1721 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1722 /// Returns the current section size.
1723 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1724 /// Returns the current section contents as a string buffer.
1725 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1727 /// Reads the given file and returns it as a memory buffer. Use
1728 /// LLVMDisposeMemoryBuffer() to get rid of it.
1729 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1731 /// Borrows the contents of the memory buffer (doesn't copy it)
1732 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1733 InputDataLength: size_t,
1734 BufferName: *const c_char,
1737 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1738 InputDataLength: size_t,
1739 BufferName: *const c_char)
1742 pub fn LLVMIsMultithreaded() -> Bool;
1743 pub fn LLVMStartMultithreaded() -> Bool;
1745 /// Returns a string describing the last error caused by an LLVMRust* call.
1746 pub fn LLVMRustGetLastError() -> *const c_char;
1748 /// Print the pass timings since static dtors aren't picking them up.
1749 pub fn LLVMRustPrintPassTimings();
1751 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1753 pub fn LLVMStructSetBody(StructTy: TypeRef,
1754 ElementTypes: *const TypeRef,
1755 ElementCount: c_uint,
1758 pub fn LLVMConstNamedStruct(S: TypeRef,
1759 ConstantVals: *const ValueRef,
1763 /// Enables LLVM debug output.
1764 pub fn LLVMSetDebug(Enabled: c_int);
1766 /// Prepares inline assembly.
1767 pub fn LLVMInlineAsm(Ty: TypeRef,
1768 AsmString: *const c_char,
1769 Constraints: *const c_char,
1775 pub fn LLVMRustDebugMetadataVersion() -> u32;
1776 pub fn LLVMVersionMajor() -> u32;
1777 pub fn LLVMVersionMinor() -> u32;
1779 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1780 name: *const c_char,
1783 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1785 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1787 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1789 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1791 File: *const c_char,
1793 Producer: *const c_char,
1795 Flags: *const c_char,
1797 SplitName: *const c_char)
1800 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1801 Filename: *const c_char,
1802 Directory: *const c_char)
1805 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1807 ParameterTypes: DIArray)
1810 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1811 Scope: DIDescriptor,
1812 Name: *const c_char,
1813 LinkageName: *const c_char,
1817 isLocalToUnit: bool,
1827 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1828 Name: *const c_char,
1829 SizeInBits: c_ulonglong,
1830 AlignInBits: c_ulonglong,
1834 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1836 SizeInBits: c_ulonglong,
1837 AlignInBits: c_ulonglong,
1838 Name: *const c_char)
1841 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1842 Scope: DIDescriptor,
1843 Name: *const c_char,
1846 SizeInBits: c_ulonglong,
1847 AlignInBits: c_ulonglong,
1849 DerivedFrom: DIType,
1851 RunTimeLang: c_uint,
1852 VTableHolder: DIType,
1853 UniqueId: *const c_char)
1856 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1857 Scope: DIDescriptor,
1858 Name: *const c_char,
1861 SizeInBits: c_ulonglong,
1862 AlignInBits: c_ulonglong,
1863 OffsetInBits: c_ulonglong,
1868 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1875 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1877 Name: *const c_char,
1878 LinkageName: *const c_char,
1882 isLocalToUnit: bool,
1885 -> DIGlobalVariable;
1887 pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef,
1889 Scope: DIDescriptor,
1890 Name: *const c_char,
1894 AlwaysPreserve: bool,
1896 AddrOps: *const i64,
1897 AddrOpsCount: c_uint,
1901 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1903 AlignInBits: c_ulonglong,
1905 Subscripts: DIArray)
1908 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1910 AlignInBits: c_ulonglong,
1912 Subscripts: DIArray)
1915 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1920 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1921 Ptr: *const DIDescriptor,
1925 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1927 VarInfo: DIVariable,
1928 AddrOps: *const i64,
1929 AddrOpsCount: c_uint,
1931 InsertAtEnd: BasicBlockRef)
1934 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1936 VarInfo: DIVariable,
1937 AddrOps: *const i64,
1938 AddrOpsCount: c_uint,
1940 InsertBefore: ValueRef)
1943 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1944 Name: *const c_char,
1948 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1950 Name: *const c_char,
1953 SizeInBits: c_ulonglong,
1954 AlignInBits: c_ulonglong,
1959 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1961 Name: *const c_char,
1964 SizeInBits: c_ulonglong,
1965 AlignInBits: c_ulonglong,
1968 RunTimeLang: c_uint,
1969 UniqueId: *const c_char)
1972 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1974 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1976 Name: *const c_char,
1981 -> DITemplateTypeParameter;
1983 pub fn LLVMDIBuilderCreateOpDeref() -> i64;
1985 pub fn LLVMDIBuilderCreateOpPlus() -> i64;
1987 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1989 Name: *const c_char,
1994 pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef,
1998 InlinedAt: MetadataRef)
2001 pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
2002 CompositeType: DIType,
2003 TypeArray: DIArray);
2004 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
2005 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
2007 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
2009 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
2010 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
2012 pub fn LLVMInitializeX86TargetInfo();
2013 pub fn LLVMInitializeX86Target();
2014 pub fn LLVMInitializeX86TargetMC();
2015 pub fn LLVMInitializeX86AsmPrinter();
2016 pub fn LLVMInitializeX86AsmParser();
2017 pub fn LLVMInitializeARMTargetInfo();
2018 pub fn LLVMInitializeARMTarget();
2019 pub fn LLVMInitializeARMTargetMC();
2020 pub fn LLVMInitializeARMAsmPrinter();
2021 pub fn LLVMInitializeARMAsmParser();
2022 pub fn LLVMInitializeAArch64TargetInfo();
2023 pub fn LLVMInitializeAArch64Target();
2024 pub fn LLVMInitializeAArch64TargetMC();
2025 pub fn LLVMInitializeAArch64AsmPrinter();
2026 pub fn LLVMInitializeAArch64AsmParser();
2027 pub fn LLVMInitializeMipsTargetInfo();
2028 pub fn LLVMInitializeMipsTarget();
2029 pub fn LLVMInitializeMipsTargetMC();
2030 pub fn LLVMInitializeMipsAsmPrinter();
2031 pub fn LLVMInitializeMipsAsmParser();
2032 pub fn LLVMInitializePowerPCTargetInfo();
2033 pub fn LLVMInitializePowerPCTarget();
2034 pub fn LLVMInitializePowerPCTargetMC();
2035 pub fn LLVMInitializePowerPCAsmPrinter();
2036 pub fn LLVMInitializePowerPCAsmParser();
2038 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
2039 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
2041 Features: *const c_char,
2042 Model: CodeGenModel,
2044 Level: CodeGenOptLevel,
2047 PositionIndependentExecutable: bool,
2048 FunctionSections: bool,
2049 DataSections: bool) -> TargetMachineRef;
2050 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
2051 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
2054 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
2056 DisableSimplifyLibCalls: bool);
2057 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
2058 OptLevel: CodeGenOptLevel,
2059 MergeFunctions: bool,
2061 LoopVectorize: bool);
2062 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
2063 DisableSimplifyLibCalls: bool);
2064 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
2065 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2068 Output: *const c_char,
2069 FileType: FileType) -> bool;
2070 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2072 Output: *const c_char);
2073 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2074 pub fn LLVMRustPrintPasses();
2075 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2076 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2077 AddLifetimes: bool);
2078 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2080 len: size_t) -> bool;
2081 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2082 syms: *const *const c_char,
2084 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2086 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2087 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
2088 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
2089 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef,
2090 size: *mut size_t) -> *const c_char;
2091 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef,
2092 size: *mut size_t) -> *const c_char;
2093 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
2094 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
2095 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2097 pub fn LLVMRustSetDLLStorageClass(V: ValueRef,
2098 C: DLLStorageClassTypes);
2100 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2101 data: *mut *const c_char) -> c_int;
2103 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2105 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2106 Handler: DiagnosticHandler,
2107 DiagnosticContext: *mut c_void);
2109 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2110 pass_name_out: *mut *const c_char,
2111 function_out: *mut ValueRef,
2112 debugloc_out: *mut DebugLocRef,
2113 message_out: *mut TwineRef);
2114 pub fn LLVMUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
2115 cookie_out: *mut c_uint,
2116 message_out: *mut TwineRef,
2117 instruction_out: *mut ValueRef);
2119 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2120 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2121 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2123 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2125 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2126 H: InlineAsmDiagHandler,
2129 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2131 pub fn LLVMRustWriteArchive(Dst: *const c_char,
2133 Members: *const RustArchiveMemberRef,
2135 Kind: ArchiveKind) -> c_int;
2136 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
2137 Name: *const c_char,
2138 Child: ArchiveChildRef) -> RustArchiveMemberRef;
2139 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
2141 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef,
2142 TM: TargetMachineRef);
2143 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
2146 // LLVM requires symbols from this library, but apparently they're not printed
2147 // during llvm-config?
2149 #[link(name = "ole32")]
2152 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2154 LLVMSetInstructionCallConv(instr, cc as c_uint);
2157 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2159 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2162 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2164 LLVMSetLinkage(global, link as c_uint);
2168 pub fn SetDLLStorageClass(global: ValueRef, class: DLLStorageClassTypes) {
2170 LLVMRustSetDLLStorageClass(global, class);
2174 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2176 LLVMSetUnnamedAddr(global, unnamed as Bool);
2180 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2182 LLVMSetThreadLocal(global, is_thread_local as Bool);
2186 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2188 LLVMConstICmp(pred as c_ushort, v1, v2)
2191 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2193 LLVMConstFCmp(pred as c_ushort, v1, v2)
2197 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2199 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint,
2200 attr.bits() as uint64_t)
2204 /* Memory-managed interface to target data. */
2206 pub struct TargetData {
2207 pub lltd: TargetDataRef
2210 impl Drop for TargetData {
2211 fn drop(&mut self) {
2213 LLVMDisposeTargetData(self.lltd);
2218 pub fn mk_target_data(string_rep: &str) -> TargetData {
2219 let string_rep = CString::new(string_rep).unwrap();
2221 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2225 /* Memory-managed interface to object files. */
2227 pub struct ObjectFile {
2228 pub llof: ObjectFileRef,
2232 // This will take ownership of llmb
2233 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2235 let llof = LLVMCreateObjectFile(llmb);
2236 if llof as isize == 0 {
2237 // LLVMCreateObjectFile took ownership of llmb
2248 impl Drop for ObjectFile {
2249 fn drop(&mut self) {
2251 LLVMDisposeObjectFile(self.llof);
2256 /* Memory-managed interface to section iterators. */
2258 pub struct SectionIter {
2259 pub llsi: SectionIteratorRef
2262 impl Drop for SectionIter {
2263 fn drop(&mut self) {
2265 LLVMDisposeSectionIterator(self.llsi);
2270 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2273 llsi: LLVMGetSections(llof)
2278 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2279 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2281 assert!(index < LLVMCountParams(llfn));
2282 LLVMGetParam(llfn, index)
2286 pub fn get_params(llfn: ValueRef) -> Vec<ValueRef> {
2288 let num_params = LLVMCountParams(llfn);
2289 let mut params = Vec::with_capacity(num_params as usize);
2290 for idx in 0..num_params {
2291 params.push(LLVMGetParam(llfn, idx));
2298 #[allow(missing_copy_implementations)]
2299 pub enum RustString_opaque {}
2300 pub type RustStringRef = *mut RustString_opaque;
2301 type RustStringRepr = *mut RefCell<Vec<u8>>;
2303 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2305 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2308 let slice = slice::from_raw_parts(ptr as *const u8, size as usize);
2310 let sr: RustStringRepr = mem::transmute(sr);
2311 (*sr).borrow_mut().push_all(slice);
2314 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2315 let mut buf = RefCell::new(Vec::new());
2316 f(&mut buf as RustStringRepr as RustStringRef);
2317 String::from_utf8(buf.into_inner()).ok()
2320 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2321 build_string(|s| LLVMWriteTwineToString(tr, s))
2322 .expect("got a non-UTF8 Twine from LLVM")
2325 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2326 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2327 .expect("got a non-UTF8 DebugLoc from LLVM")
2330 // The module containing the native LLVM dependencies, generated by the build system
2331 // Note that this must come after the rustllvm extern declaration so that
2332 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2333 // Works to the above fix for #15460 to ensure LLVM dependencies that
2334 // are only used by rustllvm don't get stripped by the linker.
2336 include! { env!("CFG_LLVM_LINKAGE_FILE") }