1 #![allow(non_camel_case_types)]
2 #![allow(non_upper_case_globals)]
4 use super::coverageinfo::{SmallVectorCounterExpression, SmallVectorCounterMappingRegion};
6 use super::debuginfo::{
7 DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
8 DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DINameSpace, DISPFlags, DIScope,
9 DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind,
12 use libc::{c_char, c_int, c_uint, size_t};
13 use libc::{c_ulonglong, c_void};
15 use std::marker::PhantomData;
17 use super::RustString;
19 pub type Bool = c_uint;
21 pub const True: Bool = 1 as Bool;
22 pub const False: Bool = 0 as Bool;
24 #[derive(Copy, Clone, PartialEq)]
26 #[allow(dead_code)] // Variants constructed by C++.
27 pub enum LLVMRustResult {
31 // Consts for the LLVM CallConv type, pre-cast to usize.
33 /// LLVM CallingConv::ID. Should we wrap this?
34 #[derive(Copy, Clone, PartialEq, Debug)]
40 X86StdcallCallConv = 64,
41 X86FastcallCallConv = 65,
42 ArmAapcsCallConv = 67,
50 AvrNonBlockingInterrupt = 84,
60 AvailableExternallyLinkage = 1,
61 LinkOnceAnyLinkage = 2,
62 LinkOnceODRLinkage = 3,
68 ExternalWeakLinkage = 9,
82 pub enum UnnamedAddr {
88 /// LLVMDLLStorageClass
89 #[derive(Copy, Clone)]
91 pub enum DLLStorageClass {
94 DllImport = 1, // Function to be imported from DLL.
96 DllExport = 2, // Function to be accessible from DLL.
99 /// Matches LLVMRustAttribute in rustllvm.h
100 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
101 /// though it is not ABI compatible (since it's a C++ enum)
103 #[derive(Copy, Clone, Debug)]
118 OptimizeForSize = 13,
126 SanitizeAddress = 21,
132 InaccessibleMemOnly = 27,
136 #[derive(Copy, Clone)]
138 pub enum IntPredicate {
152 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
154 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
155 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
156 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
157 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
158 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
159 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
160 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
161 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
162 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
163 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
168 /// LLVMRealPredicate
169 #[derive(Copy, Clone)]
171 pub enum RealPredicate {
172 RealPredicateFalse = 0,
187 RealPredicateTrue = 15,
191 pub fn from_generic(realpred: rustc_codegen_ssa::common::RealPredicate) -> Self {
193 rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
194 RealPredicate::RealPredicateFalse
196 rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
197 rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
198 rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
199 rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
200 rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
201 rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
202 rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
203 rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
204 rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
205 rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
206 rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
207 rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
208 rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
209 rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
210 rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
211 RealPredicate::RealPredicateTrue
218 #[derive(Copy, Clone, PartialEq, Debug)]
243 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
245 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
246 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
247 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
248 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
249 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
250 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
251 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
252 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
253 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
254 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
255 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
256 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
257 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
258 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
259 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
260 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
261 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
262 TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
263 TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
268 /// LLVMAtomicRmwBinOp
269 #[derive(Copy, Clone)]
271 pub enum AtomicRmwBinOp {
285 impl AtomicRmwBinOp {
286 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
288 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
289 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
290 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
291 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
292 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
293 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
294 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
295 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
296 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
297 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
298 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
303 /// LLVMAtomicOrdering
304 #[derive(Copy, Clone)]
306 pub enum AtomicOrdering {
311 // Consume = 3, // Not specified yet.
315 SequentiallyConsistent = 7,
318 impl AtomicOrdering {
319 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
321 rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
322 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
323 rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
324 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
325 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
326 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
327 AtomicOrdering::AcquireRelease
329 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
330 AtomicOrdering::SequentiallyConsistent
336 /// LLVMRustSynchronizationScope
337 #[derive(Copy, Clone)]
339 pub enum SynchronizationScope {
340 // FIXME: figure out if this variant is needed at all.
347 impl SynchronizationScope {
348 pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
350 rustc_codegen_ssa::common::SynchronizationScope::Other => SynchronizationScope::Other,
351 rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
352 SynchronizationScope::SingleThread
354 rustc_codegen_ssa::common::SynchronizationScope::CrossThread => {
355 SynchronizationScope::CrossThread
362 #[derive(Copy, Clone)]
365 // FIXME: figure out if this variant is needed at all.
373 #[derive(Copy, Clone)]
375 pub enum MetadataType {
382 MD_invariant_load = 6,
386 MD_mem_parallel_loop_access = 10,
390 /// LLVMRustAsmDialect
391 #[derive(Copy, Clone)]
393 pub enum AsmDialect {
394 // FIXME: figure out if this variant is needed at all.
402 pub fn from_generic(asm: rustc_ast::ast::LlvmAsmDialect) -> Self {
404 rustc_ast::ast::LlvmAsmDialect::Att => AsmDialect::Att,
405 rustc_ast::ast::LlvmAsmDialect::Intel => AsmDialect::Intel,
410 /// LLVMRustCodeGenOptLevel
411 #[derive(Copy, Clone, PartialEq)]
413 pub enum CodeGenOptLevel {
414 // FIXME: figure out if this variant is needed at all.
423 /// LLVMRustPassBuilderOptLevel
425 pub enum PassBuilderOptLevel {
445 /// LLVMRustSanitizerOptions
447 pub struct SanitizerOptions {
448 pub sanitize_address: bool,
449 pub sanitize_address_recover: bool,
450 pub sanitize_memory: bool,
451 pub sanitize_memory_recover: bool,
452 pub sanitize_memory_track_origins: c_int,
453 pub sanitize_thread: bool,
457 #[derive(Copy, Clone, PartialEq)]
459 pub enum RelocModel {
468 /// LLVMRustCodeModel
469 #[derive(Copy, Clone)]
480 /// LLVMRustDiagnosticKind
481 #[derive(Copy, Clone)]
483 #[allow(dead_code)] // Variants constructed by C++.
484 pub enum DiagnosticKind {
488 DebugMetadataVersion,
491 OptimizationRemarkMissed,
492 OptimizationRemarkAnalysis,
493 OptimizationRemarkAnalysisFPCommute,
494 OptimizationRemarkAnalysisAliasing,
495 OptimizationRemarkOther,
501 /// LLVMRustDiagnosticLevel
502 #[derive(Copy, Clone)]
504 #[allow(dead_code)] // Variants constructed by C++.
505 pub enum DiagnosticLevel {
512 /// LLVMRustArchiveKind
513 #[derive(Copy, Clone)]
515 pub enum ArchiveKind {
516 // FIXME: figure out if this variant is needed at all.
526 #[derive(Copy, Clone, PartialEq, Debug)]
528 #[allow(dead_code)] // Variants constructed by C++.
535 /// LLVMRustThinLTOData
537 pub type ThinLTOData;
540 /// LLVMRustThinLTOBuffer
542 pub type ThinLTOBuffer;
545 // LLVMRustModuleNameCallback
546 pub type ThinLTOModuleNameCallback =
547 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
549 /// LLVMRustThinLTOModule
551 pub struct ThinLTOModule {
552 pub identifier: *const c_char,
557 /// LLVMThreadLocalMode
558 #[derive(Copy, Clone)]
560 pub enum ThreadLocalMode {
568 /// LLVMRustChecksumKind
569 #[derive(Copy, Clone)]
571 pub enum ChecksumKind {
581 struct InvariantOpaque<'a> {
582 _marker: PhantomData<&'a mut &'a ()>,
586 // Opaque pointer types
600 pub type ConstantInt;
609 pub struct Builder<'a>(InvariantOpaque<'a>);
611 pub type MemoryBuffer;
614 pub struct PassManager<'a>(InvariantOpaque<'a>);
616 pub type PassManagerBuilder;
622 pub struct SectionIterator<'a>(InvariantOpaque<'a>);
627 pub type TargetMachine;
633 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
635 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
640 pub type DiagnosticInfo;
643 pub type SMDiagnostic;
646 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
648 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
650 pub struct Linker<'a>(InvariantOpaque<'a>);
652 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
653 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
655 pub mod coverageinfo {
656 use super::InvariantOpaque;
659 pub struct SmallVectorCounterExpression<'a>(InvariantOpaque<'a>);
662 pub struct SmallVectorCounterMappingRegion<'a>(InvariantOpaque<'a>);
666 use super::{InvariantOpaque, Metadata};
667 use bitflags::bitflags;
670 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
672 pub type DIDescriptor = Metadata;
673 pub type DIScope = DIDescriptor;
674 pub type DIFile = DIScope;
675 pub type DILexicalBlock = DIScope;
676 pub type DISubprogram = DIScope;
677 pub type DINameSpace = DIScope;
678 pub type DIType = DIDescriptor;
679 pub type DIBasicType = DIType;
680 pub type DIDerivedType = DIType;
681 pub type DICompositeType = DIDerivedType;
682 pub type DIVariable = DIDescriptor;
683 pub type DIGlobalVariableExpression = DIDescriptor;
684 pub type DIArray = DIDescriptor;
685 pub type DISubrange = DIDescriptor;
686 pub type DIEnumerator = DIDescriptor;
687 pub type DITemplateTypeParameter = DIDescriptor;
689 // These values **must** match with LLVMRustDIFlags!!
693 pub struct DIFlags: u32 {
695 const FlagPrivate = 1;
696 const FlagProtected = 2;
697 const FlagPublic = 3;
698 const FlagFwdDecl = (1 << 2);
699 const FlagAppleBlock = (1 << 3);
700 const FlagBlockByrefStruct = (1 << 4);
701 const FlagVirtual = (1 << 5);
702 const FlagArtificial = (1 << 6);
703 const FlagExplicit = (1 << 7);
704 const FlagPrototyped = (1 << 8);
705 const FlagObjcClassComplete = (1 << 9);
706 const FlagObjectPointer = (1 << 10);
707 const FlagVector = (1 << 11);
708 const FlagStaticMember = (1 << 12);
709 const FlagLValueReference = (1 << 13);
710 const FlagRValueReference = (1 << 14);
711 const FlagExternalTypeRef = (1 << 15);
712 const FlagIntroducedVirtual = (1 << 18);
713 const FlagBitField = (1 << 19);
714 const FlagNoReturn = (1 << 20);
718 // These values **must** match with LLVMRustDISPFlags!!
722 pub struct DISPFlags: u32 {
723 const SPFlagZero = 0;
724 const SPFlagVirtual = 1;
725 const SPFlagPureVirtual = 2;
726 const SPFlagLocalToUnit = (1 << 2);
727 const SPFlagDefinition = (1 << 3);
728 const SPFlagOptimized = (1 << 4);
729 const SPFlagMainSubprogram = (1 << 5);
733 /// LLVMRustDebugEmissionKind
734 #[derive(Copy, Clone)]
736 pub enum DebugEmissionKind {
742 impl DebugEmissionKind {
743 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
744 use rustc_session::config::DebugInfo;
746 DebugInfo::None => DebugEmissionKind::NoDebug,
747 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
748 DebugInfo::Full => DebugEmissionKind::FullDebug,
755 pub type ModuleBuffer;
758 pub type SelfProfileBeforePassCallback =
759 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
760 pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
763 pub fn LLVMRustInstallFatalErrorHandler();
765 // Create and destroy contexts.
766 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
767 pub fn LLVMContextDispose(C: &'static mut Context);
768 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
771 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
772 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
773 pub fn LLVMCloneModule(M: &Module) -> &Module;
775 /// Data layout. See Module::getDataLayout.
776 pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
777 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
779 /// See Module::setModuleInlineAsm.
780 pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
781 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
783 /// See llvm::LLVMTypeKind::getTypeID.
784 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
786 // Operations on integer types
787 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
788 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
789 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
790 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
791 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
792 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
794 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
796 // Operations on real types
797 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
798 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
800 // Operations on function types
801 pub fn LLVMFunctionType(
802 ReturnType: &'a Type,
803 ParamTypes: *const &'a Type,
807 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
808 pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
810 // Operations on struct types
811 pub fn LLVMStructTypeInContext(
813 ElementTypes: *const &'a Type,
814 ElementCount: c_uint,
818 // Operations on array, pointer, and vector types (sequence types)
819 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
820 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
821 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
823 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
824 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
826 // Operations on other types
827 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
828 pub fn LLVMX86MMXTypeInContext(C: &Context) -> &Type;
829 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
831 // Operations on all values
832 pub fn LLVMTypeOf(Val: &Value) -> &Type;
833 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
834 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
835 pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
836 pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
838 // Operations on constants of any type
839 pub fn LLVMConstNull(Ty: &Type) -> &Value;
840 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
842 // Operations on metadata
843 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
844 pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
845 pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
847 // Operations on scalar constants
848 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
849 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
850 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
851 pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
852 pub fn LLVMRustConstInt128Get(
853 ConstantVal: &ConstantInt,
859 // Operations on composite constants
860 pub fn LLVMConstStringInContext(
864 DontNullTerminate: Bool,
866 pub fn LLVMConstStructInContext(
868 ConstantVals: *const &'a Value,
873 pub fn LLVMConstArray(
875 ConstantVals: *const &'a Value,
878 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
880 // Constant expressions
881 pub fn LLVMConstInBoundsGEP(
882 ConstantVal: &'a Value,
883 ConstantIndices: *const &'a Value,
886 pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
887 pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
888 pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
889 pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
890 pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
891 pub fn LLVMConstExtractValue(
893 IdxList: *const c_uint,
897 // Operations on global variables, functions, and aliases (globals)
898 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
899 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
900 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
901 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
902 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
903 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
904 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
905 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
906 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
908 // Operations on global variables
909 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
910 pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
911 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
912 pub fn LLVMRustGetOrInsertGlobal(
918 pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
919 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
920 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
921 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
922 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
923 pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
924 pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
925 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
926 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
927 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
928 pub fn LLVMRustGetNamedValue(
933 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
935 // Operations on functions
936 pub fn LLVMRustGetOrInsertFunction(
940 FunctionTy: &'a Type,
942 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
943 pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
944 pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
945 pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
946 pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
947 pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
948 pub fn LLVMRustAddFunctionAttrStringValue(
952 Value: *const c_char,
954 pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
956 // Operations on parameters
957 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
958 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
959 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
961 // Operations on basic blocks
962 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
963 pub fn LLVMAppendBasicBlockInContext(
968 pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
970 // Operations on instructions
971 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
972 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
974 // Operations on call sites
975 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
976 pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
977 pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
978 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
979 pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
980 pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
982 // Operations on load/store instructions (only)
983 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
985 // Operations on phi nodes
986 pub fn LLVMAddIncoming(
988 IncomingValues: *const &'a Value,
989 IncomingBlocks: *const &'a BasicBlock,
993 // Instruction builders
994 pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
995 pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
996 pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
997 pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
1000 pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
1003 pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
1004 pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1005 pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1006 pub fn LLVMBuildCondBr(
1009 Then: &'a BasicBlock,
1010 Else: &'a BasicBlock,
1012 pub fn LLVMBuildSwitch(
1015 Else: &'a BasicBlock,
1018 pub fn LLVMRustBuildInvoke(
1021 Args: *const &'a Value,
1023 Then: &'a BasicBlock,
1024 Catch: &'a BasicBlock,
1025 Bundle: Option<&OperandBundleDef<'a>>,
1026 Name: *const c_char,
1028 pub fn LLVMBuildLandingPad(
1033 Name: *const c_char,
1035 pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1036 pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
1038 pub fn LLVMRustBuildCleanupPad(
1040 ParentPad: Option<&'a Value>,
1042 Args: *const &'a Value,
1043 Name: *const c_char,
1044 ) -> Option<&'a Value>;
1045 pub fn LLVMRustBuildCleanupRet(
1047 CleanupPad: &'a Value,
1048 UnwindBB: Option<&'a BasicBlock>,
1049 ) -> Option<&'a Value>;
1050 pub fn LLVMRustBuildCatchPad(
1052 ParentPad: &'a Value,
1054 Args: *const &'a Value,
1055 Name: *const c_char,
1056 ) -> Option<&'a Value>;
1057 pub fn LLVMRustBuildCatchRet(
1061 ) -> Option<&'a Value>;
1062 pub fn LLVMRustBuildCatchSwitch(
1063 Builder: &Builder<'a>,
1064 ParentPad: Option<&'a Value>,
1065 BB: Option<&'a BasicBlock>,
1066 NumHandlers: c_uint,
1067 Name: *const c_char,
1068 ) -> Option<&'a Value>;
1069 pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1070 pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
1072 // Add a case to the switch instruction
1073 pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1075 // Add a clause to the landing pad instruction
1076 pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
1078 // Set the cleanup on a landing pad instruction
1079 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1082 pub fn LLVMBuildAdd(
1086 Name: *const c_char,
1088 pub fn LLVMBuildFAdd(
1092 Name: *const c_char,
1094 pub fn LLVMBuildSub(
1098 Name: *const c_char,
1100 pub fn LLVMBuildFSub(
1104 Name: *const c_char,
1106 pub fn LLVMBuildMul(
1110 Name: *const c_char,
1112 pub fn LLVMBuildFMul(
1116 Name: *const c_char,
1118 pub fn LLVMBuildUDiv(
1122 Name: *const c_char,
1124 pub fn LLVMBuildExactUDiv(
1128 Name: *const c_char,
1130 pub fn LLVMBuildSDiv(
1134 Name: *const c_char,
1136 pub fn LLVMBuildExactSDiv(
1140 Name: *const c_char,
1142 pub fn LLVMBuildFDiv(
1146 Name: *const c_char,
1148 pub fn LLVMBuildURem(
1152 Name: *const c_char,
1154 pub fn LLVMBuildSRem(
1158 Name: *const c_char,
1160 pub fn LLVMBuildFRem(
1164 Name: *const c_char,
1166 pub fn LLVMBuildShl(
1170 Name: *const c_char,
1172 pub fn LLVMBuildLShr(
1176 Name: *const c_char,
1178 pub fn LLVMBuildAShr(
1182 Name: *const c_char,
1184 pub fn LLVMBuildNSWAdd(
1188 Name: *const c_char,
1190 pub fn LLVMBuildNUWAdd(
1194 Name: *const c_char,
1196 pub fn LLVMBuildNSWSub(
1200 Name: *const c_char,
1202 pub fn LLVMBuildNUWSub(
1206 Name: *const c_char,
1208 pub fn LLVMBuildNSWMul(
1212 Name: *const c_char,
1214 pub fn LLVMBuildNUWMul(
1218 Name: *const c_char,
1220 pub fn LLVMBuildAnd(
1224 Name: *const c_char,
1230 Name: *const c_char,
1232 pub fn LLVMBuildXor(
1236 Name: *const c_char,
1238 pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1239 pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1240 pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1241 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: &Value);
1244 pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1245 pub fn LLVMBuildArrayAlloca(
1249 Name: *const c_char,
1251 pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
1253 pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1255 pub fn LLVMBuildGEP(
1258 Indices: *const &'a Value,
1260 Name: *const c_char,
1262 pub fn LLVMBuildInBoundsGEP(
1265 Indices: *const &'a Value,
1267 Name: *const c_char,
1269 pub fn LLVMBuildStructGEP(
1273 Name: *const c_char,
1277 pub fn LLVMBuildTrunc(
1281 Name: *const c_char,
1283 pub fn LLVMBuildZExt(
1287 Name: *const c_char,
1289 pub fn LLVMBuildSExt(
1293 Name: *const c_char,
1295 pub fn LLVMBuildFPToUI(
1299 Name: *const c_char,
1301 pub fn LLVMBuildFPToSI(
1305 Name: *const c_char,
1307 pub fn LLVMBuildUIToFP(
1311 Name: *const c_char,
1313 pub fn LLVMBuildSIToFP(
1317 Name: *const c_char,
1319 pub fn LLVMBuildFPTrunc(
1323 Name: *const c_char,
1325 pub fn LLVMBuildFPExt(
1329 Name: *const c_char,
1331 pub fn LLVMBuildPtrToInt(
1335 Name: *const c_char,
1337 pub fn LLVMBuildIntToPtr(
1341 Name: *const c_char,
1343 pub fn LLVMBuildBitCast(
1347 Name: *const c_char,
1349 pub fn LLVMBuildPointerCast(
1353 Name: *const c_char,
1355 pub fn LLVMRustBuildIntCast(
1363 pub fn LLVMBuildICmp(
1368 Name: *const c_char,
1370 pub fn LLVMBuildFCmp(
1375 Name: *const c_char,
1378 // Miscellaneous instructions
1379 pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1380 pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &'a Value;
1381 pub fn LLVMRustBuildCall(
1384 Args: *const &'a Value,
1386 Bundle: Option<&OperandBundleDef<'a>>,
1388 pub fn LLVMRustBuildMemCpy(
1397 pub fn LLVMRustBuildMemMove(
1406 pub fn LLVMRustBuildMemSet(
1414 pub fn LLVMBuildSelect(
1419 Name: *const c_char,
1421 pub fn LLVMBuildVAArg(
1425 Name: *const c_char,
1427 pub fn LLVMBuildExtractElement(
1431 Name: *const c_char,
1433 pub fn LLVMBuildInsertElement(
1438 Name: *const c_char,
1440 pub fn LLVMBuildShuffleVector(
1445 Name: *const c_char,
1447 pub fn LLVMBuildExtractValue(
1451 Name: *const c_char,
1453 pub fn LLVMBuildInsertValue(
1458 Name: *const c_char,
1461 pub fn LLVMRustBuildVectorReduceFAdd(
1466 pub fn LLVMRustBuildVectorReduceFMul(
1471 pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1472 pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1473 pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1474 pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1475 pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1476 pub fn LLVMRustBuildVectorReduceMin(
1481 pub fn LLVMRustBuildVectorReduceMax(
1486 pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1488 pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1491 pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1492 pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1494 // Atomic Operations
1495 pub fn LLVMRustBuildAtomicLoad(
1497 PointerVal: &'a Value,
1498 Name: *const c_char,
1499 Order: AtomicOrdering,
1502 pub fn LLVMRustBuildAtomicStore(
1506 Order: AtomicOrdering,
1509 pub fn LLVMRustBuildAtomicCmpXchg(
1514 Order: AtomicOrdering,
1515 FailureOrder: AtomicOrdering,
1519 pub fn LLVMBuildAtomicRMW(
1524 Order: AtomicOrdering,
1525 SingleThreaded: Bool,
1528 pub fn LLVMRustBuildAtomicFence(
1530 Order: AtomicOrdering,
1531 Scope: SynchronizationScope,
1534 /// Writes a module to the specified path. Returns 0 on success.
1535 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1537 /// Creates a pass manager.
1538 pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1540 /// Creates a function-by-function pass manager
1541 pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1543 /// Disposes a pass manager.
1544 pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1546 /// Runs a pass manager on a module.
1547 pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1549 pub fn LLVMInitializePasses();
1551 pub fn LLVMTimeTraceProfilerInitialize();
1553 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1555 pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>);
1557 pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1558 pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1559 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1560 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1561 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1562 PMB: &PassManagerBuilder,
1565 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1566 PMB: &PassManagerBuilder,
1567 PM: &PassManager<'_>,
1570 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1571 PMB: &PassManagerBuilder,
1572 PM: &PassManager<'_>,
1574 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1575 PMB: &PassManagerBuilder,
1576 PM: &PassManager<'_>,
1580 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1581 PMB: &PassManagerBuilder,
1582 PM: &PassManager<'_>,
1585 // Stuff that's in rustllvm/ because it's not upstream yet.
1587 /// Opens an object file.
1588 pub fn LLVMCreateObjectFile(
1589 MemBuf: &'static mut MemoryBuffer,
1590 ) -> Option<&'static mut ObjectFile>;
1591 /// Closes an object file.
1592 pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1594 /// Enumerates the sections in an object file.
1595 pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1596 /// Destroys a section iterator.
1597 pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1598 /// Returns `true` if the section iterator is at the end of the section
1600 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1601 /// Moves the section iterator to point to the next section.
1602 pub fn LLVMMoveToNextSection(SI: &SectionIterator<'_>);
1603 /// Returns the current section size.
1604 pub fn LLVMGetSectionSize(SI: &SectionIterator<'_>) -> c_ulonglong;
1605 /// Returns the current section contents as a string buffer.
1606 pub fn LLVMGetSectionContents(SI: &SectionIterator<'_>) -> *const c_char;
1608 /// Reads the given file and returns it as a memory buffer. Use
1609 /// LLVMDisposeMemoryBuffer() to get rid of it.
1610 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1611 Path: *const c_char,
1612 ) -> Option<&'static mut MemoryBuffer>;
1614 pub fn LLVMStartMultithreaded() -> Bool;
1616 /// Returns a string describing the last error caused by an LLVMRust* call.
1617 pub fn LLVMRustGetLastError() -> *const c_char;
1619 /// Print the pass timings since static dtors aren't picking them up.
1620 pub fn LLVMRustPrintPassTimings();
1622 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1624 pub fn LLVMStructSetBody(
1626 ElementTypes: *const &'a Type,
1627 ElementCount: c_uint,
1631 /// Prepares inline assembly.
1632 pub fn LLVMRustInlineAsm(
1634 AsmString: *const c_char,
1635 AsmStringLen: size_t,
1636 Constraints: *const c_char,
1637 ConstraintsLen: size_t,
1640 Dialect: AsmDialect,
1642 pub fn LLVMRustInlineAsmVerify(
1644 Constraints: *const c_char,
1645 ConstraintsLen: size_t,
1648 pub fn LLVMRustCoverageSmallVectorCounterExpressionCreate()
1649 -> &'a mut SmallVectorCounterExpression<'a>;
1650 pub fn LLVMRustCoverageSmallVectorCounterExpressionDispose(
1651 Container: &'a mut SmallVectorCounterExpression<'a>,
1653 pub fn LLVMRustCoverageSmallVectorCounterExpressionAdd(
1654 Container: &mut SmallVectorCounterExpression<'a>,
1655 Kind: rustc_codegen_ssa::coverageinfo::CounterOp,
1660 pub fn LLVMRustCoverageSmallVectorCounterMappingRegionCreate()
1661 -> &'a mut SmallVectorCounterMappingRegion<'a>;
1662 pub fn LLVMRustCoverageSmallVectorCounterMappingRegionDispose(
1663 Container: &'a mut SmallVectorCounterMappingRegion<'a>,
1665 pub fn LLVMRustCoverageSmallVectorCounterMappingRegionAdd(
1666 Container: &mut SmallVectorCounterMappingRegion<'a>,
1670 ColumnStart: c_uint,
1675 #[allow(improper_ctypes)]
1676 pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1677 Filenames: *const *const c_char,
1678 FilenamesLen: size_t,
1679 BufferOut: &RustString,
1682 #[allow(improper_ctypes)]
1683 pub fn LLVMRustCoverageWriteMappingToBuffer(
1684 VirtualFileMappingIDs: *const c_uint,
1685 NumVirtualFileMappingIDs: c_uint,
1686 Expressions: *const SmallVectorCounterExpression<'_>,
1687 MappingRegions: *const SmallVectorCounterMappingRegion<'_>,
1688 BufferOut: &RustString,
1691 pub fn LLVMRustCoverageComputeHash(Name: *const c_char) -> u64;
1693 #[allow(improper_ctypes)]
1694 pub fn LLVMRustCoverageWriteSectionNameToString(M: &Module, Str: &RustString);
1696 #[allow(improper_ctypes)]
1697 pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1699 pub fn LLVMRustCoverageMappingVersion() -> u32;
1700 pub fn LLVMRustDebugMetadataVersion() -> u32;
1701 pub fn LLVMRustVersionMajor() -> u32;
1702 pub fn LLVMRustVersionMinor() -> u32;
1704 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1706 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1708 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1710 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1712 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1714 pub fn LLVMRustDIBuilderCreateCompileUnit(
1715 Builder: &DIBuilder<'a>,
1718 Producer: *const c_char,
1719 ProducerLen: size_t,
1721 Flags: *const c_char,
1723 SplitName: *const c_char,
1724 SplitNameLen: size_t,
1725 kind: DebugEmissionKind,
1726 ) -> &'a DIDescriptor;
1728 pub fn LLVMRustDIBuilderCreateFile(
1729 Builder: &DIBuilder<'a>,
1730 Filename: *const c_char,
1731 FilenameLen: size_t,
1732 Directory: *const c_char,
1733 DirectoryLen: size_t,
1734 CSKind: ChecksumKind,
1735 Checksum: *const c_char,
1736 ChecksumLen: size_t,
1739 pub fn LLVMRustDIBuilderCreateSubroutineType(
1740 Builder: &DIBuilder<'a>,
1741 ParameterTypes: &'a DIArray,
1742 ) -> &'a DICompositeType;
1744 pub fn LLVMRustDIBuilderCreateFunction(
1745 Builder: &DIBuilder<'a>,
1746 Scope: &'a DIDescriptor,
1747 Name: *const c_char,
1749 LinkageName: *const c_char,
1750 LinkageNameLen: size_t,
1758 TParam: &'a DIArray,
1759 Decl: Option<&'a DIDescriptor>,
1760 ) -> &'a DISubprogram;
1762 pub fn LLVMRustDIBuilderCreateBasicType(
1763 Builder: &DIBuilder<'a>,
1764 Name: *const c_char,
1768 ) -> &'a DIBasicType;
1770 pub fn LLVMRustDIBuilderCreateTypedef(
1771 Builder: &DIBuilder<'a>,
1772 Type: &'a DIBasicType,
1773 Name: *const c_char,
1777 Scope: Option<&'a DIScope>,
1778 ) -> &'a DIDerivedType;
1780 pub fn LLVMRustDIBuilderCreatePointerType(
1781 Builder: &DIBuilder<'a>,
1782 PointeeTy: &'a DIType,
1785 AddressSpace: c_uint,
1786 Name: *const c_char,
1788 ) -> &'a DIDerivedType;
1790 pub fn LLVMRustDIBuilderCreateStructType(
1791 Builder: &DIBuilder<'a>,
1792 Scope: Option<&'a DIDescriptor>,
1793 Name: *const c_char,
1800 DerivedFrom: Option<&'a DIType>,
1801 Elements: &'a DIArray,
1802 RunTimeLang: c_uint,
1803 VTableHolder: Option<&'a DIType>,
1804 UniqueId: *const c_char,
1805 UniqueIdLen: size_t,
1806 ) -> &'a DICompositeType;
1808 pub fn LLVMRustDIBuilderCreateMemberType(
1809 Builder: &DIBuilder<'a>,
1810 Scope: &'a DIDescriptor,
1811 Name: *const c_char,
1820 ) -> &'a DIDerivedType;
1822 pub fn LLVMRustDIBuilderCreateVariantMemberType(
1823 Builder: &DIBuilder<'a>,
1825 Name: *const c_char,
1832 Discriminant: Option<&'a Value>,
1837 pub fn LLVMRustDIBuilderCreateLexicalBlock(
1838 Builder: &DIBuilder<'a>,
1843 ) -> &'a DILexicalBlock;
1845 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(
1846 Builder: &DIBuilder<'a>,
1849 ) -> &'a DILexicalBlock;
1851 pub fn LLVMRustDIBuilderCreateStaticVariable(
1852 Builder: &DIBuilder<'a>,
1853 Context: Option<&'a DIScope>,
1854 Name: *const c_char,
1856 LinkageName: *const c_char,
1857 LinkageNameLen: size_t,
1861 isLocalToUnit: bool,
1863 Decl: Option<&'a DIDescriptor>,
1865 ) -> &'a DIGlobalVariableExpression;
1867 pub fn LLVMRustDIBuilderCreateVariable(
1868 Builder: &DIBuilder<'a>,
1870 Scope: &'a DIDescriptor,
1871 Name: *const c_char,
1876 AlwaysPreserve: bool,
1880 ) -> &'a DIVariable;
1882 pub fn LLVMRustDIBuilderCreateArrayType(
1883 Builder: &DIBuilder<'a>,
1887 Subscripts: &'a DIArray,
1890 pub fn LLVMRustDIBuilderGetOrCreateSubrange(
1891 Builder: &DIBuilder<'a>,
1894 ) -> &'a DISubrange;
1896 pub fn LLVMRustDIBuilderGetOrCreateArray(
1897 Builder: &DIBuilder<'a>,
1898 Ptr: *const Option<&'a DIDescriptor>,
1902 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(
1903 Builder: &DIBuilder<'a>,
1905 VarInfo: &'a DIVariable,
1906 AddrOps: *const i64,
1907 AddrOpsCount: c_uint,
1909 InsertAtEnd: &'a BasicBlock,
1912 pub fn LLVMRustDIBuilderCreateEnumerator(
1913 Builder: &DIBuilder<'a>,
1914 Name: *const c_char,
1918 ) -> &'a DIEnumerator;
1920 pub fn LLVMRustDIBuilderCreateEnumerationType(
1921 Builder: &DIBuilder<'a>,
1923 Name: *const c_char,
1929 Elements: &'a DIArray,
1930 ClassType: &'a DIType,
1934 pub fn LLVMRustDIBuilderCreateUnionType(
1935 Builder: &DIBuilder<'a>,
1937 Name: *const c_char,
1944 Elements: Option<&'a DIArray>,
1945 RunTimeLang: c_uint,
1946 UniqueId: *const c_char,
1947 UniqueIdLen: size_t,
1950 pub fn LLVMRustDIBuilderCreateVariantPart(
1951 Builder: &DIBuilder<'a>,
1953 Name: *const c_char,
1960 Discriminator: Option<&'a DIDerivedType>,
1961 Elements: &'a DIArray,
1962 UniqueId: *const c_char,
1963 UniqueIdLen: size_t,
1964 ) -> &'a DIDerivedType;
1966 pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
1968 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
1969 Builder: &DIBuilder<'a>,
1970 Scope: Option<&'a DIScope>,
1971 Name: *const c_char,
1974 ) -> &'a DITemplateTypeParameter;
1976 pub fn LLVMRustDIBuilderCreateNameSpace(
1977 Builder: &DIBuilder<'a>,
1978 Scope: Option<&'a DIScope>,
1979 Name: *const c_char,
1981 ExportSymbols: bool,
1982 ) -> &'a DINameSpace;
1984 pub fn LLVMRustDICompositeTypeReplaceArrays(
1985 Builder: &DIBuilder<'a>,
1986 CompositeType: &'a DIType,
1987 Elements: Option<&'a DIArray>,
1988 Params: Option<&'a DIArray>,
1991 pub fn LLVMRustDIBuilderCreateDebugLocation(
1992 Context: &'a Context,
1996 InlinedAt: Option<&'a Metadata>,
1998 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1999 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
2001 #[allow(improper_ctypes)]
2002 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2003 #[allow(improper_ctypes)]
2004 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2006 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2008 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
2009 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
2010 pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
2011 pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2012 pub fn LLVMRustCreateMemorySanitizerPass(
2013 TrackOrigins: c_int,
2015 ) -> &'static mut Pass;
2016 pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
2017 pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
2018 pub fn LLVMRustAddLastExtensionPasses(
2019 PMB: &PassManagerBuilder,
2020 Passes: *const &'static mut Pass,
2024 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2026 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
2027 pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
2029 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2030 pub fn LLVMRustCreateTargetMachine(
2031 Triple: *const c_char,
2033 Features: *const c_char,
2037 Level: CodeGenOptLevel,
2039 FunctionSections: bool,
2041 TrapUnreachable: bool,
2044 EmitStackSizeSection: bool,
2045 RelaxELFRelocations: bool,
2047 ) -> Option<&'static mut TargetMachine>;
2048 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
2049 pub fn LLVMRustAddBuilderLibraryInfo(
2050 PMB: &'a PassManagerBuilder,
2052 DisableSimplifyLibCalls: bool,
2054 pub fn LLVMRustConfigurePassManagerBuilder(
2055 PMB: &PassManagerBuilder,
2056 OptLevel: CodeGenOptLevel,
2057 MergeFunctions: bool,
2059 LoopVectorize: bool,
2060 PrepareForThinLTO: bool,
2061 PGOGenPath: *const c_char,
2062 PGOUsePath: *const c_char,
2064 pub fn LLVMRustAddLibraryInfo(
2065 PM: &PassManager<'a>,
2067 DisableSimplifyLibCalls: bool,
2069 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
2070 pub fn LLVMRustWriteOutputFile(
2071 T: &'a TargetMachine,
2072 PM: &PassManager<'a>,
2074 Output: *const c_char,
2076 ) -> LLVMRustResult;
2077 pub fn LLVMRustOptimizeWithNewPassManager(
2079 TM: &'a TargetMachine,
2080 OptLevel: PassBuilderOptLevel,
2082 NoPrepopulatePasses: bool,
2084 UseThinLTOBuffers: bool,
2085 MergeFunctions: bool,
2088 LoopVectorize: bool,
2089 DisableSimplifyLibCalls: bool,
2090 EmitLifetimeMarkers: bool,
2091 SanitizerOptions: Option<&SanitizerOptions>,
2092 PGOGenPath: *const c_char,
2093 PGOUsePath: *const c_char,
2094 llvm_selfprofiler: *mut c_void,
2095 begin_callback: SelfProfileBeforePassCallback,
2096 end_callback: SelfProfileAfterPassCallback,
2098 pub fn LLVMRustPrintModule(
2100 Output: *const c_char,
2101 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2102 ) -> LLVMRustResult;
2103 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2104 pub fn LLVMRustPrintPasses();
2105 pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
2106 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2107 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
2108 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2109 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
2111 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2112 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
2113 pub fn LLVMRustArchiveIteratorNext(
2114 AIR: &ArchiveIterator<'a>,
2115 ) -> Option<&'a mut ArchiveChild<'a>>;
2116 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2117 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2118 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
2119 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
2120 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2122 #[allow(improper_ctypes)]
2123 pub fn LLVMRustGetSectionName(
2124 SI: &SectionIterator<'_>,
2125 data: &mut Option<std::ptr::NonNull<c_char>>,
2128 #[allow(improper_ctypes)]
2129 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2131 pub fn LLVMContextSetDiagnosticHandler(
2133 Handler: DiagnosticHandler,
2134 DiagnosticContext: *mut c_void,
2137 #[allow(improper_ctypes)]
2138 pub fn LLVMRustUnpackOptimizationDiagnostic(
2139 DI: &'a DiagnosticInfo,
2140 pass_name_out: &RustString,
2141 function_out: &mut Option<&'a Value>,
2142 loc_line_out: &mut c_uint,
2143 loc_column_out: &mut c_uint,
2144 loc_filename_out: &RustString,
2145 message_out: &RustString,
2148 pub fn LLVMRustUnpackInlineAsmDiagnostic(
2149 DI: &'a DiagnosticInfo,
2150 level_out: &mut DiagnosticLevel,
2151 cookie_out: &mut c_uint,
2152 message_out: &mut Option<&'a Twine>,
2153 instruction_out: &mut Option<&'a Value>,
2156 #[allow(improper_ctypes)]
2157 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2158 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2160 pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2162 H: InlineAsmDiagHandler,
2166 #[allow(improper_ctypes)]
2167 pub fn LLVMRustUnpackSMDiagnostic(
2169 message_out: &RustString,
2170 buffer_out: &RustString,
2171 level_out: &mut DiagnosticLevel,
2172 loc_out: &mut c_uint,
2173 ranges_out: *mut c_uint,
2174 num_ranges: &mut usize,
2177 pub fn LLVMRustWriteArchive(
2180 Members: *const &RustArchiveMember<'_>,
2183 ) -> LLVMRustResult;
2184 pub fn LLVMRustArchiveMemberNew(
2185 Filename: *const c_char,
2186 Name: *const c_char,
2187 Child: Option<&ArchiveChild<'a>>,
2188 ) -> &'a mut RustArchiveMember<'a>;
2189 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
2191 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
2193 pub fn LLVMRustBuildOperandBundleDef(
2194 Name: *const c_char,
2195 Inputs: *const &'a Value,
2197 ) -> &'a mut OperandBundleDef<'a>;
2198 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
2200 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
2202 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2203 pub fn LLVMRustUnsetComdat(V: &Value);
2204 pub fn LLVMRustSetModulePICLevel(M: &Module);
2205 pub fn LLVMRustSetModulePIELevel(M: &Module);
2206 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2207 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2208 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2209 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2210 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2212 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
2213 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2214 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2215 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2216 pub fn LLVMRustCreateThinLTOData(
2217 Modules: *const ThinLTOModule,
2219 PreservedSymbols: *const *const c_char,
2220 PreservedSymbolsLen: c_uint,
2221 ) -> Option<&'static mut ThinLTOData>;
2222 pub fn LLVMRustPrepareThinLTORename(
2225 Target: &TargetMachine,
2227 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2228 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2229 pub fn LLVMRustPrepareThinLTOImport(
2232 Target: &TargetMachine,
2234 pub fn LLVMRustGetThinLTOModuleImports(
2235 Data: *const ThinLTOData,
2236 ModuleNameCallback: ThinLTOModuleNameCallback,
2237 CallbackPayload: *mut c_void,
2239 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2240 pub fn LLVMRustParseBitcodeForLTO(
2244 Identifier: *const c_char,
2245 ) -> Option<&Module>;
2246 pub fn LLVMRustGetBitcodeSliceFromObjectData(
2249 out_len: &mut usize,
2251 pub fn LLVMRustThinLTOGetDICompileUnit(
2253 CU1: &mut *mut c_void,
2254 CU2: &mut *mut c_void,
2256 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2258 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
2259 pub fn LLVMRustLinkerAdd(
2260 linker: &Linker<'_>,
2261 bytecode: *const c_char,
2262 bytecode_len: usize,
2264 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);