1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
12 #![cfg_attr(stage0, feature(custom_attribute))]
13 #![allow(non_upper_case_globals)]
14 #![allow(non_camel_case_types)]
15 #![allow(non_snake_case)]
17 #![allow(trivial_casts)]
19 #![crate_name = "rustc_llvm"]
20 #![unstable(feature = "rustc_private")]
22 #![crate_type = "dylib"]
23 #![crate_type = "rlib"]
24 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
25 html_favicon_url
= "http://www.rust-lang.org/favicon.ico",
26 html_root_url
= "http://doc.rust-lang.org/nightly/")]
28 #![feature(box_syntax)]
29 #![feature(collections)]
31 #![feature(link_args)]
32 #![feature(staged_api)]
35 #[macro_use] #[no_link] extern crate rustc_bitflags;
37 pub use self::OtherAttribute
::*;
38 pub use self::SpecialAttribute
::*;
39 pub use self::AttributeSet
::*;
40 pub use self::IntPredicate
::*;
41 pub use self::RealPredicate
::*;
42 pub use self::TypeKind
::*;
43 pub use self::AtomicBinOp
::*;
44 pub use self::AtomicOrdering
::*;
45 pub use self::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
::*;
57 use std
::ffi
::CString
;
58 use std
::cell
::RefCell
;
59 use std
::{slice, mem}
;
60 use libc
::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char}
;
61 use libc
::{c_longlong, c_ulonglong, c_void}
;
62 use debuginfo
::{DIBuilderRef
, DIDescriptor
,
63 DIFile
, DILexicalBlock
, DISubprogram
, DIType
,
64 DIBasicType
, DIDerivedType
, DICompositeType
, DIScope
,
65 DIVariable
, DIGlobalVariable
, DIArray
, DISubrange
,
66 DITemplateTypeParameter
, DIEnumerator
, DINameSpace
};
71 pub type Opcode
= u32;
72 pub type Bool
= c_uint
;
74 pub const True
: Bool
= 1 as Bool
;
75 pub const False
: Bool
= 0 as Bool
;
77 // Consts for the LLVM CallConv type, pre-cast to usize.
79 #[derive(Copy, Clone, PartialEq)]
84 X86StdcallCallConv
= 64,
85 X86FastcallCallConv
= 65,
89 #[derive(Copy, Clone)]
91 LLVMDefaultVisibility
= 0,
93 ProtectedVisibility
= 2,
96 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
97 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
98 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
99 // they've been removed in upstream LLVM commit r203866.
100 #[derive(Copy, Clone)]
103 AvailableExternallyLinkage
= 1,
104 LinkOnceAnyLinkage
= 2,
105 LinkOnceODRLinkage
= 3,
108 AppendingLinkage
= 7,
111 ExternalWeakLinkage
= 12,
116 #[derive(Copy, Clone, Debug)]
117 pub enum DiagnosticSeverity
{
125 flags Attribute
: u32 {
126 const ZExtAttribute
= 1 << 0,
127 const SExtAttribute
= 1 << 1,
128 const NoReturnAttribute
= 1 << 2,
129 const InRegAttribute
= 1 << 3,
130 const StructRetAttribute
= 1 << 4,
131 const NoUnwindAttribute
= 1 << 5,
132 const NoAliasAttribute
= 1 << 6,
133 const ByValAttribute
= 1 << 7,
134 const NestAttribute
= 1 << 8,
135 const ReadNoneAttribute
= 1 << 9,
136 const ReadOnlyAttribute
= 1 << 10,
137 const NoInlineAttribute
= 1 << 11,
138 const AlwaysInlineAttribute
= 1 << 12,
139 const OptimizeForSizeAttribute
= 1 << 13,
140 const StackProtectAttribute
= 1 << 14,
141 const StackProtectReqAttribute
= 1 << 15,
142 const AlignmentAttribute
= 31 << 16,
143 const NoCaptureAttribute
= 1 << 21,
144 const NoRedZoneAttribute
= 1 << 22,
145 const NoImplicitFloatAttribute
= 1 << 23,
146 const NakedAttribute
= 1 << 24,
147 const InlineHintAttribute
= 1 << 25,
148 const StackAttribute
= 7 << 26,
149 const ReturnsTwiceAttribute
= 1 << 29,
150 const UWTableAttribute
= 1 << 30,
151 const NonLazyBindAttribute
= 1 << 31,
157 #[derive(Copy, Clone)]
158 pub enum OtherAttribute
{
159 // The following are not really exposed in
160 // the LLVM c api so instead to add these
161 // we call a wrapper function in RustWrapper
162 // that uses the C++ api.
163 SanitizeAddressAttribute
= 1 << 32,
164 MinSizeAttribute
= 1 << 33,
165 NoDuplicateAttribute
= 1 << 34,
166 StackProtectStrongAttribute
= 1 << 35,
167 SanitizeThreadAttribute
= 1 << 36,
168 SanitizeMemoryAttribute
= 1 << 37,
169 NoBuiltinAttribute
= 1 << 38,
170 ReturnedAttribute
= 1 << 39,
171 ColdAttribute
= 1 << 40,
172 BuiltinAttribute
= 1 << 41,
173 OptimizeNoneAttribute
= 1 << 42,
174 InAllocaAttribute
= 1 << 43,
175 NonNullAttribute
= 1 << 44,
178 #[derive(Copy, Clone)]
179 pub enum SpecialAttribute
{
180 DereferenceableAttribute(u64)
184 #[derive(Copy, Clone)]
185 pub enum AttributeSet
{
190 pub trait AttrHelper
{
191 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
);
192 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
);
195 impl AttrHelper
for Attribute
{
196 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
) {
198 LLVMAddFunctionAttribute(llfn
, idx
, self.bits() as uint64_t
);
202 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
) {
204 LLVMAddCallSiteAttribute(callsite
, idx
, self.bits() as uint64_t
);
209 impl AttrHelper
for OtherAttribute
{
210 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
) {
212 LLVMAddFunctionAttribute(llfn
, idx
, *self as uint64_t
);
216 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
) {
218 LLVMAddCallSiteAttribute(callsite
, idx
, *self as uint64_t
);
223 impl AttrHelper
for SpecialAttribute
{
224 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
) {
226 DereferenceableAttribute(bytes
) => unsafe {
227 LLVMAddDereferenceableAttr(llfn
, idx
, bytes
as uint64_t
);
232 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
) {
234 DereferenceableAttribute(bytes
) => unsafe {
235 LLVMAddDereferenceableCallSiteAttr(callsite
, idx
, bytes
as uint64_t
);
241 pub struct AttrBuilder
{
242 attrs
: Vec
<(usize, Box
<AttrHelper
+'
static>)>
246 pub fn new() -> AttrBuilder
{
252 pub fn arg
<'a
, T
: AttrHelper
+ '
static>(&'a
mut self, idx
: usize, a
: T
) -> &'a
mut AttrBuilder
{
253 self.attrs
.push((idx
, box a
as Box
<AttrHelper
+'
static>));
257 pub fn ret
<'a
, T
: AttrHelper
+ '
static>(&'a
mut self, a
: T
) -> &'a
mut AttrBuilder
{
258 self.attrs
.push((ReturnIndex
as usize, box a
as Box
<AttrHelper
+'
static>));
262 pub fn apply_llfn(&self, llfn
: ValueRef
) {
263 for &(idx
, ref attr
) in &self.attrs
{
264 attr
.apply_llfn(idx
as c_uint
, llfn
);
268 pub fn apply_callsite(&self, callsite
: ValueRef
) {
269 for &(idx
, ref attr
) in &self.attrs
{
270 attr
.apply_callsite(idx
as c_uint
, callsite
);
275 // enum for the LLVM IntPredicate type
276 #[derive(Copy, Clone)]
277 pub enum IntPredicate
{
290 // enum for the LLVM RealPredicate type
291 #[derive(Copy, Clone)]
292 pub enum RealPredicate
{
293 RealPredicateFalse
= 0,
308 RealPredicateTrue
= 15,
311 // The LLVM TypeKind type - must stay in sync with the def of
312 // LLVMTypeKind in llvm/include/llvm-c/Core.h
313 #[derive(Copy, Clone, PartialEq, Debug)]
335 #[derive(Copy, Clone)]
336 pub enum AtomicBinOp
{
351 #[derive(Copy, Clone)]
352 pub enum AtomicOrdering
{
356 // Consume = 3, // Not specified yet.
360 SequentiallyConsistent
= 7
363 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
365 #[derive(Copy, Clone)]
367 AssemblyFileType
= 0,
371 #[derive(Copy, Clone)]
372 pub enum MetadataType
{
379 MD_invariant_load
= 6,
383 MD_mem_parallel_loop_access
= 10,
387 // Inline Asm Dialect
388 #[derive(Copy, Clone)]
389 pub enum AsmDialect
{
394 #[derive(Copy, Clone, PartialEq)]
396 pub enum CodeGenOptLevel
{
397 CodeGenLevelNone
= 0,
398 CodeGenLevelLess
= 1,
399 CodeGenLevelDefault
= 2,
400 CodeGenLevelAggressive
= 3,
403 #[derive(Copy, Clone, PartialEq)]
409 RelocDynamicNoPic
= 3,
413 #[derive(Copy, Clone)]
414 pub enum CodeGenModel
{
415 CodeModelDefault
= 0,
416 CodeModelJITDefault
= 1,
424 #[derive(Copy, Clone)]
425 pub enum DiagnosticKind
{
428 DK_DebugMetadataVersion
,
430 DK_OptimizationRemark
,
431 DK_OptimizationRemarkMissed
,
432 DK_OptimizationRemarkAnalysis
,
433 DK_OptimizationFailure
,
436 // Opaque pointer types
437 #[allow(missing_copy_implementations)]
438 pub enum Module_opaque {}
439 pub type ModuleRef
= *mut Module_opaque
;
440 #[allow(missing_copy_implementations)]
441 pub enum Context_opaque {}
442 pub type ContextRef
= *mut Context_opaque
;
443 #[allow(missing_copy_implementations)]
444 pub enum Type_opaque {}
445 pub type TypeRef
= *mut Type_opaque
;
446 #[allow(missing_copy_implementations)]
447 pub enum Value_opaque {}
448 pub type ValueRef
= *mut Value_opaque
;
449 #[allow(missing_copy_implementations)]
450 pub enum Metadata_opaque {}
451 pub type MetadataRef
= *mut Metadata_opaque
;
452 #[allow(missing_copy_implementations)]
453 pub enum BasicBlock_opaque {}
454 pub type BasicBlockRef
= *mut BasicBlock_opaque
;
455 #[allow(missing_copy_implementations)]
456 pub enum Builder_opaque {}
457 pub type BuilderRef
= *mut Builder_opaque
;
458 #[allow(missing_copy_implementations)]
459 pub enum ExecutionEngine_opaque {}
460 pub type ExecutionEngineRef
= *mut ExecutionEngine_opaque
;
461 #[allow(missing_copy_implementations)]
462 pub enum RustJITMemoryManager_opaque {}
463 pub type RustJITMemoryManagerRef
= *mut RustJITMemoryManager_opaque
;
464 #[allow(missing_copy_implementations)]
465 pub enum MemoryBuffer_opaque {}
466 pub type MemoryBufferRef
= *mut MemoryBuffer_opaque
;
467 #[allow(missing_copy_implementations)]
468 pub enum PassManager_opaque {}
469 pub type PassManagerRef
= *mut PassManager_opaque
;
470 #[allow(missing_copy_implementations)]
471 pub enum PassManagerBuilder_opaque {}
472 pub type PassManagerBuilderRef
= *mut PassManagerBuilder_opaque
;
473 #[allow(missing_copy_implementations)]
474 pub enum Use_opaque {}
475 pub type UseRef
= *mut Use_opaque
;
476 #[allow(missing_copy_implementations)]
477 pub enum TargetData_opaque {}
478 pub type TargetDataRef
= *mut TargetData_opaque
;
479 #[allow(missing_copy_implementations)]
480 pub enum ObjectFile_opaque {}
481 pub type ObjectFileRef
= *mut ObjectFile_opaque
;
482 #[allow(missing_copy_implementations)]
483 pub enum SectionIterator_opaque {}
484 pub type SectionIteratorRef
= *mut SectionIterator_opaque
;
485 #[allow(missing_copy_implementations)]
486 pub enum Pass_opaque {}
487 pub type PassRef
= *mut Pass_opaque
;
488 #[allow(missing_copy_implementations)]
489 pub enum TargetMachine_opaque {}
490 pub type TargetMachineRef
= *mut TargetMachine_opaque
;
491 #[allow(missing_copy_implementations)]
492 pub enum Archive_opaque {}
493 pub type ArchiveRef
= *mut Archive_opaque
;
494 #[allow(missing_copy_implementations)]
495 pub enum Twine_opaque {}
496 pub type TwineRef
= *mut Twine_opaque
;
497 #[allow(missing_copy_implementations)]
498 pub enum DiagnosticInfo_opaque {}
499 pub type DiagnosticInfoRef
= *mut DiagnosticInfo_opaque
;
500 #[allow(missing_copy_implementations)]
501 pub enum DebugLoc_opaque {}
502 pub type DebugLocRef
= *mut DebugLoc_opaque
;
503 #[allow(missing_copy_implementations)]
504 pub enum SMDiagnostic_opaque {}
505 pub type SMDiagnosticRef
= *mut SMDiagnostic_opaque
;
507 pub type DiagnosticHandler
= unsafe extern "C" fn(DiagnosticInfoRef
, *mut c_void
);
508 pub type InlineAsmDiagHandler
= unsafe extern "C" fn(SMDiagnosticRef
, *const c_void
, c_uint
);
511 pub use self::DIDescriptorFlags
::*;
512 use super::{MetadataRef}
;
514 #[allow(missing_copy_implementations)]
515 pub enum DIBuilder_opaque {}
516 pub type DIBuilderRef
= *mut DIBuilder_opaque
;
518 pub type DIDescriptor
= MetadataRef
;
519 pub type DIScope
= DIDescriptor
;
520 pub type DILocation
= DIDescriptor
;
521 pub type DIFile
= DIScope
;
522 pub type DILexicalBlock
= DIScope
;
523 pub type DISubprogram
= DIScope
;
524 pub type DINameSpace
= DIScope
;
525 pub type DIType
= DIDescriptor
;
526 pub type DIBasicType
= DIType
;
527 pub type DIDerivedType
= DIType
;
528 pub type DICompositeType
= DIDerivedType
;
529 pub type DIVariable
= DIDescriptor
;
530 pub type DIGlobalVariable
= DIDescriptor
;
531 pub type DIArray
= DIDescriptor
;
532 pub type DISubrange
= DIDescriptor
;
533 pub type DIEnumerator
= DIDescriptor
;
534 pub type DITemplateTypeParameter
= DIDescriptor
;
536 #[derive(Copy, Clone)]
537 pub enum DIDescriptorFlags
{
538 FlagPrivate
= 1 << 0,
539 FlagProtected
= 1 << 1,
540 FlagFwdDecl
= 1 << 2,
541 FlagAppleBlock
= 1 << 3,
542 FlagBlockByrefStruct
= 1 << 4,
543 FlagVirtual
= 1 << 5,
544 FlagArtificial
= 1 << 6,
545 FlagExplicit
= 1 << 7,
546 FlagPrototyped
= 1 << 8,
547 FlagObjcClassComplete
= 1 << 9,
548 FlagObjectPointer
= 1 << 10,
549 FlagVector
= 1 << 11,
550 FlagStaticMember
= 1 << 12,
551 FlagIndirectVariable
= 1 << 13,
552 FlagLValueReference
= 1 << 14,
553 FlagRValueReference
= 1 << 15
558 // Link to our native llvm bindings (things that we need to use the C++ api
559 // for) and because llvm is written in C++ we need to link against libstdc++
561 // You'll probably notice that there is an omission of all LLVM libraries
562 // from this location. This is because the set of LLVM libraries that we
563 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
564 // figure out the exact set of libraries. To do this, the build system
565 // generates an llvmdeps.rs file next to this one which will be
566 // automatically updated whenever LLVM is updated to include an up-to-date
567 // set of the libraries we need to link to LLVM for.
568 #[link(name = "rustllvm", kind = "static")]
570 /* Create and destroy contexts. */
571 pub fn LLVMContextCreate() -> ContextRef
;
572 pub fn LLVMContextDispose(C
: ContextRef
);
573 pub fn LLVMGetMDKindIDInContext(C
: ContextRef
,
578 /* Create and destroy modules. */
579 pub fn LLVMModuleCreateWithNameInContext(ModuleID
: *const c_char
,
582 pub fn LLVMGetModuleContext(M
: ModuleRef
) -> ContextRef
;
583 pub fn LLVMDisposeModule(M
: ModuleRef
);
585 /// Data layout. See Module::getDataLayout.
586 pub fn LLVMGetDataLayout(M
: ModuleRef
) -> *const c_char
;
587 pub fn LLVMSetDataLayout(M
: ModuleRef
, Triple
: *const c_char
);
589 /// Target triple. See Module::getTargetTriple.
590 pub fn LLVMGetTarget(M
: ModuleRef
) -> *const c_char
;
591 pub fn LLVMSetTarget(M
: ModuleRef
, Triple
: *const c_char
);
593 /// See Module::dump.
594 pub fn LLVMDumpModule(M
: ModuleRef
);
596 /// See Module::setModuleInlineAsm.
597 pub fn LLVMSetModuleInlineAsm(M
: ModuleRef
, Asm
: *const c_char
);
599 /// See llvm::LLVMTypeKind::getTypeID.
600 pub fn LLVMGetTypeKind(Ty
: TypeRef
) -> TypeKind
;
602 /// See llvm::LLVMType::getContext.
603 pub fn LLVMGetTypeContext(Ty
: TypeRef
) -> ContextRef
;
605 /* Operations on integer types */
606 pub fn LLVMInt1TypeInContext(C
: ContextRef
) -> TypeRef
;
607 pub fn LLVMInt8TypeInContext(C
: ContextRef
) -> TypeRef
;
608 pub fn LLVMInt16TypeInContext(C
: ContextRef
) -> TypeRef
;
609 pub fn LLVMInt32TypeInContext(C
: ContextRef
) -> TypeRef
;
610 pub fn LLVMInt64TypeInContext(C
: ContextRef
) -> TypeRef
;
611 pub fn LLVMIntTypeInContext(C
: ContextRef
, NumBits
: c_uint
)
614 pub fn LLVMGetIntTypeWidth(IntegerTy
: TypeRef
) -> c_uint
;
616 /* Operations on real types */
617 pub fn LLVMFloatTypeInContext(C
: ContextRef
) -> TypeRef
;
618 pub fn LLVMDoubleTypeInContext(C
: ContextRef
) -> TypeRef
;
619 pub fn LLVMX86FP80TypeInContext(C
: ContextRef
) -> TypeRef
;
620 pub fn LLVMFP128TypeInContext(C
: ContextRef
) -> TypeRef
;
621 pub fn LLVMPPCFP128TypeInContext(C
: ContextRef
) -> TypeRef
;
623 /* Operations on function types */
624 pub fn LLVMFunctionType(ReturnType
: TypeRef
,
625 ParamTypes
: *const TypeRef
,
629 pub fn LLVMIsFunctionVarArg(FunctionTy
: TypeRef
) -> Bool
;
630 pub fn LLVMGetReturnType(FunctionTy
: TypeRef
) -> TypeRef
;
631 pub fn LLVMCountParamTypes(FunctionTy
: TypeRef
) -> c_uint
;
632 pub fn LLVMGetParamTypes(FunctionTy
: TypeRef
, Dest
: *mut TypeRef
);
634 /* Operations on struct types */
635 pub fn LLVMStructTypeInContext(C
: ContextRef
,
636 ElementTypes
: *const TypeRef
,
637 ElementCount
: c_uint
,
640 pub fn LLVMCountStructElementTypes(StructTy
: TypeRef
) -> c_uint
;
641 pub fn LLVMGetStructElementTypes(StructTy
: TypeRef
,
643 pub fn LLVMIsPackedStruct(StructTy
: TypeRef
) -> Bool
;
645 /* Operations on array, pointer, and vector types (sequence types) */
646 pub fn LLVMRustArrayType(ElementType
: TypeRef
, ElementCount
: u64) -> TypeRef
;
647 pub fn LLVMPointerType(ElementType
: TypeRef
, AddressSpace
: c_uint
)
649 pub fn LLVMVectorType(ElementType
: TypeRef
, ElementCount
: c_uint
)
652 pub fn LLVMGetElementType(Ty
: TypeRef
) -> TypeRef
;
653 pub fn LLVMGetArrayLength(ArrayTy
: TypeRef
) -> c_uint
;
654 pub fn LLVMGetPointerAddressSpace(PointerTy
: TypeRef
) -> c_uint
;
655 pub fn LLVMGetPointerToGlobal(EE
: ExecutionEngineRef
, V
: ValueRef
)
657 pub fn LLVMGetVectorSize(VectorTy
: TypeRef
) -> c_uint
;
659 /* Operations on other types */
660 pub fn LLVMVoidTypeInContext(C
: ContextRef
) -> TypeRef
;
661 pub fn LLVMLabelTypeInContext(C
: ContextRef
) -> TypeRef
;
662 pub fn LLVMMetadataTypeInContext(C
: ContextRef
) -> TypeRef
;
664 /* Operations on all values */
665 pub fn LLVMTypeOf(Val
: ValueRef
) -> TypeRef
;
666 pub fn LLVMGetValueName(Val
: ValueRef
) -> *const c_char
;
667 pub fn LLVMSetValueName(Val
: ValueRef
, Name
: *const c_char
);
668 pub fn LLVMDumpValue(Val
: ValueRef
);
669 pub fn LLVMReplaceAllUsesWith(OldVal
: ValueRef
, NewVal
: ValueRef
);
670 pub fn LLVMHasMetadata(Val
: ValueRef
) -> c_int
;
671 pub fn LLVMGetMetadata(Val
: ValueRef
, KindID
: c_uint
) -> ValueRef
;
672 pub fn LLVMSetMetadata(Val
: ValueRef
, KindID
: c_uint
, Node
: ValueRef
);
674 /* Operations on Uses */
675 pub fn LLVMGetFirstUse(Val
: ValueRef
) -> UseRef
;
676 pub fn LLVMGetNextUse(U
: UseRef
) -> UseRef
;
677 pub fn LLVMGetUser(U
: UseRef
) -> ValueRef
;
678 pub fn LLVMGetUsedValue(U
: UseRef
) -> ValueRef
;
680 /* Operations on Users */
681 pub fn LLVMGetNumOperands(Val
: ValueRef
) -> c_int
;
682 pub fn LLVMGetOperand(Val
: ValueRef
, Index
: c_uint
) -> ValueRef
;
683 pub fn LLVMSetOperand(Val
: ValueRef
, Index
: c_uint
, Op
: ValueRef
);
685 /* Operations on constants of any type */
686 pub fn LLVMConstNull(Ty
: TypeRef
) -> ValueRef
;
688 pub fn LLVMConstAllOnes(Ty
: TypeRef
) -> ValueRef
;
689 pub fn LLVMConstICmp(Pred
: c_ushort
, V1
: ValueRef
, V2
: ValueRef
)
691 pub fn LLVMConstFCmp(Pred
: c_ushort
, V1
: ValueRef
, V2
: ValueRef
)
693 /* only for isize/vector */
694 pub fn LLVMGetUndef(Ty
: TypeRef
) -> ValueRef
;
695 pub fn LLVMIsConstant(Val
: ValueRef
) -> Bool
;
696 pub fn LLVMIsNull(Val
: ValueRef
) -> Bool
;
697 pub fn LLVMIsUndef(Val
: ValueRef
) -> Bool
;
698 pub fn LLVMConstPointerNull(Ty
: TypeRef
) -> ValueRef
;
700 /* Operations on metadata */
701 pub fn LLVMMDStringInContext(C
: ContextRef
,
705 pub fn LLVMMDNodeInContext(C
: ContextRef
,
706 Vals
: *const ValueRef
,
709 pub fn LLVMAddNamedMetadataOperand(M
: ModuleRef
,
713 /* Operations on scalar constants */
714 pub fn LLVMConstInt(IntTy
: TypeRef
, N
: c_ulonglong
, SignExtend
: Bool
)
716 pub fn LLVMConstIntOfString(IntTy
: TypeRef
, Text
: *const c_char
, Radix
: u8)
718 pub fn LLVMConstIntOfStringAndSize(IntTy
: TypeRef
,
723 pub fn LLVMConstReal(RealTy
: TypeRef
, N
: f64) -> ValueRef
;
724 pub fn LLVMConstRealOfString(RealTy
: TypeRef
, Text
: *const c_char
)
726 pub fn LLVMConstRealOfStringAndSize(RealTy
: TypeRef
,
730 pub fn LLVMConstIntGetZExtValue(ConstantVal
: ValueRef
) -> c_ulonglong
;
731 pub fn LLVMConstIntGetSExtValue(ConstantVal
: ValueRef
) -> c_longlong
;
734 /* Operations on composite constants */
735 pub fn LLVMConstStringInContext(C
: ContextRef
,
738 DontNullTerminate
: Bool
)
740 pub fn LLVMConstStructInContext(C
: ContextRef
,
741 ConstantVals
: *const ValueRef
,
746 pub fn LLVMConstArray(ElementTy
: TypeRef
,
747 ConstantVals
: *const ValueRef
,
750 pub fn LLVMConstVector(ScalarConstantVals
: *const ValueRef
, Size
: c_uint
)
753 /* Constant expressions */
754 pub fn LLVMAlignOf(Ty
: TypeRef
) -> ValueRef
;
755 pub fn LLVMSizeOf(Ty
: TypeRef
) -> ValueRef
;
756 pub fn LLVMConstNeg(ConstantVal
: ValueRef
) -> ValueRef
;
757 pub fn LLVMConstNSWNeg(ConstantVal
: ValueRef
) -> ValueRef
;
758 pub fn LLVMConstNUWNeg(ConstantVal
: ValueRef
) -> ValueRef
;
759 pub fn LLVMConstFNeg(ConstantVal
: ValueRef
) -> ValueRef
;
760 pub fn LLVMConstNot(ConstantVal
: ValueRef
) -> ValueRef
;
761 pub fn LLVMConstAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
763 pub fn LLVMConstNSWAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
765 pub fn LLVMConstNUWAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
767 pub fn LLVMConstFAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
769 pub fn LLVMConstSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
771 pub fn LLVMConstNSWSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
773 pub fn LLVMConstNUWSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
775 pub fn LLVMConstFSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
777 pub fn LLVMConstMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
779 pub fn LLVMConstNSWMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
781 pub fn LLVMConstNUWMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
783 pub fn LLVMConstFMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
785 pub fn LLVMConstUDiv(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
787 pub fn LLVMConstSDiv(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
789 pub fn LLVMConstExactSDiv(LHSConstant
: ValueRef
,
790 RHSConstant
: ValueRef
)
792 pub fn LLVMConstFDiv(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
794 pub fn LLVMConstURem(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
796 pub fn LLVMConstSRem(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
798 pub fn LLVMConstFRem(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
800 pub fn LLVMConstAnd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
802 pub fn LLVMConstOr(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
804 pub fn LLVMConstXor(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
806 pub fn LLVMConstShl(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
808 pub fn LLVMConstLShr(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
810 pub fn LLVMConstAShr(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
812 pub fn LLVMConstGEP(ConstantVal
: ValueRef
,
813 ConstantIndices
: *const ValueRef
,
816 pub fn LLVMConstInBoundsGEP(ConstantVal
: ValueRef
,
817 ConstantIndices
: *const ValueRef
,
820 pub fn LLVMConstTrunc(ConstantVal
: ValueRef
, ToType
: TypeRef
)
822 pub fn LLVMConstSExt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
824 pub fn LLVMConstZExt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
826 pub fn LLVMConstFPTrunc(ConstantVal
: ValueRef
, ToType
: TypeRef
)
828 pub fn LLVMConstFPExt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
830 pub fn LLVMConstUIToFP(ConstantVal
: ValueRef
, ToType
: TypeRef
)
832 pub fn LLVMConstSIToFP(ConstantVal
: ValueRef
, ToType
: TypeRef
)
834 pub fn LLVMConstFPToUI(ConstantVal
: ValueRef
, ToType
: TypeRef
)
836 pub fn LLVMConstFPToSI(ConstantVal
: ValueRef
, ToType
: TypeRef
)
838 pub fn LLVMConstPtrToInt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
840 pub fn LLVMConstIntToPtr(ConstantVal
: ValueRef
, ToType
: TypeRef
)
842 pub fn LLVMConstBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
844 pub fn LLVMConstZExtOrBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
846 pub fn LLVMConstSExtOrBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
848 pub fn LLVMConstTruncOrBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
850 pub fn LLVMConstPointerCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
852 pub fn LLVMConstIntCast(ConstantVal
: ValueRef
,
856 pub fn LLVMConstFPCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
858 pub fn LLVMConstSelect(ConstantCondition
: ValueRef
,
859 ConstantIfTrue
: ValueRef
,
860 ConstantIfFalse
: ValueRef
)
862 pub fn LLVMConstExtractElement(VectorConstant
: ValueRef
,
863 IndexConstant
: ValueRef
)
865 pub fn LLVMConstInsertElement(VectorConstant
: ValueRef
,
866 ElementValueConstant
: ValueRef
,
867 IndexConstant
: ValueRef
)
869 pub fn LLVMConstShuffleVector(VectorAConstant
: ValueRef
,
870 VectorBConstant
: ValueRef
,
871 MaskConstant
: ValueRef
)
873 pub fn LLVMConstExtractValue(AggConstant
: ValueRef
,
874 IdxList
: *const c_uint
,
877 pub fn LLVMConstInsertValue(AggConstant
: ValueRef
,
878 ElementValueConstant
: ValueRef
,
879 IdxList
: *const c_uint
,
882 pub fn LLVMConstInlineAsm(Ty
: TypeRef
,
883 AsmString
: *const c_char
,
884 Constraints
: *const c_char
,
885 HasSideEffects
: Bool
,
888 pub fn LLVMBlockAddress(F
: ValueRef
, BB
: BasicBlockRef
) -> ValueRef
;
892 /* Operations on global variables, functions, and aliases (globals) */
893 pub fn LLVMGetGlobalParent(Global
: ValueRef
) -> ModuleRef
;
894 pub fn LLVMIsDeclaration(Global
: ValueRef
) -> Bool
;
895 pub fn LLVMGetLinkage(Global
: ValueRef
) -> c_uint
;
896 pub fn LLVMSetLinkage(Global
: ValueRef
, Link
: c_uint
);
897 pub fn LLVMGetSection(Global
: ValueRef
) -> *const c_char
;
898 pub fn LLVMSetSection(Global
: ValueRef
, Section
: *const c_char
);
899 pub fn LLVMGetVisibility(Global
: ValueRef
) -> c_uint
;
900 pub fn LLVMSetVisibility(Global
: ValueRef
, Viz
: c_uint
);
901 pub fn LLVMGetAlignment(Global
: ValueRef
) -> c_uint
;
902 pub fn LLVMSetAlignment(Global
: ValueRef
, Bytes
: c_uint
);
905 /* Operations on global variables */
906 pub fn LLVMIsAGlobalVariable(GlobalVar
: ValueRef
) -> ValueRef
;
907 pub fn LLVMAddGlobal(M
: ModuleRef
, Ty
: TypeRef
, Name
: *const c_char
)
909 pub fn LLVMAddGlobalInAddressSpace(M
: ModuleRef
,
912 AddressSpace
: c_uint
)
914 pub fn LLVMGetNamedGlobal(M
: ModuleRef
, Name
: *const c_char
) -> ValueRef
;
915 pub fn LLVMGetFirstGlobal(M
: ModuleRef
) -> ValueRef
;
916 pub fn LLVMGetLastGlobal(M
: ModuleRef
) -> ValueRef
;
917 pub fn LLVMGetNextGlobal(GlobalVar
: ValueRef
) -> ValueRef
;
918 pub fn LLVMGetPreviousGlobal(GlobalVar
: ValueRef
) -> ValueRef
;
919 pub fn LLVMDeleteGlobal(GlobalVar
: ValueRef
);
920 pub fn LLVMGetInitializer(GlobalVar
: ValueRef
) -> ValueRef
;
921 pub fn LLVMSetInitializer(GlobalVar
: ValueRef
,
922 ConstantVal
: ValueRef
);
923 pub fn LLVMIsThreadLocal(GlobalVar
: ValueRef
) -> Bool
;
924 pub fn LLVMSetThreadLocal(GlobalVar
: ValueRef
, IsThreadLocal
: Bool
);
925 pub fn LLVMIsGlobalConstant(GlobalVar
: ValueRef
) -> Bool
;
926 pub fn LLVMSetGlobalConstant(GlobalVar
: ValueRef
, IsConstant
: Bool
);
928 /* Operations on aliases */
929 pub fn LLVMAddAlias(M
: ModuleRef
,
935 /* Operations on functions */
936 pub fn LLVMAddFunction(M
: ModuleRef
,
940 pub fn LLVMGetNamedFunction(M
: ModuleRef
, Name
: *const c_char
) -> ValueRef
;
941 pub fn LLVMGetFirstFunction(M
: ModuleRef
) -> ValueRef
;
942 pub fn LLVMGetLastFunction(M
: ModuleRef
) -> ValueRef
;
943 pub fn LLVMGetNextFunction(Fn
: ValueRef
) -> ValueRef
;
944 pub fn LLVMGetPreviousFunction(Fn
: ValueRef
) -> ValueRef
;
945 pub fn LLVMDeleteFunction(Fn
: ValueRef
);
946 pub fn LLVMGetOrInsertFunction(M
: ModuleRef
,
950 pub fn LLVMGetIntrinsicID(Fn
: ValueRef
) -> c_uint
;
951 pub fn LLVMGetFunctionCallConv(Fn
: ValueRef
) -> c_uint
;
952 pub fn LLVMSetFunctionCallConv(Fn
: ValueRef
, CC
: c_uint
);
953 pub fn LLVMGetGC(Fn
: ValueRef
) -> *const c_char
;
954 pub fn LLVMSetGC(Fn
: ValueRef
, Name
: *const c_char
);
955 pub fn LLVMAddDereferenceableAttr(Fn
: ValueRef
, index
: c_uint
, bytes
: uint64_t
);
956 pub fn LLVMAddFunctionAttribute(Fn
: ValueRef
, index
: c_uint
, PA
: uint64_t
);
957 pub fn LLVMAddFunctionAttrString(Fn
: ValueRef
, index
: c_uint
, Name
: *const c_char
);
958 pub fn LLVMRemoveFunctionAttrString(Fn
: ValueRef
, index
: c_uint
, Name
: *const c_char
);
959 pub fn LLVMGetFunctionAttr(Fn
: ValueRef
) -> c_ulonglong
;
961 /* Operations on parameters */
962 pub fn LLVMCountParams(Fn
: ValueRef
) -> c_uint
;
963 pub fn LLVMGetParams(Fn
: ValueRef
, Params
: *const ValueRef
);
964 pub fn LLVMGetParam(Fn
: ValueRef
, Index
: c_uint
) -> ValueRef
;
965 pub fn LLVMGetParamParent(Inst
: ValueRef
) -> ValueRef
;
966 pub fn LLVMGetFirstParam(Fn
: ValueRef
) -> ValueRef
;
967 pub fn LLVMGetLastParam(Fn
: ValueRef
) -> ValueRef
;
968 pub fn LLVMGetNextParam(Arg
: ValueRef
) -> ValueRef
;
969 pub fn LLVMGetPreviousParam(Arg
: ValueRef
) -> ValueRef
;
970 pub fn LLVMAddAttribute(Arg
: ValueRef
, PA
: c_uint
);
971 pub fn LLVMRemoveAttribute(Arg
: ValueRef
, PA
: c_uint
);
972 pub fn LLVMGetAttribute(Arg
: ValueRef
) -> c_uint
;
973 pub fn LLVMSetParamAlignment(Arg
: ValueRef
, align
: c_uint
);
975 /* Operations on basic blocks */
976 pub fn LLVMBasicBlockAsValue(BB
: BasicBlockRef
) -> ValueRef
;
977 pub fn LLVMValueIsBasicBlock(Val
: ValueRef
) -> Bool
;
978 pub fn LLVMValueAsBasicBlock(Val
: ValueRef
) -> BasicBlockRef
;
979 pub fn LLVMGetBasicBlockParent(BB
: BasicBlockRef
) -> ValueRef
;
980 pub fn LLVMCountBasicBlocks(Fn
: ValueRef
) -> c_uint
;
981 pub fn LLVMGetBasicBlocks(Fn
: ValueRef
, BasicBlocks
: *const ValueRef
);
982 pub fn LLVMGetFirstBasicBlock(Fn
: ValueRef
) -> BasicBlockRef
;
983 pub fn LLVMGetLastBasicBlock(Fn
: ValueRef
) -> BasicBlockRef
;
984 pub fn LLVMGetNextBasicBlock(BB
: BasicBlockRef
) -> BasicBlockRef
;
985 pub fn LLVMGetPreviousBasicBlock(BB
: BasicBlockRef
) -> BasicBlockRef
;
986 pub fn LLVMGetEntryBasicBlock(Fn
: ValueRef
) -> BasicBlockRef
;
988 pub fn LLVMAppendBasicBlockInContext(C
: ContextRef
,
992 pub fn LLVMInsertBasicBlockInContext(C
: ContextRef
,
996 pub fn LLVMDeleteBasicBlock(BB
: BasicBlockRef
);
998 pub fn LLVMMoveBasicBlockAfter(BB
: BasicBlockRef
,
999 MoveAfter
: BasicBlockRef
);
1001 pub fn LLVMMoveBasicBlockBefore(BB
: BasicBlockRef
,
1002 MoveBefore
: BasicBlockRef
);
1004 /* Operations on instructions */
1005 pub fn LLVMGetInstructionParent(Inst
: ValueRef
) -> BasicBlockRef
;
1006 pub fn LLVMGetFirstInstruction(BB
: BasicBlockRef
) -> ValueRef
;
1007 pub fn LLVMGetLastInstruction(BB
: BasicBlockRef
) -> ValueRef
;
1008 pub fn LLVMGetNextInstruction(Inst
: ValueRef
) -> ValueRef
;
1009 pub fn LLVMGetPreviousInstruction(Inst
: ValueRef
) -> ValueRef
;
1010 pub fn LLVMInstructionEraseFromParent(Inst
: ValueRef
);
1012 /* Operations on call sites */
1013 pub fn LLVMSetInstructionCallConv(Instr
: ValueRef
, CC
: c_uint
);
1014 pub fn LLVMGetInstructionCallConv(Instr
: ValueRef
) -> c_uint
;
1015 pub fn LLVMAddInstrAttribute(Instr
: ValueRef
,
1018 pub fn LLVMRemoveInstrAttribute(Instr
: ValueRef
,
1021 pub fn LLVMSetInstrParamAlignment(Instr
: ValueRef
,
1024 pub fn LLVMAddCallSiteAttribute(Instr
: ValueRef
,
1027 pub fn LLVMAddDereferenceableCallSiteAttr(Instr
: ValueRef
,
1031 /* Operations on call instructions (only) */
1032 pub fn LLVMIsTailCall(CallInst
: ValueRef
) -> Bool
;
1033 pub fn LLVMSetTailCall(CallInst
: ValueRef
, IsTailCall
: Bool
);
1035 /* Operations on load/store instructions (only) */
1036 pub fn LLVMGetVolatile(MemoryAccessInst
: ValueRef
) -> Bool
;
1037 pub fn LLVMSetVolatile(MemoryAccessInst
: ValueRef
, volatile
: Bool
);
1039 /* Operations on phi nodes */
1040 pub fn LLVMAddIncoming(PhiNode
: ValueRef
,
1041 IncomingValues
: *const ValueRef
,
1042 IncomingBlocks
: *const BasicBlockRef
,
1044 pub fn LLVMCountIncoming(PhiNode
: ValueRef
) -> c_uint
;
1045 pub fn LLVMGetIncomingValue(PhiNode
: ValueRef
, Index
: c_uint
)
1047 pub fn LLVMGetIncomingBlock(PhiNode
: ValueRef
, Index
: c_uint
)
1050 /* Instruction builders */
1051 pub fn LLVMCreateBuilderInContext(C
: ContextRef
) -> BuilderRef
;
1052 pub fn LLVMPositionBuilder(Builder
: BuilderRef
,
1053 Block
: BasicBlockRef
,
1055 pub fn LLVMPositionBuilderBefore(Builder
: BuilderRef
,
1057 pub fn LLVMPositionBuilderAtEnd(Builder
: BuilderRef
,
1058 Block
: BasicBlockRef
);
1059 pub fn LLVMGetInsertBlock(Builder
: BuilderRef
) -> BasicBlockRef
;
1060 pub fn LLVMClearInsertionPosition(Builder
: BuilderRef
);
1061 pub fn LLVMInsertIntoBuilder(Builder
: BuilderRef
, Instr
: ValueRef
);
1062 pub fn LLVMInsertIntoBuilderWithName(Builder
: BuilderRef
,
1064 Name
: *const c_char
);
1065 pub fn LLVMDisposeBuilder(Builder
: BuilderRef
);
1067 /* Execution engine */
1068 pub fn LLVMRustCreateJITMemoryManager(morestack
: *const ())
1069 -> RustJITMemoryManagerRef
;
1070 pub fn LLVMBuildExecutionEngine(Mod
: ModuleRef
,
1071 MM
: RustJITMemoryManagerRef
) -> ExecutionEngineRef
;
1072 pub fn LLVMDisposeExecutionEngine(EE
: ExecutionEngineRef
);
1073 pub fn LLVMExecutionEngineFinalizeObject(EE
: ExecutionEngineRef
);
1074 pub fn LLVMRustLoadDynamicLibrary(path
: *const c_char
) -> Bool
;
1075 pub fn LLVMExecutionEngineAddModule(EE
: ExecutionEngineRef
, M
: ModuleRef
);
1076 pub fn LLVMExecutionEngineRemoveModule(EE
: ExecutionEngineRef
, M
: ModuleRef
)
1080 pub fn LLVMSetCurrentDebugLocation(Builder
: BuilderRef
, L
: ValueRef
);
1081 pub fn LLVMGetCurrentDebugLocation(Builder
: BuilderRef
) -> ValueRef
;
1082 pub fn LLVMSetInstDebugLocation(Builder
: BuilderRef
, Inst
: ValueRef
);
1085 pub fn LLVMBuildRetVoid(B
: BuilderRef
) -> ValueRef
;
1086 pub fn LLVMBuildRet(B
: BuilderRef
, V
: ValueRef
) -> ValueRef
;
1087 pub fn LLVMBuildAggregateRet(B
: BuilderRef
,
1088 RetVals
: *const ValueRef
,
1091 pub fn LLVMBuildBr(B
: BuilderRef
, Dest
: BasicBlockRef
) -> ValueRef
;
1092 pub fn LLVMBuildCondBr(B
: BuilderRef
,
1094 Then
: BasicBlockRef
,
1095 Else
: BasicBlockRef
)
1097 pub fn LLVMBuildSwitch(B
: BuilderRef
,
1099 Else
: BasicBlockRef
,
1102 pub fn LLVMBuildIndirectBr(B
: BuilderRef
,
1106 pub fn LLVMBuildInvoke(B
: BuilderRef
,
1108 Args
: *const ValueRef
,
1110 Then
: BasicBlockRef
,
1111 Catch
: BasicBlockRef
,
1112 Name
: *const c_char
)
1114 pub fn LLVMBuildLandingPad(B
: BuilderRef
,
1118 Name
: *const c_char
)
1120 pub fn LLVMBuildResume(B
: BuilderRef
, Exn
: ValueRef
) -> ValueRef
;
1121 pub fn LLVMBuildUnreachable(B
: BuilderRef
) -> ValueRef
;
1123 /* Add a case to the switch instruction */
1124 pub fn LLVMAddCase(Switch
: ValueRef
,
1126 Dest
: BasicBlockRef
);
1128 /* Add a destination to the indirectbr instruction */
1129 pub fn LLVMAddDestination(IndirectBr
: ValueRef
, Dest
: BasicBlockRef
);
1131 /* Add a clause to the landing pad instruction */
1132 pub fn LLVMAddClause(LandingPad
: ValueRef
, ClauseVal
: ValueRef
);
1134 /* Set the cleanup on a landing pad instruction */
1135 pub fn LLVMSetCleanup(LandingPad
: ValueRef
, Val
: Bool
);
1138 pub fn LLVMBuildAdd(B
: BuilderRef
,
1141 Name
: *const c_char
)
1143 pub fn LLVMBuildNSWAdd(B
: BuilderRef
,
1146 Name
: *const c_char
)
1148 pub fn LLVMBuildNUWAdd(B
: BuilderRef
,
1151 Name
: *const c_char
)
1153 pub fn LLVMBuildFAdd(B
: BuilderRef
,
1156 Name
: *const c_char
)
1158 pub fn LLVMBuildSub(B
: BuilderRef
,
1161 Name
: *const c_char
)
1163 pub fn LLVMBuildNSWSub(B
: BuilderRef
,
1166 Name
: *const c_char
)
1168 pub fn LLVMBuildNUWSub(B
: BuilderRef
,
1171 Name
: *const c_char
)
1173 pub fn LLVMBuildFSub(B
: BuilderRef
,
1176 Name
: *const c_char
)
1178 pub fn LLVMBuildMul(B
: BuilderRef
,
1181 Name
: *const c_char
)
1183 pub fn LLVMBuildNSWMul(B
: BuilderRef
,
1186 Name
: *const c_char
)
1188 pub fn LLVMBuildNUWMul(B
: BuilderRef
,
1191 Name
: *const c_char
)
1193 pub fn LLVMBuildFMul(B
: BuilderRef
,
1196 Name
: *const c_char
)
1198 pub fn LLVMBuildUDiv(B
: BuilderRef
,
1201 Name
: *const c_char
)
1203 pub fn LLVMBuildSDiv(B
: BuilderRef
,
1206 Name
: *const c_char
)
1208 pub fn LLVMBuildExactSDiv(B
: BuilderRef
,
1211 Name
: *const c_char
)
1213 pub fn LLVMBuildFDiv(B
: BuilderRef
,
1216 Name
: *const c_char
)
1218 pub fn LLVMBuildURem(B
: BuilderRef
,
1221 Name
: *const c_char
)
1223 pub fn LLVMBuildSRem(B
: BuilderRef
,
1226 Name
: *const c_char
)
1228 pub fn LLVMBuildFRem(B
: BuilderRef
,
1231 Name
: *const c_char
)
1233 pub fn LLVMBuildShl(B
: BuilderRef
,
1236 Name
: *const c_char
)
1238 pub fn LLVMBuildLShr(B
: BuilderRef
,
1241 Name
: *const c_char
)
1243 pub fn LLVMBuildAShr(B
: BuilderRef
,
1246 Name
: *const c_char
)
1248 pub fn LLVMBuildAnd(B
: BuilderRef
,
1251 Name
: *const c_char
)
1253 pub fn LLVMBuildOr(B
: BuilderRef
,
1256 Name
: *const c_char
)
1258 pub fn LLVMBuildXor(B
: BuilderRef
,
1261 Name
: *const c_char
)
1263 pub fn LLVMBuildBinOp(B
: BuilderRef
,
1267 Name
: *const c_char
)
1269 pub fn LLVMBuildNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1271 pub fn LLVMBuildNSWNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1273 pub fn LLVMBuildNUWNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1275 pub fn LLVMBuildFNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1277 pub fn LLVMBuildNot(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1281 pub fn LLVMBuildMalloc(B
: BuilderRef
, Ty
: TypeRef
, Name
: *const c_char
)
1283 pub fn LLVMBuildArrayMalloc(B
: BuilderRef
,
1286 Name
: *const c_char
)
1288 pub fn LLVMBuildAlloca(B
: BuilderRef
, Ty
: TypeRef
, Name
: *const c_char
)
1290 pub fn LLVMBuildArrayAlloca(B
: BuilderRef
,
1293 Name
: *const c_char
)
1295 pub fn LLVMBuildFree(B
: BuilderRef
, PointerVal
: ValueRef
) -> ValueRef
;
1296 pub fn LLVMBuildLoad(B
: BuilderRef
,
1297 PointerVal
: ValueRef
,
1298 Name
: *const c_char
)
1301 pub fn LLVMBuildStore(B
: BuilderRef
, Val
: ValueRef
, Ptr
: ValueRef
)
1304 pub fn LLVMBuildGEP(B
: BuilderRef
,
1306 Indices
: *const ValueRef
,
1308 Name
: *const c_char
)
1310 pub fn LLVMBuildInBoundsGEP(B
: BuilderRef
,
1312 Indices
: *const ValueRef
,
1314 Name
: *const c_char
)
1316 pub fn LLVMBuildStructGEP(B
: BuilderRef
,
1319 Name
: *const c_char
)
1321 pub fn LLVMBuildGlobalString(B
: BuilderRef
,
1323 Name
: *const c_char
)
1325 pub fn LLVMBuildGlobalStringPtr(B
: BuilderRef
,
1327 Name
: *const c_char
)
1331 pub fn LLVMBuildTrunc(B
: BuilderRef
,
1334 Name
: *const c_char
)
1336 pub fn LLVMBuildZExt(B
: BuilderRef
,
1339 Name
: *const c_char
)
1341 pub fn LLVMBuildSExt(B
: BuilderRef
,
1344 Name
: *const c_char
)
1346 pub fn LLVMBuildFPToUI(B
: BuilderRef
,
1349 Name
: *const c_char
)
1351 pub fn LLVMBuildFPToSI(B
: BuilderRef
,
1354 Name
: *const c_char
)
1356 pub fn LLVMBuildUIToFP(B
: BuilderRef
,
1359 Name
: *const c_char
)
1361 pub fn LLVMBuildSIToFP(B
: BuilderRef
,
1364 Name
: *const c_char
)
1366 pub fn LLVMBuildFPTrunc(B
: BuilderRef
,
1369 Name
: *const c_char
)
1371 pub fn LLVMBuildFPExt(B
: BuilderRef
,
1374 Name
: *const c_char
)
1376 pub fn LLVMBuildPtrToInt(B
: BuilderRef
,
1379 Name
: *const c_char
)
1381 pub fn LLVMBuildIntToPtr(B
: BuilderRef
,
1384 Name
: *const c_char
)
1386 pub fn LLVMBuildBitCast(B
: BuilderRef
,
1389 Name
: *const c_char
)
1391 pub fn LLVMBuildZExtOrBitCast(B
: BuilderRef
,
1394 Name
: *const c_char
)
1396 pub fn LLVMBuildSExtOrBitCast(B
: BuilderRef
,
1399 Name
: *const c_char
)
1401 pub fn LLVMBuildTruncOrBitCast(B
: BuilderRef
,
1404 Name
: *const c_char
)
1406 pub fn LLVMBuildCast(B
: BuilderRef
,
1410 Name
: *const c_char
) -> ValueRef
;
1411 pub fn LLVMBuildPointerCast(B
: BuilderRef
,
1414 Name
: *const c_char
)
1416 pub fn LLVMBuildIntCast(B
: BuilderRef
,
1419 Name
: *const c_char
)
1421 pub fn LLVMBuildFPCast(B
: BuilderRef
,
1424 Name
: *const c_char
)
1428 pub fn LLVMBuildICmp(B
: BuilderRef
,
1432 Name
: *const c_char
)
1434 pub fn LLVMBuildFCmp(B
: BuilderRef
,
1438 Name
: *const c_char
)
1441 /* Miscellaneous instructions */
1442 pub fn LLVMBuildPhi(B
: BuilderRef
, Ty
: TypeRef
, Name
: *const c_char
)
1444 pub fn LLVMBuildCall(B
: BuilderRef
,
1446 Args
: *const ValueRef
,
1448 Name
: *const c_char
)
1450 pub fn LLVMBuildSelect(B
: BuilderRef
,
1454 Name
: *const c_char
)
1456 pub fn LLVMBuildVAArg(B
: BuilderRef
,
1459 Name
: *const c_char
)
1461 pub fn LLVMBuildExtractElement(B
: BuilderRef
,
1464 Name
: *const c_char
)
1466 pub fn LLVMBuildInsertElement(B
: BuilderRef
,
1470 Name
: *const c_char
)
1472 pub fn LLVMBuildShuffleVector(B
: BuilderRef
,
1476 Name
: *const c_char
)
1478 pub fn LLVMBuildExtractValue(B
: BuilderRef
,
1481 Name
: *const c_char
)
1483 pub fn LLVMBuildInsertValue(B
: BuilderRef
,
1487 Name
: *const c_char
)
1490 pub fn LLVMBuildIsNull(B
: BuilderRef
, Val
: ValueRef
, Name
: *const c_char
)
1492 pub fn LLVMBuildIsNotNull(B
: BuilderRef
, Val
: ValueRef
, Name
: *const c_char
)
1494 pub fn LLVMBuildPtrDiff(B
: BuilderRef
,
1497 Name
: *const c_char
)
1500 /* Atomic Operations */
1501 pub fn LLVMBuildAtomicLoad(B
: BuilderRef
,
1502 PointerVal
: ValueRef
,
1503 Name
: *const c_char
,
1504 Order
: AtomicOrdering
,
1508 pub fn LLVMBuildAtomicStore(B
: BuilderRef
,
1511 Order
: AtomicOrdering
,
1515 pub fn LLVMBuildAtomicCmpXchg(B
: BuilderRef
,
1519 Order
: AtomicOrdering
,
1520 FailureOrder
: AtomicOrdering
)
1522 pub fn LLVMBuildAtomicRMW(B
: BuilderRef
,
1526 Order
: AtomicOrdering
,
1527 SingleThreaded
: Bool
)
1530 pub fn LLVMBuildAtomicFence(B
: BuilderRef
, Order
: AtomicOrdering
);
1533 /* Selected entries from the downcasts. */
1534 pub fn LLVMIsATerminatorInst(Inst
: ValueRef
) -> ValueRef
;
1535 pub fn LLVMIsAStoreInst(Inst
: ValueRef
) -> ValueRef
;
1537 /// Writes a module to the specified path. Returns 0 on success.
1538 pub fn LLVMWriteBitcodeToFile(M
: ModuleRef
, Path
: *const c_char
) -> c_int
;
1540 /// Creates target data from a target layout string.
1541 pub fn LLVMCreateTargetData(StringRep
: *const c_char
) -> TargetDataRef
;
1542 /// Adds the target data to the given pass manager. The pass manager
1543 /// references the target data only weakly.
1544 pub fn LLVMAddTargetData(TD
: TargetDataRef
, PM
: PassManagerRef
);
1545 /// Number of bytes clobbered when doing a Store to *T.
1546 pub fn LLVMStoreSizeOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1549 /// Number of bytes clobbered when doing a Store to *T.
1550 pub fn LLVMSizeOfTypeInBits(TD
: TargetDataRef
, Ty
: TypeRef
)
1553 /// Distance between successive elements in an array of T. Includes ABI padding.
1554 pub fn LLVMABISizeOfType(TD
: TargetDataRef
, Ty
: TypeRef
) -> c_ulonglong
;
1556 /// Returns the preferred alignment of a type.
1557 pub fn LLVMPreferredAlignmentOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1559 /// Returns the minimum alignment of a type.
1560 pub fn LLVMABIAlignmentOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1563 /// Computes the byte offset of the indexed struct element for a
1565 pub fn LLVMOffsetOfElement(TD
: TargetDataRef
,
1570 /// Returns the minimum alignment of a type when part of a call frame.
1571 pub fn LLVMCallFrameAlignmentOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1574 /// Disposes target data.
1575 pub fn LLVMDisposeTargetData(TD
: TargetDataRef
);
1577 /// Creates a pass manager.
1578 pub fn LLVMCreatePassManager() -> PassManagerRef
;
1580 /// Creates a function-by-function pass manager
1581 pub fn LLVMCreateFunctionPassManagerForModule(M
: ModuleRef
)
1584 /// Disposes a pass manager.
1585 pub fn LLVMDisposePassManager(PM
: PassManagerRef
);
1587 /// Runs a pass manager on a module.
1588 pub fn LLVMRunPassManager(PM
: PassManagerRef
, M
: ModuleRef
) -> Bool
;
1590 /// Runs the function passes on the provided function.
1591 pub fn LLVMRunFunctionPassManager(FPM
: PassManagerRef
, F
: ValueRef
)
1594 /// Initializes all the function passes scheduled in the manager
1595 pub fn LLVMInitializeFunctionPassManager(FPM
: PassManagerRef
) -> Bool
;
1597 /// Finalizes all the function passes scheduled in the manager
1598 pub fn LLVMFinalizeFunctionPassManager(FPM
: PassManagerRef
) -> Bool
;
1600 pub fn LLVMInitializePasses();
1602 /// Adds a verification pass.
1603 pub fn LLVMAddVerifierPass(PM
: PassManagerRef
);
1605 pub fn LLVMAddGlobalOptimizerPass(PM
: PassManagerRef
);
1606 pub fn LLVMAddIPSCCPPass(PM
: PassManagerRef
);
1607 pub fn LLVMAddDeadArgEliminationPass(PM
: PassManagerRef
);
1608 pub fn LLVMAddInstructionCombiningPass(PM
: PassManagerRef
);
1609 pub fn LLVMAddCFGSimplificationPass(PM
: PassManagerRef
);
1610 pub fn LLVMAddFunctionInliningPass(PM
: PassManagerRef
);
1611 pub fn LLVMAddFunctionAttrsPass(PM
: PassManagerRef
);
1612 pub fn LLVMAddScalarReplAggregatesPass(PM
: PassManagerRef
);
1613 pub fn LLVMAddScalarReplAggregatesPassSSA(PM
: PassManagerRef
);
1614 pub fn LLVMAddJumpThreadingPass(PM
: PassManagerRef
);
1615 pub fn LLVMAddConstantPropagationPass(PM
: PassManagerRef
);
1616 pub fn LLVMAddReassociatePass(PM
: PassManagerRef
);
1617 pub fn LLVMAddLoopRotatePass(PM
: PassManagerRef
);
1618 pub fn LLVMAddLICMPass(PM
: PassManagerRef
);
1619 pub fn LLVMAddLoopUnswitchPass(PM
: PassManagerRef
);
1620 pub fn LLVMAddLoopDeletionPass(PM
: PassManagerRef
);
1621 pub fn LLVMAddLoopUnrollPass(PM
: PassManagerRef
);
1622 pub fn LLVMAddGVNPass(PM
: PassManagerRef
);
1623 pub fn LLVMAddMemCpyOptPass(PM
: PassManagerRef
);
1624 pub fn LLVMAddSCCPPass(PM
: PassManagerRef
);
1625 pub fn LLVMAddDeadStoreEliminationPass(PM
: PassManagerRef
);
1626 pub fn LLVMAddStripDeadPrototypesPass(PM
: PassManagerRef
);
1627 pub fn LLVMAddConstantMergePass(PM
: PassManagerRef
);
1628 pub fn LLVMAddArgumentPromotionPass(PM
: PassManagerRef
);
1629 pub fn LLVMAddTailCallEliminationPass(PM
: PassManagerRef
);
1630 pub fn LLVMAddIndVarSimplifyPass(PM
: PassManagerRef
);
1631 pub fn LLVMAddAggressiveDCEPass(PM
: PassManagerRef
);
1632 pub fn LLVMAddGlobalDCEPass(PM
: PassManagerRef
);
1633 pub fn LLVMAddCorrelatedValuePropagationPass(PM
: PassManagerRef
);
1634 pub fn LLVMAddPruneEHPass(PM
: PassManagerRef
);
1635 pub fn LLVMAddSimplifyLibCallsPass(PM
: PassManagerRef
);
1636 pub fn LLVMAddLoopIdiomPass(PM
: PassManagerRef
);
1637 pub fn LLVMAddEarlyCSEPass(PM
: PassManagerRef
);
1638 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM
: PassManagerRef
);
1639 pub fn LLVMAddBasicAliasAnalysisPass(PM
: PassManagerRef
);
1641 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef
;
1642 pub fn LLVMPassManagerBuilderDispose(PMB
: PassManagerBuilderRef
);
1643 pub fn LLVMPassManagerBuilderSetOptLevel(PMB
: PassManagerBuilderRef
,
1644 OptimizationLevel
: c_uint
);
1645 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB
: PassManagerBuilderRef
,
1647 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1648 PMB
: PassManagerBuilderRef
,
1650 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1651 PMB
: PassManagerBuilderRef
,
1653 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1654 PMB
: PassManagerBuilderRef
,
1656 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1657 PMB
: PassManagerBuilderRef
,
1659 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1660 PMB
: PassManagerBuilderRef
,
1661 PM
: PassManagerRef
);
1663 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1664 PMB
: PassManagerBuilderRef
,
1665 PM
: PassManagerRef
);
1666 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1667 PMB
: PassManagerBuilderRef
,
1672 /// Destroys a memory buffer.
1673 pub fn LLVMDisposeMemoryBuffer(MemBuf
: MemoryBufferRef
);
1676 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1678 /// Opens an object file.
1679 pub fn LLVMCreateObjectFile(MemBuf
: MemoryBufferRef
) -> ObjectFileRef
;
1680 /// Closes an object file.
1681 pub fn LLVMDisposeObjectFile(ObjFile
: ObjectFileRef
);
1683 /// Enumerates the sections in an object file.
1684 pub fn LLVMGetSections(ObjFile
: ObjectFileRef
) -> SectionIteratorRef
;
1685 /// Destroys a section iterator.
1686 pub fn LLVMDisposeSectionIterator(SI
: SectionIteratorRef
);
1687 /// Returns true if the section iterator is at the end of the section
1689 pub fn LLVMIsSectionIteratorAtEnd(ObjFile
: ObjectFileRef
,
1690 SI
: SectionIteratorRef
)
1692 /// Moves the section iterator to point to the next section.
1693 pub fn LLVMMoveToNextSection(SI
: SectionIteratorRef
);
1694 /// Returns the current section size.
1695 pub fn LLVMGetSectionSize(SI
: SectionIteratorRef
) -> c_ulonglong
;
1696 /// Returns the current section contents as a string buffer.
1697 pub fn LLVMGetSectionContents(SI
: SectionIteratorRef
) -> *const c_char
;
1699 /// Reads the given file and returns it as a memory buffer. Use
1700 /// LLVMDisposeMemoryBuffer() to get rid of it.
1701 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path
: *const c_char
)
1703 /// Borrows the contents of the memory buffer (doesn't copy it)
1704 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData
: *const c_char
,
1705 InputDataLength
: size_t
,
1706 BufferName
: *const c_char
,
1709 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData
: *const c_char
,
1710 InputDataLength
: size_t
,
1711 BufferName
: *const c_char
)
1714 pub fn LLVMIsMultithreaded() -> Bool
;
1715 pub fn LLVMStartMultithreaded() -> Bool
;
1717 /// Returns a string describing the last error caused by an LLVMRust* call.
1718 pub fn LLVMRustGetLastError() -> *const c_char
;
1720 /// Print the pass timings since static dtors aren't picking them up.
1721 pub fn LLVMRustPrintPassTimings();
1723 pub fn LLVMStructCreateNamed(C
: ContextRef
, Name
: *const c_char
) -> TypeRef
;
1725 pub fn LLVMStructSetBody(StructTy
: TypeRef
,
1726 ElementTypes
: *const TypeRef
,
1727 ElementCount
: c_uint
,
1730 pub fn LLVMConstNamedStruct(S
: TypeRef
,
1731 ConstantVals
: *const ValueRef
,
1735 /// Enables LLVM debug output.
1736 pub fn LLVMSetDebug(Enabled
: c_int
);
1738 /// Prepares inline assembly.
1739 pub fn LLVMInlineAsm(Ty
: TypeRef
,
1740 AsmString
: *const c_char
,
1741 Constraints
: *const c_char
,
1747 pub static LLVMRustDebugMetadataVersion
: u32;
1749 pub fn LLVMRustAddModuleFlag(M
: ModuleRef
,
1750 name
: *const c_char
,
1753 pub fn LLVMDIBuilderCreate(M
: ModuleRef
) -> DIBuilderRef
;
1755 pub fn LLVMDIBuilderDispose(Builder
: DIBuilderRef
);
1757 pub fn LLVMDIBuilderFinalize(Builder
: DIBuilderRef
);
1759 pub fn LLVMDIBuilderCreateCompileUnit(Builder
: DIBuilderRef
,
1761 File
: *const c_char
,
1763 Producer
: *const c_char
,
1765 Flags
: *const c_char
,
1767 SplitName
: *const c_char
)
1770 pub fn LLVMDIBuilderCreateFile(Builder
: DIBuilderRef
,
1771 Filename
: *const c_char
,
1772 Directory
: *const c_char
)
1775 pub fn LLVMDIBuilderCreateSubroutineType(Builder
: DIBuilderRef
,
1777 ParameterTypes
: DIArray
)
1780 pub fn LLVMDIBuilderCreateFunction(Builder
: DIBuilderRef
,
1781 Scope
: DIDescriptor
,
1782 Name
: *const c_char
,
1783 LinkageName
: *const c_char
,
1787 isLocalToUnit
: bool
,
1797 pub fn LLVMDIBuilderCreateBasicType(Builder
: DIBuilderRef
,
1798 Name
: *const c_char
,
1799 SizeInBits
: c_ulonglong
,
1800 AlignInBits
: c_ulonglong
,
1804 pub fn LLVMDIBuilderCreatePointerType(Builder
: DIBuilderRef
,
1806 SizeInBits
: c_ulonglong
,
1807 AlignInBits
: c_ulonglong
,
1808 Name
: *const c_char
)
1811 pub fn LLVMDIBuilderCreateStructType(Builder
: DIBuilderRef
,
1812 Scope
: DIDescriptor
,
1813 Name
: *const c_char
,
1816 SizeInBits
: c_ulonglong
,
1817 AlignInBits
: c_ulonglong
,
1819 DerivedFrom
: DIType
,
1821 RunTimeLang
: c_uint
,
1822 VTableHolder
: DIType
,
1823 UniqueId
: *const c_char
)
1826 pub fn LLVMDIBuilderCreateMemberType(Builder
: DIBuilderRef
,
1827 Scope
: DIDescriptor
,
1828 Name
: *const c_char
,
1831 SizeInBits
: c_ulonglong
,
1832 AlignInBits
: c_ulonglong
,
1833 OffsetInBits
: c_ulonglong
,
1838 pub fn LLVMDIBuilderCreateLexicalBlock(Builder
: DIBuilderRef
,
1845 pub fn LLVMDIBuilderCreateStaticVariable(Builder
: DIBuilderRef
,
1847 Name
: *const c_char
,
1848 LinkageName
: *const c_char
,
1852 isLocalToUnit
: bool
,
1855 -> DIGlobalVariable
;
1857 pub fn LLVMDIBuilderCreateVariable(Builder
: DIBuilderRef
,
1859 Scope
: DIDescriptor
,
1860 Name
: *const c_char
,
1864 AlwaysPreserve
: bool
,
1866 AddrOps
: *const i64,
1867 AddrOpsCount
: c_uint
,
1871 pub fn LLVMDIBuilderCreateArrayType(Builder
: DIBuilderRef
,
1873 AlignInBits
: c_ulonglong
,
1875 Subscripts
: DIArray
)
1878 pub fn LLVMDIBuilderCreateVectorType(Builder
: DIBuilderRef
,
1880 AlignInBits
: c_ulonglong
,
1882 Subscripts
: DIArray
)
1885 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder
: DIBuilderRef
,
1890 pub fn LLVMDIBuilderGetOrCreateArray(Builder
: DIBuilderRef
,
1891 Ptr
: *const DIDescriptor
,
1895 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder
: DIBuilderRef
,
1897 VarInfo
: DIVariable
,
1898 AddrOps
: *const i64,
1899 AddrOpsCount
: c_uint
,
1900 InsertAtEnd
: BasicBlockRef
)
1903 pub fn LLVMDIBuilderInsertDeclareBefore(Builder
: DIBuilderRef
,
1905 VarInfo
: DIVariable
,
1906 AddrOps
: *const i64,
1907 AddrOpsCount
: c_uint
,
1908 InsertBefore
: ValueRef
)
1911 pub fn LLVMDIBuilderCreateEnumerator(Builder
: DIBuilderRef
,
1912 Name
: *const c_char
,
1916 pub fn LLVMDIBuilderCreateEnumerationType(Builder
: DIBuilderRef
,
1918 Name
: *const c_char
,
1921 SizeInBits
: c_ulonglong
,
1922 AlignInBits
: c_ulonglong
,
1927 pub fn LLVMDIBuilderCreateUnionType(Builder
: DIBuilderRef
,
1929 Name
: *const c_char
,
1932 SizeInBits
: c_ulonglong
,
1933 AlignInBits
: c_ulonglong
,
1936 RunTimeLang
: c_uint
,
1937 UniqueId
: *const c_char
)
1940 pub fn LLVMSetUnnamedAddr(GlobalVar
: ValueRef
, UnnamedAddr
: Bool
);
1942 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder
: DIBuilderRef
,
1944 Name
: *const c_char
,
1949 -> DITemplateTypeParameter
;
1951 pub fn LLVMDIBuilderCreateOpDeref() -> i64;
1953 pub fn LLVMDIBuilderCreateOpPlus() -> i64;
1955 pub fn LLVMDIBuilderCreateNameSpace(Builder
: DIBuilderRef
,
1957 Name
: *const c_char
,
1962 pub fn LLVMDIBuilderCreateDebugLocation(Context
: ContextRef
,
1966 InlinedAt
: MetadataRef
)
1969 pub fn LLVMDICompositeTypeSetTypeArray(Builder
: DIBuilderRef
,
1970 CompositeType
: DIType
,
1971 TypeArray
: DIArray
);
1972 pub fn LLVMWriteTypeToString(Type
: TypeRef
, s
: RustStringRef
);
1973 pub fn LLVMWriteValueToString(value_ref
: ValueRef
, s
: RustStringRef
);
1975 pub fn LLVMIsAArgument(value_ref
: ValueRef
) -> ValueRef
;
1977 pub fn LLVMIsAAllocaInst(value_ref
: ValueRef
) -> ValueRef
;
1978 pub fn LLVMIsAConstantInt(value_ref
: ValueRef
) -> ValueRef
;
1980 pub fn LLVMInitializeX86TargetInfo();
1981 pub fn LLVMInitializeX86Target();
1982 pub fn LLVMInitializeX86TargetMC();
1983 pub fn LLVMInitializeX86AsmPrinter();
1984 pub fn LLVMInitializeX86AsmParser();
1985 pub fn LLVMInitializeARMTargetInfo();
1986 pub fn LLVMInitializeARMTarget();
1987 pub fn LLVMInitializeARMTargetMC();
1988 pub fn LLVMInitializeARMAsmPrinter();
1989 pub fn LLVMInitializeARMAsmParser();
1990 pub fn LLVMInitializeAArch64TargetInfo();
1991 pub fn LLVMInitializeAArch64Target();
1992 pub fn LLVMInitializeAArch64TargetMC();
1993 pub fn LLVMInitializeAArch64AsmPrinter();
1994 pub fn LLVMInitializeAArch64AsmParser();
1995 pub fn LLVMInitializeMipsTargetInfo();
1996 pub fn LLVMInitializeMipsTarget();
1997 pub fn LLVMInitializeMipsTargetMC();
1998 pub fn LLVMInitializeMipsAsmPrinter();
1999 pub fn LLVMInitializeMipsAsmParser();
2000 pub fn LLVMInitializePowerPCTargetInfo();
2001 pub fn LLVMInitializePowerPCTarget();
2002 pub fn LLVMInitializePowerPCTargetMC();
2003 pub fn LLVMInitializePowerPCAsmPrinter();
2004 pub fn LLVMInitializePowerPCAsmParser();
2006 pub fn LLVMRustAddPass(PM
: PassManagerRef
, Pass
: *const c_char
) -> bool
;
2007 pub fn LLVMRustCreateTargetMachine(Triple
: *const c_char
,
2009 Features
: *const c_char
,
2010 Model
: CodeGenModel
,
2012 Level
: CodeGenOptLevel
,
2015 NoFramePointerElim
: bool
,
2016 PositionIndependentExecutable
: bool
,
2017 FunctionSections
: bool
,
2018 DataSections
: bool
) -> TargetMachineRef
;
2019 pub fn LLVMRustDisposeTargetMachine(T
: TargetMachineRef
);
2020 pub fn LLVMRustAddAnalysisPasses(T
: TargetMachineRef
,
2023 pub fn LLVMRustAddBuilderLibraryInfo(PMB
: PassManagerBuilderRef
,
2025 DisableSimplifyLibCalls
: bool
);
2026 pub fn LLVMRustAddLibraryInfo(PM
: PassManagerRef
, M
: ModuleRef
,
2027 DisableSimplifyLibCalls
: bool
);
2028 pub fn LLVMRustRunFunctionPassManager(PM
: PassManagerRef
, M
: ModuleRef
);
2029 pub fn LLVMRustWriteOutputFile(T
: TargetMachineRef
,
2032 Output
: *const c_char
,
2033 FileType
: FileType
) -> bool
;
2034 pub fn LLVMRustPrintModule(PM
: PassManagerRef
,
2036 Output
: *const c_char
);
2037 pub fn LLVMRustSetLLVMOptions(Argc
: c_int
, Argv
: *const *const c_char
);
2038 pub fn LLVMRustPrintPasses();
2039 pub fn LLVMRustSetNormalizedTarget(M
: ModuleRef
, triple
: *const c_char
);
2040 pub fn LLVMRustAddAlwaysInlinePass(P
: PassManagerBuilderRef
,
2041 AddLifetimes
: bool
);
2042 pub fn LLVMRustLinkInExternalBitcode(M
: ModuleRef
,
2044 len
: size_t
) -> bool
;
2045 pub fn LLVMRustRunRestrictionPass(M
: ModuleRef
,
2046 syms
: *const *const c_char
,
2048 pub fn LLVMRustMarkAllFunctionsNounwind(M
: ModuleRef
);
2050 pub fn LLVMRustOpenArchive(path
: *const c_char
) -> ArchiveRef
;
2051 pub fn LLVMRustArchiveReadSection(AR
: ArchiveRef
, name
: *const c_char
,
2052 out_len
: *mut size_t
) -> *const c_char
;
2053 pub fn LLVMRustDestroyArchive(AR
: ArchiveRef
);
2055 pub fn LLVMRustSetDLLExportStorageClass(V
: ValueRef
);
2056 pub fn LLVMVersionMajor() -> c_int
;
2057 pub fn LLVMVersionMinor() -> c_int
;
2059 pub fn LLVMRustGetSectionName(SI
: SectionIteratorRef
,
2060 data
: *mut *const c_char
) -> c_int
;
2062 pub fn LLVMWriteTwineToString(T
: TwineRef
, s
: RustStringRef
);
2064 pub fn LLVMContextSetDiagnosticHandler(C
: ContextRef
,
2065 Handler
: DiagnosticHandler
,
2066 DiagnosticContext
: *mut c_void
);
2068 pub fn LLVMUnpackOptimizationDiagnostic(DI
: DiagnosticInfoRef
,
2069 pass_name_out
: *mut *const c_char
,
2070 function_out
: *mut ValueRef
,
2071 debugloc_out
: *mut DebugLocRef
,
2072 message_out
: *mut TwineRef
);
2073 pub fn LLVMUnpackInlineAsmDiagnostic(DI
: DiagnosticInfoRef
,
2074 cookie_out
: *mut c_uint
,
2075 message_out
: *mut TwineRef
,
2076 instruction_out
: *mut ValueRef
);
2078 pub fn LLVMWriteDiagnosticInfoToString(DI
: DiagnosticInfoRef
, s
: RustStringRef
);
2079 pub fn LLVMGetDiagInfoSeverity(DI
: DiagnosticInfoRef
) -> DiagnosticSeverity
;
2080 pub fn LLVMGetDiagInfoKind(DI
: DiagnosticInfoRef
) -> DiagnosticKind
;
2082 pub fn LLVMWriteDebugLocToString(C
: ContextRef
, DL
: DebugLocRef
, s
: RustStringRef
);
2084 pub fn LLVMSetInlineAsmDiagnosticHandler(C
: ContextRef
,
2085 H
: InlineAsmDiagHandler
,
2088 pub fn LLVMWriteSMDiagnosticToString(d
: SMDiagnosticRef
, s
: RustStringRef
);
2091 pub fn SetInstructionCallConv(instr
: ValueRef
, cc
: CallConv
) {
2093 LLVMSetInstructionCallConv(instr
, cc
as c_uint
);
2096 pub fn SetFunctionCallConv(fn_
: ValueRef
, cc
: CallConv
) {
2098 LLVMSetFunctionCallConv(fn_
, cc
as c_uint
);
2101 pub fn SetLinkage(global
: ValueRef
, link
: Linkage
) {
2103 LLVMSetLinkage(global
, link
as c_uint
);
2107 pub fn SetUnnamedAddr(global
: ValueRef
, unnamed
: bool
) {
2109 LLVMSetUnnamedAddr(global
, unnamed
as Bool
);
2113 pub fn set_thread_local(global
: ValueRef
, is_thread_local
: bool
) {
2115 LLVMSetThreadLocal(global
, is_thread_local
as Bool
);
2119 pub fn ConstICmp(pred
: IntPredicate
, v1
: ValueRef
, v2
: ValueRef
) -> ValueRef
{
2121 LLVMConstICmp(pred
as c_ushort
, v1
, v2
)
2124 pub fn ConstFCmp(pred
: RealPredicate
, v1
: ValueRef
, v2
: ValueRef
) -> ValueRef
{
2126 LLVMConstFCmp(pred
as c_ushort
, v1
, v2
)
2130 pub fn SetFunctionAttribute(fn_
: ValueRef
, attr
: Attribute
) {
2132 LLVMAddFunctionAttribute(fn_
, FunctionIndex
as c_uint
, attr
.bits() as uint64_t
)
2136 /* Memory-managed interface to target data. */
2138 pub struct TargetData
{
2139 pub lltd
: TargetDataRef
2142 impl Drop
for TargetData
{
2143 fn drop(&mut self) {
2145 LLVMDisposeTargetData(self.lltd
);
2150 pub fn mk_target_data(string_rep
: &str) -> TargetData
{
2151 let string_rep
= CString
::new(string_rep
).unwrap();
2153 lltd
: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2157 /* Memory-managed interface to object files. */
2159 pub struct ObjectFile
{
2160 pub llof
: ObjectFileRef
,
2164 // This will take ownership of llmb
2165 pub fn new(llmb
: MemoryBufferRef
) -> Option
<ObjectFile
> {
2167 let llof
= LLVMCreateObjectFile(llmb
);
2168 if llof
as isize == 0 {
2169 // LLVMCreateObjectFile took ownership of llmb
2180 impl Drop
for ObjectFile
{
2181 fn drop(&mut self) {
2183 LLVMDisposeObjectFile(self.llof
);
2188 /* Memory-managed interface to section iterators. */
2190 pub struct SectionIter
{
2191 pub llsi
: SectionIteratorRef
2194 impl Drop
for SectionIter
{
2195 fn drop(&mut self) {
2197 LLVMDisposeSectionIterator(self.llsi
);
2202 pub fn mk_section_iter(llof
: ObjectFileRef
) -> SectionIter
{
2205 llsi
: LLVMGetSections(llof
)
2210 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2211 pub fn get_param(llfn
: ValueRef
, index
: c_uint
) -> ValueRef
{
2213 assert
!(index
< LLVMCountParams(llfn
));
2214 LLVMGetParam(llfn
, index
)
2218 #[allow(missing_copy_implementations)]
2219 pub enum RustString_opaque {}
2220 pub type RustStringRef
= *mut RustString_opaque
;
2221 type RustStringRepr
= *mut RefCell
<Vec
<u8>>;
2223 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2225 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr
: RustStringRef
,
2228 let slice
= slice
::from_raw_parts(ptr
as *const u8, size
as usize);
2230 let sr
: RustStringRepr
= mem
::transmute(sr
);
2231 (*sr
).borrow_mut().push_all(slice
);
2234 pub fn build_string
<F
>(f
: F
) -> Option
<String
> where F
: FnOnce(RustStringRef
){
2235 let mut buf
= RefCell
::new(Vec
::new());
2236 f(&mut buf
as RustStringRepr
as RustStringRef
);
2237 String
::from_utf8(buf
.into_inner()).ok()
2240 pub unsafe fn twine_to_string(tr
: TwineRef
) -> String
{
2241 build_string(|s
| LLVMWriteTwineToString(tr
, s
))
2242 .expect("got a non-UTF8 Twine from LLVM")
2245 pub unsafe fn debug_loc_to_string(c
: ContextRef
, tr
: DebugLocRef
) -> String
{
2246 build_string(|s
| LLVMWriteDebugLocToString(c
, tr
, s
))
2247 .expect("got a non-UTF8 DebugLoc from LLVM")
2250 // The module containing the native LLVM dependencies, generated by the build system
2251 // Note that this must come after the rustllvm extern declaration so that
2252 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2253 // Works to the above fix for #15460 to ensure LLVM dependencies that
2254 // are only used by rustllvm don't get stripped by the linker.
2256 include
! { env!("CFG_LLVM_LINKAGE_FILE") }