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")]
19 #![crate_type = "dylib"]
20 #![crate_type = "rlib"]
21 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22 html_favicon_url
= "http://www.rust-lang.org/favicon.ico",
23 html_root_url
= "http://doc.rust-lang.org/nightly/")]
25 #![feature(box_syntax)]
26 #![feature(collections)]
30 #![feature(link_args)]
32 #![feature(staged_api)]
36 #[macro_use] #[no_link] extern crate rustc_bitflags;
38 pub use self::OtherAttribute
::*;
39 pub use self::SpecialAttribute
::*;
40 pub use self::AttributeSet
::*;
41 pub use self::IntPredicate
::*;
42 pub use self::RealPredicate
::*;
43 pub use self::TypeKind
::*;
44 pub use self::AtomicBinOp
::*;
45 pub use self::AtomicOrdering
::*;
46 pub use self::FileType
::*;
47 pub use self::MetadataType
::*;
48 pub use self::AsmDialect
::*;
49 pub use self::CodeGenOptLevel
::*;
50 pub use self::RelocMode
::*;
51 pub use self::CodeGenModel
::*;
52 pub use self::DiagnosticKind
::*;
53 pub use self::CallConv
::*;
54 pub use self::Visibility
::*;
55 pub use self::DiagnosticSeverity
::*;
56 pub use self::Linkage
::*;
58 use std
::ffi
::CString
;
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 uint.
80 #[derive(Copy, PartialEq)]
85 X86StdcallCallConv
= 64,
86 X86FastcallCallConv
= 65,
92 LLVMDefaultVisibility
= 0,
94 ProtectedVisibility
= 2,
97 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
98 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
99 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
100 // they've been removed in upstream LLVM commit r203866.
104 AvailableExternallyLinkage
= 1,
105 LinkOnceAnyLinkage
= 2,
106 LinkOnceODRLinkage
= 3,
109 AppendingLinkage
= 7,
112 ExternalWeakLinkage
= 12,
117 #[derive(Copy, Debug)]
118 pub enum DiagnosticSeverity
{
126 flags Attribute
: u32 {
127 const ZExtAttribute
= 1 << 0,
128 const SExtAttribute
= 1 << 1,
129 const NoReturnAttribute
= 1 << 2,
130 const InRegAttribute
= 1 << 3,
131 const StructRetAttribute
= 1 << 4,
132 const NoUnwindAttribute
= 1 << 5,
133 const NoAliasAttribute
= 1 << 6,
134 const ByValAttribute
= 1 << 7,
135 const NestAttribute
= 1 << 8,
136 const ReadNoneAttribute
= 1 << 9,
137 const ReadOnlyAttribute
= 1 << 10,
138 const NoInlineAttribute
= 1 << 11,
139 const AlwaysInlineAttribute
= 1 << 12,
140 const OptimizeForSizeAttribute
= 1 << 13,
141 const StackProtectAttribute
= 1 << 14,
142 const StackProtectReqAttribute
= 1 << 15,
143 const AlignmentAttribute
= 31 << 16,
144 const NoCaptureAttribute
= 1 << 21,
145 const NoRedZoneAttribute
= 1 << 22,
146 const NoImplicitFloatAttribute
= 1 << 23,
147 const NakedAttribute
= 1 << 24,
148 const InlineHintAttribute
= 1 << 25,
149 const StackAttribute
= 7 << 26,
150 const ReturnsTwiceAttribute
= 1 << 29,
151 const UWTableAttribute
= 1 << 30,
152 const NonLazyBindAttribute
= 1 << 31,
159 pub enum OtherAttribute
{
160 // The following are not really exposed in
161 // the LLVM c api so instead to add these
162 // we call a wrapper function in RustWrapper
163 // that uses the C++ api.
164 SanitizeAddressAttribute
= 1 << 32,
165 MinSizeAttribute
= 1 << 33,
166 NoDuplicateAttribute
= 1 << 34,
167 StackProtectStrongAttribute
= 1 << 35,
168 SanitizeThreadAttribute
= 1 << 36,
169 SanitizeMemoryAttribute
= 1 << 37,
170 NoBuiltinAttribute
= 1 << 38,
171 ReturnedAttribute
= 1 << 39,
172 ColdAttribute
= 1 << 40,
173 BuiltinAttribute
= 1 << 41,
174 OptimizeNoneAttribute
= 1 << 42,
175 InAllocaAttribute
= 1 << 43,
176 NonNullAttribute
= 1 << 44,
180 pub enum SpecialAttribute
{
181 DereferenceableAttribute(u64)
186 pub enum AttributeSet
{
191 pub trait AttrHelper
{
192 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
);
193 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
);
196 impl AttrHelper
for Attribute
{
197 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
) {
199 LLVMAddFunctionAttribute(llfn
, idx
, self.bits() as uint64_t
);
203 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
) {
205 LLVMAddCallSiteAttribute(callsite
, idx
, self.bits() as uint64_t
);
210 impl AttrHelper
for OtherAttribute
{
211 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
) {
213 LLVMAddFunctionAttribute(llfn
, idx
, *self as uint64_t
);
217 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
) {
219 LLVMAddCallSiteAttribute(callsite
, idx
, *self as uint64_t
);
224 impl AttrHelper
for SpecialAttribute
{
225 fn apply_llfn(&self, idx
: c_uint
, llfn
: ValueRef
) {
227 DereferenceableAttribute(bytes
) => unsafe {
228 LLVMAddDereferenceableAttr(llfn
, idx
, bytes
as uint64_t
);
233 fn apply_callsite(&self, idx
: c_uint
, callsite
: ValueRef
) {
235 DereferenceableAttribute(bytes
) => unsafe {
236 LLVMAddDereferenceableCallSiteAttr(callsite
, idx
, bytes
as uint64_t
);
242 pub struct AttrBuilder
{
243 attrs
: Vec
<(uint
, Box
<AttrHelper
+'
static>)>
247 pub fn new() -> AttrBuilder
{
253 pub fn arg
<'a
, T
: AttrHelper
+ '
static>(&'a
mut self, idx
: uint
, a
: T
) -> &'a
mut AttrBuilder
{
254 self.attrs
.push((idx
, box a
as Box
<AttrHelper
+'
static>));
258 pub fn ret
<'a
, T
: AttrHelper
+ '
static>(&'a
mut self, a
: T
) -> &'a
mut AttrBuilder
{
259 self.attrs
.push((ReturnIndex
as uint
, box a
as Box
<AttrHelper
+'
static>));
263 pub fn apply_llfn(&self, llfn
: ValueRef
) {
264 for &(idx
, ref attr
) in &self.attrs
{
265 attr
.apply_llfn(idx
as c_uint
, llfn
);
269 pub fn apply_callsite(&self, callsite
: ValueRef
) {
270 for &(idx
, ref attr
) in &self.attrs
{
271 attr
.apply_callsite(idx
as c_uint
, callsite
);
276 // enum for the LLVM IntPredicate type
278 pub enum IntPredicate
{
291 // enum for the LLVM RealPredicate type
293 pub enum RealPredicate
{
294 RealPredicateFalse
= 0,
309 RealPredicateTrue
= 15,
312 // The LLVM TypeKind type - must stay in sync with the def of
313 // LLVMTypeKind in llvm/include/llvm-c/Core.h
314 #[derive(Copy, PartialEq, Debug)]
337 pub enum AtomicBinOp
{
353 pub enum AtomicOrdering
{
357 // Consume = 3, // Not specified yet.
361 SequentiallyConsistent
= 7
364 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
368 AssemblyFileType
= 0,
373 pub enum MetadataType
{
380 MD_invariant_load
= 6,
384 MD_mem_parallel_loop_access
= 10,
388 // Inline Asm Dialect
390 pub enum AsmDialect
{
395 #[derive(Copy, PartialEq, Clone)]
397 pub enum CodeGenOptLevel
{
398 CodeGenLevelNone
= 0,
399 CodeGenLevelLess
= 1,
400 CodeGenLevelDefault
= 2,
401 CodeGenLevelAggressive
= 3,
404 #[derive(Copy, PartialEq)]
410 RelocDynamicNoPic
= 3,
415 pub enum CodeGenModel
{
416 CodeModelDefault
= 0,
417 CodeModelJITDefault
= 1,
426 pub enum DiagnosticKind
{
429 DK_DebugMetadataVersion
,
431 DK_OptimizationRemark
,
432 DK_OptimizationRemarkMissed
,
433 DK_OptimizationRemarkAnalysis
,
434 DK_OptimizationFailure
,
437 // Opaque pointer types
438 #[allow(missing_copy_implementations)]
439 pub enum Module_opaque {}
440 pub type ModuleRef
= *mut Module_opaque
;
441 #[allow(missing_copy_implementations)]
442 pub enum Context_opaque {}
443 pub type ContextRef
= *mut Context_opaque
;
444 #[allow(missing_copy_implementations)]
445 pub enum Type_opaque {}
446 pub type TypeRef
= *mut Type_opaque
;
447 #[allow(missing_copy_implementations)]
448 pub enum Value_opaque {}
449 pub type ValueRef
= *mut Value_opaque
;
450 #[allow(missing_copy_implementations)]
451 pub enum Metadata_opaque {}
452 pub type MetadataRef
= *mut Metadata_opaque
;
453 #[allow(missing_copy_implementations)]
454 pub enum BasicBlock_opaque {}
455 pub type BasicBlockRef
= *mut BasicBlock_opaque
;
456 #[allow(missing_copy_implementations)]
457 pub enum Builder_opaque {}
458 pub type BuilderRef
= *mut Builder_opaque
;
459 #[allow(missing_copy_implementations)]
460 pub enum ExecutionEngine_opaque {}
461 pub type ExecutionEngineRef
= *mut ExecutionEngine_opaque
;
462 #[allow(missing_copy_implementations)]
463 pub enum RustJITMemoryManager_opaque {}
464 pub type RustJITMemoryManagerRef
= *mut RustJITMemoryManager_opaque
;
465 #[allow(missing_copy_implementations)]
466 pub enum MemoryBuffer_opaque {}
467 pub type MemoryBufferRef
= *mut MemoryBuffer_opaque
;
468 #[allow(missing_copy_implementations)]
469 pub enum PassManager_opaque {}
470 pub type PassManagerRef
= *mut PassManager_opaque
;
471 #[allow(missing_copy_implementations)]
472 pub enum PassManagerBuilder_opaque {}
473 pub type PassManagerBuilderRef
= *mut PassManagerBuilder_opaque
;
474 #[allow(missing_copy_implementations)]
475 pub enum Use_opaque {}
476 pub type UseRef
= *mut Use_opaque
;
477 #[allow(missing_copy_implementations)]
478 pub enum TargetData_opaque {}
479 pub type TargetDataRef
= *mut TargetData_opaque
;
480 #[allow(missing_copy_implementations)]
481 pub enum ObjectFile_opaque {}
482 pub type ObjectFileRef
= *mut ObjectFile_opaque
;
483 #[allow(missing_copy_implementations)]
484 pub enum SectionIterator_opaque {}
485 pub type SectionIteratorRef
= *mut SectionIterator_opaque
;
486 #[allow(missing_copy_implementations)]
487 pub enum Pass_opaque {}
488 pub type PassRef
= *mut Pass_opaque
;
489 #[allow(missing_copy_implementations)]
490 pub enum TargetMachine_opaque {}
491 pub type TargetMachineRef
= *mut TargetMachine_opaque
;
492 #[allow(missing_copy_implementations)]
493 pub enum Archive_opaque {}
494 pub type ArchiveRef
= *mut Archive_opaque
;
495 #[allow(missing_copy_implementations)]
496 pub enum Twine_opaque {}
497 pub type TwineRef
= *mut Twine_opaque
;
498 #[allow(missing_copy_implementations)]
499 pub enum DiagnosticInfo_opaque {}
500 pub type DiagnosticInfoRef
= *mut DiagnosticInfo_opaque
;
501 #[allow(missing_copy_implementations)]
502 pub enum DebugLoc_opaque {}
503 pub type DebugLocRef
= *mut DebugLoc_opaque
;
504 #[allow(missing_copy_implementations)]
505 pub enum SMDiagnostic_opaque {}
506 pub type SMDiagnosticRef
= *mut SMDiagnostic_opaque
;
508 pub type DiagnosticHandler
= unsafe extern "C" fn(DiagnosticInfoRef
, *mut c_void
);
509 pub type InlineAsmDiagHandler
= unsafe extern "C" fn(SMDiagnosticRef
, *const c_void
, c_uint
);
512 pub use self::DIDescriptorFlags
::*;
513 use super::{MetadataRef}
;
515 #[allow(missing_copy_implementations)]
516 pub enum DIBuilder_opaque {}
517 pub type DIBuilderRef
= *mut DIBuilder_opaque
;
519 pub type DIDescriptor
= MetadataRef
;
520 pub type DIScope
= DIDescriptor
;
521 pub type DILocation
= DIDescriptor
;
522 pub type DIFile
= DIScope
;
523 pub type DILexicalBlock
= DIScope
;
524 pub type DISubprogram
= DIScope
;
525 pub type DINameSpace
= DIScope
;
526 pub type DIType
= DIDescriptor
;
527 pub type DIBasicType
= DIType
;
528 pub type DIDerivedType
= DIType
;
529 pub type DICompositeType
= DIDerivedType
;
530 pub type DIVariable
= DIDescriptor
;
531 pub type DIGlobalVariable
= DIDescriptor
;
532 pub type DIArray
= DIDescriptor
;
533 pub type DISubrange
= DIDescriptor
;
534 pub type DIEnumerator
= DIDescriptor
;
535 pub type DITemplateTypeParameter
= DIDescriptor
;
538 pub enum DIDescriptorFlags
{
539 FlagPrivate
= 1 << 0,
540 FlagProtected
= 1 << 1,
541 FlagFwdDecl
= 1 << 2,
542 FlagAppleBlock
= 1 << 3,
543 FlagBlockByrefStruct
= 1 << 4,
544 FlagVirtual
= 1 << 5,
545 FlagArtificial
= 1 << 6,
546 FlagExplicit
= 1 << 7,
547 FlagPrototyped
= 1 << 8,
548 FlagObjcClassComplete
= 1 << 9,
549 FlagObjectPointer
= 1 << 10,
550 FlagVector
= 1 << 11,
551 FlagStaticMember
= 1 << 12,
552 FlagIndirectVariable
= 1 << 13,
553 FlagLValueReference
= 1 << 14,
554 FlagRValueReference
= 1 << 15
559 // Link to our native llvm bindings (things that we need to use the C++ api
560 // for) and because llvm is written in C++ we need to link against libstdc++
562 // You'll probably notice that there is an omission of all LLVM libraries
563 // from this location. This is because the set of LLVM libraries that we
564 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
565 // figure out the exact set of libraries. To do this, the build system
566 // generates an llvmdeps.rs file next to this one which will be
567 // automatically updated whenever LLVM is updated to include an up-to-date
568 // set of the libraries we need to link to LLVM for.
569 #[link(name = "rustllvm", kind = "static")]
571 /* Create and destroy contexts. */
572 pub fn LLVMContextCreate() -> ContextRef
;
573 pub fn LLVMContextDispose(C
: ContextRef
);
574 pub fn LLVMGetMDKindIDInContext(C
: ContextRef
,
579 /* Create and destroy modules. */
580 pub fn LLVMModuleCreateWithNameInContext(ModuleID
: *const c_char
,
583 pub fn LLVMGetModuleContext(M
: ModuleRef
) -> ContextRef
;
584 pub fn LLVMDisposeModule(M
: ModuleRef
);
586 /// Data layout. See Module::getDataLayout.
587 pub fn LLVMGetDataLayout(M
: ModuleRef
) -> *const c_char
;
588 pub fn LLVMSetDataLayout(M
: ModuleRef
, Triple
: *const c_char
);
590 /// Target triple. See Module::getTargetTriple.
591 pub fn LLVMGetTarget(M
: ModuleRef
) -> *const c_char
;
592 pub fn LLVMSetTarget(M
: ModuleRef
, Triple
: *const c_char
);
594 /// See Module::dump.
595 pub fn LLVMDumpModule(M
: ModuleRef
);
597 /// See Module::setModuleInlineAsm.
598 pub fn LLVMSetModuleInlineAsm(M
: ModuleRef
, Asm
: *const c_char
);
600 /// See llvm::LLVMTypeKind::getTypeID.
601 pub fn LLVMGetTypeKind(Ty
: TypeRef
) -> TypeKind
;
603 /// See llvm::LLVMType::getContext.
604 pub fn LLVMGetTypeContext(Ty
: TypeRef
) -> ContextRef
;
606 /* Operations on integer types */
607 pub fn LLVMInt1TypeInContext(C
: ContextRef
) -> TypeRef
;
608 pub fn LLVMInt8TypeInContext(C
: ContextRef
) -> TypeRef
;
609 pub fn LLVMInt16TypeInContext(C
: ContextRef
) -> TypeRef
;
610 pub fn LLVMInt32TypeInContext(C
: ContextRef
) -> TypeRef
;
611 pub fn LLVMInt64TypeInContext(C
: ContextRef
) -> TypeRef
;
612 pub fn LLVMIntTypeInContext(C
: ContextRef
, NumBits
: c_uint
)
615 pub fn LLVMGetIntTypeWidth(IntegerTy
: TypeRef
) -> c_uint
;
617 /* Operations on real types */
618 pub fn LLVMFloatTypeInContext(C
: ContextRef
) -> TypeRef
;
619 pub fn LLVMDoubleTypeInContext(C
: ContextRef
) -> TypeRef
;
620 pub fn LLVMX86FP80TypeInContext(C
: ContextRef
) -> TypeRef
;
621 pub fn LLVMFP128TypeInContext(C
: ContextRef
) -> TypeRef
;
622 pub fn LLVMPPCFP128TypeInContext(C
: ContextRef
) -> TypeRef
;
624 /* Operations on function types */
625 pub fn LLVMFunctionType(ReturnType
: TypeRef
,
626 ParamTypes
: *const TypeRef
,
630 pub fn LLVMIsFunctionVarArg(FunctionTy
: TypeRef
) -> Bool
;
631 pub fn LLVMGetReturnType(FunctionTy
: TypeRef
) -> TypeRef
;
632 pub fn LLVMCountParamTypes(FunctionTy
: TypeRef
) -> c_uint
;
633 pub fn LLVMGetParamTypes(FunctionTy
: TypeRef
, Dest
: *mut TypeRef
);
635 /* Operations on struct types */
636 pub fn LLVMStructTypeInContext(C
: ContextRef
,
637 ElementTypes
: *const TypeRef
,
638 ElementCount
: c_uint
,
641 pub fn LLVMCountStructElementTypes(StructTy
: TypeRef
) -> c_uint
;
642 pub fn LLVMGetStructElementTypes(StructTy
: TypeRef
,
644 pub fn LLVMIsPackedStruct(StructTy
: TypeRef
) -> Bool
;
646 /* Operations on array, pointer, and vector types (sequence types) */
647 pub fn LLVMRustArrayType(ElementType
: TypeRef
, ElementCount
: u64) -> TypeRef
;
648 pub fn LLVMPointerType(ElementType
: TypeRef
, AddressSpace
: c_uint
)
650 pub fn LLVMVectorType(ElementType
: TypeRef
, ElementCount
: c_uint
)
653 pub fn LLVMGetElementType(Ty
: TypeRef
) -> TypeRef
;
654 pub fn LLVMGetArrayLength(ArrayTy
: TypeRef
) -> c_uint
;
655 pub fn LLVMGetPointerAddressSpace(PointerTy
: TypeRef
) -> c_uint
;
656 pub fn LLVMGetPointerToGlobal(EE
: ExecutionEngineRef
, V
: ValueRef
)
658 pub fn LLVMGetVectorSize(VectorTy
: TypeRef
) -> c_uint
;
660 /* Operations on other types */
661 pub fn LLVMVoidTypeInContext(C
: ContextRef
) -> TypeRef
;
662 pub fn LLVMLabelTypeInContext(C
: ContextRef
) -> TypeRef
;
663 pub fn LLVMMetadataTypeInContext(C
: ContextRef
) -> TypeRef
;
665 /* Operations on all values */
666 pub fn LLVMTypeOf(Val
: ValueRef
) -> TypeRef
;
667 pub fn LLVMGetValueName(Val
: ValueRef
) -> *const c_char
;
668 pub fn LLVMSetValueName(Val
: ValueRef
, Name
: *const c_char
);
669 pub fn LLVMDumpValue(Val
: ValueRef
);
670 pub fn LLVMReplaceAllUsesWith(OldVal
: ValueRef
, NewVal
: ValueRef
);
671 pub fn LLVMHasMetadata(Val
: ValueRef
) -> c_int
;
672 pub fn LLVMGetMetadata(Val
: ValueRef
, KindID
: c_uint
) -> ValueRef
;
673 pub fn LLVMSetMetadata(Val
: ValueRef
, KindID
: c_uint
, Node
: ValueRef
);
675 /* Operations on Uses */
676 pub fn LLVMGetFirstUse(Val
: ValueRef
) -> UseRef
;
677 pub fn LLVMGetNextUse(U
: UseRef
) -> UseRef
;
678 pub fn LLVMGetUser(U
: UseRef
) -> ValueRef
;
679 pub fn LLVMGetUsedValue(U
: UseRef
) -> ValueRef
;
681 /* Operations on Users */
682 pub fn LLVMGetNumOperands(Val
: ValueRef
) -> c_int
;
683 pub fn LLVMGetOperand(Val
: ValueRef
, Index
: c_uint
) -> ValueRef
;
684 pub fn LLVMSetOperand(Val
: ValueRef
, Index
: c_uint
, Op
: ValueRef
);
686 /* Operations on constants of any type */
687 pub fn LLVMConstNull(Ty
: TypeRef
) -> ValueRef
;
689 pub fn LLVMConstAllOnes(Ty
: TypeRef
) -> ValueRef
;
690 pub fn LLVMConstICmp(Pred
: c_ushort
, V1
: ValueRef
, V2
: ValueRef
)
692 pub fn LLVMConstFCmp(Pred
: c_ushort
, V1
: ValueRef
, V2
: ValueRef
)
694 /* only for int/vector */
695 pub fn LLVMGetUndef(Ty
: TypeRef
) -> ValueRef
;
696 pub fn LLVMIsConstant(Val
: ValueRef
) -> Bool
;
697 pub fn LLVMIsNull(Val
: ValueRef
) -> Bool
;
698 pub fn LLVMIsUndef(Val
: ValueRef
) -> Bool
;
699 pub fn LLVMConstPointerNull(Ty
: TypeRef
) -> ValueRef
;
701 /* Operations on metadata */
702 pub fn LLVMMDStringInContext(C
: ContextRef
,
706 pub fn LLVMMDNodeInContext(C
: ContextRef
,
707 Vals
: *const ValueRef
,
710 pub fn LLVMAddNamedMetadataOperand(M
: ModuleRef
,
714 /* Operations on scalar constants */
715 pub fn LLVMConstInt(IntTy
: TypeRef
, N
: c_ulonglong
, SignExtend
: Bool
)
717 pub fn LLVMConstIntOfString(IntTy
: TypeRef
, Text
: *const c_char
, Radix
: u8)
719 pub fn LLVMConstIntOfStringAndSize(IntTy
: TypeRef
,
724 pub fn LLVMConstReal(RealTy
: TypeRef
, N
: f64) -> ValueRef
;
725 pub fn LLVMConstRealOfString(RealTy
: TypeRef
, Text
: *const c_char
)
727 pub fn LLVMConstRealOfStringAndSize(RealTy
: TypeRef
,
731 pub fn LLVMConstIntGetZExtValue(ConstantVal
: ValueRef
) -> c_ulonglong
;
732 pub fn LLVMConstIntGetSExtValue(ConstantVal
: ValueRef
) -> c_longlong
;
735 /* Operations on composite constants */
736 pub fn LLVMConstStringInContext(C
: ContextRef
,
739 DontNullTerminate
: Bool
)
741 pub fn LLVMConstStructInContext(C
: ContextRef
,
742 ConstantVals
: *const ValueRef
,
747 pub fn LLVMConstArray(ElementTy
: TypeRef
,
748 ConstantVals
: *const ValueRef
,
751 pub fn LLVMConstVector(ScalarConstantVals
: *const ValueRef
, Size
: c_uint
)
754 /* Constant expressions */
755 pub fn LLVMAlignOf(Ty
: TypeRef
) -> ValueRef
;
756 pub fn LLVMSizeOf(Ty
: TypeRef
) -> ValueRef
;
757 pub fn LLVMConstNeg(ConstantVal
: ValueRef
) -> ValueRef
;
758 pub fn LLVMConstNSWNeg(ConstantVal
: ValueRef
) -> ValueRef
;
759 pub fn LLVMConstNUWNeg(ConstantVal
: ValueRef
) -> ValueRef
;
760 pub fn LLVMConstFNeg(ConstantVal
: ValueRef
) -> ValueRef
;
761 pub fn LLVMConstNot(ConstantVal
: ValueRef
) -> ValueRef
;
762 pub fn LLVMConstAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
764 pub fn LLVMConstNSWAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
766 pub fn LLVMConstNUWAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
768 pub fn LLVMConstFAdd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
770 pub fn LLVMConstSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
772 pub fn LLVMConstNSWSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
774 pub fn LLVMConstNUWSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
776 pub fn LLVMConstFSub(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
778 pub fn LLVMConstMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
780 pub fn LLVMConstNSWMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
782 pub fn LLVMConstNUWMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
784 pub fn LLVMConstFMul(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
786 pub fn LLVMConstUDiv(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
788 pub fn LLVMConstSDiv(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
790 pub fn LLVMConstExactSDiv(LHSConstant
: ValueRef
,
791 RHSConstant
: ValueRef
)
793 pub fn LLVMConstFDiv(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
795 pub fn LLVMConstURem(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
797 pub fn LLVMConstSRem(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
799 pub fn LLVMConstFRem(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
801 pub fn LLVMConstAnd(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
803 pub fn LLVMConstOr(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
805 pub fn LLVMConstXor(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
807 pub fn LLVMConstShl(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
809 pub fn LLVMConstLShr(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
811 pub fn LLVMConstAShr(LHSConstant
: ValueRef
, RHSConstant
: ValueRef
)
813 pub fn LLVMConstGEP(ConstantVal
: ValueRef
,
814 ConstantIndices
: *const ValueRef
,
817 pub fn LLVMConstInBoundsGEP(ConstantVal
: ValueRef
,
818 ConstantIndices
: *const ValueRef
,
821 pub fn LLVMConstTrunc(ConstantVal
: ValueRef
, ToType
: TypeRef
)
823 pub fn LLVMConstSExt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
825 pub fn LLVMConstZExt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
827 pub fn LLVMConstFPTrunc(ConstantVal
: ValueRef
, ToType
: TypeRef
)
829 pub fn LLVMConstFPExt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
831 pub fn LLVMConstUIToFP(ConstantVal
: ValueRef
, ToType
: TypeRef
)
833 pub fn LLVMConstSIToFP(ConstantVal
: ValueRef
, ToType
: TypeRef
)
835 pub fn LLVMConstFPToUI(ConstantVal
: ValueRef
, ToType
: TypeRef
)
837 pub fn LLVMConstFPToSI(ConstantVal
: ValueRef
, ToType
: TypeRef
)
839 pub fn LLVMConstPtrToInt(ConstantVal
: ValueRef
, ToType
: TypeRef
)
841 pub fn LLVMConstIntToPtr(ConstantVal
: ValueRef
, ToType
: TypeRef
)
843 pub fn LLVMConstBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
845 pub fn LLVMConstZExtOrBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
847 pub fn LLVMConstSExtOrBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
849 pub fn LLVMConstTruncOrBitCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
851 pub fn LLVMConstPointerCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
853 pub fn LLVMConstIntCast(ConstantVal
: ValueRef
,
857 pub fn LLVMConstFPCast(ConstantVal
: ValueRef
, ToType
: TypeRef
)
859 pub fn LLVMConstSelect(ConstantCondition
: ValueRef
,
860 ConstantIfTrue
: ValueRef
,
861 ConstantIfFalse
: ValueRef
)
863 pub fn LLVMConstExtractElement(VectorConstant
: ValueRef
,
864 IndexConstant
: ValueRef
)
866 pub fn LLVMConstInsertElement(VectorConstant
: ValueRef
,
867 ElementValueConstant
: ValueRef
,
868 IndexConstant
: ValueRef
)
870 pub fn LLVMConstShuffleVector(VectorAConstant
: ValueRef
,
871 VectorBConstant
: ValueRef
,
872 MaskConstant
: ValueRef
)
874 pub fn LLVMConstExtractValue(AggConstant
: ValueRef
,
875 IdxList
: *const c_uint
,
878 pub fn LLVMConstInsertValue(AggConstant
: ValueRef
,
879 ElementValueConstant
: ValueRef
,
880 IdxList
: *const c_uint
,
883 pub fn LLVMConstInlineAsm(Ty
: TypeRef
,
884 AsmString
: *const c_char
,
885 Constraints
: *const c_char
,
886 HasSideEffects
: Bool
,
889 pub fn LLVMBlockAddress(F
: ValueRef
, BB
: BasicBlockRef
) -> ValueRef
;
893 /* Operations on global variables, functions, and aliases (globals) */
894 pub fn LLVMGetGlobalParent(Global
: ValueRef
) -> ModuleRef
;
895 pub fn LLVMIsDeclaration(Global
: ValueRef
) -> Bool
;
896 pub fn LLVMGetLinkage(Global
: ValueRef
) -> c_uint
;
897 pub fn LLVMSetLinkage(Global
: ValueRef
, Link
: c_uint
);
898 pub fn LLVMGetSection(Global
: ValueRef
) -> *const c_char
;
899 pub fn LLVMSetSection(Global
: ValueRef
, Section
: *const c_char
);
900 pub fn LLVMGetVisibility(Global
: ValueRef
) -> c_uint
;
901 pub fn LLVMSetVisibility(Global
: ValueRef
, Viz
: c_uint
);
902 pub fn LLVMGetAlignment(Global
: ValueRef
) -> c_uint
;
903 pub fn LLVMSetAlignment(Global
: ValueRef
, Bytes
: c_uint
);
906 /* Operations on global variables */
907 pub fn LLVMIsAGlobalVariable(GlobalVar
: ValueRef
) -> ValueRef
;
908 pub fn LLVMAddGlobal(M
: ModuleRef
, Ty
: TypeRef
, Name
: *const c_char
)
910 pub fn LLVMAddGlobalInAddressSpace(M
: ModuleRef
,
913 AddressSpace
: c_uint
)
915 pub fn LLVMGetNamedGlobal(M
: ModuleRef
, Name
: *const c_char
) -> ValueRef
;
916 pub fn LLVMGetFirstGlobal(M
: ModuleRef
) -> ValueRef
;
917 pub fn LLVMGetLastGlobal(M
: ModuleRef
) -> ValueRef
;
918 pub fn LLVMGetNextGlobal(GlobalVar
: ValueRef
) -> ValueRef
;
919 pub fn LLVMGetPreviousGlobal(GlobalVar
: ValueRef
) -> ValueRef
;
920 pub fn LLVMDeleteGlobal(GlobalVar
: ValueRef
);
921 pub fn LLVMGetInitializer(GlobalVar
: ValueRef
) -> ValueRef
;
922 pub fn LLVMSetInitializer(GlobalVar
: ValueRef
,
923 ConstantVal
: ValueRef
);
924 pub fn LLVMIsThreadLocal(GlobalVar
: ValueRef
) -> Bool
;
925 pub fn LLVMSetThreadLocal(GlobalVar
: ValueRef
, IsThreadLocal
: Bool
);
926 pub fn LLVMIsGlobalConstant(GlobalVar
: ValueRef
) -> Bool
;
927 pub fn LLVMSetGlobalConstant(GlobalVar
: ValueRef
, IsConstant
: Bool
);
929 /* Operations on aliases */
930 pub fn LLVMAddAlias(M
: ModuleRef
,
936 /* Operations on functions */
937 pub fn LLVMAddFunction(M
: ModuleRef
,
941 pub fn LLVMGetNamedFunction(M
: ModuleRef
, Name
: *const c_char
) -> ValueRef
;
942 pub fn LLVMGetFirstFunction(M
: ModuleRef
) -> ValueRef
;
943 pub fn LLVMGetLastFunction(M
: ModuleRef
) -> ValueRef
;
944 pub fn LLVMGetNextFunction(Fn
: ValueRef
) -> ValueRef
;
945 pub fn LLVMGetPreviousFunction(Fn
: ValueRef
) -> ValueRef
;
946 pub fn LLVMDeleteFunction(Fn
: ValueRef
);
947 pub fn LLVMGetOrInsertFunction(M
: ModuleRef
,
951 pub fn LLVMGetIntrinsicID(Fn
: ValueRef
) -> c_uint
;
952 pub fn LLVMGetFunctionCallConv(Fn
: ValueRef
) -> c_uint
;
953 pub fn LLVMSetFunctionCallConv(Fn
: ValueRef
, CC
: c_uint
);
954 pub fn LLVMGetGC(Fn
: ValueRef
) -> *const c_char
;
955 pub fn LLVMSetGC(Fn
: ValueRef
, Name
: *const c_char
);
956 pub fn LLVMAddDereferenceableAttr(Fn
: ValueRef
, index
: c_uint
, bytes
: uint64_t
);
957 pub fn LLVMAddFunctionAttribute(Fn
: ValueRef
, index
: c_uint
, PA
: uint64_t
);
958 pub fn LLVMAddFunctionAttrString(Fn
: ValueRef
, index
: c_uint
, Name
: *const c_char
);
959 pub fn LLVMRemoveFunctionAttrString(Fn
: ValueRef
, index
: c_uint
, Name
: *const c_char
);
960 pub fn LLVMGetFunctionAttr(Fn
: ValueRef
) -> c_ulonglong
;
962 /* Operations on parameters */
963 pub fn LLVMCountParams(Fn
: ValueRef
) -> c_uint
;
964 pub fn LLVMGetParams(Fn
: ValueRef
, Params
: *const ValueRef
);
965 pub fn LLVMGetParam(Fn
: ValueRef
, Index
: c_uint
) -> ValueRef
;
966 pub fn LLVMGetParamParent(Inst
: ValueRef
) -> ValueRef
;
967 pub fn LLVMGetFirstParam(Fn
: ValueRef
) -> ValueRef
;
968 pub fn LLVMGetLastParam(Fn
: ValueRef
) -> ValueRef
;
969 pub fn LLVMGetNextParam(Arg
: ValueRef
) -> ValueRef
;
970 pub fn LLVMGetPreviousParam(Arg
: ValueRef
) -> ValueRef
;
971 pub fn LLVMAddAttribute(Arg
: ValueRef
, PA
: c_uint
);
972 pub fn LLVMRemoveAttribute(Arg
: ValueRef
, PA
: c_uint
);
973 pub fn LLVMGetAttribute(Arg
: ValueRef
) -> c_uint
;
974 pub fn LLVMSetParamAlignment(Arg
: ValueRef
, align
: c_uint
);
976 /* Operations on basic blocks */
977 pub fn LLVMBasicBlockAsValue(BB
: BasicBlockRef
) -> ValueRef
;
978 pub fn LLVMValueIsBasicBlock(Val
: ValueRef
) -> Bool
;
979 pub fn LLVMValueAsBasicBlock(Val
: ValueRef
) -> BasicBlockRef
;
980 pub fn LLVMGetBasicBlockParent(BB
: BasicBlockRef
) -> ValueRef
;
981 pub fn LLVMCountBasicBlocks(Fn
: ValueRef
) -> c_uint
;
982 pub fn LLVMGetBasicBlocks(Fn
: ValueRef
, BasicBlocks
: *const ValueRef
);
983 pub fn LLVMGetFirstBasicBlock(Fn
: ValueRef
) -> BasicBlockRef
;
984 pub fn LLVMGetLastBasicBlock(Fn
: ValueRef
) -> BasicBlockRef
;
985 pub fn LLVMGetNextBasicBlock(BB
: BasicBlockRef
) -> BasicBlockRef
;
986 pub fn LLVMGetPreviousBasicBlock(BB
: BasicBlockRef
) -> BasicBlockRef
;
987 pub fn LLVMGetEntryBasicBlock(Fn
: ValueRef
) -> BasicBlockRef
;
989 pub fn LLVMAppendBasicBlockInContext(C
: ContextRef
,
993 pub fn LLVMInsertBasicBlockInContext(C
: ContextRef
,
997 pub fn LLVMDeleteBasicBlock(BB
: BasicBlockRef
);
999 pub fn LLVMMoveBasicBlockAfter(BB
: BasicBlockRef
,
1000 MoveAfter
: BasicBlockRef
);
1002 pub fn LLVMMoveBasicBlockBefore(BB
: BasicBlockRef
,
1003 MoveBefore
: BasicBlockRef
);
1005 /* Operations on instructions */
1006 pub fn LLVMGetInstructionParent(Inst
: ValueRef
) -> BasicBlockRef
;
1007 pub fn LLVMGetFirstInstruction(BB
: BasicBlockRef
) -> ValueRef
;
1008 pub fn LLVMGetLastInstruction(BB
: BasicBlockRef
) -> ValueRef
;
1009 pub fn LLVMGetNextInstruction(Inst
: ValueRef
) -> ValueRef
;
1010 pub fn LLVMGetPreviousInstruction(Inst
: ValueRef
) -> ValueRef
;
1011 pub fn LLVMInstructionEraseFromParent(Inst
: ValueRef
);
1013 /* Operations on call sites */
1014 pub fn LLVMSetInstructionCallConv(Instr
: ValueRef
, CC
: c_uint
);
1015 pub fn LLVMGetInstructionCallConv(Instr
: ValueRef
) -> c_uint
;
1016 pub fn LLVMAddInstrAttribute(Instr
: ValueRef
,
1019 pub fn LLVMRemoveInstrAttribute(Instr
: ValueRef
,
1022 pub fn LLVMSetInstrParamAlignment(Instr
: ValueRef
,
1025 pub fn LLVMAddCallSiteAttribute(Instr
: ValueRef
,
1028 pub fn LLVMAddDereferenceableCallSiteAttr(Instr
: ValueRef
,
1032 /* Operations on call instructions (only) */
1033 pub fn LLVMIsTailCall(CallInst
: ValueRef
) -> Bool
;
1034 pub fn LLVMSetTailCall(CallInst
: ValueRef
, IsTailCall
: Bool
);
1036 /* Operations on load/store instructions (only) */
1037 pub fn LLVMGetVolatile(MemoryAccessInst
: ValueRef
) -> Bool
;
1038 pub fn LLVMSetVolatile(MemoryAccessInst
: ValueRef
, volatile
: Bool
);
1040 /* Operations on phi nodes */
1041 pub fn LLVMAddIncoming(PhiNode
: ValueRef
,
1042 IncomingValues
: *const ValueRef
,
1043 IncomingBlocks
: *const BasicBlockRef
,
1045 pub fn LLVMCountIncoming(PhiNode
: ValueRef
) -> c_uint
;
1046 pub fn LLVMGetIncomingValue(PhiNode
: ValueRef
, Index
: c_uint
)
1048 pub fn LLVMGetIncomingBlock(PhiNode
: ValueRef
, Index
: c_uint
)
1051 /* Instruction builders */
1052 pub fn LLVMCreateBuilderInContext(C
: ContextRef
) -> BuilderRef
;
1053 pub fn LLVMPositionBuilder(Builder
: BuilderRef
,
1054 Block
: BasicBlockRef
,
1056 pub fn LLVMPositionBuilderBefore(Builder
: BuilderRef
,
1058 pub fn LLVMPositionBuilderAtEnd(Builder
: BuilderRef
,
1059 Block
: BasicBlockRef
);
1060 pub fn LLVMGetInsertBlock(Builder
: BuilderRef
) -> BasicBlockRef
;
1061 pub fn LLVMClearInsertionPosition(Builder
: BuilderRef
);
1062 pub fn LLVMInsertIntoBuilder(Builder
: BuilderRef
, Instr
: ValueRef
);
1063 pub fn LLVMInsertIntoBuilderWithName(Builder
: BuilderRef
,
1065 Name
: *const c_char
);
1066 pub fn LLVMDisposeBuilder(Builder
: BuilderRef
);
1068 /* Execution engine */
1069 pub fn LLVMRustCreateJITMemoryManager(morestack
: *const ())
1070 -> RustJITMemoryManagerRef
;
1071 pub fn LLVMBuildExecutionEngine(Mod
: ModuleRef
,
1072 MM
: RustJITMemoryManagerRef
) -> ExecutionEngineRef
;
1073 pub fn LLVMDisposeExecutionEngine(EE
: ExecutionEngineRef
);
1074 pub fn LLVMExecutionEngineFinalizeObject(EE
: ExecutionEngineRef
);
1075 pub fn LLVMRustLoadDynamicLibrary(path
: *const c_char
) -> Bool
;
1076 pub fn LLVMExecutionEngineAddModule(EE
: ExecutionEngineRef
, M
: ModuleRef
);
1077 pub fn LLVMExecutionEngineRemoveModule(EE
: ExecutionEngineRef
, M
: ModuleRef
)
1081 pub fn LLVMSetCurrentDebugLocation(Builder
: BuilderRef
, L
: ValueRef
);
1082 pub fn LLVMGetCurrentDebugLocation(Builder
: BuilderRef
) -> ValueRef
;
1083 pub fn LLVMSetInstDebugLocation(Builder
: BuilderRef
, Inst
: ValueRef
);
1086 pub fn LLVMBuildRetVoid(B
: BuilderRef
) -> ValueRef
;
1087 pub fn LLVMBuildRet(B
: BuilderRef
, V
: ValueRef
) -> ValueRef
;
1088 pub fn LLVMBuildAggregateRet(B
: BuilderRef
,
1089 RetVals
: *const ValueRef
,
1092 pub fn LLVMBuildBr(B
: BuilderRef
, Dest
: BasicBlockRef
) -> ValueRef
;
1093 pub fn LLVMBuildCondBr(B
: BuilderRef
,
1095 Then
: BasicBlockRef
,
1096 Else
: BasicBlockRef
)
1098 pub fn LLVMBuildSwitch(B
: BuilderRef
,
1100 Else
: BasicBlockRef
,
1103 pub fn LLVMBuildIndirectBr(B
: BuilderRef
,
1107 pub fn LLVMBuildInvoke(B
: BuilderRef
,
1109 Args
: *const ValueRef
,
1111 Then
: BasicBlockRef
,
1112 Catch
: BasicBlockRef
,
1113 Name
: *const c_char
)
1115 pub fn LLVMBuildLandingPad(B
: BuilderRef
,
1119 Name
: *const c_char
)
1121 pub fn LLVMBuildResume(B
: BuilderRef
, Exn
: ValueRef
) -> ValueRef
;
1122 pub fn LLVMBuildUnreachable(B
: BuilderRef
) -> ValueRef
;
1124 /* Add a case to the switch instruction */
1125 pub fn LLVMAddCase(Switch
: ValueRef
,
1127 Dest
: BasicBlockRef
);
1129 /* Add a destination to the indirectbr instruction */
1130 pub fn LLVMAddDestination(IndirectBr
: ValueRef
, Dest
: BasicBlockRef
);
1132 /* Add a clause to the landing pad instruction */
1133 pub fn LLVMAddClause(LandingPad
: ValueRef
, ClauseVal
: ValueRef
);
1135 /* Set the cleanup on a landing pad instruction */
1136 pub fn LLVMSetCleanup(LandingPad
: ValueRef
, Val
: Bool
);
1139 pub fn LLVMBuildAdd(B
: BuilderRef
,
1142 Name
: *const c_char
)
1144 pub fn LLVMBuildNSWAdd(B
: BuilderRef
,
1147 Name
: *const c_char
)
1149 pub fn LLVMBuildNUWAdd(B
: BuilderRef
,
1152 Name
: *const c_char
)
1154 pub fn LLVMBuildFAdd(B
: BuilderRef
,
1157 Name
: *const c_char
)
1159 pub fn LLVMBuildSub(B
: BuilderRef
,
1162 Name
: *const c_char
)
1164 pub fn LLVMBuildNSWSub(B
: BuilderRef
,
1167 Name
: *const c_char
)
1169 pub fn LLVMBuildNUWSub(B
: BuilderRef
,
1172 Name
: *const c_char
)
1174 pub fn LLVMBuildFSub(B
: BuilderRef
,
1177 Name
: *const c_char
)
1179 pub fn LLVMBuildMul(B
: BuilderRef
,
1182 Name
: *const c_char
)
1184 pub fn LLVMBuildNSWMul(B
: BuilderRef
,
1187 Name
: *const c_char
)
1189 pub fn LLVMBuildNUWMul(B
: BuilderRef
,
1192 Name
: *const c_char
)
1194 pub fn LLVMBuildFMul(B
: BuilderRef
,
1197 Name
: *const c_char
)
1199 pub fn LLVMBuildUDiv(B
: BuilderRef
,
1202 Name
: *const c_char
)
1204 pub fn LLVMBuildSDiv(B
: BuilderRef
,
1207 Name
: *const c_char
)
1209 pub fn LLVMBuildExactSDiv(B
: BuilderRef
,
1212 Name
: *const c_char
)
1214 pub fn LLVMBuildFDiv(B
: BuilderRef
,
1217 Name
: *const c_char
)
1219 pub fn LLVMBuildURem(B
: BuilderRef
,
1222 Name
: *const c_char
)
1224 pub fn LLVMBuildSRem(B
: BuilderRef
,
1227 Name
: *const c_char
)
1229 pub fn LLVMBuildFRem(B
: BuilderRef
,
1232 Name
: *const c_char
)
1234 pub fn LLVMBuildShl(B
: BuilderRef
,
1237 Name
: *const c_char
)
1239 pub fn LLVMBuildLShr(B
: BuilderRef
,
1242 Name
: *const c_char
)
1244 pub fn LLVMBuildAShr(B
: BuilderRef
,
1247 Name
: *const c_char
)
1249 pub fn LLVMBuildAnd(B
: BuilderRef
,
1252 Name
: *const c_char
)
1254 pub fn LLVMBuildOr(B
: BuilderRef
,
1257 Name
: *const c_char
)
1259 pub fn LLVMBuildXor(B
: BuilderRef
,
1262 Name
: *const c_char
)
1264 pub fn LLVMBuildBinOp(B
: BuilderRef
,
1268 Name
: *const c_char
)
1270 pub fn LLVMBuildNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1272 pub fn LLVMBuildNSWNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1274 pub fn LLVMBuildNUWNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1276 pub fn LLVMBuildFNeg(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1278 pub fn LLVMBuildNot(B
: BuilderRef
, V
: ValueRef
, Name
: *const c_char
)
1282 pub fn LLVMBuildMalloc(B
: BuilderRef
, Ty
: TypeRef
, Name
: *const c_char
)
1284 pub fn LLVMBuildArrayMalloc(B
: BuilderRef
,
1287 Name
: *const c_char
)
1289 pub fn LLVMBuildAlloca(B
: BuilderRef
, Ty
: TypeRef
, Name
: *const c_char
)
1291 pub fn LLVMBuildArrayAlloca(B
: BuilderRef
,
1294 Name
: *const c_char
)
1296 pub fn LLVMBuildFree(B
: BuilderRef
, PointerVal
: ValueRef
) -> ValueRef
;
1297 pub fn LLVMBuildLoad(B
: BuilderRef
,
1298 PointerVal
: ValueRef
,
1299 Name
: *const c_char
)
1302 pub fn LLVMBuildStore(B
: BuilderRef
, Val
: ValueRef
, Ptr
: ValueRef
)
1305 pub fn LLVMBuildGEP(B
: BuilderRef
,
1307 Indices
: *const ValueRef
,
1309 Name
: *const c_char
)
1311 pub fn LLVMBuildInBoundsGEP(B
: BuilderRef
,
1313 Indices
: *const ValueRef
,
1315 Name
: *const c_char
)
1317 pub fn LLVMBuildStructGEP(B
: BuilderRef
,
1320 Name
: *const c_char
)
1322 pub fn LLVMBuildGlobalString(B
: BuilderRef
,
1324 Name
: *const c_char
)
1326 pub fn LLVMBuildGlobalStringPtr(B
: BuilderRef
,
1328 Name
: *const c_char
)
1332 pub fn LLVMBuildTrunc(B
: BuilderRef
,
1335 Name
: *const c_char
)
1337 pub fn LLVMBuildZExt(B
: BuilderRef
,
1340 Name
: *const c_char
)
1342 pub fn LLVMBuildSExt(B
: BuilderRef
,
1345 Name
: *const c_char
)
1347 pub fn LLVMBuildFPToUI(B
: BuilderRef
,
1350 Name
: *const c_char
)
1352 pub fn LLVMBuildFPToSI(B
: BuilderRef
,
1355 Name
: *const c_char
)
1357 pub fn LLVMBuildUIToFP(B
: BuilderRef
,
1360 Name
: *const c_char
)
1362 pub fn LLVMBuildSIToFP(B
: BuilderRef
,
1365 Name
: *const c_char
)
1367 pub fn LLVMBuildFPTrunc(B
: BuilderRef
,
1370 Name
: *const c_char
)
1372 pub fn LLVMBuildFPExt(B
: BuilderRef
,
1375 Name
: *const c_char
)
1377 pub fn LLVMBuildPtrToInt(B
: BuilderRef
,
1380 Name
: *const c_char
)
1382 pub fn LLVMBuildIntToPtr(B
: BuilderRef
,
1385 Name
: *const c_char
)
1387 pub fn LLVMBuildBitCast(B
: BuilderRef
,
1390 Name
: *const c_char
)
1392 pub fn LLVMBuildZExtOrBitCast(B
: BuilderRef
,
1395 Name
: *const c_char
)
1397 pub fn LLVMBuildSExtOrBitCast(B
: BuilderRef
,
1400 Name
: *const c_char
)
1402 pub fn LLVMBuildTruncOrBitCast(B
: BuilderRef
,
1405 Name
: *const c_char
)
1407 pub fn LLVMBuildCast(B
: BuilderRef
,
1411 Name
: *const c_char
) -> ValueRef
;
1412 pub fn LLVMBuildPointerCast(B
: BuilderRef
,
1415 Name
: *const c_char
)
1417 pub fn LLVMBuildIntCast(B
: BuilderRef
,
1420 Name
: *const c_char
)
1422 pub fn LLVMBuildFPCast(B
: BuilderRef
,
1425 Name
: *const c_char
)
1429 pub fn LLVMBuildICmp(B
: BuilderRef
,
1433 Name
: *const c_char
)
1435 pub fn LLVMBuildFCmp(B
: BuilderRef
,
1439 Name
: *const c_char
)
1442 /* Miscellaneous instructions */
1443 pub fn LLVMBuildPhi(B
: BuilderRef
, Ty
: TypeRef
, Name
: *const c_char
)
1445 pub fn LLVMBuildCall(B
: BuilderRef
,
1447 Args
: *const ValueRef
,
1449 Name
: *const c_char
)
1451 pub fn LLVMBuildSelect(B
: BuilderRef
,
1455 Name
: *const c_char
)
1457 pub fn LLVMBuildVAArg(B
: BuilderRef
,
1460 Name
: *const c_char
)
1462 pub fn LLVMBuildExtractElement(B
: BuilderRef
,
1465 Name
: *const c_char
)
1467 pub fn LLVMBuildInsertElement(B
: BuilderRef
,
1471 Name
: *const c_char
)
1473 pub fn LLVMBuildShuffleVector(B
: BuilderRef
,
1477 Name
: *const c_char
)
1479 pub fn LLVMBuildExtractValue(B
: BuilderRef
,
1482 Name
: *const c_char
)
1484 pub fn LLVMBuildInsertValue(B
: BuilderRef
,
1488 Name
: *const c_char
)
1491 pub fn LLVMBuildIsNull(B
: BuilderRef
, Val
: ValueRef
, Name
: *const c_char
)
1493 pub fn LLVMBuildIsNotNull(B
: BuilderRef
, Val
: ValueRef
, Name
: *const c_char
)
1495 pub fn LLVMBuildPtrDiff(B
: BuilderRef
,
1498 Name
: *const c_char
)
1501 /* Atomic Operations */
1502 pub fn LLVMBuildAtomicLoad(B
: BuilderRef
,
1503 PointerVal
: ValueRef
,
1504 Name
: *const c_char
,
1505 Order
: AtomicOrdering
,
1509 pub fn LLVMBuildAtomicStore(B
: BuilderRef
,
1512 Order
: AtomicOrdering
,
1516 pub fn LLVMBuildAtomicCmpXchg(B
: BuilderRef
,
1520 Order
: AtomicOrdering
,
1521 FailureOrder
: AtomicOrdering
)
1523 pub fn LLVMBuildAtomicRMW(B
: BuilderRef
,
1527 Order
: AtomicOrdering
,
1528 SingleThreaded
: Bool
)
1531 pub fn LLVMBuildAtomicFence(B
: BuilderRef
, Order
: AtomicOrdering
);
1534 /* Selected entries from the downcasts. */
1535 pub fn LLVMIsATerminatorInst(Inst
: ValueRef
) -> ValueRef
;
1536 pub fn LLVMIsAStoreInst(Inst
: ValueRef
) -> ValueRef
;
1538 /// Writes a module to the specified path. Returns 0 on success.
1539 pub fn LLVMWriteBitcodeToFile(M
: ModuleRef
, Path
: *const c_char
) -> c_int
;
1541 /// Creates target data from a target layout string.
1542 pub fn LLVMCreateTargetData(StringRep
: *const c_char
) -> TargetDataRef
;
1543 /// Adds the target data to the given pass manager. The pass manager
1544 /// references the target data only weakly.
1545 pub fn LLVMAddTargetData(TD
: TargetDataRef
, PM
: PassManagerRef
);
1546 /// Number of bytes clobbered when doing a Store to *T.
1547 pub fn LLVMStoreSizeOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1550 /// Number of bytes clobbered when doing a Store to *T.
1551 pub fn LLVMSizeOfTypeInBits(TD
: TargetDataRef
, Ty
: TypeRef
)
1554 /// Distance between successive elements in an array of T. Includes ABI padding.
1555 pub fn LLVMABISizeOfType(TD
: TargetDataRef
, Ty
: TypeRef
) -> c_ulonglong
;
1557 /// Returns the preferred alignment of a type.
1558 pub fn LLVMPreferredAlignmentOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1560 /// Returns the minimum alignment of a type.
1561 pub fn LLVMABIAlignmentOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1564 /// Computes the byte offset of the indexed struct element for a
1566 pub fn LLVMOffsetOfElement(TD
: TargetDataRef
,
1571 /// Returns the minimum alignment of a type when part of a call frame.
1572 pub fn LLVMCallFrameAlignmentOfType(TD
: TargetDataRef
, Ty
: TypeRef
)
1575 /// Disposes target data.
1576 pub fn LLVMDisposeTargetData(TD
: TargetDataRef
);
1578 /// Creates a pass manager.
1579 pub fn LLVMCreatePassManager() -> PassManagerRef
;
1581 /// Creates a function-by-function pass manager
1582 pub fn LLVMCreateFunctionPassManagerForModule(M
: ModuleRef
)
1585 /// Disposes a pass manager.
1586 pub fn LLVMDisposePassManager(PM
: PassManagerRef
);
1588 /// Runs a pass manager on a module.
1589 pub fn LLVMRunPassManager(PM
: PassManagerRef
, M
: ModuleRef
) -> Bool
;
1591 /// Runs the function passes on the provided function.
1592 pub fn LLVMRunFunctionPassManager(FPM
: PassManagerRef
, F
: ValueRef
)
1595 /// Initializes all the function passes scheduled in the manager
1596 pub fn LLVMInitializeFunctionPassManager(FPM
: PassManagerRef
) -> Bool
;
1598 /// Finalizes all the function passes scheduled in the manager
1599 pub fn LLVMFinalizeFunctionPassManager(FPM
: PassManagerRef
) -> Bool
;
1601 pub fn LLVMInitializePasses();
1603 /// Adds a verification pass.
1604 pub fn LLVMAddVerifierPass(PM
: PassManagerRef
);
1606 pub fn LLVMAddGlobalOptimizerPass(PM
: PassManagerRef
);
1607 pub fn LLVMAddIPSCCPPass(PM
: PassManagerRef
);
1608 pub fn LLVMAddDeadArgEliminationPass(PM
: PassManagerRef
);
1609 pub fn LLVMAddInstructionCombiningPass(PM
: PassManagerRef
);
1610 pub fn LLVMAddCFGSimplificationPass(PM
: PassManagerRef
);
1611 pub fn LLVMAddFunctionInliningPass(PM
: PassManagerRef
);
1612 pub fn LLVMAddFunctionAttrsPass(PM
: PassManagerRef
);
1613 pub fn LLVMAddScalarReplAggregatesPass(PM
: PassManagerRef
);
1614 pub fn LLVMAddScalarReplAggregatesPassSSA(PM
: PassManagerRef
);
1615 pub fn LLVMAddJumpThreadingPass(PM
: PassManagerRef
);
1616 pub fn LLVMAddConstantPropagationPass(PM
: PassManagerRef
);
1617 pub fn LLVMAddReassociatePass(PM
: PassManagerRef
);
1618 pub fn LLVMAddLoopRotatePass(PM
: PassManagerRef
);
1619 pub fn LLVMAddLICMPass(PM
: PassManagerRef
);
1620 pub fn LLVMAddLoopUnswitchPass(PM
: PassManagerRef
);
1621 pub fn LLVMAddLoopDeletionPass(PM
: PassManagerRef
);
1622 pub fn LLVMAddLoopUnrollPass(PM
: PassManagerRef
);
1623 pub fn LLVMAddGVNPass(PM
: PassManagerRef
);
1624 pub fn LLVMAddMemCpyOptPass(PM
: PassManagerRef
);
1625 pub fn LLVMAddSCCPPass(PM
: PassManagerRef
);
1626 pub fn LLVMAddDeadStoreEliminationPass(PM
: PassManagerRef
);
1627 pub fn LLVMAddStripDeadPrototypesPass(PM
: PassManagerRef
);
1628 pub fn LLVMAddConstantMergePass(PM
: PassManagerRef
);
1629 pub fn LLVMAddArgumentPromotionPass(PM
: PassManagerRef
);
1630 pub fn LLVMAddTailCallEliminationPass(PM
: PassManagerRef
);
1631 pub fn LLVMAddIndVarSimplifyPass(PM
: PassManagerRef
);
1632 pub fn LLVMAddAggressiveDCEPass(PM
: PassManagerRef
);
1633 pub fn LLVMAddGlobalDCEPass(PM
: PassManagerRef
);
1634 pub fn LLVMAddCorrelatedValuePropagationPass(PM
: PassManagerRef
);
1635 pub fn LLVMAddPruneEHPass(PM
: PassManagerRef
);
1636 pub fn LLVMAddSimplifyLibCallsPass(PM
: PassManagerRef
);
1637 pub fn LLVMAddLoopIdiomPass(PM
: PassManagerRef
);
1638 pub fn LLVMAddEarlyCSEPass(PM
: PassManagerRef
);
1639 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM
: PassManagerRef
);
1640 pub fn LLVMAddBasicAliasAnalysisPass(PM
: PassManagerRef
);
1642 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef
;
1643 pub fn LLVMPassManagerBuilderDispose(PMB
: PassManagerBuilderRef
);
1644 pub fn LLVMPassManagerBuilderSetOptLevel(PMB
: PassManagerBuilderRef
,
1645 OptimizationLevel
: c_uint
);
1646 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB
: PassManagerBuilderRef
,
1648 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1649 PMB
: PassManagerBuilderRef
,
1651 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1652 PMB
: PassManagerBuilderRef
,
1654 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1655 PMB
: PassManagerBuilderRef
,
1657 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1658 PMB
: PassManagerBuilderRef
,
1660 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1661 PMB
: PassManagerBuilderRef
,
1662 PM
: PassManagerRef
);
1664 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1665 PMB
: PassManagerBuilderRef
,
1666 PM
: PassManagerRef
);
1667 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1668 PMB
: PassManagerBuilderRef
,
1673 /// Destroys a memory buffer.
1674 pub fn LLVMDisposeMemoryBuffer(MemBuf
: MemoryBufferRef
);
1677 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1679 /// Opens an object file.
1680 pub fn LLVMCreateObjectFile(MemBuf
: MemoryBufferRef
) -> ObjectFileRef
;
1681 /// Closes an object file.
1682 pub fn LLVMDisposeObjectFile(ObjFile
: ObjectFileRef
);
1684 /// Enumerates the sections in an object file.
1685 pub fn LLVMGetSections(ObjFile
: ObjectFileRef
) -> SectionIteratorRef
;
1686 /// Destroys a section iterator.
1687 pub fn LLVMDisposeSectionIterator(SI
: SectionIteratorRef
);
1688 /// Returns true if the section iterator is at the end of the section
1690 pub fn LLVMIsSectionIteratorAtEnd(ObjFile
: ObjectFileRef
,
1691 SI
: SectionIteratorRef
)
1693 /// Moves the section iterator to point to the next section.
1694 pub fn LLVMMoveToNextSection(SI
: SectionIteratorRef
);
1695 /// Returns the current section size.
1696 pub fn LLVMGetSectionSize(SI
: SectionIteratorRef
) -> c_ulonglong
;
1697 /// Returns the current section contents as a string buffer.
1698 pub fn LLVMGetSectionContents(SI
: SectionIteratorRef
) -> *const c_char
;
1700 /// Reads the given file and returns it as a memory buffer. Use
1701 /// LLVMDisposeMemoryBuffer() to get rid of it.
1702 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path
: *const c_char
)
1704 /// Borrows the contents of the memory buffer (doesn't copy it)
1705 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData
: *const c_char
,
1706 InputDataLength
: size_t
,
1707 BufferName
: *const c_char
,
1710 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData
: *const c_char
,
1711 InputDataLength
: size_t
,
1712 BufferName
: *const c_char
)
1715 pub fn LLVMIsMultithreaded() -> Bool
;
1716 pub fn LLVMStartMultithreaded() -> Bool
;
1718 /// Returns a string describing the last error caused by an LLVMRust* call.
1719 pub fn LLVMRustGetLastError() -> *const c_char
;
1721 /// Print the pass timings since static dtors aren't picking them up.
1722 pub fn LLVMRustPrintPassTimings();
1724 pub fn LLVMStructCreateNamed(C
: ContextRef
, Name
: *const c_char
) -> TypeRef
;
1726 pub fn LLVMStructSetBody(StructTy
: TypeRef
,
1727 ElementTypes
: *const TypeRef
,
1728 ElementCount
: c_uint
,
1731 pub fn LLVMConstNamedStruct(S
: TypeRef
,
1732 ConstantVals
: *const ValueRef
,
1736 /// Enables LLVM debug output.
1737 pub fn LLVMSetDebug(Enabled
: c_int
);
1739 /// Prepares inline assembly.
1740 pub fn LLVMInlineAsm(Ty
: TypeRef
,
1741 AsmString
: *const c_char
,
1742 Constraints
: *const c_char
,
1748 pub static LLVMRustDebugMetadataVersion
: u32;
1750 pub fn LLVMRustAddModuleFlag(M
: ModuleRef
,
1751 name
: *const c_char
,
1754 pub fn LLVMDIBuilderCreate(M
: ModuleRef
) -> DIBuilderRef
;
1756 pub fn LLVMDIBuilderDispose(Builder
: DIBuilderRef
);
1758 pub fn LLVMDIBuilderFinalize(Builder
: DIBuilderRef
);
1760 pub fn LLVMDIBuilderCreateCompileUnit(Builder
: DIBuilderRef
,
1762 File
: *const c_char
,
1764 Producer
: *const c_char
,
1766 Flags
: *const c_char
,
1768 SplitName
: *const c_char
)
1771 pub fn LLVMDIBuilderCreateFile(Builder
: DIBuilderRef
,
1772 Filename
: *const c_char
,
1773 Directory
: *const c_char
)
1776 pub fn LLVMDIBuilderCreateSubroutineType(Builder
: DIBuilderRef
,
1778 ParameterTypes
: DIArray
)
1781 pub fn LLVMDIBuilderCreateFunction(Builder
: DIBuilderRef
,
1782 Scope
: DIDescriptor
,
1783 Name
: *const c_char
,
1784 LinkageName
: *const c_char
,
1788 isLocalToUnit
: bool
,
1798 pub fn LLVMDIBuilderCreateBasicType(Builder
: DIBuilderRef
,
1799 Name
: *const c_char
,
1800 SizeInBits
: c_ulonglong
,
1801 AlignInBits
: c_ulonglong
,
1805 pub fn LLVMDIBuilderCreatePointerType(Builder
: DIBuilderRef
,
1807 SizeInBits
: c_ulonglong
,
1808 AlignInBits
: c_ulonglong
,
1809 Name
: *const c_char
)
1812 pub fn LLVMDIBuilderCreateStructType(Builder
: DIBuilderRef
,
1813 Scope
: DIDescriptor
,
1814 Name
: *const c_char
,
1817 SizeInBits
: c_ulonglong
,
1818 AlignInBits
: c_ulonglong
,
1820 DerivedFrom
: DIType
,
1822 RunTimeLang
: c_uint
,
1823 VTableHolder
: DIType
,
1824 UniqueId
: *const c_char
)
1827 pub fn LLVMDIBuilderCreateMemberType(Builder
: DIBuilderRef
,
1828 Scope
: DIDescriptor
,
1829 Name
: *const c_char
,
1832 SizeInBits
: c_ulonglong
,
1833 AlignInBits
: c_ulonglong
,
1834 OffsetInBits
: c_ulonglong
,
1839 pub fn LLVMDIBuilderCreateLexicalBlock(Builder
: DIBuilderRef
,
1846 pub fn LLVMDIBuilderCreateStaticVariable(Builder
: DIBuilderRef
,
1848 Name
: *const c_char
,
1849 LinkageName
: *const c_char
,
1853 isLocalToUnit
: bool
,
1856 -> DIGlobalVariable
;
1858 pub fn LLVMDIBuilderCreateVariable(Builder
: DIBuilderRef
,
1860 Scope
: DIDescriptor
,
1861 Name
: *const c_char
,
1865 AlwaysPreserve
: bool
,
1867 AddrOps
: *const i64,
1868 AddrOpsCount
: c_uint
,
1872 pub fn LLVMDIBuilderCreateArrayType(Builder
: DIBuilderRef
,
1874 AlignInBits
: c_ulonglong
,
1876 Subscripts
: DIArray
)
1879 pub fn LLVMDIBuilderCreateVectorType(Builder
: DIBuilderRef
,
1881 AlignInBits
: c_ulonglong
,
1883 Subscripts
: DIArray
)
1886 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder
: DIBuilderRef
,
1891 pub fn LLVMDIBuilderGetOrCreateArray(Builder
: DIBuilderRef
,
1892 Ptr
: *const DIDescriptor
,
1896 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder
: DIBuilderRef
,
1898 VarInfo
: DIVariable
,
1899 AddrOps
: *const i64,
1900 AddrOpsCount
: c_uint
,
1901 InsertAtEnd
: BasicBlockRef
)
1904 pub fn LLVMDIBuilderInsertDeclareBefore(Builder
: DIBuilderRef
,
1906 VarInfo
: DIVariable
,
1907 AddrOps
: *const i64,
1908 AddrOpsCount
: c_uint
,
1909 InsertBefore
: ValueRef
)
1912 pub fn LLVMDIBuilderCreateEnumerator(Builder
: DIBuilderRef
,
1913 Name
: *const c_char
,
1917 pub fn LLVMDIBuilderCreateEnumerationType(Builder
: DIBuilderRef
,
1919 Name
: *const c_char
,
1922 SizeInBits
: c_ulonglong
,
1923 AlignInBits
: c_ulonglong
,
1928 pub fn LLVMDIBuilderCreateUnionType(Builder
: DIBuilderRef
,
1930 Name
: *const c_char
,
1933 SizeInBits
: c_ulonglong
,
1934 AlignInBits
: c_ulonglong
,
1937 RunTimeLang
: c_uint
,
1938 UniqueId
: *const c_char
)
1941 pub fn LLVMSetUnnamedAddr(GlobalVar
: ValueRef
, UnnamedAddr
: Bool
);
1943 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder
: DIBuilderRef
,
1945 Name
: *const c_char
,
1950 -> DITemplateTypeParameter
;
1952 pub fn LLVMDIBuilderCreateOpDeref() -> i64;
1954 pub fn LLVMDIBuilderCreateOpPlus() -> i64;
1956 pub fn LLVMDIBuilderCreateNameSpace(Builder
: DIBuilderRef
,
1958 Name
: *const c_char
,
1963 pub fn LLVMDIBuilderCreateDebugLocation(Context
: ContextRef
,
1967 InlinedAt
: MetadataRef
)
1970 pub fn LLVMDICompositeTypeSetTypeArray(Builder
: DIBuilderRef
,
1971 CompositeType
: DIType
,
1972 TypeArray
: DIArray
);
1973 pub fn LLVMWriteTypeToString(Type
: TypeRef
, s
: RustStringRef
);
1974 pub fn LLVMWriteValueToString(value_ref
: ValueRef
, s
: RustStringRef
);
1976 pub fn LLVMIsAArgument(value_ref
: ValueRef
) -> ValueRef
;
1978 pub fn LLVMIsAAllocaInst(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 int
== 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
: &[u8] = mem
::transmute(raw
::Slice
{
2229 data
: ptr
as *const u8,
2233 let sr
: RustStringRepr
= mem
::transmute(sr
);
2234 (*sr
).borrow_mut().push_all(slice
);
2237 pub fn build_string
<F
>(f
: F
) -> Option
<String
> where F
: FnOnce(RustStringRef
){
2238 let mut buf
= RefCell
::new(Vec
::new());
2239 f(&mut buf
as RustStringRepr
as RustStringRef
);
2240 String
::from_utf8(buf
.into_inner()).ok()
2243 pub unsafe fn twine_to_string(tr
: TwineRef
) -> String
{
2244 build_string(|s
| LLVMWriteTwineToString(tr
, s
))
2245 .expect("got a non-UTF8 Twine from LLVM")
2248 pub unsafe fn debug_loc_to_string(c
: ContextRef
, tr
: DebugLocRef
) -> String
{
2249 build_string(|s
| LLVMWriteDebugLocToString(c
, tr
, s
))
2250 .expect("got a non-UTF8 DebugLoc from LLVM")
2253 // The module containing the native LLVM dependencies, generated by the build system
2254 // Note that this must come after the rustllvm extern declaration so that
2255 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2256 // Works to the above fix for #15460 to ensure LLVM dependencies that
2257 // are only used by rustllvm don't get stripped by the linker.
2259 include
! { env!("CFG_LLVM_LINKAGE_FILE") }