1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![allow(non_upper_case_globals)]
12 #![allow(non_camel_case_types)]
13 #![allow(non_snake_case)]
16 #![crate_name = "rustc_llvm"]
17 #![unstable(feature = "rustc_private", issue = "27812")]
18 #![crate_type = "dylib"]
19 #![crate_type = "rlib"]
20 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
21 html_favicon_url
= "https://doc.rust-lang.org/favicon.ico",
22 html_root_url
= "https://doc.rust-lang.org/nightly/")]
23 #![cfg_attr(not(stage0), deny(warnings))]
25 #![feature(associated_consts)]
26 #![feature(box_syntax)]
28 #![feature(link_args)]
29 #![feature(staged_api)]
30 #![feature(linked_from)]
31 #![feature(concat_idents)]
34 #[macro_use] #[no_link] extern crate rustc_bitflags;
36 pub use self::OtherAttribute
::*;
37 pub use self::SpecialAttribute
::*;
38 pub use self::AttributeSet
::*;
39 pub use self::IntPredicate
::*;
40 pub use self::RealPredicate
::*;
41 pub use self::TypeKind
::*;
42 pub use self::AtomicBinOp
::*;
43 pub use self::AtomicOrdering
::*;
44 pub use self::SynchronizationScope
::*;
45 pub use self::FileType
::*;
46 pub use self::MetadataType
::*;
47 pub use self::AsmDialect
::*;
48 pub use self::CodeGenOptLevel
::*;
49 pub use self::RelocMode
::*;
50 pub use self::CodeGenModel
::*;
51 pub use self::DiagnosticKind
::*;
52 pub use self::CallConv
::*;
53 pub use self::Visibility
::*;
54 pub use self::DiagnosticSeverity
::*;
55 pub use self::Linkage
::*;
56 pub use self::DLLStorageClassTypes
::*;
58 use std
::ffi
::{CString, CStr}
;
59 use std
::cell
::RefCell
;
61 use libc
::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char}
;
62 use libc
::{c_longlong, c_ulonglong, c_void}
;
63 use debuginfo
::{DIBuilderRef
, DIDescriptor
,
64 DIFile
, DILexicalBlock
, DISubprogram
, DIType
,
65 DIBasicType
, DIDerivedType
, DICompositeType
, DIScope
,
66 DIVariable
, DIGlobalVariable
, DIArray
, DISubrange
,
67 DITemplateTypeParameter
, DIEnumerator
, DINameSpace
};
72 pub type Opcode
= u32;
73 pub type Bool
= c_uint
;
75 pub const True
: Bool
= 1 as Bool
;
76 pub const False
: Bool
= 0 as Bool
;
78 // Consts for the LLVM CallConv type, pre-cast to usize.
80 #[derive(Copy, Clone, PartialEq)]
85 X86StdcallCallConv
= 64,
86 X86FastcallCallConv
= 65,
91 #[derive(Copy, Clone)]
93 LLVMDefaultVisibility
= 0,
95 ProtectedVisibility
= 2,
98 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
99 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
100 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
101 // they've been removed in upstream LLVM commit r203866.
102 #[derive(Copy, Clone)]
105 AvailableExternallyLinkage
= 1,
106 LinkOnceAnyLinkage
= 2,
107 LinkOnceODRLinkage
= 3,
110 AppendingLinkage
= 7,
113 ExternalWeakLinkage
= 12,
118 #[derive(Copy, Clone, Debug)]
119 pub enum DiagnosticSeverity
{
128 #[derive(Copy, Clone)]
129 pub enum DLLStorageClassTypes
{
130 DefaultStorageClass
= 0,
131 DLLImportStorageClass
= 1,
132 DLLExportStorageClass
= 2,
136 flags Attribute
: u64 {
139 const NoReturn
= 1 << 2,
140 const InReg
= 1 << 3,
141 const StructRet
= 1 << 4,
142 const NoUnwind
= 1 << 5,
143 const NoAlias
= 1 << 6,
144 const ByVal
= 1 << 7,
146 const ReadNone
= 1 << 9,
147 const ReadOnly
= 1 << 10,
148 const NoInline
= 1 << 11,
149 const AlwaysInline
= 1 << 12,
150 const OptimizeForSize
= 1 << 13,
151 const StackProtect
= 1 << 14,
152 const StackProtectReq
= 1 << 15,
153 const Alignment
= 1 << 16,
154 const NoCapture
= 1 << 21,
155 const NoRedZone
= 1 << 22,
156 const NoImplicitFloat
= 1 << 23,
157 const Naked
= 1 << 24,
158 const InlineHint
= 1 << 25,
159 const Stack
= 7 << 26,
160 const ReturnsTwice
= 1 << 29,
161 const UWTable
= 1 << 30,
162 const NonLazyBind
= 1 << 31,
163 const OptimizeNone
= 1 << 42,
169 #[derive(Copy, Clone)]
170 pub enum OtherAttribute
{
171 // The following are not really exposed in
172 // the LLVM C api so instead to add these
173 // we call a wrapper function in RustWrapper
174 // that uses the C++ api.
175 SanitizeAddressAttribute
= 1 << 32,
176 MinSizeAttribute
= 1 << 33,
177 NoDuplicateAttribute
= 1 << 34,
178 StackProtectStrongAttribute
= 1 << 35,
179 SanitizeThreadAttribute
= 1 << 36,
180 SanitizeMemoryAttribute
= 1 << 37,
181 NoBuiltinAttribute
= 1 << 38,
182 ReturnedAttribute
= 1 << 39,
183 ColdAttribute
= 1 << 40,
184 BuiltinAttribute
= 1 << 41,
185 OptimizeNoneAttribute
= 1 << 42,
186 InAllocaAttribute
= 1 << 43,
187 NonNullAttribute
= 1 << 44,
190 #[derive(Copy, Clone)]
191 pub enum SpecialAttribute
{
192 DereferenceableAttribute(u64)
196 #[derive(Copy, Clone)]
197 pub enum AttributeSet
{
202 pub trait AttrHelper
{
203 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
);
204 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
);
207 impl AttrHelper
for Attribute
{
208 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
) {
210 LLVMAddFunctionAttribute(llfn
, idx
, self.bits() as uint64_t
);
214 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
) {
216 LLVMAddCallSiteAttribute(callsite
, idx
, self.bits() as uint64_t
);
221 impl AttrHelper
for OtherAttribute
{
222 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
) {
224 LLVMAddFunctionAttribute(llfn
, idx
, *self as uint64_t
);
228 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
) {
230 LLVMAddCallSiteAttribute(callsite
, idx
, *self as uint64_t
);
235 impl AttrHelper
for SpecialAttribute
{
236 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
) {
238 DereferenceableAttribute(bytes
) => unsafe {
239 LLVMAddDereferenceableAttr(llfn
, idx
, bytes
as uint64_t
);
244 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
) {
246 DereferenceableAttribute(bytes
) => unsafe {
247 LLVMAddDereferenceableCallSiteAttr(callsite
, idx
, bytes
as uint64_t
);
253 pub struct AttrBuilder
{
254 attrs
: Vec
<(usize, Box
<AttrHelper
+'
static>)>
258 pub fn new() -> AttrBuilder
{
264 pub fn arg
<T
: AttrHelper
+ '
static>(&mut self, idx
: usize, a
: T
) -> &mut AttrBuilder
{
265 self.attrs
.push((idx
, box a
as Box
<AttrHelper
+'
static>));
269 pub fn ret
<T
: AttrHelper
+ '
static>(&mut self, a
: T
) -> &mut AttrBuilder
{
270 self.attrs
.push((ReturnIndex
as usize, box a
as Box
<AttrHelper
+'
static>));
274 pub fn apply_llfn(&self, llfn
: ValueRef
) {
275 for &(idx
, ref attr
) in &self.attrs
{
276 attr
.apply_llfn(idx
as c_uint
, llfn
);
280 pub fn apply_callsite(&self, callsite
: ValueRef
) {
281 for &(idx
, ref attr
) in &self.attrs
{
282 attr
.apply_callsite(idx
as c_uint
, callsite
);
287 // enum for the LLVM IntPredicate type
288 #[derive(Copy, Clone)]
289 pub enum IntPredicate
{
302 // enum for the LLVM RealPredicate type
303 #[derive(Copy, Clone)]
304 pub enum RealPredicate
{
305 RealPredicateFalse
= 0,
320 RealPredicateTrue
= 15,
323 // The LLVM TypeKind type - must stay in sync with the def of
324 // LLVMTypeKind in llvm/include/llvm-c/Core.h
325 #[derive(Copy, Clone, PartialEq, Debug)]
347 #[derive(Copy, Clone)]
348 pub enum AtomicBinOp
{
363 #[derive(Copy, Clone)]
364 pub enum AtomicOrdering
{
368 // Consume = 3, // Not specified yet.
372 SequentiallyConsistent
= 7
376 #[derive(Copy, Clone)]
377 pub enum SynchronizationScope
{
382 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
384 #[derive(Copy, Clone)]
386 AssemblyFileType
= 0,
390 #[derive(Copy, Clone)]
391 pub enum MetadataType
{
398 MD_invariant_load
= 6,
402 MD_mem_parallel_loop_access
= 10,
406 // Inline Asm Dialect
407 #[derive(Copy, Clone)]
408 pub enum AsmDialect
{
413 #[derive(Copy, Clone, PartialEq)]
415 pub enum CodeGenOptLevel
{
416 CodeGenLevelNone
= 0,
417 CodeGenLevelLess
= 1,
418 CodeGenLevelDefault
= 2,
419 CodeGenLevelAggressive
= 3,
422 #[derive(Copy, Clone, PartialEq)]
428 RelocDynamicNoPic
= 3,
432 #[derive(Copy, Clone)]
433 pub enum CodeGenModel
{
434 CodeModelDefault
= 0,
435 CodeModelJITDefault
= 1,
443 #[derive(Copy, Clone)]
444 pub enum DiagnosticKind
{
447 DK_DebugMetadataVersion
,
449 DK_OptimizationRemark
,
450 DK_OptimizationRemarkMissed
,
451 DK_OptimizationRemarkAnalysis
,
452 DK_OptimizationFailure
,
456 #[derive(Copy, Clone)]
457 pub enum ArchiveKind
{
464 /// Represents the different LLVM passes Rust supports
465 #[derive(Copy, Clone, PartialEq, Debug)]
467 pub enum SupportedPassKind
{
473 // Opaque pointer types
474 #[allow(missing_copy_implementations)]
475 pub enum Module_opaque {}
476 pub type ModuleRef
= *mut Module_opaque
;
477 #[allow(missing_copy_implementations)]
478 pub enum Context_opaque {}
479 pub type ContextRef
= *mut Context_opaque
;
480 #[allow(missing_copy_implementations)]
481 pub enum Type_opaque {}
482 pub type TypeRef
= *mut Type_opaque
;
483 #[allow(missing_copy_implementations)]
484 pub enum Value_opaque {}
485 pub type ValueRef
= *mut Value_opaque
;
486 #[allow(missing_copy_implementations)]
487 pub enum Metadata_opaque {}
488 pub type MetadataRef
= *mut Metadata_opaque
;
489 #[allow(missing_copy_implementations)]
490 pub enum BasicBlock_opaque {}
491 pub type BasicBlockRef
= *mut BasicBlock_opaque
;
492 #[allow(missing_copy_implementations)]
493 pub enum Builder_opaque {}
494 pub type BuilderRef
= *mut Builder_opaque
;
495 #[allow(missing_copy_implementations)]
496 pub enum ExecutionEngine_opaque {}
497 pub type ExecutionEngineRef
= *mut ExecutionEngine_opaque
;
498 #[allow(missing_copy_implementations)]
499 pub enum MemoryBuffer_opaque {}
500 pub type MemoryBufferRef
= *mut MemoryBuffer_opaque
;
501 #[allow(missing_copy_implementations)]
502 pub enum PassManager_opaque {}
503 pub type PassManagerRef
= *mut PassManager_opaque
;
504 #[allow(missing_copy_implementations)]
505 pub enum PassManagerBuilder_opaque {}
506 pub type PassManagerBuilderRef
= *mut PassManagerBuilder_opaque
;
507 #[allow(missing_copy_implementations)]
508 pub enum Use_opaque {}
509 pub type UseRef
= *mut Use_opaque
;
510 #[allow(missing_copy_implementations)]
511 pub enum TargetData_opaque {}
512 pub type TargetDataRef
= *mut TargetData_opaque
;
513 #[allow(missing_copy_implementations)]
514 pub enum ObjectFile_opaque {}
515 pub type ObjectFileRef
= *mut ObjectFile_opaque
;
516 #[allow(missing_copy_implementations)]
517 pub enum SectionIterator_opaque {}
518 pub type SectionIteratorRef
= *mut SectionIterator_opaque
;
519 #[allow(missing_copy_implementations)]
520 pub enum Pass_opaque {}
521 pub type PassRef
= *mut Pass_opaque
;
522 #[allow(missing_copy_implementations)]
523 pub enum TargetMachine_opaque {}
524 pub type TargetMachineRef
= *mut TargetMachine_opaque
;
525 pub enum Archive_opaque {}
526 pub type ArchiveRef
= *mut Archive_opaque
;
527 pub enum ArchiveIterator_opaque {}
528 pub type ArchiveIteratorRef
= *mut ArchiveIterator_opaque
;
529 pub enum ArchiveChild_opaque {}
530 pub type ArchiveChildRef
= *mut ArchiveChild_opaque
;
531 #[allow(missing_copy_implementations)]
532 pub enum Twine_opaque {}
533 pub type TwineRef
= *mut Twine_opaque
;
534 #[allow(missing_copy_implementations)]
535 pub enum DiagnosticInfo_opaque {}
536 pub type DiagnosticInfoRef
= *mut DiagnosticInfo_opaque
;
537 #[allow(missing_copy_implementations)]
538 pub enum DebugLoc_opaque {}
539 pub type DebugLocRef
= *mut DebugLoc_opaque
;
540 #[allow(missing_copy_implementations)]
541 pub enum SMDiagnostic_opaque {}
542 pub type SMDiagnosticRef
= *mut SMDiagnostic_opaque
;
543 #[allow(missing_copy_implementations)]
544 pub enum RustArchiveMember_opaque {}
545 pub type RustArchiveMemberRef
= *mut RustArchiveMember_opaque
;
546 #[allow(missing_copy_implementations)]
547 pub enum OperandBundleDef_opaque {}
548 pub type OperandBundleDefRef
= *mut OperandBundleDef_opaque
;
550 pub type DiagnosticHandler
= unsafe extern "C" fn(DiagnosticInfoRef
, *mut c_void
);
551 pub type InlineAsmDiagHandler
= unsafe extern "C" fn(SMDiagnosticRef
, *const c_void
, c_uint
);
554 pub use self::DIDescriptorFlags
::*;
555 use super::{MetadataRef}
;
557 #[allow(missing_copy_implementations)]
558 pub enum DIBuilder_opaque {}
559 pub type DIBuilderRef
= *mut DIBuilder_opaque
;
561 pub type DIDescriptor
= MetadataRef
;
562 pub type DIScope
= DIDescriptor
;
563 pub type DILocation
= DIDescriptor
;
564 pub type DIFile
= DIScope
;
565 pub type DILexicalBlock
= DIScope
;
566 pub type DISubprogram
= DIScope
;
567 pub type DINameSpace
= DIScope
;
568 pub type DIType
= DIDescriptor
;
569 pub type DIBasicType
= DIType
;
570 pub type DIDerivedType
= DIType
;
571 pub type DICompositeType
= DIDerivedType
;
572 pub type DIVariable
= DIDescriptor
;
573 pub type DIGlobalVariable
= DIDescriptor
;
574 pub type DIArray
= DIDescriptor
;
575 pub type DISubrange
= DIDescriptor
;
576 pub type DIEnumerator
= DIDescriptor
;
577 pub type DITemplateTypeParameter
= DIDescriptor
;
579 #[derive(Copy, Clone)]
580 pub enum DIDescriptorFlags
{
581 FlagPrivate
= 1 << 0,
582 FlagProtected
= 1 << 1,
583 FlagFwdDecl
= 1 << 2,
584 FlagAppleBlock
= 1 << 3,
585 FlagBlockByrefStruct
= 1 << 4,
586 FlagVirtual
= 1 << 5,
587 FlagArtificial
= 1 << 6,
588 FlagExplicit
= 1 << 7,
589 FlagPrototyped
= 1 << 8,
590 FlagObjcClassComplete
= 1 << 9,
591 FlagObjectPointer
= 1 << 10,
592 FlagVector
= 1 << 11,
593 FlagStaticMember
= 1 << 12,
594 FlagIndirectVariable
= 1 << 13,
595 FlagLValueReference
= 1 << 14,
596 FlagRValueReference
= 1 << 15
601 // Link to our native llvm bindings (things that we need to use the C++ api
602 // for) and because llvm is written in C++ we need to link against libstdc++
604 // You'll probably notice that there is an omission of all LLVM libraries
605 // from this location. This is because the set of LLVM libraries that we
606 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
607 // figure out the exact set of libraries. To do this, the build system
608 // generates an llvmdeps.rs file next to this one which will be
609 // automatically updated whenever LLVM is updated to include an up-to-date
610 // set of the libraries we need to link to LLVM for.
611 #[link(name = "rustllvm", kind = "static")]
612 #[cfg(not(cargobuild))]
615 #[linked_from = "rustllvm"] // not quite true but good enough
617 /* Create and destroy contexts. */
618 pub fn LLVMContextCreate() -> ContextRef
;
619 pub fn LLVMContextDispose(C
: ContextRef
);
620 pub fn LLVMGetMDKindIDInContext(C
: ContextRef
,
625 /* Create and destroy modules. */
626 pub fn LLVMModuleCreateWithNameInContext(ModuleID
: *const c_char
,
629 pub fn LLVMGetModuleContext(M
: ModuleRef
) -> ContextRef
;
630 pub fn LLVMCloneModule(M
: ModuleRef
) -> ModuleRef
;
631 pub fn LLVMDisposeModule(M
: ModuleRef
);
633 /// Data layout. See Module::getDataLayout.
634 pub fn LLVMGetDataLayout(M
: ModuleRef
) -> *const c_char
;
635 pub fn LLVMSetDataLayout(M
: ModuleRef
, Triple
: *const c_char
);
637 /// Target triple. See Module::getTargetTriple.
638 pub fn LLVMGetTarget(M
: ModuleRef
) -> *const c_char
;
639 pub fn LLVMSetTarget(M
: ModuleRef
, Triple
: *const c_char
);
641 /// See Module::dump.
642 pub fn LLVMDumpModule(M
: ModuleRef
);
644 /// See Module::setModuleInlineAsm.
645 pub fn LLVMSetModuleInlineAsm(M
: ModuleRef
, Asm
: *const c_char
);
647 /// See llvm::LLVMTypeKind::getTypeID.
648 pub fn LLVMGetTypeKind(Ty
: TypeRef
) -> TypeKind
;
650 /// See llvm::LLVMType::getContext.
651 pub fn LLVMGetTypeContext(Ty
: TypeRef
) -> ContextRef
;
653 /* Operations on integer types */
654 pub fn LLVMInt1TypeInContext(C
: ContextRef
) -> TypeRef
;
655 pub fn LLVMInt8TypeInContext(C
: ContextRef
) -> TypeRef
;
656 pub fn LLVMInt16TypeInContext(C
: ContextRef
) -> TypeRef
;
657 pub fn LLVMInt32TypeInContext(C
: ContextRef
) -> TypeRef
;
658 pub fn LLVMInt64TypeInContext(C
: ContextRef
) -> TypeRef
;
659 pub fn LLVMIntTypeInContext(C
: ContextRef
, NumBits
: c_uint
)
662 pub fn LLVMGetIntTypeWidth(IntegerTy
: TypeRef
) -> c_uint
;
664 /* Operations on real types */
665 pub fn LLVMFloatTypeInContext(C
: ContextRef
) -> TypeRef
;
666 pub fn LLVMDoubleTypeInContext(C
: ContextRef
) -> TypeRef
;
667 pub fn LLVMX86FP80TypeInContext(C
: ContextRef
) -> TypeRef
;
668 pub fn LLVMFP128TypeInContext(C
: ContextRef
) -> TypeRef
;
669 pub fn LLVMPPCFP128TypeInContext(C
: ContextRef
) -> TypeRef
;
671 /* Operations on function types */
672 pub fn LLVMFunctionType(ReturnType
: TypeRef
,
673 ParamTypes
: *const TypeRef
,
677 pub fn LLVMIsFunctionVarArg(FunctionTy
: TypeRef
) -> Bool
;
678 pub fn LLVMGetReturnType(FunctionTy
: TypeRef
) -> TypeRef
;
679 pub fn LLVMCountParamTypes(FunctionTy
: TypeRef
) -> c_uint
;
680 pub fn LLVMGetParamTypes(FunctionTy
: TypeRef
, Dest
: *mut TypeRef
);
682 /* Operations on struct types */
683 pub fn LLVMStructTypeInContext(C
: ContextRef
,
684 ElementTypes
: *const TypeRef
,
685 ElementCount
: c_uint
,
688 pub fn LLVMCountStructElementTypes(StructTy
: TypeRef
) -> c_uint
;
689 pub fn LLVMGetStructElementTypes(StructTy
: TypeRef
,
691 pub fn LLVMIsPackedStruct(StructTy
: TypeRef
) -> Bool
;
693 /* Operations on array, pointer, and vector types (sequence types) */
694 pub fn LLVMRustArrayType(ElementType
: TypeRef
, ElementCount
: u64) -> TypeRef
;
695 pub fn LLVMPointerType(ElementType
: TypeRef
, AddressSpace
: c_uint
)
697 pub fn LLVMVectorType(ElementType
: TypeRef
, ElementCount
: c_uint
)
700 pub fn LLVMGetElementType(Ty
: TypeRef
) -> TypeRef
;
701 pub fn LLVMGetArrayLength(ArrayTy
: TypeRef
) -> c_uint
;
702 pub fn LLVMGetPointerAddressSpace(PointerTy
: TypeRef
) -> c_uint
;
703 pub fn LLVMGetPointerToGlobal(EE
: ExecutionEngineRef
, V
: ValueRef
)
705 pub fn LLVMGetVectorSize(VectorTy
: TypeRef
) -> c_uint
;
707 /* Operations on other types */
708 pub fn LLVMVoidTypeInContext(C
: ContextRef
) -> TypeRef
;
709 pub fn LLVMLabelTypeInContext(C
: ContextRef
) -> TypeRef
;
710 pub fn LLVMMetadataTypeInContext(C
: ContextRef
) -> TypeRef
;
712 /* Operations on all values */
713 pub fn LLVMTypeOf(Val
: ValueRef
) -> TypeRef
;
714 pub fn LLVMGetValueName(Val
: ValueRef
) -> *const c_char
;
715 pub fn LLVMSetValueName(Val
: ValueRef
, Name
: *const c_char
);
716 pub fn LLVMDumpValue(Val
: ValueRef
);
717 pub fn LLVMReplaceAllUsesWith(OldVal
: ValueRef
, NewVal
: ValueRef
);
718 pub fn LLVMHasMetadata(Val
: ValueRef
) -> c_int
;
719 pub fn LLVMGetMetadata(Val
: ValueRef
, KindID
: c_uint
) -> ValueRef
;
720 pub fn LLVMSetMetadata(Val
: ValueRef
, KindID
: c_uint
, Node
: ValueRef
);
722 /* Operations on Uses */
723 pub fn LLVMGetFirstUse(Val
: ValueRef
) -> UseRef
;
724 pub fn LLVMGetNextUse(U
: UseRef
) -> UseRef
;
725 pub fn LLVMGetUser(U
: UseRef
) -> ValueRef
;
726 pub fn LLVMGetUsedValue(U
: UseRef
) -> ValueRef
;
728 /* Operations on Users */
729 pub fn LLVMGetNumOperands(Val
: ValueRef
) -> c_int
;
730 pub fn LLVMGetOperand(Val
: ValueRef
, Index
: c_uint
) -> ValueRef
;
731 pub fn LLVMSetOperand(Val
: ValueRef
, Index
: c_uint
, Op
: ValueRef
);
733 /* Operations on constants of any type */
734 pub fn LLVMConstNull(Ty
: TypeRef
) -> ValueRef
;
736 pub fn LLVMConstAllOnes(Ty
: TypeRef
) -> ValueRef
;
737 pub fn LLVMConstICmp(Pred
: c_ushort
, V1
: ValueRef
, V2
: ValueRef
)
739 pub fn LLVMConstFCmp(Pred
: c_ushort
, V1
: ValueRef
, V2
: ValueRef
)
741 /* only for isize/vector */
742 pub fn LLVMGetUndef(Ty
: TypeRef
) -> ValueRef
;
743 pub fn LLVMIsConstant(Val
: ValueRef
) -> Bool
;
744 pub fn LLVMIsNull(Val
: ValueRef
) -> Bool
;
745 pub fn LLVMIsUndef(Val
: ValueRef
) -> Bool
;
746 pub fn LLVMConstPointerNull(Ty
: TypeRef
) -> ValueRef
;
748 /* Operations on metadata */
749 pub fn LLVMMDStringInContext(C
: ContextRef
,
753 pub fn LLVMMDNodeInContext(C
: ContextRef
,
754 Vals
: *const ValueRef
,
757 pub fn LLVMAddNamedMetadataOperand(M
: ModuleRef
,
761 /* Operations on scalar constants */
762 pub fn LLVMConstInt(IntTy
: TypeRef
, N
: c_ulonglong
, SignExtend
: Bool
)
764 pub fn LLVMConstIntOfString(IntTy
: TypeRef
, Text
: *const c_char
, Radix
: u8)
766 pub fn LLVMConstIntOfStringAndSize(IntTy
: TypeRef
,
771 pub fn LLVMConstReal(RealTy
: TypeRef
, N
: f64) -> ValueRef
;
772 pub fn LLVMConstRealOfString(RealTy
: TypeRef
, Text
: *const c_char
)
774 pub fn LLVMConstRealOfStringAndSize(RealTy
: TypeRef
,
778 pub fn LLVMConstIntGetZExtValue(ConstantVal
: ValueRef
) -> c_ulonglong
;
779 pub fn LLVMConstIntGetSExtValue(ConstantVal
: ValueRef
) -> c_longlong
;
782 /* Operations on composite constants */
783 pub fn LLVMConstStringInContext(C
: ContextRef
,
786 DontNullTerminate
: Bool
)
788 pub fn LLVMConstStructInContext(C
: ContextRef
,
789 ConstantVals
: *const ValueRef
,
794 pub fn LLVMConstArray(ElementTy
: TypeRef
,
795 ConstantVals
: *const ValueRef
,
798 pub fn LLVMConstVector(ScalarConstantVals
: *const ValueRef
, Size
: c_uint
)
801 /* Constant expressions */
802 pub fn LLVMAlignOf(Ty
: TypeRef
) -> ValueRef
;
803 pub fn LLVMSizeOf(Ty
: TypeRef
) -> ValueRef
;
804 pub fn LLVMConstNeg(ConstantVal
: ValueRef
) -> ValueRef
;
805 pub fn LLVMConstNSWNeg(ConstantVal
: ValueRef
) -> ValueRef
;
806 pub fn LLVMConstNUWNeg(ConstantVal
: ValueRef
) -> ValueRef
;
807 pub fn LLVMConstFNeg(ConstantVal
: ValueRef
) -> ValueRef
;
808 pub fn LLVMConstNot(ConstantVal
: ValueRef
) -> ValueRef
;
809 pub fn LLVMConstAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
811 pub fn LLVMConstNSWAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
813 pub fn LLVMConstNUWAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
815 pub fn LLVMConstFAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
817 pub fn LLVMConstSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
819 pub fn LLVMConstNSWSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
821 pub fn LLVMConstNUWSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
823 pub fn LLVMConstFSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
825 pub fn LLVMConstMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
827 pub fn LLVMConstNSWMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
829 pub fn LLVMConstNUWMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
831 pub fn LLVMConstFMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
833 pub fn LLVMConstUDiv(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
835 pub fn LLVMConstSDiv(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
837 pub fn LLVMConstExactSDiv(LHSConstant
: ValueRef
,
838 RHSConstant
: ValueRef
)
840 pub fn LLVMConstFDiv(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
842 pub fn LLVMConstURem(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
844 pub fn LLVMConstSRem(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
846 pub fn LLVMConstFRem(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
848 pub fn LLVMConstAnd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
850 pub fn LLVMConstOr(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
852 pub fn LLVMConstXor(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
854 pub fn LLVMConstShl(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
856 pub fn LLVMConstLShr(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
858 pub fn LLVMConstAShr(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
860 pub fn LLVMConstGEP(ConstantVal
: ValueRef
,
861 ConstantIndices
: *const ValueRef
,
864 pub fn LLVMConstInBoundsGEP(ConstantVal
: ValueRef
,
865 ConstantIndices
: *const ValueRef
,
868 pub fn LLVMConstTrunc(ConstantVal
: ValueRef
, ToType
: TypeRef
)
870 pub fn LLVMConstSExt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
872 pub fn LLVMConstZExt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
874 pub fn LLVMConstFPTrunc(ConstantVal
: ValueRef
, ToType
: TypeRef
)
876 pub fn LLVMConstFPExt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
878 pub fn LLVMConstUIToFP(ConstantVal
: ValueRef
, ToType
: TypeRef
)
880 pub fn LLVMConstSIToFP(ConstantVal
: ValueRef
, ToType
: TypeRef
)
882 pub fn LLVMConstFPToUI(ConstantVal
: ValueRef
, ToType
: TypeRef
)
884 pub fn LLVMConstFPToSI(ConstantVal
: ValueRef
, ToType
: TypeRef
)
886 pub fn LLVMConstPtrToInt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
888 pub fn LLVMConstIntToPtr(ConstantVal
: ValueRef
, ToType
: TypeRef
)
890 pub fn LLVMConstBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
892 pub fn LLVMConstZExtOrBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
894 pub fn LLVMConstSExtOrBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
896 pub fn LLVMConstTruncOrBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
898 pub fn LLVMConstPointerCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
900 pub fn LLVMConstIntCast(ConstantVal
: ValueRef
,
904 pub fn LLVMConstFPCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
906 pub fn LLVMConstSelect(ConstantCondition
: ValueRef
,
907 ConstantIfTrue
: ValueRef
,
908 ConstantIfFalse
: ValueRef
)
910 pub fn LLVMConstExtractElement(VectorConstant
: ValueRef
,
911 IndexConstant
: ValueRef
)
913 pub fn LLVMConstInsertElement(VectorConstant
: ValueRef
,
914 ElementValueConstant
: ValueRef
,
915 IndexConstant
: ValueRef
)
917 pub fn LLVMConstShuffleVector(VectorAConstant
: ValueRef
,
918 VectorBConstant
: ValueRef
,
919 MaskConstant
: ValueRef
)
921 pub fn LLVMConstExtractValue(AggConstant
: ValueRef
,
922 IdxList
: *const c_uint
,
925 pub fn LLVMConstInsertValue(AggConstant
: ValueRef
,
926 ElementValueConstant
: ValueRef
,
927 IdxList
: *const c_uint
,
930 pub fn LLVMConstInlineAsm(Ty
: TypeRef
,
931 AsmString
: *const c_char
,
932 Constraints
: *const c_char
,
933 HasSideEffects
: Bool
,
936 pub fn LLVMBlockAddress(F
: ValueRef
, BB
: BasicBlockRef
) -> ValueRef
;
940 /* Operations on global variables, functions, and aliases (globals) */
941 pub fn LLVMGetGlobalParent(Global
: ValueRef
) -> ModuleRef
;
942 pub fn LLVMIsDeclaration(Global
: ValueRef
) -> Bool
;
943 pub fn LLVMGetLinkage(Global
: ValueRef
) -> c_uint
;
944 pub fn LLVMSetLinkage(Global
: ValueRef
, Link
: c_uint
);
945 pub fn LLVMGetSection(Global
: ValueRef
) -> *const c_char
;
946 pub fn LLVMSetSection(Global
: ValueRef
, Section
: *const c_char
);
947 pub fn LLVMGetVisibility(Global
: ValueRef
) -> c_uint
;
948 pub fn LLVMSetVisibility(Global
: ValueRef
, Viz
: c_uint
);
949 pub fn LLVMGetAlignment(Global
: ValueRef
) -> c_uint
;
950 pub fn LLVMSetAlignment(Global
: ValueRef
, Bytes
: c_uint
);
953 /* Operations on global variables */
954 pub fn LLVMIsAGlobalVariable(GlobalVar
: ValueRef
) -> ValueRef
;
955 pub fn LLVMAddGlobal(M
: ModuleRef
, Ty
: TypeRef
, Name
: *const c_char
)
957 pub fn LLVMAddGlobalInAddressSpace(M
: ModuleRef
,
960 AddressSpace
: c_uint
)
962 pub fn LLVMGetNamedGlobal(M
: ModuleRef
, Name
: *const c_char
) -> ValueRef
;
963 pub fn LLVMGetOrInsertGlobal(M
: ModuleRef
, Name
: *const c_char
, T
: TypeRef
) -> ValueRef
;
964 pub fn LLVMGetFirstGlobal(M
: ModuleRef
) -> ValueRef
;
965 pub fn LLVMGetLastGlobal(M
: ModuleRef
) -> ValueRef
;
966 pub fn LLVMGetNextGlobal(GlobalVar
: ValueRef
) -> ValueRef
;
967 pub fn LLVMGetPreviousGlobal(GlobalVar
: ValueRef
) -> ValueRef
;
968 pub fn LLVMDeleteGlobal(GlobalVar
: ValueRef
);
969 pub fn LLVMGetInitializer(GlobalVar
: ValueRef
) -> ValueRef
;
970 pub fn LLVMSetInitializer(GlobalVar
: ValueRef
,
971 ConstantVal
: ValueRef
);
972 pub fn LLVMIsThreadLocal(GlobalVar
: ValueRef
) -> Bool
;
973 pub fn LLVMSetThreadLocal(GlobalVar
: ValueRef
, IsThreadLocal
: Bool
);
974 pub fn LLVMIsGlobalConstant(GlobalVar
: ValueRef
) -> Bool
;
975 pub fn LLVMSetGlobalConstant(GlobalVar
: ValueRef
, IsConstant
: Bool
);
976 pub fn LLVMGetNamedValue(M
: ModuleRef
, Name
: *const c_char
) -> ValueRef
;
978 /* Operations on aliases */
979 pub fn LLVMAddAlias(M
: ModuleRef
,
985 /* Operations on functions */
986 pub fn LLVMAddFunction(M
: ModuleRef
,
990 pub fn LLVMGetNamedFunction(M
: ModuleRef
, Name
: *const c_char
) -> ValueRef
;
991 pub fn LLVMGetFirstFunction(M
: ModuleRef
) -> ValueRef
;
992 pub fn LLVMGetLastFunction(M
: ModuleRef
) -> ValueRef
;
993 pub fn LLVMGetNextFunction(Fn
: ValueRef
) -> ValueRef
;
994 pub fn LLVMGetPreviousFunction(Fn
: ValueRef
) -> ValueRef
;
995 pub fn LLVMDeleteFunction(Fn
: ValueRef
);
996 pub fn LLVMGetOrInsertFunction(M
: ModuleRef
,
1000 pub fn LLVMGetIntrinsicID(Fn
: ValueRef
) -> c_uint
;
1001 pub fn LLVMGetFunctionCallConv(Fn
: ValueRef
) -> c_uint
;
1002 pub fn LLVMSetFunctionCallConv(Fn
: ValueRef
, CC
: c_uint
);
1003 pub fn LLVMGetGC(Fn
: ValueRef
) -> *const c_char
;
1004 pub fn LLVMSetGC(Fn
: ValueRef
, Name
: *const c_char
);
1005 pub fn LLVMAddDereferenceableAttr(Fn
: ValueRef
, index
: c_uint
, bytes
: uint64_t
);
1006 pub fn LLVMAddFunctionAttribute(Fn
: ValueRef
, index
: c_uint
, PA
: uint64_t
);
1007 pub fn LLVMAddFunctionAttrString(Fn
: ValueRef
, index
: c_uint
, Name
: *const c_char
);
1008 pub fn LLVMAddFunctionAttrStringValue(Fn
: ValueRef
, index
: c_uint
,
1009 Name
: *const c_char
,
1010 Value
: *const c_char
);
1011 pub fn LLVMRemoveFunctionAttrString(Fn
: ValueRef
, index
: c_uint
, Name
: *const c_char
);
1012 pub fn LLVMGetFunctionAttr(Fn
: ValueRef
) -> c_ulonglong
;
1013 pub fn LLVMRemoveFunctionAttr(Fn
: ValueRef
, val
: c_ulonglong
);
1015 /* Operations on parameters */
1016 pub fn LLVMCountParams(Fn
: ValueRef
) -> c_uint
;
1017 pub fn LLVMGetParams(Fn
: ValueRef
, Params
: *const ValueRef
);
1018 pub fn LLVMGetParam(Fn
: ValueRef
, Index
: c_uint
) -> ValueRef
;
1019 pub fn LLVMGetParamParent(Inst
: ValueRef
) -> ValueRef
;
1020 pub fn LLVMGetFirstParam(Fn
: ValueRef
) -> ValueRef
;
1021 pub fn LLVMGetLastParam(Fn
: ValueRef
) -> ValueRef
;
1022 pub fn LLVMGetNextParam(Arg
: ValueRef
) -> ValueRef
;
1023 pub fn LLVMGetPreviousParam(Arg
: ValueRef
) -> ValueRef
;
1024 pub fn LLVMAddAttribute(Arg
: ValueRef
, PA
: c_uint
);
1025 pub fn LLVMRemoveAttribute(Arg
: ValueRef
, PA
: c_uint
);
1026 pub fn LLVMGetAttribute(Arg
: ValueRef
) -> c_uint
;
1027 pub fn LLVMSetParamAlignment(Arg
: ValueRef
, align
: c_uint
);
1029 /* Operations on basic blocks */
1030 pub fn LLVMBasicBlockAsValue(BB
: BasicBlockRef
) -> ValueRef
;
1031 pub fn LLVMValueIsBasicBlock(Val
: ValueRef
) -> Bool
;
1032 pub fn LLVMValueAsBasicBlock(Val
: ValueRef
) -> BasicBlockRef
;
1033 pub fn LLVMGetBasicBlockParent(BB
: BasicBlockRef
) -> ValueRef
;
1034 pub fn LLVMCountBasicBlocks(Fn
: ValueRef
) -> c_uint
;
1035 pub fn LLVMGetBasicBlocks(Fn
: ValueRef
, BasicBlocks
: *const ValueRef
);
1036 pub fn LLVMGetFirstBasicBlock(Fn
: ValueRef
) -> BasicBlockRef
;
1037 pub fn LLVMGetLastBasicBlock(Fn
: ValueRef
) -> BasicBlockRef
;
1038 pub fn LLVMGetNextBasicBlock(BB
: BasicBlockRef
) -> BasicBlockRef
;
1039 pub fn LLVMGetPreviousBasicBlock(BB
: BasicBlockRef
) -> BasicBlockRef
;
1040 pub fn LLVMGetEntryBasicBlock(Fn
: ValueRef
) -> BasicBlockRef
;
1042 pub fn LLVMAppendBasicBlockInContext(C
: ContextRef
,
1044 Name
: *const c_char
)
1046 pub fn LLVMInsertBasicBlockInContext(C
: ContextRef
,
1048 Name
: *const c_char
)
1050 pub fn LLVMDeleteBasicBlock(BB
: BasicBlockRef
);
1052 pub fn LLVMMoveBasicBlockAfter(BB
: BasicBlockRef
,
1053 MoveAfter
: BasicBlockRef
);
1055 pub fn LLVMMoveBasicBlockBefore(BB
: BasicBlockRef
,
1056 MoveBefore
: BasicBlockRef
);
1058 /* Operations on instructions */
1059 pub fn LLVMGetInstructionParent(Inst
: ValueRef
) -> BasicBlockRef
;
1060 pub fn LLVMGetFirstInstruction(BB
: BasicBlockRef
) -> ValueRef
;
1061 pub fn LLVMGetLastInstruction(BB
: BasicBlockRef
) -> ValueRef
;
1062 pub fn LLVMGetNextInstruction(Inst
: ValueRef
) -> ValueRef
;
1063 pub fn LLVMGetPreviousInstruction(Inst
: ValueRef
) -> ValueRef
;
1064 pub fn LLVMInstructionEraseFromParent(Inst
: ValueRef
);
1066 /* Operations on call sites */
1067 pub fn LLVMSetInstructionCallConv(Instr
: ValueRef
, CC
: c_uint
);
1068 pub fn LLVMGetInstructionCallConv(Instr
: ValueRef
) -> c_uint
;
1069 pub fn LLVMAddInstrAttribute(Instr
: ValueRef
,
1072 pub fn LLVMRemoveInstrAttribute(Instr
: ValueRef
,
1075 pub fn LLVMSetInstrParamAlignment(Instr
: ValueRef
,
1078 pub fn LLVMAddCallSiteAttribute(Instr
: ValueRef
,
1081 pub fn LLVMAddDereferenceableCallSiteAttr(Instr
: ValueRef
,
1085 /* Operations on call instructions (only) */
1086 pub fn LLVMIsTailCall(CallInst
: ValueRef
) -> Bool
;
1087 pub fn LLVMSetTailCall(CallInst
: ValueRef
, IsTailCall
: Bool
);
1089 /* Operations on load/store instructions (only) */
1090 pub fn LLVMGetVolatile(MemoryAccessInst
: ValueRef
) -> Bool
;
1091 pub fn LLVMSetVolatile(MemoryAccessInst
: ValueRef
, volatile
: Bool
);
1093 /* Operations on phi nodes */
1094 pub fn LLVMAddIncoming(PhiNode
: ValueRef
,
1095 IncomingValues
: *const ValueRef
,
1096 IncomingBlocks
: *const BasicBlockRef
,
1098 pub fn LLVMCountIncoming(PhiNode
: ValueRef
) -> c_uint
;
1099 pub fn LLVMGetIncomingValue(PhiNode
: ValueRef
, Index
: c_uint
)
1101 pub fn LLVMGetIncomingBlock(PhiNode
: ValueRef
, Index
: c_uint
)
1104 /* Instruction builders */
1105 pub fn LLVMCreateBuilderInContext(C
: ContextRef
) -> BuilderRef
;
1106 pub fn LLVMPositionBuilder(Builder
: BuilderRef
,
1107 Block
: BasicBlockRef
,
1109 pub fn LLVMPositionBuilderBefore(Builder
: BuilderRef
,
1111 pub fn LLVMPositionBuilderAtEnd(Builder
: BuilderRef
,
1112 Block
: BasicBlockRef
);
1113 pub fn LLVMGetInsertBlock(Builder
: BuilderRef
) -> BasicBlockRef
;
1114 pub fn LLVMClearInsertionPosition(Builder
: BuilderRef
);
1115 pub fn LLVMInsertIntoBuilder(Builder
: BuilderRef
, Instr
: ValueRef
);
1116 pub fn LLVMInsertIntoBuilderWithName(Builder
: BuilderRef
,
1118 Name
: *const c_char
);
1119 pub fn LLVMDisposeBuilder(Builder
: BuilderRef
);
1121 /* Execution engine */
1122 pub fn LLVMBuildExecutionEngine(Mod
: ModuleRef
) -> ExecutionEngineRef
;
1123 pub fn LLVMDisposeExecutionEngine(EE
: ExecutionEngineRef
);
1124 pub fn LLVMExecutionEngineFinalizeObject(EE
: ExecutionEngineRef
);
1125 pub fn LLVMRustLoadDynamicLibrary(path
: *const c_char
) -> Bool
;
1126 pub fn LLVMExecutionEngineAddModule(EE
: ExecutionEngineRef
, M
: ModuleRef
);
1127 pub fn LLVMExecutionEngineRemoveModule(EE
: ExecutionEngineRef
, M
: ModuleRef
)
1131 pub fn LLVMSetCurrentDebugLocation(Builder
: BuilderRef
, L
: ValueRef
);
1132 pub fn LLVMGetCurrentDebugLocation(Builder
: BuilderRef
) -> ValueRef
;
1133 pub fn LLVMSetInstDebugLocation(Builder
: BuilderRef
, Inst
: ValueRef
);
1136 pub fn LLVMBuildRetVoid(B
: BuilderRef
) -> ValueRef
;
1137 pub fn LLVMBuildRet(B
: BuilderRef
, V
: ValueRef
) -> ValueRef
;
1138 pub fn LLVMBuildAggregateRet(B
: BuilderRef
,
1139 RetVals
: *const ValueRef
,
1142 pub fn LLVMBuildBr(B
: BuilderRef
, Dest
: BasicBlockRef
) -> ValueRef
;
1143 pub fn LLVMBuildCondBr(B
: BuilderRef
,
1145 Then
: BasicBlockRef
,
1146 Else
: BasicBlockRef
)
1148 pub fn LLVMBuildSwitch(B
: BuilderRef
,
1150 Else
: BasicBlockRef
,
1153 pub fn LLVMBuildIndirectBr(B
: BuilderRef
,
1157 pub fn LLVMRustBuildInvoke(B
: BuilderRef
,
1159 Args
: *const ValueRef
,
1161 Then
: BasicBlockRef
,
1162 Catch
: BasicBlockRef
,
1163 Bundle
: OperandBundleDefRef
,
1164 Name
: *const c_char
)
1166 pub fn LLVMRustBuildLandingPad(B
: BuilderRef
,
1170 Name
: *const c_char
,
1173 pub fn LLVMBuildResume(B
: BuilderRef
, Exn
: ValueRef
) -> ValueRef
;
1174 pub fn LLVMBuildUnreachable(B
: BuilderRef
) -> ValueRef
;
1176 pub fn LLVMRustBuildCleanupPad(B
: BuilderRef
,
1177 ParentPad
: ValueRef
,
1179 Args
: *const ValueRef
,
1180 Name
: *const c_char
) -> ValueRef
;
1181 pub fn LLVMRustBuildCleanupRet(B
: BuilderRef
,
1182 CleanupPad
: ValueRef
,
1183 UnwindBB
: BasicBlockRef
) -> ValueRef
;
1184 pub fn LLVMRustBuildCatchPad(B
: BuilderRef
,
1185 ParentPad
: ValueRef
,
1187 Args
: *const ValueRef
,
1188 Name
: *const c_char
) -> ValueRef
;
1189 pub fn LLVMRustBuildCatchRet(B
: BuilderRef
,
1191 BB
: BasicBlockRef
) -> ValueRef
;
1192 pub fn LLVMRustBuildCatchSwitch(Builder
: BuilderRef
,
1193 ParentPad
: ValueRef
,
1195 NumHandlers
: c_uint
,
1196 Name
: *const c_char
) -> ValueRef
;
1197 pub fn LLVMRustAddHandler(CatchSwitch
: ValueRef
,
1198 Handler
: BasicBlockRef
);
1199 pub fn LLVMRustSetPersonalityFn(B
: BuilderRef
, Pers
: ValueRef
);
1201 /* Add a case to the switch instruction */
1202 pub fn LLVMAddCase(Switch
: ValueRef
,
1204 Dest
: BasicBlockRef
);
1206 /* Add a destination to the indirectbr instruction */
1207 pub fn LLVMAddDestination(IndirectBr
: ValueRef
, Dest
: BasicBlockRef
);
1209 /* Add a clause to the landing pad instruction */
1210 pub fn LLVMAddClause(LandingPad
: ValueRef
, ClauseVal
: ValueRef
);
1212 /* Set the cleanup on a landing pad instruction */
1213 pub fn LLVMSetCleanup(LandingPad
: ValueRef
, Val
: Bool
);
1216 pub fn LLVMBuildAdd(B
: BuilderRef
,
1219 Name
: *const c_char
)
1221 pub fn LLVMBuildNSWAdd(B
: BuilderRef
,
1224 Name
: *const c_char
)
1226 pub fn LLVMBuildNUWAdd(B
: BuilderRef
,
1229 Name
: *const c_char
)
1231 pub fn LLVMBuildFAdd(B
: BuilderRef
,
1234 Name
: *const c_char
)
1236 pub fn LLVMBuildSub(B
: BuilderRef
,
1239 Name
: *const c_char
)
1241 pub fn LLVMBuildNSWSub(B
: BuilderRef
,
1244 Name
: *const c_char
)
1246 pub fn LLVMBuildNUWSub(B
: BuilderRef
,
1249 Name
: *const c_char
)
1251 pub fn LLVMBuildFSub(B
: BuilderRef
,
1254 Name
: *const c_char
)
1256 pub fn LLVMBuildMul(B
: BuilderRef
,
1259 Name
: *const c_char
)
1261 pub fn LLVMBuildNSWMul(B
: BuilderRef
,
1264 Name
: *const c_char
)
1266 pub fn LLVMBuildNUWMul(B
: BuilderRef
,
1269 Name
: *const c_char
)
1271 pub fn LLVMBuildFMul(B
: BuilderRef
,
1274 Name
: *const c_char
)
1276 pub fn LLVMBuildUDiv(B
: BuilderRef
,
1279 Name
: *const c_char
)
1281 pub fn LLVMBuildSDiv(B
: BuilderRef
,
1284 Name
: *const c_char
)
1286 pub fn LLVMBuildExactSDiv(B
: BuilderRef
,
1289 Name
: *const c_char
)
1291 pub fn LLVMBuildFDiv(B
: BuilderRef
,
1294 Name
: *const c_char
)
1296 pub fn LLVMBuildURem(B
: BuilderRef
,
1299 Name
: *const c_char
)
1301 pub fn LLVMBuildSRem(B
: BuilderRef
,
1304 Name
: *const c_char
)
1306 pub fn LLVMBuildFRem(B
: BuilderRef
,
1309 Name
: *const c_char
)
1311 pub fn LLVMBuildShl(B
: BuilderRef
,
1314 Name
: *const c_char
)
1316 pub fn LLVMBuildLShr(B
: BuilderRef
,
1319 Name
: *const c_char
)
1321 pub fn LLVMBuildAShr(B
: BuilderRef
,
1324 Name
: *const c_char
)
1326 pub fn LLVMBuildAnd(B
: BuilderRef
,
1329 Name
: *const c_char
)
1331 pub fn LLVMBuildOr(B
: BuilderRef
,
1334 Name
: *const c_char
)
1336 pub fn LLVMBuildXor(B
: BuilderRef
,
1339 Name
: *const c_char
)
1341 pub fn LLVMBuildBinOp(B
: BuilderRef
,
1345 Name
: *const c_char
)
1347 pub fn LLVMBuildNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1349 pub fn LLVMBuildNSWNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1351 pub fn LLVMBuildNUWNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1353 pub fn LLVMBuildFNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1355 pub fn LLVMBuildNot(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1359 pub fn LLVMBuildAlloca(B
: BuilderRef
, Ty
: TypeRef
, Name
: *const c_char
)
1361 pub fn LLVMBuildFree(B
: BuilderRef
, PointerVal
: ValueRef
) -> ValueRef
;
1362 pub fn LLVMBuildLoad(B
: BuilderRef
,
1363 PointerVal
: ValueRef
,
1364 Name
: *const c_char
)
1367 pub fn LLVMBuildStore(B
: BuilderRef
, Val
: ValueRef
, Ptr
: ValueRef
)
1370 pub fn LLVMBuildGEP(B
: BuilderRef
,
1372 Indices
: *const ValueRef
,
1374 Name
: *const c_char
)
1376 pub fn LLVMBuildInBoundsGEP(B
: BuilderRef
,
1378 Indices
: *const ValueRef
,
1380 Name
: *const c_char
)
1382 pub fn LLVMBuildStructGEP(B
: BuilderRef
,
1385 Name
: *const c_char
)
1387 pub fn LLVMBuildGlobalString(B
: BuilderRef
,
1389 Name
: *const c_char
)
1391 pub fn LLVMBuildGlobalStringPtr(B
: BuilderRef
,
1393 Name
: *const c_char
)
1397 pub fn LLVMBuildTrunc(B
: BuilderRef
,
1400 Name
: *const c_char
)
1402 pub fn LLVMBuildZExt(B
: BuilderRef
,
1405 Name
: *const c_char
)
1407 pub fn LLVMBuildSExt(B
: BuilderRef
,
1410 Name
: *const c_char
)
1412 pub fn LLVMBuildFPToUI(B
: BuilderRef
,
1415 Name
: *const c_char
)
1417 pub fn LLVMBuildFPToSI(B
: BuilderRef
,
1420 Name
: *const c_char
)
1422 pub fn LLVMBuildUIToFP(B
: BuilderRef
,
1425 Name
: *const c_char
)
1427 pub fn LLVMBuildSIToFP(B
: BuilderRef
,
1430 Name
: *const c_char
)
1432 pub fn LLVMBuildFPTrunc(B
: BuilderRef
,
1435 Name
: *const c_char
)
1437 pub fn LLVMBuildFPExt(B
: BuilderRef
,
1440 Name
: *const c_char
)
1442 pub fn LLVMBuildPtrToInt(B
: BuilderRef
,
1445 Name
: *const c_char
)
1447 pub fn LLVMBuildIntToPtr(B
: BuilderRef
,
1450 Name
: *const c_char
)
1452 pub fn LLVMBuildBitCast(B
: BuilderRef
,
1455 Name
: *const c_char
)
1457 pub fn LLVMBuildZExtOrBitCast(B
: BuilderRef
,
1460 Name
: *const c_char
)
1462 pub fn LLVMBuildSExtOrBitCast(B
: BuilderRef
,
1465 Name
: *const c_char
)
1467 pub fn LLVMBuildTruncOrBitCast(B
: BuilderRef
,
1470 Name
: *const c_char
)
1472 pub fn LLVMBuildCast(B
: BuilderRef
,
1476 Name
: *const c_char
) -> ValueRef
;
1477 pub fn LLVMBuildPointerCast(B
: BuilderRef
,
1480 Name
: *const c_char
)
1482 pub fn LLVMBuildIntCast(B
: BuilderRef
,
1485 Name
: *const c_char
)
1487 pub fn LLVMBuildFPCast(B
: BuilderRef
,
1490 Name
: *const c_char
)
1494 pub fn LLVMBuildICmp(B
: BuilderRef
,
1498 Name
: *const c_char
)
1500 pub fn LLVMBuildFCmp(B
: BuilderRef
,
1504 Name
: *const c_char
)
1507 /* Miscellaneous instructions */
1508 pub fn LLVMBuildPhi(B
: BuilderRef
, Ty
: TypeRef
, Name
: *const c_char
)
1510 pub fn LLVMRustBuildCall(B
: BuilderRef
,
1512 Args
: *const ValueRef
,
1514 Bundle
: OperandBundleDefRef
,
1515 Name
: *const c_char
)
1517 pub fn LLVMBuildSelect(B
: BuilderRef
,
1521 Name
: *const c_char
)
1523 pub fn LLVMBuildVAArg(B
: BuilderRef
,
1526 Name
: *const c_char
)
1528 pub fn LLVMBuildExtractElement(B
: BuilderRef
,
1531 Name
: *const c_char
)
1533 pub fn LLVMBuildInsertElement(B
: BuilderRef
,
1537 Name
: *const c_char
)
1539 pub fn LLVMBuildShuffleVector(B
: BuilderRef
,
1543 Name
: *const c_char
)
1545 pub fn LLVMBuildExtractValue(B
: BuilderRef
,
1548 Name
: *const c_char
)
1550 pub fn LLVMBuildInsertValue(B
: BuilderRef
,
1554 Name
: *const c_char
)
1557 pub fn LLVMBuildIsNull(B
: BuilderRef
, Val
: ValueRef
, Name
: *const c_char
)
1559 pub fn LLVMBuildIsNotNull(B
: BuilderRef
, Val
: ValueRef
, Name
: *const c_char
)
1561 pub fn LLVMBuildPtrDiff(B
: BuilderRef
,
1564 Name
: *const c_char
)
1567 /* Atomic Operations */
1568 pub fn LLVMBuildAtomicLoad(B
: BuilderRef
,
1569 PointerVal
: ValueRef
,
1570 Name
: *const c_char
,
1571 Order
: AtomicOrdering
,
1575 pub fn LLVMBuildAtomicStore(B
: BuilderRef
,
1578 Order
: AtomicOrdering
,
1582 pub fn LLVMBuildAtomicCmpXchg(B
: BuilderRef
,
1586 Order
: AtomicOrdering
,
1587 FailureOrder
: AtomicOrdering
,
1590 pub fn LLVMBuildAtomicRMW(B
: BuilderRef
,
1594 Order
: AtomicOrdering
,
1595 SingleThreaded
: Bool
)
1598 pub fn LLVMBuildAtomicFence(B
: BuilderRef
,
1599 Order
: AtomicOrdering
,
1600 Scope
: SynchronizationScope
);
1603 /* Selected entries from the downcasts. */
1604 pub fn LLVMIsATerminatorInst(Inst
: ValueRef
) -> ValueRef
;
1605 pub fn LLVMIsAStoreInst(Inst
: ValueRef
) -> ValueRef
;
1607 /// Writes a module to the specified path. Returns 0 on success.
1608 pub fn LLVMWriteBitcodeToFile(M
: ModuleRef
, Path
: *const c_char
) -> c_int
;
1610 /// Creates target data from a target layout string.
1611 pub fn LLVMCreateTargetData(StringRep
: *const c_char
) -> TargetDataRef
;
1612 /// Adds the target data to the given pass manager. The pass manager
1613 /// references the target data only weakly.
1614 pub fn LLVMAddTargetData(TD
: TargetDataRef
, PM
: PassManagerRef
);
1615 /// Number of bytes clobbered when doing a Store to *T.
1616 pub fn LLVMStoreSizeOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1619 /// Number of bytes clobbered when doing a Store to *T.
1620 pub fn LLVMSizeOfTypeInBits(TD
: TargetDataRef
, Ty
: TypeRef
)
1623 /// Distance between successive elements in an array of T. Includes ABI padding.
1624 pub fn LLVMABISizeOfType(TD
: TargetDataRef
, Ty
: TypeRef
) -> c_ulonglong
;
1626 /// Returns the preferred alignment of a type.
1627 pub fn LLVMPreferredAlignmentOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1629 /// Returns the minimum alignment of a type.
1630 pub fn LLVMABIAlignmentOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1633 /// Computes the byte offset of the indexed struct element for a
1635 pub fn LLVMOffsetOfElement(TD
: TargetDataRef
,
1640 /// Returns the minimum alignment of a type when part of a call frame.
1641 pub fn LLVMCallFrameAlignmentOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1644 /// Disposes target data.
1645 pub fn LLVMDisposeTargetData(TD
: TargetDataRef
);
1647 /// Creates a pass manager.
1648 pub fn LLVMCreatePassManager() -> PassManagerRef
;
1650 /// Creates a function-by-function pass manager
1651 pub fn LLVMCreateFunctionPassManagerForModule(M
: ModuleRef
)
1654 /// Disposes a pass manager.
1655 pub fn LLVMDisposePassManager(PM
: PassManagerRef
);
1657 /// Runs a pass manager on a module.
1658 pub fn LLVMRunPassManager(PM
: PassManagerRef
, M
: ModuleRef
) -> Bool
;
1660 /// Runs the function passes on the provided function.
1661 pub fn LLVMRunFunctionPassManager(FPM
: PassManagerRef
, F
: ValueRef
)
1664 /// Initializes all the function passes scheduled in the manager
1665 pub fn LLVMInitializeFunctionPassManager(FPM
: PassManagerRef
) -> Bool
;
1667 /// Finalizes all the function passes scheduled in the manager
1668 pub fn LLVMFinalizeFunctionPassManager(FPM
: PassManagerRef
) -> Bool
;
1670 pub fn LLVMInitializePasses();
1672 /// Adds a verification pass.
1673 pub fn LLVMAddVerifierPass(PM
: PassManagerRef
);
1675 pub fn LLVMAddGlobalOptimizerPass(PM
: PassManagerRef
);
1676 pub fn LLVMAddIPSCCPPass(PM
: PassManagerRef
);
1677 pub fn LLVMAddDeadArgEliminationPass(PM
: PassManagerRef
);
1678 pub fn LLVMAddInstructionCombiningPass(PM
: PassManagerRef
);
1679 pub fn LLVMAddCFGSimplificationPass(PM
: PassManagerRef
);
1680 pub fn LLVMAddFunctionInliningPass(PM
: PassManagerRef
);
1681 pub fn LLVMAddFunctionAttrsPass(PM
: PassManagerRef
);
1682 pub fn LLVMAddScalarReplAggregatesPass(PM
: PassManagerRef
);
1683 pub fn LLVMAddScalarReplAggregatesPassSSA(PM
: PassManagerRef
);
1684 pub fn LLVMAddJumpThreadingPass(PM
: PassManagerRef
);
1685 pub fn LLVMAddConstantPropagationPass(PM
: PassManagerRef
);
1686 pub fn LLVMAddReassociatePass(PM
: PassManagerRef
);
1687 pub fn LLVMAddLoopRotatePass(PM
: PassManagerRef
);
1688 pub fn LLVMAddLICMPass(PM
: PassManagerRef
);
1689 pub fn LLVMAddLoopUnswitchPass(PM
: PassManagerRef
);
1690 pub fn LLVMAddLoopDeletionPass(PM
: PassManagerRef
);
1691 pub fn LLVMAddLoopUnrollPass(PM
: PassManagerRef
);
1692 pub fn LLVMAddGVNPass(PM
: PassManagerRef
);
1693 pub fn LLVMAddMemCpyOptPass(PM
: PassManagerRef
);
1694 pub fn LLVMAddSCCPPass(PM
: PassManagerRef
);
1695 pub fn LLVMAddDeadStoreEliminationPass(PM
: PassManagerRef
);
1696 pub fn LLVMAddStripDeadPrototypesPass(PM
: PassManagerRef
);
1697 pub fn LLVMAddConstantMergePass(PM
: PassManagerRef
);
1698 pub fn LLVMAddArgumentPromotionPass(PM
: PassManagerRef
);
1699 pub fn LLVMAddTailCallEliminationPass(PM
: PassManagerRef
);
1700 pub fn LLVMAddIndVarSimplifyPass(PM
: PassManagerRef
);
1701 pub fn LLVMAddAggressiveDCEPass(PM
: PassManagerRef
);
1702 pub fn LLVMAddGlobalDCEPass(PM
: PassManagerRef
);
1703 pub fn LLVMAddCorrelatedValuePropagationPass(PM
: PassManagerRef
);
1704 pub fn LLVMAddPruneEHPass(PM
: PassManagerRef
);
1705 pub fn LLVMAddSimplifyLibCallsPass(PM
: PassManagerRef
);
1706 pub fn LLVMAddLoopIdiomPass(PM
: PassManagerRef
);
1707 pub fn LLVMAddEarlyCSEPass(PM
: PassManagerRef
);
1708 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM
: PassManagerRef
);
1709 pub fn LLVMAddBasicAliasAnalysisPass(PM
: PassManagerRef
);
1711 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef
;
1712 pub fn LLVMPassManagerBuilderDispose(PMB
: PassManagerBuilderRef
);
1713 pub fn LLVMPassManagerBuilderSetOptLevel(PMB
: PassManagerBuilderRef
,
1714 OptimizationLevel
: c_uint
);
1715 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB
: PassManagerBuilderRef
,
1717 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1718 PMB
: PassManagerBuilderRef
,
1720 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1721 PMB
: PassManagerBuilderRef
,
1723 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1724 PMB
: PassManagerBuilderRef
,
1726 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1727 PMB
: PassManagerBuilderRef
,
1729 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1730 PMB
: PassManagerBuilderRef
,
1731 PM
: PassManagerRef
);
1733 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1734 PMB
: PassManagerBuilderRef
,
1735 PM
: PassManagerRef
);
1736 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1737 PMB
: PassManagerBuilderRef
,
1742 /// Destroys a memory buffer.
1743 pub fn LLVMDisposeMemoryBuffer(MemBuf
: MemoryBufferRef
);
1746 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1748 /// Opens an object file.
1749 pub fn LLVMCreateObjectFile(MemBuf
: MemoryBufferRef
) -> ObjectFileRef
;
1750 /// Closes an object file.
1751 pub fn LLVMDisposeObjectFile(ObjFile
: ObjectFileRef
);
1753 /// Enumerates the sections in an object file.
1754 pub fn LLVMGetSections(ObjFile
: ObjectFileRef
) -> SectionIteratorRef
;
1755 /// Destroys a section iterator.
1756 pub fn LLVMDisposeSectionIterator(SI
: SectionIteratorRef
);
1757 /// Returns true if the section iterator is at the end of the section
1759 pub fn LLVMIsSectionIteratorAtEnd(ObjFile
: ObjectFileRef
,
1760 SI
: SectionIteratorRef
)
1762 /// Moves the section iterator to point to the next section.
1763 pub fn LLVMMoveToNextSection(SI
: SectionIteratorRef
);
1764 /// Returns the current section size.
1765 pub fn LLVMGetSectionSize(SI
: SectionIteratorRef
) -> c_ulonglong
;
1766 /// Returns the current section contents as a string buffer.
1767 pub fn LLVMGetSectionContents(SI
: SectionIteratorRef
) -> *const c_char
;
1769 /// Reads the given file and returns it as a memory buffer. Use
1770 /// LLVMDisposeMemoryBuffer() to get rid of it.
1771 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path
: *const c_char
)
1773 /// Borrows the contents of the memory buffer (doesn't copy it)
1774 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData
: *const c_char
,
1775 InputDataLength
: size_t
,
1776 BufferName
: *const c_char
,
1779 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData
: *const c_char
,
1780 InputDataLength
: size_t
,
1781 BufferName
: *const c_char
)
1784 pub fn LLVMIsMultithreaded() -> Bool
;
1785 pub fn LLVMStartMultithreaded() -> Bool
;
1787 /// Returns a string describing the last error caused by an LLVMRust* call.
1788 pub fn LLVMRustGetLastError() -> *const c_char
;
1790 /// Print the pass timings since static dtors aren't picking them up.
1791 pub fn LLVMRustPrintPassTimings();
1793 pub fn LLVMStructCreateNamed(C
: ContextRef
, Name
: *const c_char
) -> TypeRef
;
1795 pub fn LLVMStructSetBody(StructTy
: TypeRef
,
1796 ElementTypes
: *const TypeRef
,
1797 ElementCount
: c_uint
,
1800 pub fn LLVMConstNamedStruct(S
: TypeRef
,
1801 ConstantVals
: *const ValueRef
,
1805 /// Enables LLVM debug output.
1806 pub fn LLVMSetDebug(Enabled
: c_int
);
1808 /// Prepares inline assembly.
1809 pub fn LLVMInlineAsm(Ty
: TypeRef
,
1810 AsmString
: *const c_char
,
1811 Constraints
: *const c_char
,
1817 pub fn LLVMRustDebugMetadataVersion() -> u32;
1818 pub fn LLVMVersionMajor() -> u32;
1819 pub fn LLVMVersionMinor() -> u32;
1821 pub fn LLVMRustAddModuleFlag(M
: ModuleRef
,
1822 name
: *const c_char
,
1825 pub fn LLVMDIBuilderCreate(M
: ModuleRef
) -> DIBuilderRef
;
1827 pub fn LLVMDIBuilderDispose(Builder
: DIBuilderRef
);
1829 pub fn LLVMDIBuilderFinalize(Builder
: DIBuilderRef
);
1831 pub fn LLVMDIBuilderCreateCompileUnit(Builder
: DIBuilderRef
,
1833 File
: *const c_char
,
1835 Producer
: *const c_char
,
1837 Flags
: *const c_char
,
1839 SplitName
: *const c_char
)
1842 pub fn LLVMDIBuilderCreateFile(Builder
: DIBuilderRef
,
1843 Filename
: *const c_char
,
1844 Directory
: *const c_char
)
1847 pub fn LLVMDIBuilderCreateSubroutineType(Builder
: DIBuilderRef
,
1849 ParameterTypes
: DIArray
)
1852 pub fn LLVMDIBuilderCreateFunction(Builder
: DIBuilderRef
,
1853 Scope
: DIDescriptor
,
1854 Name
: *const c_char
,
1855 LinkageName
: *const c_char
,
1859 isLocalToUnit
: bool
,
1869 pub fn LLVMDIBuilderCreateBasicType(Builder
: DIBuilderRef
,
1870 Name
: *const c_char
,
1871 SizeInBits
: c_ulonglong
,
1872 AlignInBits
: c_ulonglong
,
1876 pub fn LLVMDIBuilderCreatePointerType(Builder
: DIBuilderRef
,
1878 SizeInBits
: c_ulonglong
,
1879 AlignInBits
: c_ulonglong
,
1880 Name
: *const c_char
)
1883 pub fn LLVMDIBuilderCreateStructType(Builder
: DIBuilderRef
,
1884 Scope
: DIDescriptor
,
1885 Name
: *const c_char
,
1888 SizeInBits
: c_ulonglong
,
1889 AlignInBits
: c_ulonglong
,
1891 DerivedFrom
: DIType
,
1893 RunTimeLang
: c_uint
,
1894 VTableHolder
: DIType
,
1895 UniqueId
: *const c_char
)
1898 pub fn LLVMDIBuilderCreateMemberType(Builder
: DIBuilderRef
,
1899 Scope
: DIDescriptor
,
1900 Name
: *const c_char
,
1903 SizeInBits
: c_ulonglong
,
1904 AlignInBits
: c_ulonglong
,
1905 OffsetInBits
: c_ulonglong
,
1910 pub fn LLVMDIBuilderCreateLexicalBlock(Builder
: DIBuilderRef
,
1917 pub fn LLVMDIBuilderCreateStaticVariable(Builder
: DIBuilderRef
,
1919 Name
: *const c_char
,
1920 LinkageName
: *const c_char
,
1924 isLocalToUnit
: bool
,
1927 -> DIGlobalVariable
;
1929 pub fn LLVMDIBuilderCreateVariable(Builder
: DIBuilderRef
,
1931 Scope
: DIDescriptor
,
1932 Name
: *const c_char
,
1936 AlwaysPreserve
: bool
,
1938 AddrOps
: *const i64,
1939 AddrOpsCount
: c_uint
,
1943 pub fn LLVMDIBuilderCreateArrayType(Builder
: DIBuilderRef
,
1945 AlignInBits
: c_ulonglong
,
1947 Subscripts
: DIArray
)
1950 pub fn LLVMDIBuilderCreateVectorType(Builder
: DIBuilderRef
,
1952 AlignInBits
: c_ulonglong
,
1954 Subscripts
: DIArray
)
1957 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder
: DIBuilderRef
,
1962 pub fn LLVMDIBuilderGetOrCreateArray(Builder
: DIBuilderRef
,
1963 Ptr
: *const DIDescriptor
,
1967 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder
: DIBuilderRef
,
1969 VarInfo
: DIVariable
,
1970 AddrOps
: *const i64,
1971 AddrOpsCount
: c_uint
,
1973 InsertAtEnd
: BasicBlockRef
)
1976 pub fn LLVMDIBuilderInsertDeclareBefore(Builder
: DIBuilderRef
,
1978 VarInfo
: DIVariable
,
1979 AddrOps
: *const i64,
1980 AddrOpsCount
: c_uint
,
1982 InsertBefore
: ValueRef
)
1985 pub fn LLVMDIBuilderCreateEnumerator(Builder
: DIBuilderRef
,
1986 Name
: *const c_char
,
1990 pub fn LLVMDIBuilderCreateEnumerationType(Builder
: DIBuilderRef
,
1992 Name
: *const c_char
,
1995 SizeInBits
: c_ulonglong
,
1996 AlignInBits
: c_ulonglong
,
2001 pub fn LLVMDIBuilderCreateUnionType(Builder
: DIBuilderRef
,
2003 Name
: *const c_char
,
2006 SizeInBits
: c_ulonglong
,
2007 AlignInBits
: c_ulonglong
,
2010 RunTimeLang
: c_uint
,
2011 UniqueId
: *const c_char
)
2014 pub fn LLVMSetUnnamedAddr(GlobalVar
: ValueRef
, UnnamedAddr
: Bool
);
2016 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder
: DIBuilderRef
,
2018 Name
: *const c_char
,
2023 -> DITemplateTypeParameter
;
2025 pub fn LLVMDIBuilderCreateOpDeref() -> i64;
2027 pub fn LLVMDIBuilderCreateOpPlus() -> i64;
2029 pub fn LLVMDIBuilderCreateNameSpace(Builder
: DIBuilderRef
,
2031 Name
: *const c_char
,
2036 pub fn LLVMDIBuilderCreateDebugLocation(Context
: ContextRef
,
2040 InlinedAt
: MetadataRef
)
2043 pub fn LLVMDICompositeTypeSetTypeArray(Builder
: DIBuilderRef
,
2044 CompositeType
: DIType
,
2045 TypeArray
: DIArray
);
2046 pub fn LLVMWriteTypeToString(Type
: TypeRef
, s
: RustStringRef
);
2047 pub fn LLVMWriteValueToString(value_ref
: ValueRef
, s
: RustStringRef
);
2049 pub fn LLVMIsAArgument(value_ref
: ValueRef
) -> ValueRef
;
2051 pub fn LLVMIsAAllocaInst(value_ref
: ValueRef
) -> ValueRef
;
2052 pub fn LLVMIsAConstantInt(value_ref
: ValueRef
) -> ValueRef
;
2054 pub fn LLVMRustPassKind(Pass
: PassRef
) -> SupportedPassKind
;
2055 pub fn LLVMRustFindAndCreatePass(Pass
: *const c_char
) -> PassRef
;
2056 pub fn LLVMRustAddPass(PM
: PassManagerRef
, Pass
: PassRef
);
2058 pub fn LLVMRustCreateTargetMachine(Triple
: *const c_char
,
2060 Features
: *const c_char
,
2061 Model
: CodeGenModel
,
2063 Level
: CodeGenOptLevel
,
2065 PositionIndependentExecutable
: bool
,
2066 FunctionSections
: bool
,
2067 DataSections
: bool
) -> TargetMachineRef
;
2068 pub fn LLVMRustDisposeTargetMachine(T
: TargetMachineRef
);
2069 pub fn LLVMRustAddAnalysisPasses(T
: TargetMachineRef
,
2072 pub fn LLVMRustAddBuilderLibraryInfo(PMB
: PassManagerBuilderRef
,
2074 DisableSimplifyLibCalls
: bool
);
2075 pub fn LLVMRustConfigurePassManagerBuilder(PMB
: PassManagerBuilderRef
,
2076 OptLevel
: CodeGenOptLevel
,
2077 MergeFunctions
: bool
,
2079 LoopVectorize
: bool
);
2080 pub fn LLVMRustAddLibraryInfo(PM
: PassManagerRef
, M
: ModuleRef
,
2081 DisableSimplifyLibCalls
: bool
);
2082 pub fn LLVMRustRunFunctionPassManager(PM
: PassManagerRef
, M
: ModuleRef
);
2083 pub fn LLVMRustWriteOutputFile(T
: TargetMachineRef
,
2086 Output
: *const c_char
,
2087 FileType
: FileType
) -> bool
;
2088 pub fn LLVMRustPrintModule(PM
: PassManagerRef
,
2090 Output
: *const c_char
);
2091 pub fn LLVMRustSetLLVMOptions(Argc
: c_int
, Argv
: *const *const c_char
);
2092 pub fn LLVMRustPrintPasses();
2093 pub fn LLVMRustSetNormalizedTarget(M
: ModuleRef
, triple
: *const c_char
);
2094 pub fn LLVMRustAddAlwaysInlinePass(P
: PassManagerBuilderRef
,
2095 AddLifetimes
: bool
);
2096 pub fn LLVMRustLinkInExternalBitcode(M
: ModuleRef
,
2098 len
: size_t
) -> bool
;
2099 pub fn LLVMRustRunRestrictionPass(M
: ModuleRef
,
2100 syms
: *const *const c_char
,
2102 pub fn LLVMRustMarkAllFunctionsNounwind(M
: ModuleRef
);
2104 pub fn LLVMRustOpenArchive(path
: *const c_char
) -> ArchiveRef
;
2105 pub fn LLVMRustArchiveIteratorNew(AR
: ArchiveRef
) -> ArchiveIteratorRef
;
2106 pub fn LLVMRustArchiveIteratorNext(AIR
: ArchiveIteratorRef
) -> ArchiveChildRef
;
2107 pub fn LLVMRustArchiveChildName(ACR
: ArchiveChildRef
,
2108 size
: *mut size_t
) -> *const c_char
;
2109 pub fn LLVMRustArchiveChildData(ACR
: ArchiveChildRef
,
2110 size
: *mut size_t
) -> *const c_char
;
2111 pub fn LLVMRustArchiveChildFree(ACR
: ArchiveChildRef
);
2112 pub fn LLVMRustArchiveIteratorFree(AIR
: ArchiveIteratorRef
);
2113 pub fn LLVMRustDestroyArchive(AR
: ArchiveRef
);
2115 pub fn LLVMRustSetDLLStorageClass(V
: ValueRef
,
2116 C
: DLLStorageClassTypes
);
2118 pub fn LLVMRustGetSectionName(SI
: SectionIteratorRef
,
2119 data
: *mut *const c_char
) -> c_int
;
2121 pub fn LLVMWriteTwineToString(T
: TwineRef
, s
: RustStringRef
);
2123 pub fn LLVMContextSetDiagnosticHandler(C
: ContextRef
,
2124 Handler
: DiagnosticHandler
,
2125 DiagnosticContext
: *mut c_void
);
2127 pub fn LLVMUnpackOptimizationDiagnostic(DI
: DiagnosticInfoRef
,
2128 pass_name_out
: *mut *const c_char
,
2129 function_out
: *mut ValueRef
,
2130 debugloc_out
: *mut DebugLocRef
,
2131 message_out
: *mut TwineRef
);
2132 pub fn LLVMUnpackInlineAsmDiagnostic(DI
: DiagnosticInfoRef
,
2133 cookie_out
: *mut c_uint
,
2134 message_out
: *mut TwineRef
,
2135 instruction_out
: *mut ValueRef
);
2137 pub fn LLVMWriteDiagnosticInfoToString(DI
: DiagnosticInfoRef
, s
: RustStringRef
);
2138 pub fn LLVMGetDiagInfoSeverity(DI
: DiagnosticInfoRef
) -> DiagnosticSeverity
;
2139 pub fn LLVMGetDiagInfoKind(DI
: DiagnosticInfoRef
) -> DiagnosticKind
;
2141 pub fn LLVMWriteDebugLocToString(C
: ContextRef
, DL
: DebugLocRef
, s
: RustStringRef
);
2143 pub fn LLVMSetInlineAsmDiagnosticHandler(C
: ContextRef
,
2144 H
: InlineAsmDiagHandler
,
2147 pub fn LLVMWriteSMDiagnosticToString(d
: SMDiagnosticRef
, s
: RustStringRef
);
2149 pub fn LLVMRustWriteArchive(Dst
: *const c_char
,
2151 Members
: *const RustArchiveMemberRef
,
2153 Kind
: ArchiveKind
) -> c_int
;
2154 pub fn LLVMRustArchiveMemberNew(Filename
: *const c_char
,
2155 Name
: *const c_char
,
2156 Child
: ArchiveChildRef
) -> RustArchiveMemberRef
;
2157 pub fn LLVMRustArchiveMemberFree(Member
: RustArchiveMemberRef
);
2159 pub fn LLVMRustSetDataLayoutFromTargetMachine(M
: ModuleRef
,
2160 TM
: TargetMachineRef
);
2161 pub fn LLVMRustGetModuleDataLayout(M
: ModuleRef
) -> TargetDataRef
;
2163 pub fn LLVMRustBuildOperandBundleDef(Name
: *const c_char
,
2164 Inputs
: *const ValueRef
,
2166 -> OperandBundleDefRef
;
2167 pub fn LLVMRustFreeOperandBundleDef(Bundle
: OperandBundleDefRef
);
2170 // LLVM requires symbols from this library, but apparently they're not printed
2171 // during llvm-config?
2173 #[link(name = "ole32")]
2176 pub fn SetInstructionCallConv(instr
: ValueRef
, cc
: CallConv
) {
2178 LLVMSetInstructionCallConv(instr
, cc
as c_uint
);
2181 pub fn SetFunctionCallConv(fn_
: ValueRef
, cc
: CallConv
) {
2183 LLVMSetFunctionCallConv(fn_
, cc
as c_uint
);
2186 pub fn SetLinkage(global
: ValueRef
, link
: Linkage
) {
2188 LLVMSetLinkage(global
, link
as c_uint
);
2192 pub fn SetDLLStorageClass(global
: ValueRef
, class
: DLLStorageClassTypes
) {
2194 LLVMRustSetDLLStorageClass(global
, class
);
2198 pub fn SetUnnamedAddr(global
: ValueRef
, unnamed
: bool
) {
2200 LLVMSetUnnamedAddr(global
, unnamed
as Bool
);
2204 pub fn set_thread_local(global
: ValueRef
, is_thread_local
: bool
) {
2206 LLVMSetThreadLocal(global
, is_thread_local
as Bool
);
2210 pub fn ConstICmp(pred
: IntPredicate
, v1
: ValueRef
, v2
: ValueRef
) -> ValueRef
{
2212 LLVMConstICmp(pred
as c_ushort
, v1
, v2
)
2215 pub fn ConstFCmp(pred
: RealPredicate
, v1
: ValueRef
, v2
: ValueRef
) -> ValueRef
{
2217 LLVMConstFCmp(pred
as c_ushort
, v1
, v2
)
2221 pub fn SetFunctionAttribute(fn_
: ValueRef
, attr
: Attribute
) {
2223 LLVMAddFunctionAttribute(fn_
, FunctionIndex
as c_uint
,
2224 attr
.bits() as uint64_t
)
2228 /* Memory-managed interface to target data. */
2230 pub struct TargetData
{
2231 pub lltd
: TargetDataRef
2234 impl Drop
for TargetData
{
2235 fn drop(&mut self) {
2237 LLVMDisposeTargetData(self.lltd
);
2242 pub fn mk_target_data(string_rep
: &str) -> TargetData
{
2243 let string_rep
= CString
::new(string_rep
).unwrap();
2245 lltd
: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2249 /* Memory-managed interface to object files. */
2251 pub struct ObjectFile
{
2252 pub llof
: ObjectFileRef
,
2256 // This will take ownership of llmb
2257 pub fn new(llmb
: MemoryBufferRef
) -> Option
<ObjectFile
> {
2259 let llof
= LLVMCreateObjectFile(llmb
);
2260 if llof
as isize == 0 {
2261 // LLVMCreateObjectFile took ownership of llmb
2272 impl Drop
for ObjectFile
{
2273 fn drop(&mut self) {
2275 LLVMDisposeObjectFile(self.llof
);
2280 /* Memory-managed interface to section iterators. */
2282 pub struct SectionIter
{
2283 pub llsi
: SectionIteratorRef
2286 impl Drop
for SectionIter
{
2287 fn drop(&mut self) {
2289 LLVMDisposeSectionIterator(self.llsi
);
2294 pub fn mk_section_iter(llof
: ObjectFileRef
) -> SectionIter
{
2297 llsi
: LLVMGetSections(llof
)
2302 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2303 pub fn get_param(llfn
: ValueRef
, index
: c_uint
) -> ValueRef
{
2305 assert
!(index
< LLVMCountParams(llfn
));
2306 LLVMGetParam(llfn
, index
)
2310 pub fn get_params(llfn
: ValueRef
) -> Vec
<ValueRef
> {
2312 let num_params
= LLVMCountParams(llfn
);
2313 let mut params
= Vec
::with_capacity(num_params
as usize);
2314 for idx
in 0..num_params
{
2315 params
.push(LLVMGetParam(llfn
, idx
));
2322 #[allow(missing_copy_implementations)]
2323 pub enum RustString_opaque {}
2324 pub type RustStringRef
= *mut RustString_opaque
;
2325 type RustStringRepr
= *mut RefCell
<Vec
<u8>>;
2327 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2329 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr
: RustStringRef
,
2332 let slice
= slice
::from_raw_parts(ptr
as *const u8, size
as usize);
2334 let sr
= sr
as RustStringRepr
;
2335 (*sr
).borrow_mut().extend_from_slice(slice
);
2338 pub fn build_string
<F
>(f
: F
) -> Option
<String
> where F
: FnOnce(RustStringRef
){
2339 let mut buf
= RefCell
::new(Vec
::new());
2340 f(&mut buf
as RustStringRepr
as RustStringRef
);
2341 String
::from_utf8(buf
.into_inner()).ok()
2344 pub unsafe fn twine_to_string(tr
: TwineRef
) -> String
{
2345 build_string(|s
| LLVMWriteTwineToString(tr
, s
))
2346 .expect("got a non-UTF8 Twine from LLVM")
2349 pub unsafe fn debug_loc_to_string(c
: ContextRef
, tr
: DebugLocRef
) -> String
{
2350 build_string(|s
| LLVMWriteDebugLocToString(c
, tr
, s
))
2351 .expect("got a non-UTF8 DebugLoc from LLVM")
2354 pub fn initialize_available_targets() {
2355 macro_rules
! init_target(
2356 ($cfg
:meta
, $
($method
:ident
),*) => { {
2371 init_target
!(llvm_component
= "x86",
2372 LLVMInitializeX86TargetInfo
,
2373 LLVMInitializeX86Target
,
2374 LLVMInitializeX86TargetMC
,
2375 LLVMInitializeX86AsmPrinter
,
2376 LLVMInitializeX86AsmParser
);
2377 init_target
!(llvm_component
= "arm",
2378 LLVMInitializeARMTargetInfo
,
2379 LLVMInitializeARMTarget
,
2380 LLVMInitializeARMTargetMC
,
2381 LLVMInitializeARMAsmPrinter
,
2382 LLVMInitializeARMAsmParser
);
2383 init_target
!(llvm_component
= "aarch64",
2384 LLVMInitializeAArch64TargetInfo
,
2385 LLVMInitializeAArch64Target
,
2386 LLVMInitializeAArch64TargetMC
,
2387 LLVMInitializeAArch64AsmPrinter
,
2388 LLVMInitializeAArch64AsmParser
);
2389 init_target
!(llvm_component
= "mips",
2390 LLVMInitializeMipsTargetInfo
,
2391 LLVMInitializeMipsTarget
,
2392 LLVMInitializeMipsTargetMC
,
2393 LLVMInitializeMipsAsmPrinter
,
2394 LLVMInitializeMipsAsmParser
);
2395 init_target
!(llvm_component
= "powerpc",
2396 LLVMInitializePowerPCTargetInfo
,
2397 LLVMInitializePowerPCTarget
,
2398 LLVMInitializePowerPCTargetMC
,
2399 LLVMInitializePowerPCAsmPrinter
,
2400 LLVMInitializePowerPCAsmParser
);
2401 init_target
!(llvm_component
= "pnacl",
2402 LLVMInitializePNaClTargetInfo
,
2403 LLVMInitializePNaClTarget
,
2404 LLVMInitializePNaClTargetMC
);
2407 pub fn last_error() -> Option
<String
> {
2409 let cstr
= LLVMRustGetLastError();
2413 let err
= CStr
::from_ptr(cstr
).to_bytes();
2414 let err
= String
::from_utf8_lossy(err
).to_string();
2415 libc
::free(cstr
as *mut _
);
2421 pub struct OperandBundleDef
{
2422 inner
: OperandBundleDefRef
,
2425 impl OperandBundleDef
{
2426 pub fn new(name
: &str, vals
: &[ValueRef
]) -> OperandBundleDef
{
2427 let name
= CString
::new(name
).unwrap();
2429 LLVMRustBuildOperandBundleDef(name
.as_ptr(),
2431 vals
.len() as c_uint
)
2433 OperandBundleDef { inner: def }
2436 pub fn raw(&self) -> OperandBundleDefRef
{
2441 impl Drop
for OperandBundleDef
{
2442 fn drop(&mut self) {
2444 LLVMRustFreeOperandBundleDef(self.inner
);
2449 // The module containing the native LLVM dependencies, generated by the build system
2450 // Note that this must come after the rustllvm extern declaration so that
2451 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2452 // Works to the above fix for #15460 to ensure LLVM dependencies that
2453 // are only used by rustllvm don't get stripped by the linker.
2454 #[cfg(not(cargobuild))]
2456 include
! { env!("CFG_LLVM_LINKAGE_FILE") }