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(vec_push_all)]
36 #![feature(linked_from)]
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 LLVMDisposeModule(M: ModuleRef);
621 /// Data layout. See Module::getDataLayout.
622 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
623 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
625 /// Target triple. See Module::getTargetTriple.
626 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
627 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
629 /// See Module::dump.
630 pub fn LLVMDumpModule(M: ModuleRef);
632 /// See Module::setModuleInlineAsm.
633 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
635 /// See llvm::LLVMTypeKind::getTypeID.
636 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
638 /// See llvm::LLVMType::getContext.
639 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
641 /* Operations on integer types */
642 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
643 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
644 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
645 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
646 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
647 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
650 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
652 /* Operations on real types */
653 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
654 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
655 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
656 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
657 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
659 /* Operations on function types */
660 pub fn LLVMFunctionType(ReturnType: TypeRef,
661 ParamTypes: *const TypeRef,
665 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
666 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
667 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
668 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
670 /* Operations on struct types */
671 pub fn LLVMStructTypeInContext(C: ContextRef,
672 ElementTypes: *const TypeRef,
673 ElementCount: c_uint,
676 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
677 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
679 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
681 /* Operations on array, pointer, and vector types (sequence types) */
682 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
683 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
685 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
688 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
689 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
690 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
691 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
693 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
695 /* Operations on other types */
696 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
697 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
698 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
700 /* Operations on all values */
701 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
702 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
703 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
704 pub fn LLVMDumpValue(Val: ValueRef);
705 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
706 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
707 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
708 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
710 /* Operations on Uses */
711 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
712 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
713 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
714 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
716 /* Operations on Users */
717 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
718 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
719 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
721 /* Operations on constants of any type */
722 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
724 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
725 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
727 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
729 /* only for isize/vector */
730 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
731 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
732 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
733 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
734 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
736 /* Operations on metadata */
737 pub fn LLVMMDStringInContext(C: ContextRef,
741 pub fn LLVMMDNodeInContext(C: ContextRef,
742 Vals: *const ValueRef,
745 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
749 /* Operations on scalar constants */
750 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
752 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
754 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
759 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
760 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
762 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
766 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
767 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
770 /* Operations on composite constants */
771 pub fn LLVMConstStringInContext(C: ContextRef,
774 DontNullTerminate: Bool)
776 pub fn LLVMConstStructInContext(C: ContextRef,
777 ConstantVals: *const ValueRef,
782 pub fn LLVMConstArray(ElementTy: TypeRef,
783 ConstantVals: *const ValueRef,
786 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
789 /* Constant expressions */
790 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
791 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
792 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
793 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
794 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
795 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
796 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
797 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
799 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
801 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
803 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
805 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
807 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
809 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
811 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
813 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
815 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
817 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
819 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
821 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
823 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
825 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
826 RHSConstant: ValueRef)
828 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
830 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
832 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
834 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
836 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
838 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
840 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
842 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
844 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
846 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
848 pub fn LLVMConstGEP(ConstantVal: ValueRef,
849 ConstantIndices: *const ValueRef,
852 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
853 ConstantIndices: *const ValueRef,
856 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
858 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
860 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
862 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
864 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
866 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
868 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
870 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
872 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
874 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
876 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
878 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
880 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
882 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
884 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
886 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
888 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
892 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
894 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
895 ConstantIfTrue: ValueRef,
896 ConstantIfFalse: ValueRef)
898 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
899 IndexConstant: ValueRef)
901 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
902 ElementValueConstant: ValueRef,
903 IndexConstant: ValueRef)
905 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
906 VectorBConstant: ValueRef,
907 MaskConstant: ValueRef)
909 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
910 IdxList: *const c_uint,
913 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
914 ElementValueConstant: ValueRef,
915 IdxList: *const c_uint,
918 pub fn LLVMConstInlineAsm(Ty: TypeRef,
919 AsmString: *const c_char,
920 Constraints: *const c_char,
921 HasSideEffects: Bool,
924 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
928 /* Operations on global variables, functions, and aliases (globals) */
929 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
930 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
931 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
932 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
933 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
934 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
935 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
936 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
937 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
938 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
941 /* Operations on global variables */
942 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
943 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
945 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
948 AddressSpace: c_uint)
950 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
951 pub fn LLVMGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
952 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
953 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
954 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
955 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
956 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
957 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
958 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
959 ConstantVal: ValueRef);
960 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
961 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
962 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
963 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
964 pub fn LLVMGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
966 /* Operations on aliases */
967 pub fn LLVMAddAlias(M: ModuleRef,
973 /* Operations on functions */
974 pub fn LLVMAddFunction(M: ModuleRef,
978 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
979 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
980 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
981 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
982 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
983 pub fn LLVMDeleteFunction(Fn: ValueRef);
984 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
988 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
989 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
990 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
991 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
992 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
993 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
994 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
995 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
996 pub fn LLVMAddFunctionAttrStringValue(Fn: ValueRef, index: c_uint,
998 Value: *const c_char);
999 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
1000 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
1001 pub fn LLVMRemoveFunctionAttr(Fn: ValueRef, val: c_ulonglong);
1003 /* Operations on parameters */
1004 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
1005 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
1006 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
1007 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
1008 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
1009 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
1010 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
1011 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
1012 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
1013 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
1014 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
1015 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
1017 /* Operations on basic blocks */
1018 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
1019 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
1020 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
1021 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
1022 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
1023 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
1024 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1025 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1026 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
1027 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
1028 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1030 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
1032 Name: *const c_char)
1034 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
1036 Name: *const c_char)
1038 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
1040 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
1041 MoveAfter: BasicBlockRef);
1043 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
1044 MoveBefore: BasicBlockRef);
1046 /* Operations on instructions */
1047 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
1048 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
1049 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
1050 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
1051 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
1052 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
1054 /* Operations on call sites */
1055 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
1056 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
1057 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
1060 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1063 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1066 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1069 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1073 /* Operations on call instructions (only) */
1074 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1075 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1077 /* Operations on load/store instructions (only) */
1078 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1079 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1081 /* Operations on phi nodes */
1082 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1083 IncomingValues: *const ValueRef,
1084 IncomingBlocks: *const BasicBlockRef,
1086 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1087 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1089 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1092 /* Instruction builders */
1093 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1094 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1095 Block: BasicBlockRef,
1097 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1099 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1100 Block: BasicBlockRef);
1101 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1102 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1103 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1104 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1106 Name: *const c_char);
1107 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1109 /* Execution engine */
1110 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef) -> ExecutionEngineRef;
1111 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1112 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1113 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1114 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1115 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1119 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1120 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1121 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1124 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1125 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1126 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1127 RetVals: *const ValueRef,
1130 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1131 pub fn LLVMBuildCondBr(B: BuilderRef,
1133 Then: BasicBlockRef,
1134 Else: BasicBlockRef)
1136 pub fn LLVMBuildSwitch(B: BuilderRef,
1138 Else: BasicBlockRef,
1141 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1145 pub fn LLVMBuildInvoke(B: BuilderRef,
1147 Args: *const ValueRef,
1149 Then: BasicBlockRef,
1150 Catch: BasicBlockRef,
1151 Name: *const c_char)
1153 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
1157 Name: *const c_char,
1160 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1161 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1163 /* Add a case to the switch instruction */
1164 pub fn LLVMAddCase(Switch: ValueRef,
1166 Dest: BasicBlockRef);
1168 /* Add a destination to the indirectbr instruction */
1169 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1171 /* Add a clause to the landing pad instruction */
1172 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1174 /* Set the cleanup on a landing pad instruction */
1175 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1178 pub fn LLVMBuildAdd(B: BuilderRef,
1181 Name: *const c_char)
1183 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1186 Name: *const c_char)
1188 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1191 Name: *const c_char)
1193 pub fn LLVMBuildFAdd(B: BuilderRef,
1196 Name: *const c_char)
1198 pub fn LLVMBuildSub(B: BuilderRef,
1201 Name: *const c_char)
1203 pub fn LLVMBuildNSWSub(B: BuilderRef,
1206 Name: *const c_char)
1208 pub fn LLVMBuildNUWSub(B: BuilderRef,
1211 Name: *const c_char)
1213 pub fn LLVMBuildFSub(B: BuilderRef,
1216 Name: *const c_char)
1218 pub fn LLVMBuildMul(B: BuilderRef,
1221 Name: *const c_char)
1223 pub fn LLVMBuildNSWMul(B: BuilderRef,
1226 Name: *const c_char)
1228 pub fn LLVMBuildNUWMul(B: BuilderRef,
1231 Name: *const c_char)
1233 pub fn LLVMBuildFMul(B: BuilderRef,
1236 Name: *const c_char)
1238 pub fn LLVMBuildUDiv(B: BuilderRef,
1241 Name: *const c_char)
1243 pub fn LLVMBuildSDiv(B: BuilderRef,
1246 Name: *const c_char)
1248 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1251 Name: *const c_char)
1253 pub fn LLVMBuildFDiv(B: BuilderRef,
1256 Name: *const c_char)
1258 pub fn LLVMBuildURem(B: BuilderRef,
1261 Name: *const c_char)
1263 pub fn LLVMBuildSRem(B: BuilderRef,
1266 Name: *const c_char)
1268 pub fn LLVMBuildFRem(B: BuilderRef,
1271 Name: *const c_char)
1273 pub fn LLVMBuildShl(B: BuilderRef,
1276 Name: *const c_char)
1278 pub fn LLVMBuildLShr(B: BuilderRef,
1281 Name: *const c_char)
1283 pub fn LLVMBuildAShr(B: BuilderRef,
1286 Name: *const c_char)
1288 pub fn LLVMBuildAnd(B: BuilderRef,
1291 Name: *const c_char)
1293 pub fn LLVMBuildOr(B: BuilderRef,
1296 Name: *const c_char)
1298 pub fn LLVMBuildXor(B: BuilderRef,
1301 Name: *const c_char)
1303 pub fn LLVMBuildBinOp(B: BuilderRef,
1307 Name: *const c_char)
1309 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1311 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1313 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1315 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1317 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1321 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1323 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1324 pub fn LLVMBuildLoad(B: BuilderRef,
1325 PointerVal: ValueRef,
1326 Name: *const c_char)
1329 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1332 pub fn LLVMBuildGEP(B: BuilderRef,
1334 Indices: *const ValueRef,
1336 Name: *const c_char)
1338 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1340 Indices: *const ValueRef,
1342 Name: *const c_char)
1344 pub fn LLVMBuildStructGEP(B: BuilderRef,
1347 Name: *const c_char)
1349 pub fn LLVMBuildGlobalString(B: BuilderRef,
1351 Name: *const c_char)
1353 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1355 Name: *const c_char)
1359 pub fn LLVMBuildTrunc(B: BuilderRef,
1362 Name: *const c_char)
1364 pub fn LLVMBuildZExt(B: BuilderRef,
1367 Name: *const c_char)
1369 pub fn LLVMBuildSExt(B: BuilderRef,
1372 Name: *const c_char)
1374 pub fn LLVMBuildFPToUI(B: BuilderRef,
1377 Name: *const c_char)
1379 pub fn LLVMBuildFPToSI(B: BuilderRef,
1382 Name: *const c_char)
1384 pub fn LLVMBuildUIToFP(B: BuilderRef,
1387 Name: *const c_char)
1389 pub fn LLVMBuildSIToFP(B: BuilderRef,
1392 Name: *const c_char)
1394 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1397 Name: *const c_char)
1399 pub fn LLVMBuildFPExt(B: BuilderRef,
1402 Name: *const c_char)
1404 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1407 Name: *const c_char)
1409 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1412 Name: *const c_char)
1414 pub fn LLVMBuildBitCast(B: BuilderRef,
1417 Name: *const c_char)
1419 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1422 Name: *const c_char)
1424 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1427 Name: *const c_char)
1429 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1432 Name: *const c_char)
1434 pub fn LLVMBuildCast(B: BuilderRef,
1438 Name: *const c_char) -> ValueRef;
1439 pub fn LLVMBuildPointerCast(B: BuilderRef,
1442 Name: *const c_char)
1444 pub fn LLVMBuildIntCast(B: BuilderRef,
1447 Name: *const c_char)
1449 pub fn LLVMBuildFPCast(B: BuilderRef,
1452 Name: *const c_char)
1456 pub fn LLVMBuildICmp(B: BuilderRef,
1460 Name: *const c_char)
1462 pub fn LLVMBuildFCmp(B: BuilderRef,
1466 Name: *const c_char)
1469 /* Miscellaneous instructions */
1470 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1472 pub fn LLVMBuildCall(B: BuilderRef,
1474 Args: *const ValueRef,
1476 Name: *const c_char)
1478 pub fn LLVMBuildSelect(B: BuilderRef,
1482 Name: *const c_char)
1484 pub fn LLVMBuildVAArg(B: BuilderRef,
1487 Name: *const c_char)
1489 pub fn LLVMBuildExtractElement(B: BuilderRef,
1492 Name: *const c_char)
1494 pub fn LLVMBuildInsertElement(B: BuilderRef,
1498 Name: *const c_char)
1500 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1504 Name: *const c_char)
1506 pub fn LLVMBuildExtractValue(B: BuilderRef,
1509 Name: *const c_char)
1511 pub fn LLVMBuildInsertValue(B: BuilderRef,
1515 Name: *const c_char)
1518 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1520 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1522 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1525 Name: *const c_char)
1528 /* Atomic Operations */
1529 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1530 PointerVal: ValueRef,
1531 Name: *const c_char,
1532 Order: AtomicOrdering,
1536 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1539 Order: AtomicOrdering,
1543 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1547 Order: AtomicOrdering,
1548 FailureOrder: AtomicOrdering)
1550 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1554 Order: AtomicOrdering,
1555 SingleThreaded: Bool)
1558 pub fn LLVMBuildAtomicFence(B: BuilderRef,
1559 Order: AtomicOrdering,
1560 Scope: SynchronizationScope);
1563 /* Selected entries from the downcasts. */
1564 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1565 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1567 /// Writes a module to the specified path. Returns 0 on success.
1568 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1570 /// Creates target data from a target layout string.
1571 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1572 /// Adds the target data to the given pass manager. The pass manager
1573 /// references the target data only weakly.
1574 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1575 /// Number of bytes clobbered when doing a Store to *T.
1576 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1579 /// Number of bytes clobbered when doing a Store to *T.
1580 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1583 /// Distance between successive elements in an array of T. Includes ABI padding.
1584 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1586 /// Returns the preferred alignment of a type.
1587 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1589 /// Returns the minimum alignment of a type.
1590 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1593 /// Computes the byte offset of the indexed struct element for a
1595 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1600 /// Returns the minimum alignment of a type when part of a call frame.
1601 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1604 /// Disposes target data.
1605 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1607 /// Creates a pass manager.
1608 pub fn LLVMCreatePassManager() -> PassManagerRef;
1610 /// Creates a function-by-function pass manager
1611 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1614 /// Disposes a pass manager.
1615 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1617 /// Runs a pass manager on a module.
1618 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1620 /// Runs the function passes on the provided function.
1621 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1624 /// Initializes all the function passes scheduled in the manager
1625 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1627 /// Finalizes all the function passes scheduled in the manager
1628 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1630 pub fn LLVMInitializePasses();
1632 /// Adds a verification pass.
1633 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1635 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1636 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1637 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1638 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1639 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1640 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1641 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1642 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1643 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1644 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1645 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1646 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1647 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1648 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1649 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1650 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1651 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1652 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1653 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1654 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1655 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1656 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1657 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1658 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1659 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1660 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1661 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1662 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1663 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1664 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1665 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1666 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1667 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1668 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1669 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1671 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1672 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1673 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1674 OptimizationLevel: c_uint);
1675 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1677 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1678 PMB: PassManagerBuilderRef,
1680 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1681 PMB: PassManagerBuilderRef,
1683 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1684 PMB: PassManagerBuilderRef,
1686 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1687 PMB: PassManagerBuilderRef,
1689 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1690 PMB: PassManagerBuilderRef,
1691 PM: PassManagerRef);
1693 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1694 PMB: PassManagerBuilderRef,
1695 PM: PassManagerRef);
1696 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1697 PMB: PassManagerBuilderRef,
1702 /// Destroys a memory buffer.
1703 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1706 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1708 /// Opens an object file.
1709 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1710 /// Closes an object file.
1711 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1713 /// Enumerates the sections in an object file.
1714 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1715 /// Destroys a section iterator.
1716 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1717 /// Returns true if the section iterator is at the end of the section
1719 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1720 SI: SectionIteratorRef)
1722 /// Moves the section iterator to point to the next section.
1723 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1724 /// Returns the current section size.
1725 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1726 /// Returns the current section contents as a string buffer.
1727 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1729 /// Reads the given file and returns it as a memory buffer. Use
1730 /// LLVMDisposeMemoryBuffer() to get rid of it.
1731 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1733 /// Borrows the contents of the memory buffer (doesn't copy it)
1734 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1735 InputDataLength: size_t,
1736 BufferName: *const c_char,
1739 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1740 InputDataLength: size_t,
1741 BufferName: *const c_char)
1744 pub fn LLVMIsMultithreaded() -> Bool;
1745 pub fn LLVMStartMultithreaded() -> Bool;
1747 /// Returns a string describing the last error caused by an LLVMRust* call.
1748 pub fn LLVMRustGetLastError() -> *const c_char;
1750 /// Print the pass timings since static dtors aren't picking them up.
1751 pub fn LLVMRustPrintPassTimings();
1753 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1755 pub fn LLVMStructSetBody(StructTy: TypeRef,
1756 ElementTypes: *const TypeRef,
1757 ElementCount: c_uint,
1760 pub fn LLVMConstNamedStruct(S: TypeRef,
1761 ConstantVals: *const ValueRef,
1765 /// Enables LLVM debug output.
1766 pub fn LLVMSetDebug(Enabled: c_int);
1768 /// Prepares inline assembly.
1769 pub fn LLVMInlineAsm(Ty: TypeRef,
1770 AsmString: *const c_char,
1771 Constraints: *const c_char,
1777 pub fn LLVMRustDebugMetadataVersion() -> u32;
1778 pub fn LLVMVersionMajor() -> u32;
1779 pub fn LLVMVersionMinor() -> u32;
1781 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1782 name: *const c_char,
1785 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1787 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1789 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1791 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1793 File: *const c_char,
1795 Producer: *const c_char,
1797 Flags: *const c_char,
1799 SplitName: *const c_char)
1802 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1803 Filename: *const c_char,
1804 Directory: *const c_char)
1807 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1809 ParameterTypes: DIArray)
1812 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1813 Scope: DIDescriptor,
1814 Name: *const c_char,
1815 LinkageName: *const c_char,
1819 isLocalToUnit: bool,
1829 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1830 Name: *const c_char,
1831 SizeInBits: c_ulonglong,
1832 AlignInBits: c_ulonglong,
1836 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1838 SizeInBits: c_ulonglong,
1839 AlignInBits: c_ulonglong,
1840 Name: *const c_char)
1843 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1844 Scope: DIDescriptor,
1845 Name: *const c_char,
1848 SizeInBits: c_ulonglong,
1849 AlignInBits: c_ulonglong,
1851 DerivedFrom: DIType,
1853 RunTimeLang: c_uint,
1854 VTableHolder: DIType,
1855 UniqueId: *const c_char)
1858 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1859 Scope: DIDescriptor,
1860 Name: *const c_char,
1863 SizeInBits: c_ulonglong,
1864 AlignInBits: c_ulonglong,
1865 OffsetInBits: c_ulonglong,
1870 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1877 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1879 Name: *const c_char,
1880 LinkageName: *const c_char,
1884 isLocalToUnit: bool,
1887 -> DIGlobalVariable;
1889 pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef,
1891 Scope: DIDescriptor,
1892 Name: *const c_char,
1896 AlwaysPreserve: bool,
1898 AddrOps: *const i64,
1899 AddrOpsCount: c_uint,
1903 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1905 AlignInBits: c_ulonglong,
1907 Subscripts: DIArray)
1910 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1912 AlignInBits: c_ulonglong,
1914 Subscripts: DIArray)
1917 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1922 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1923 Ptr: *const DIDescriptor,
1927 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1929 VarInfo: DIVariable,
1930 AddrOps: *const i64,
1931 AddrOpsCount: c_uint,
1933 InsertAtEnd: BasicBlockRef)
1936 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1938 VarInfo: DIVariable,
1939 AddrOps: *const i64,
1940 AddrOpsCount: c_uint,
1942 InsertBefore: ValueRef)
1945 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1946 Name: *const c_char,
1950 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1952 Name: *const c_char,
1955 SizeInBits: c_ulonglong,
1956 AlignInBits: c_ulonglong,
1961 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1963 Name: *const c_char,
1966 SizeInBits: c_ulonglong,
1967 AlignInBits: c_ulonglong,
1970 RunTimeLang: c_uint,
1971 UniqueId: *const c_char)
1974 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1976 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1978 Name: *const c_char,
1983 -> DITemplateTypeParameter;
1985 pub fn LLVMDIBuilderCreateOpDeref() -> i64;
1987 pub fn LLVMDIBuilderCreateOpPlus() -> i64;
1989 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1991 Name: *const c_char,
1996 pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef,
2000 InlinedAt: MetadataRef)
2003 pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
2004 CompositeType: DIType,
2005 TypeArray: DIArray);
2006 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
2007 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
2009 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
2011 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
2012 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
2014 pub fn LLVMInitializeX86TargetInfo();
2015 pub fn LLVMInitializeX86Target();
2016 pub fn LLVMInitializeX86TargetMC();
2017 pub fn LLVMInitializeX86AsmPrinter();
2018 pub fn LLVMInitializeX86AsmParser();
2019 pub fn LLVMInitializeARMTargetInfo();
2020 pub fn LLVMInitializeARMTarget();
2021 pub fn LLVMInitializeARMTargetMC();
2022 pub fn LLVMInitializeARMAsmPrinter();
2023 pub fn LLVMInitializeARMAsmParser();
2024 pub fn LLVMInitializeAArch64TargetInfo();
2025 pub fn LLVMInitializeAArch64Target();
2026 pub fn LLVMInitializeAArch64TargetMC();
2027 pub fn LLVMInitializeAArch64AsmPrinter();
2028 pub fn LLVMInitializeAArch64AsmParser();
2029 pub fn LLVMInitializeMipsTargetInfo();
2030 pub fn LLVMInitializeMipsTarget();
2031 pub fn LLVMInitializeMipsTargetMC();
2032 pub fn LLVMInitializeMipsAsmPrinter();
2033 pub fn LLVMInitializeMipsAsmParser();
2034 pub fn LLVMInitializePowerPCTargetInfo();
2035 pub fn LLVMInitializePowerPCTarget();
2036 pub fn LLVMInitializePowerPCTargetMC();
2037 pub fn LLVMInitializePowerPCAsmPrinter();
2038 pub fn LLVMInitializePowerPCAsmParser();
2040 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
2041 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
2043 Features: *const c_char,
2044 Model: CodeGenModel,
2046 Level: CodeGenOptLevel,
2048 PositionIndependentExecutable: bool,
2049 FunctionSections: bool,
2050 DataSections: bool) -> TargetMachineRef;
2051 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
2052 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
2055 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
2057 DisableSimplifyLibCalls: bool);
2058 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
2059 OptLevel: CodeGenOptLevel,
2060 MergeFunctions: bool,
2062 LoopVectorize: bool);
2063 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
2064 DisableSimplifyLibCalls: bool);
2065 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
2066 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2069 Output: *const c_char,
2070 FileType: FileType) -> bool;
2071 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2073 Output: *const c_char);
2074 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2075 pub fn LLVMRustPrintPasses();
2076 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2077 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2078 AddLifetimes: bool);
2079 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2081 len: size_t) -> bool;
2082 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2083 syms: *const *const c_char,
2085 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2087 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2088 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
2089 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
2090 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef,
2091 size: *mut size_t) -> *const c_char;
2092 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef,
2093 size: *mut size_t) -> *const c_char;
2094 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
2095 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
2096 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2098 pub fn LLVMRustSetDLLStorageClass(V: ValueRef,
2099 C: DLLStorageClassTypes);
2101 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2102 data: *mut *const c_char) -> c_int;
2104 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2106 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2107 Handler: DiagnosticHandler,
2108 DiagnosticContext: *mut c_void);
2110 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2111 pass_name_out: *mut *const c_char,
2112 function_out: *mut ValueRef,
2113 debugloc_out: *mut DebugLocRef,
2114 message_out: *mut TwineRef);
2115 pub fn LLVMUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
2116 cookie_out: *mut c_uint,
2117 message_out: *mut TwineRef,
2118 instruction_out: *mut ValueRef);
2120 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2121 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2122 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2124 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2126 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2127 H: InlineAsmDiagHandler,
2130 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2132 pub fn LLVMRustWriteArchive(Dst: *const c_char,
2134 Members: *const RustArchiveMemberRef,
2136 Kind: ArchiveKind) -> c_int;
2137 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
2138 Name: *const c_char,
2139 Child: ArchiveChildRef) -> RustArchiveMemberRef;
2140 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
2142 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef,
2143 TM: TargetMachineRef);
2144 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
2147 // LLVM requires symbols from this library, but apparently they're not printed
2148 // during llvm-config?
2150 #[link(name = "ole32")]
2153 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2155 LLVMSetInstructionCallConv(instr, cc as c_uint);
2158 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2160 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2163 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2165 LLVMSetLinkage(global, link as c_uint);
2169 pub fn SetDLLStorageClass(global: ValueRef, class: DLLStorageClassTypes) {
2171 LLVMRustSetDLLStorageClass(global, class);
2175 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2177 LLVMSetUnnamedAddr(global, unnamed as Bool);
2181 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2183 LLVMSetThreadLocal(global, is_thread_local as Bool);
2187 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2189 LLVMConstICmp(pred as c_ushort, v1, v2)
2192 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2194 LLVMConstFCmp(pred as c_ushort, v1, v2)
2198 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2200 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint,
2201 attr.bits() as uint64_t)
2205 /* Memory-managed interface to target data. */
2207 pub struct TargetData {
2208 pub lltd: TargetDataRef
2211 impl Drop for TargetData {
2212 fn drop(&mut self) {
2214 LLVMDisposeTargetData(self.lltd);
2219 pub fn mk_target_data(string_rep: &str) -> TargetData {
2220 let string_rep = CString::new(string_rep).unwrap();
2222 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2226 /* Memory-managed interface to object files. */
2228 pub struct ObjectFile {
2229 pub llof: ObjectFileRef,
2233 // This will take ownership of llmb
2234 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2236 let llof = LLVMCreateObjectFile(llmb);
2237 if llof as isize == 0 {
2238 // LLVMCreateObjectFile took ownership of llmb
2249 impl Drop for ObjectFile {
2250 fn drop(&mut self) {
2252 LLVMDisposeObjectFile(self.llof);
2257 /* Memory-managed interface to section iterators. */
2259 pub struct SectionIter {
2260 pub llsi: SectionIteratorRef
2263 impl Drop for SectionIter {
2264 fn drop(&mut self) {
2266 LLVMDisposeSectionIterator(self.llsi);
2271 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2274 llsi: LLVMGetSections(llof)
2279 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2280 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2282 assert!(index < LLVMCountParams(llfn));
2283 LLVMGetParam(llfn, index)
2287 pub fn get_params(llfn: ValueRef) -> Vec<ValueRef> {
2289 let num_params = LLVMCountParams(llfn);
2290 let mut params = Vec::with_capacity(num_params as usize);
2291 for idx in 0..num_params {
2292 params.push(LLVMGetParam(llfn, idx));
2299 #[allow(missing_copy_implementations)]
2300 pub enum RustString_opaque {}
2301 pub type RustStringRef = *mut RustString_opaque;
2302 type RustStringRepr = *mut RefCell<Vec<u8>>;
2304 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2306 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2309 let slice = slice::from_raw_parts(ptr as *const u8, size as usize);
2311 let sr = sr as RustStringRepr;
2312 (*sr).borrow_mut().push_all(slice);
2315 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2316 let mut buf = RefCell::new(Vec::new());
2317 f(&mut buf as RustStringRepr as RustStringRef);
2318 String::from_utf8(buf.into_inner()).ok()
2321 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2322 build_string(|s| LLVMWriteTwineToString(tr, s))
2323 .expect("got a non-UTF8 Twine from LLVM")
2326 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2327 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2328 .expect("got a non-UTF8 DebugLoc from LLVM")
2331 // The module containing the native LLVM dependencies, generated by the build system
2332 // Note that this must come after the rustllvm extern declaration so that
2333 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2334 // Works to the above fix for #15460 to ensure LLVM dependencies that
2335 // are only used by rustllvm don't get stripped by the linker.
2337 include! { env!("CFG_LLVM_LINKAGE_FILE") }