1 #![allow(non_camel_case_types)]
2 #![allow(non_upper_case_globals)]
4 use rustc_codegen_ssa::coverageinfo::map as coverage_map;
6 use super::debuginfo::{
7 DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
8 DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace,
9 DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable,
13 use libc::{c_char, c_int, c_uint, size_t};
14 use libc::{c_ulonglong, c_void};
16 use std::marker::PhantomData;
18 use super::RustString;
20 pub type Bool = c_uint;
22 pub const True: Bool = 1 as Bool;
23 pub const False: Bool = 0 as Bool;
25 #[derive(Copy, Clone, PartialEq)]
27 #[allow(dead_code)] // Variants constructed by C++.
28 pub enum LLVMRustResult {
33 // Rust version of the C struct with the same name in rustc_llvm/llvm-wrapper/RustWrapper.cpp.
35 pub struct LLVMRustCOFFShortExport {
36 pub name: *const c_char,
37 pub ordinal_present: bool,
38 /// value of `ordinal` only important when `ordinal_present` is true
42 impl LLVMRustCOFFShortExport {
43 pub fn new(name: *const c_char, ordinal: Option<u16>) -> LLVMRustCOFFShortExport {
44 LLVMRustCOFFShortExport {
46 ordinal_present: ordinal.is_some(),
47 ordinal: ordinal.unwrap_or(0),
52 /// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h.
54 /// We include only architectures supported on Windows.
55 #[derive(Copy, Clone, PartialEq)]
57 pub enum LLVMMachineType {
64 /// LLVM's Module::ModFlagBehavior, defined in llvm/include/llvm/IR/Module.h.
66 /// When merging modules (e.g. during LTO), their metadata flags are combined. Conflicts are
67 /// resolved according to the merge behaviors specified here. Flags differing only in merge
68 /// behavior are still considered to be in conflict.
70 /// In order for Rust-C LTO to work, we must specify behaviors compatible with Clang. Notably,
71 /// 'Error' and 'Warning' cannot be mixed for a given flag.
72 #[derive(Copy, Clone, PartialEq)]
74 pub enum LLVMModFlagBehavior {
84 // Consts for the LLVM CallConv type, pre-cast to usize.
86 /// LLVM CallingConv::ID. Should we wrap this?
87 #[derive(Copy, Clone, PartialEq, Debug)]
93 X86StdcallCallConv = 64,
94 X86FastcallCallConv = 65,
95 ArmAapcsCallConv = 67,
103 AvrNonBlockingInterrupt = 84,
109 #[derive(Copy, Clone, PartialEq)]
113 AvailableExternallyLinkage = 1,
114 LinkOnceAnyLinkage = 2,
115 LinkOnceODRLinkage = 3,
118 AppendingLinkage = 6,
121 ExternalWeakLinkage = 9,
125 // LLVMRustVisibility
127 #[derive(Copy, Clone, PartialEq)]
128 pub enum Visibility {
136 pub enum UnnamedAddr {
142 /// LLVMDLLStorageClass
143 #[derive(Copy, Clone)]
145 pub enum DLLStorageClass {
148 DllImport = 1, // Function to be imported from DLL.
150 DllExport = 2, // Function to be accessible from DLL.
153 /// Matches LLVMRustAttribute in LLVMWrapper.h
154 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
155 /// though it is not ABI compatible (since it's a C++ enum)
157 #[derive(Copy, Clone, Debug)]
158 pub enum AttributeKind {
172 OptimizeForSize = 13,
180 SanitizeAddress = 21,
186 SanitizeHWAddress = 28,
188 StackProtectReq = 30,
189 StackProtectStrong = 31,
194 ShadowCallStack = 36,
196 AllocatedPointer = 38,
201 #[derive(Copy, Clone)]
203 pub enum IntPredicate {
217 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
219 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
220 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
221 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
222 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
223 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
224 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
225 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
226 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
227 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
228 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
233 /// LLVMRealPredicate
234 #[derive(Copy, Clone)]
236 pub enum RealPredicate {
237 RealPredicateFalse = 0,
252 RealPredicateTrue = 15,
256 pub fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self {
258 rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
259 RealPredicate::RealPredicateFalse
261 rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
262 rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
263 rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
264 rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
265 rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
266 rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
267 rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
268 rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
269 rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
270 rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
271 rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
272 rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
273 rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
274 rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
275 rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
276 RealPredicate::RealPredicateTrue
283 #[derive(Copy, Clone, PartialEq, Debug)]
309 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
311 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
312 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
313 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
314 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
315 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
316 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
317 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
318 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
319 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
320 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
321 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
322 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
323 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
324 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
325 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
326 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
327 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
328 TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
329 TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
330 TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX,
335 /// LLVMAtomicRmwBinOp
336 #[derive(Copy, Clone)]
338 pub enum AtomicRmwBinOp {
352 impl AtomicRmwBinOp {
353 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
355 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
356 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
357 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
358 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
359 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
360 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
361 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
362 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
363 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
364 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
365 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
370 /// LLVMAtomicOrdering
371 #[derive(Copy, Clone)]
373 pub enum AtomicOrdering {
378 // Consume = 3, // Not specified yet.
382 SequentiallyConsistent = 7,
385 impl AtomicOrdering {
386 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
388 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
389 rustc_codegen_ssa::common::AtomicOrdering::Relaxed => AtomicOrdering::Monotonic,
390 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
391 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
392 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
393 AtomicOrdering::AcquireRelease
395 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
396 AtomicOrdering::SequentiallyConsistent
403 #[derive(Copy, Clone)]
411 #[derive(Copy, Clone)]
413 pub enum MetadataType {
420 MD_invariant_load = 6,
424 MD_mem_parallel_loop_access = 10,
428 MD_vcall_visibility = 28,
433 /// LLVMRustAsmDialect
434 #[derive(Copy, Clone, PartialEq)]
436 pub enum AsmDialect {
441 /// LLVMRustCodeGenOptLevel
442 #[derive(Copy, Clone, PartialEq)]
444 pub enum CodeGenOptLevel {
451 /// LLVMRustPassBuilderOptLevel
453 pub enum PassBuilderOptLevel {
473 /// LLVMRustSanitizerOptions
475 pub struct SanitizerOptions {
476 pub sanitize_address: bool,
477 pub sanitize_address_recover: bool,
478 pub sanitize_memory: bool,
479 pub sanitize_memory_recover: bool,
480 pub sanitize_memory_track_origins: c_int,
481 pub sanitize_thread: bool,
482 pub sanitize_hwaddress: bool,
483 pub sanitize_hwaddress_recover: bool,
487 #[derive(Copy, Clone, PartialEq)]
489 pub enum RelocModel {
498 /// LLVMRustCodeModel
499 #[derive(Copy, Clone)]
510 /// LLVMRustDiagnosticKind
511 #[derive(Copy, Clone)]
513 #[allow(dead_code)] // Variants constructed by C++.
514 pub enum DiagnosticKind {
518 DebugMetadataVersion,
521 OptimizationRemarkMissed,
522 OptimizationRemarkAnalysis,
523 OptimizationRemarkAnalysisFPCommute,
524 OptimizationRemarkAnalysisAliasing,
525 OptimizationRemarkOther,
533 /// LLVMRustDiagnosticLevel
534 #[derive(Copy, Clone)]
536 #[allow(dead_code)] // Variants constructed by C++.
537 pub enum DiagnosticLevel {
544 /// LLVMRustArchiveKind
545 #[derive(Copy, Clone)]
547 pub enum ArchiveKind {
554 // LLVMRustThinLTOData
556 pub type ThinLTOData;
559 // LLVMRustThinLTOBuffer
561 pub type ThinLTOBuffer;
564 /// LLVMRustThinLTOModule
566 pub struct ThinLTOModule {
567 pub identifier: *const c_char,
572 /// LLVMThreadLocalMode
573 #[derive(Copy, Clone)]
575 pub enum ThreadLocalMode {
583 /// LLVMRustChecksumKind
584 #[derive(Copy, Clone)]
586 pub enum ChecksumKind {
593 /// LLVMRustMemoryEffects
594 #[derive(Copy, Clone)]
596 pub enum MemoryEffects {
606 struct InvariantOpaque<'a> {
607 _marker: PhantomData<&'a mut &'a ()>,
611 // Opaque pointer types
625 pub type ConstantInt;
637 pub struct Builder<'a>(InvariantOpaque<'a>);
639 pub struct PassManager<'a>(InvariantOpaque<'a>);
641 pub type PassManagerBuilder;
647 pub type TargetMachine;
653 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
655 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
660 pub type DiagnosticInfo;
663 pub type SMDiagnostic;
666 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
668 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
670 pub struct Linker<'a>(InvariantOpaque<'a>);
673 pub type DiagnosticHandler;
676 pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
677 pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
679 pub mod coverageinfo {
680 use super::coverage_map;
682 /// Aligns with [llvm::coverage::CounterMappingRegion::RegionKind](https://github.com/rust-lang/llvm-project/blob/rustc/13.0-2021-09-30/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L209-L230)
683 #[derive(Copy, Clone, Debug)]
685 pub enum RegionKind {
686 /// A CodeRegion associates some code with a counter
689 /// An ExpansionRegion represents a file expansion region that associates
690 /// a source range with the expansion of a virtual source file, such as
691 /// for a macro instantiation or #include file.
694 /// A SkippedRegion represents a source range with code that was skipped
695 /// by a preprocessor or similar means.
698 /// A GapRegion is like a CodeRegion, but its count is only set as the
699 /// line execution count when its the only region in the line.
702 /// A BranchRegion represents leaf-level boolean expressions and is
703 /// associated with two counters, each representing the number of times the
704 /// expression evaluates to true or false.
708 /// This struct provides LLVM's representation of a "CoverageMappingRegion", encoded into the
709 /// coverage map, in accordance with the
710 /// [LLVM Code Coverage Mapping Format](https://github.com/rust-lang/llvm-project/blob/rustc/13.0-2021-09-30/llvm/docs/CoverageMappingFormat.rst#llvm-code-coverage-mapping-format).
711 /// The struct composes fields representing the `Counter` type and value(s) (injected counter
712 /// ID, or expression type and operands), the source file (an indirect index into a "filenames
713 /// array", encoded separately), and source location (start and end positions of the represented
716 /// Matches LLVMRustCounterMappingRegion.
717 #[derive(Copy, Clone, Debug)]
719 pub struct CounterMappingRegion {
720 /// The counter type and type-dependent counter data, if any.
721 counter: coverage_map::Counter,
723 /// If the `RegionKind` is a `BranchRegion`, this represents the counter
724 /// for the false branch of the region.
725 false_counter: coverage_map::Counter,
727 /// An indirect reference to the source filename. In the LLVM Coverage Mapping Format, the
728 /// file_id is an index into a function-specific `virtual_file_mapping` array of indexes
729 /// that, in turn, are used to look up the filename for this region.
732 /// If the `RegionKind` is an `ExpansionRegion`, the `expanded_file_id` can be used to find
733 /// the mapping regions created as a result of macro expansion, by checking if their file id
734 /// matches the expanded file id.
735 expanded_file_id: u32,
737 /// 1-based starting line of the mapping region.
740 /// 1-based starting column of the mapping region.
743 /// 1-based ending line of the mapping region.
746 /// 1-based ending column of the mapping region. If the high bit is set, the current
747 /// mapping region is a gap area.
753 impl CounterMappingRegion {
754 pub(crate) fn code_region(
755 counter: coverage_map::Counter,
764 false_counter: coverage_map::Counter::zero(),
771 kind: RegionKind::CodeRegion,
775 // This function might be used in the future; the LLVM API is still evolving, as is coverage
778 pub(crate) fn branch_region(
779 counter: coverage_map::Counter,
780 false_counter: coverage_map::Counter,
796 kind: RegionKind::BranchRegion,
800 // This function might be used in the future; the LLVM API is still evolving, as is coverage
803 pub(crate) fn expansion_region(
805 expanded_file_id: u32,
812 counter: coverage_map::Counter::zero(),
813 false_counter: coverage_map::Counter::zero(),
820 kind: RegionKind::ExpansionRegion,
824 // This function might be used in the future; the LLVM API is still evolving, as is coverage
827 pub(crate) fn skipped_region(
835 counter: coverage_map::Counter::zero(),
836 false_counter: coverage_map::Counter::zero(),
843 kind: RegionKind::SkippedRegion,
847 // This function might be used in the future; the LLVM API is still evolving, as is coverage
850 pub(crate) fn gap_region(
851 counter: coverage_map::Counter,
860 false_counter: coverage_map::Counter::zero(),
866 end_col: (1_u32 << 31) | end_col,
867 kind: RegionKind::GapRegion,
874 use super::{InvariantOpaque, Metadata};
875 use bitflags::bitflags;
878 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
880 pub type DIDescriptor = Metadata;
881 pub type DILocation = Metadata;
882 pub type DIScope = DIDescriptor;
883 pub type DIFile = DIScope;
884 pub type DILexicalBlock = DIScope;
885 pub type DISubprogram = DIScope;
886 pub type DINameSpace = DIScope;
887 pub type DIType = DIDescriptor;
888 pub type DIBasicType = DIType;
889 pub type DIDerivedType = DIType;
890 pub type DICompositeType = DIDerivedType;
891 pub type DIVariable = DIDescriptor;
892 pub type DIGlobalVariableExpression = DIDescriptor;
893 pub type DIArray = DIDescriptor;
894 pub type DISubrange = DIDescriptor;
895 pub type DIEnumerator = DIDescriptor;
896 pub type DITemplateTypeParameter = DIDescriptor;
898 // These values **must** match with LLVMRustDIFlags!!
902 pub struct DIFlags: u32 {
904 const FlagPrivate = 1;
905 const FlagProtected = 2;
906 const FlagPublic = 3;
907 const FlagFwdDecl = (1 << 2);
908 const FlagAppleBlock = (1 << 3);
909 const FlagBlockByrefStruct = (1 << 4);
910 const FlagVirtual = (1 << 5);
911 const FlagArtificial = (1 << 6);
912 const FlagExplicit = (1 << 7);
913 const FlagPrototyped = (1 << 8);
914 const FlagObjcClassComplete = (1 << 9);
915 const FlagObjectPointer = (1 << 10);
916 const FlagVector = (1 << 11);
917 const FlagStaticMember = (1 << 12);
918 const FlagLValueReference = (1 << 13);
919 const FlagRValueReference = (1 << 14);
920 const FlagExternalTypeRef = (1 << 15);
921 const FlagIntroducedVirtual = (1 << 18);
922 const FlagBitField = (1 << 19);
923 const FlagNoReturn = (1 << 20);
927 // These values **must** match with LLVMRustDISPFlags!!
931 pub struct DISPFlags: u32 {
932 const SPFlagZero = 0;
933 const SPFlagVirtual = 1;
934 const SPFlagPureVirtual = 2;
935 const SPFlagLocalToUnit = (1 << 2);
936 const SPFlagDefinition = (1 << 3);
937 const SPFlagOptimized = (1 << 4);
938 const SPFlagMainSubprogram = (1 << 5);
942 /// LLVMRustDebugEmissionKind
943 #[derive(Copy, Clone)]
945 pub enum DebugEmissionKind {
951 impl DebugEmissionKind {
952 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
953 use rustc_session::config::DebugInfo;
955 DebugInfo::None => DebugEmissionKind::NoDebug,
956 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
957 DebugInfo::Full => DebugEmissionKind::FullDebug,
963 use bitflags::bitflags;
964 // These values **must** match with LLVMRustAllocKindFlags
968 pub struct AllocKindFlags : u64 {
971 const Realloc = 1 << 1;
973 const Uninitialized = 1 << 3;
974 const Zeroed = 1 << 4;
975 const Aligned = 1 << 5;
980 pub type ModuleBuffer;
983 pub type SelfProfileBeforePassCallback =
984 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
985 pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
987 pub type GetSymbolsCallback = unsafe extern "C" fn(*mut c_void, *const c_char) -> *mut c_void;
988 pub type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) -> *mut c_void;
991 pub fn LLVMRustInstallFatalErrorHandler();
992 pub fn LLVMRustDisableSystemDialogsOnCrash();
994 // Create and destroy contexts.
995 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
996 pub fn LLVMContextDispose(C: &'static mut Context);
997 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
1000 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
1001 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
1002 pub fn LLVMCloneModule(M: &Module) -> &Module;
1004 /// Data layout. See Module::getDataLayout.
1005 pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
1006 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
1008 /// See Module::setModuleInlineAsm.
1009 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
1011 /// See llvm::LLVMTypeKind::getTypeID.
1012 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
1014 // Operations on integer types
1015 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
1016 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
1017 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
1018 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
1019 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
1020 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
1022 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
1024 // Operations on real types
1025 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
1026 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
1028 // Operations on function types
1029 pub fn LLVMFunctionType<'a>(
1030 ReturnType: &'a Type,
1031 ParamTypes: *const &'a Type,
1035 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
1036 pub fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type);
1038 // Operations on struct types
1039 pub fn LLVMStructTypeInContext<'a>(
1041 ElementTypes: *const &'a Type,
1042 ElementCount: c_uint,
1046 // Operations on array, pointer, and vector types (sequence types)
1047 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
1048 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
1049 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
1051 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
1052 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
1054 // Operations on other types
1055 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
1056 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
1058 // Operations on all values
1059 pub fn LLVMTypeOf(Val: &Value) -> &Type;
1060 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
1061 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
1062 pub fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value);
1063 pub fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Node: &'a Value);
1064 pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
1065 pub fn LLVMRustGlobalAddMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
1066 pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
1067 pub fn LLVMIsAFunction(Val: &Value) -> Option<&Value>;
1069 // Operations on constants of any type
1070 pub fn LLVMConstNull(Ty: &Type) -> &Value;
1071 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
1073 // Operations on metadata
1074 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
1075 pub fn LLVMMDNodeInContext<'a>(
1077 Vals: *const &'a Value,
1080 pub fn LLVMMDNodeInContext2<'a>(
1082 Vals: *const &'a Metadata,
1085 pub fn LLVMAddNamedMetadataOperand<'a>(M: &'a Module, Name: *const c_char, Val: &'a Value);
1087 // Operations on scalar constants
1088 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
1089 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
1090 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
1091 pub fn LLVMRustConstIntGetZExtValue(ConstantVal: &ConstantInt, Value: &mut u64) -> bool;
1092 pub fn LLVMRustConstInt128Get(
1093 ConstantVal: &ConstantInt,
1099 // Operations on composite constants
1100 pub fn LLVMConstStringInContext(
1104 DontNullTerminate: Bool,
1106 pub fn LLVMConstStructInContext<'a>(
1108 ConstantVals: *const &'a Value,
1113 pub fn LLVMConstArray<'a>(
1114 ElementTy: &'a Type,
1115 ConstantVals: *const &'a Value,
1118 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
1120 // Constant expressions
1121 pub fn LLVMRustConstInBoundsGEP2<'a>(
1123 ConstantVal: &'a Value,
1124 ConstantIndices: *const &'a Value,
1127 pub fn LLVMConstZExt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1128 pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1129 pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1130 pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1131 pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1132 pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
1134 // Operations on global variables, functions, and aliases (globals)
1135 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
1136 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
1137 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
1138 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
1139 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
1140 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
1141 pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
1142 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
1143 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1144 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1146 // Operations on global variables
1147 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
1148 pub fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1149 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
1150 pub fn LLVMRustGetOrInsertGlobal<'a>(
1152 Name: *const c_char,
1156 pub fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value;
1157 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1158 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1159 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
1160 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1161 pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
1162 pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
1163 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1164 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1165 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1166 pub fn LLVMRustGetNamedValue(
1168 Name: *const c_char,
1170 ) -> Option<&Value>;
1171 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1173 // Operations on attributes
1174 pub fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute;
1175 pub fn LLVMCreateStringAttribute(
1177 Name: *const c_char,
1179 Value: *const c_char,
1182 pub fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute;
1183 pub fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute;
1184 pub fn LLVMRustCreateDereferenceableOrNullAttr(C: &Context, bytes: u64) -> &Attribute;
1185 pub fn LLVMRustCreateByValAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1186 pub fn LLVMRustCreateStructRetAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1187 pub fn LLVMRustCreateElementTypeAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1188 pub fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute;
1189 pub fn LLVMRustCreateAllocSizeAttr(C: &Context, size_arg: u32) -> &Attribute;
1190 pub fn LLVMRustCreateAllocKindAttr(C: &Context, size_arg: u64) -> &Attribute;
1191 pub fn LLVMRustCreateMemoryEffectsAttr(C: &Context, effects: MemoryEffects) -> &Attribute;
1193 // Operations on functions
1194 pub fn LLVMRustGetOrInsertFunction<'a>(
1196 Name: *const c_char,
1198 FunctionTy: &'a Type,
1200 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1201 pub fn LLVMRustAddFunctionAttributes<'a>(
1204 Attrs: *const &'a Attribute,
1208 // Operations on parameters
1209 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1210 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
1211 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1213 // Operations on basic blocks
1214 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1215 pub fn LLVMAppendBasicBlockInContext<'a>(
1218 Name: *const c_char,
1219 ) -> &'a BasicBlock;
1221 // Operations on instructions
1222 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1223 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1225 // Operations on call sites
1226 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1227 pub fn LLVMRustAddCallSiteAttributes<'a>(
1230 Attrs: *const &'a Attribute,
1234 // Operations on load/store instructions (only)
1235 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1237 // Operations on phi nodes
1238 pub fn LLVMAddIncoming<'a>(
1240 IncomingValues: *const &'a Value,
1241 IncomingBlocks: *const &'a BasicBlock,
1245 // Instruction builders
1246 pub fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>;
1247 pub fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock);
1248 pub fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock;
1249 pub fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);
1252 pub fn LLVMSetCurrentDebugLocation<'a>(Builder: &Builder<'a>, L: &'a Value);
1255 pub fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;
1256 pub fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1257 pub fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1258 pub fn LLVMBuildCondBr<'a>(
1261 Then: &'a BasicBlock,
1262 Else: &'a BasicBlock,
1264 pub fn LLVMBuildSwitch<'a>(
1267 Else: &'a BasicBlock,
1270 pub fn LLVMRustBuildInvoke<'a>(
1274 Args: *const &'a Value,
1276 Then: &'a BasicBlock,
1277 Catch: &'a BasicBlock,
1278 OpBundles: *const Option<&OperandBundleDef<'a>>,
1279 NumOpBundles: c_uint,
1280 Name: *const c_char,
1282 pub fn LLVMBuildLandingPad<'a>(
1285 PersFn: Option<&'a Value>,
1287 Name: *const c_char,
1289 pub fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1290 pub fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value;
1292 pub fn LLVMRustBuildCleanupPad<'a>(
1294 ParentPad: Option<&'a Value>,
1296 Args: *const &'a Value,
1297 Name: *const c_char,
1298 ) -> Option<&'a Value>;
1299 pub fn LLVMRustBuildCleanupRet<'a>(
1301 CleanupPad: &'a Value,
1302 UnwindBB: Option<&'a BasicBlock>,
1303 ) -> Option<&'a Value>;
1304 pub fn LLVMRustBuildCatchPad<'a>(
1306 ParentPad: &'a Value,
1308 Args: *const &'a Value,
1309 Name: *const c_char,
1310 ) -> Option<&'a Value>;
1311 pub fn LLVMRustBuildCatchRet<'a>(
1315 ) -> Option<&'a Value>;
1316 pub fn LLVMRustBuildCatchSwitch<'a>(
1317 Builder: &Builder<'a>,
1318 ParentPad: Option<&'a Value>,
1319 BB: Option<&'a BasicBlock>,
1320 NumHandlers: c_uint,
1321 Name: *const c_char,
1322 ) -> Option<&'a Value>;
1323 pub fn LLVMRustAddHandler<'a>(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1324 pub fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value);
1326 // Add a case to the switch instruction
1327 pub fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1329 // Add a clause to the landing pad instruction
1330 pub fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value);
1332 // Set the cleanup on a landing pad instruction
1333 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1336 pub fn LLVMBuildAdd<'a>(
1340 Name: *const c_char,
1342 pub fn LLVMBuildFAdd<'a>(
1346 Name: *const c_char,
1348 pub fn LLVMBuildSub<'a>(
1352 Name: *const c_char,
1354 pub fn LLVMBuildFSub<'a>(
1358 Name: *const c_char,
1360 pub fn LLVMBuildMul<'a>(
1364 Name: *const c_char,
1366 pub fn LLVMBuildFMul<'a>(
1370 Name: *const c_char,
1372 pub fn LLVMBuildUDiv<'a>(
1376 Name: *const c_char,
1378 pub fn LLVMBuildExactUDiv<'a>(
1382 Name: *const c_char,
1384 pub fn LLVMBuildSDiv<'a>(
1388 Name: *const c_char,
1390 pub fn LLVMBuildExactSDiv<'a>(
1394 Name: *const c_char,
1396 pub fn LLVMBuildFDiv<'a>(
1400 Name: *const c_char,
1402 pub fn LLVMBuildURem<'a>(
1406 Name: *const c_char,
1408 pub fn LLVMBuildSRem<'a>(
1412 Name: *const c_char,
1414 pub fn LLVMBuildFRem<'a>(
1418 Name: *const c_char,
1420 pub fn LLVMBuildShl<'a>(
1424 Name: *const c_char,
1426 pub fn LLVMBuildLShr<'a>(
1430 Name: *const c_char,
1432 pub fn LLVMBuildAShr<'a>(
1436 Name: *const c_char,
1438 pub fn LLVMBuildNSWAdd<'a>(
1442 Name: *const c_char,
1444 pub fn LLVMBuildNUWAdd<'a>(
1448 Name: *const c_char,
1450 pub fn LLVMBuildNSWSub<'a>(
1454 Name: *const c_char,
1456 pub fn LLVMBuildNUWSub<'a>(
1460 Name: *const c_char,
1462 pub fn LLVMBuildNSWMul<'a>(
1466 Name: *const c_char,
1468 pub fn LLVMBuildNUWMul<'a>(
1472 Name: *const c_char,
1474 pub fn LLVMBuildAnd<'a>(
1478 Name: *const c_char,
1480 pub fn LLVMBuildOr<'a>(
1484 Name: *const c_char,
1486 pub fn LLVMBuildXor<'a>(
1490 Name: *const c_char,
1492 pub fn LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1493 pub fn LLVMBuildFNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1494 pub fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1495 pub fn LLVMRustSetFastMath(Instr: &Value);
1498 pub fn LLVMBuildAlloca<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1499 pub fn LLVMBuildArrayAlloca<'a>(
1503 Name: *const c_char,
1505 pub fn LLVMBuildLoad2<'a>(
1508 PointerVal: &'a Value,
1509 Name: *const c_char,
1512 pub fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1514 pub fn LLVMBuildGEP2<'a>(
1518 Indices: *const &'a Value,
1520 Name: *const c_char,
1522 pub fn LLVMBuildInBoundsGEP2<'a>(
1526 Indices: *const &'a Value,
1528 Name: *const c_char,
1530 pub fn LLVMBuildStructGEP2<'a>(
1535 Name: *const c_char,
1539 pub fn LLVMBuildTrunc<'a>(
1543 Name: *const c_char,
1545 pub fn LLVMBuildZExt<'a>(
1549 Name: *const c_char,
1551 pub fn LLVMBuildSExt<'a>(
1555 Name: *const c_char,
1557 pub fn LLVMBuildFPToUI<'a>(
1561 Name: *const c_char,
1563 pub fn LLVMBuildFPToSI<'a>(
1567 Name: *const c_char,
1569 pub fn LLVMBuildUIToFP<'a>(
1573 Name: *const c_char,
1575 pub fn LLVMBuildSIToFP<'a>(
1579 Name: *const c_char,
1581 pub fn LLVMBuildFPTrunc<'a>(
1585 Name: *const c_char,
1587 pub fn LLVMBuildFPExt<'a>(
1591 Name: *const c_char,
1593 pub fn LLVMBuildPtrToInt<'a>(
1597 Name: *const c_char,
1599 pub fn LLVMBuildIntToPtr<'a>(
1603 Name: *const c_char,
1605 pub fn LLVMBuildBitCast<'a>(
1609 Name: *const c_char,
1611 pub fn LLVMBuildPointerCast<'a>(
1615 Name: *const c_char,
1617 pub fn LLVMRustBuildIntCast<'a>(
1625 pub fn LLVMBuildICmp<'a>(
1630 Name: *const c_char,
1632 pub fn LLVMBuildFCmp<'a>(
1637 Name: *const c_char,
1640 // Miscellaneous instructions
1641 pub fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1642 pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &Value;
1643 pub fn LLVMRustBuildCall<'a>(
1647 Args: *const &'a Value,
1649 OpBundles: *const Option<&OperandBundleDef<'a>>,
1650 NumOpBundles: c_uint,
1652 pub fn LLVMRustBuildMemCpy<'a>(
1661 pub fn LLVMRustBuildMemMove<'a>(
1670 pub fn LLVMRustBuildMemSet<'a>(
1678 pub fn LLVMBuildSelect<'a>(
1683 Name: *const c_char,
1685 pub fn LLVMBuildVAArg<'a>(
1689 Name: *const c_char,
1691 pub fn LLVMBuildExtractElement<'a>(
1695 Name: *const c_char,
1697 pub fn LLVMBuildInsertElement<'a>(
1702 Name: *const c_char,
1704 pub fn LLVMBuildShuffleVector<'a>(
1709 Name: *const c_char,
1711 pub fn LLVMBuildExtractValue<'a>(
1715 Name: *const c_char,
1717 pub fn LLVMBuildInsertValue<'a>(
1722 Name: *const c_char,
1725 pub fn LLVMRustBuildVectorReduceFAdd<'a>(
1730 pub fn LLVMRustBuildVectorReduceFMul<'a>(
1735 pub fn LLVMRustBuildVectorReduceAdd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1736 pub fn LLVMRustBuildVectorReduceMul<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1737 pub fn LLVMRustBuildVectorReduceAnd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1738 pub fn LLVMRustBuildVectorReduceOr<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1739 pub fn LLVMRustBuildVectorReduceXor<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1740 pub fn LLVMRustBuildVectorReduceMin<'a>(
1745 pub fn LLVMRustBuildVectorReduceMax<'a>(
1750 pub fn LLVMRustBuildVectorReduceFMin<'a>(
1755 pub fn LLVMRustBuildVectorReduceFMax<'a>(
1761 pub fn LLVMRustBuildMinNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1762 pub fn LLVMRustBuildMaxNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1764 // Atomic Operations
1765 pub fn LLVMRustBuildAtomicLoad<'a>(
1767 ElementType: &'a Type,
1768 PointerVal: &'a Value,
1769 Name: *const c_char,
1770 Order: AtomicOrdering,
1773 pub fn LLVMRustBuildAtomicStore<'a>(
1777 Order: AtomicOrdering,
1780 pub fn LLVMBuildAtomicCmpXchg<'a>(
1785 Order: AtomicOrdering,
1786 FailureOrder: AtomicOrdering,
1787 SingleThreaded: Bool,
1790 pub fn LLVMSetWeak(CmpXchgInst: &Value, IsWeak: Bool);
1792 pub fn LLVMBuildAtomicRMW<'a>(
1797 Order: AtomicOrdering,
1798 SingleThreaded: Bool,
1801 pub fn LLVMBuildFence<'a>(
1803 Order: AtomicOrdering,
1804 SingleThreaded: Bool,
1805 Name: *const c_char,
1808 /// Writes a module to the specified path. Returns 0 on success.
1809 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1811 /// Creates a legacy pass manager -- only used for final codegen.
1812 pub fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>;
1814 pub fn LLVMInitializePasses();
1816 pub fn LLVMTimeTraceProfilerInitialize();
1818 pub fn LLVMTimeTraceProfilerFinishThread();
1820 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1822 pub fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>);
1824 pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
1826 pub fn LLVMDisposeMessage(message: *mut c_char);
1828 pub fn LLVMIsMultithreaded() -> Bool;
1830 /// Returns a string describing the last error caused by an LLVMRust* call.
1831 pub fn LLVMRustGetLastError() -> *const c_char;
1833 /// Print the pass timings since static dtors aren't picking them up.
1834 pub fn LLVMRustPrintPassTimings();
1836 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1838 pub fn LLVMStructSetBody<'a>(
1840 ElementTypes: *const &'a Type,
1841 ElementCount: c_uint,
1845 /// Prepares inline assembly.
1846 pub fn LLVMRustInlineAsm(
1848 AsmString: *const c_char,
1849 AsmStringLen: size_t,
1850 Constraints: *const c_char,
1851 ConstraintsLen: size_t,
1854 Dialect: AsmDialect,
1857 pub fn LLVMRustInlineAsmVerify(
1859 Constraints: *const c_char,
1860 ConstraintsLen: size_t,
1863 #[allow(improper_ctypes)]
1864 pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1865 Filenames: *const *const c_char,
1866 FilenamesLen: size_t,
1867 BufferOut: &RustString,
1870 #[allow(improper_ctypes)]
1871 pub fn LLVMRustCoverageWriteMappingToBuffer(
1872 VirtualFileMappingIDs: *const c_uint,
1873 NumVirtualFileMappingIDs: c_uint,
1874 Expressions: *const coverage_map::CounterExpression,
1875 NumExpressions: c_uint,
1876 MappingRegions: *const coverageinfo::CounterMappingRegion,
1877 NumMappingRegions: c_uint,
1878 BufferOut: &RustString,
1881 pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &Value, FuncName: *const c_char) -> &Value;
1882 pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64;
1883 pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
1885 #[allow(improper_ctypes)]
1886 pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
1888 #[allow(improper_ctypes)]
1889 pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
1891 #[allow(improper_ctypes)]
1892 pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1894 pub fn LLVMRustCoverageMappingVersion() -> u32;
1895 pub fn LLVMRustDebugMetadataVersion() -> u32;
1896 pub fn LLVMRustVersionMajor() -> u32;
1897 pub fn LLVMRustVersionMinor() -> u32;
1898 pub fn LLVMRustVersionPatch() -> u32;
1900 /// Add LLVM module flags.
1902 /// In order for Rust-C LTO to work, module flags must be compatible with Clang. What
1903 /// "compatible" means depends on the merge behaviors involved.
1904 pub fn LLVMRustAddModuleFlag(
1906 merge_behavior: LLVMModFlagBehavior,
1907 name: *const c_char,
1910 pub fn LLVMRustHasModuleFlag(M: &Module, name: *const c_char, len: size_t) -> bool;
1912 pub fn LLVMRustMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1914 pub fn LLVMRustDIBuilderCreate(M: &Module) -> &mut DIBuilder<'_>;
1916 pub fn LLVMRustDIBuilderDispose<'a>(Builder: &'a mut DIBuilder<'a>);
1918 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1920 pub fn LLVMRustDIBuilderCreateCompileUnit<'a>(
1921 Builder: &DIBuilder<'a>,
1924 Producer: *const c_char,
1925 ProducerLen: size_t,
1927 Flags: *const c_char,
1929 SplitName: *const c_char,
1930 SplitNameLen: size_t,
1931 kind: DebugEmissionKind,
1933 SplitDebugInlining: bool,
1934 ) -> &'a DIDescriptor;
1936 pub fn LLVMRustDIBuilderCreateFile<'a>(
1937 Builder: &DIBuilder<'a>,
1938 Filename: *const c_char,
1939 FilenameLen: size_t,
1940 Directory: *const c_char,
1941 DirectoryLen: size_t,
1942 CSKind: ChecksumKind,
1943 Checksum: *const c_char,
1944 ChecksumLen: size_t,
1947 pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
1948 Builder: &DIBuilder<'a>,
1949 ParameterTypes: &'a DIArray,
1950 ) -> &'a DICompositeType;
1952 pub fn LLVMRustDIBuilderCreateFunction<'a>(
1953 Builder: &DIBuilder<'a>,
1954 Scope: &'a DIDescriptor,
1955 Name: *const c_char,
1957 LinkageName: *const c_char,
1958 LinkageNameLen: size_t,
1965 MaybeFn: Option<&'a Value>,
1966 TParam: &'a DIArray,
1967 Decl: Option<&'a DIDescriptor>,
1968 ) -> &'a DISubprogram;
1970 pub fn LLVMRustDIBuilderCreateBasicType<'a>(
1971 Builder: &DIBuilder<'a>,
1972 Name: *const c_char,
1976 ) -> &'a DIBasicType;
1978 pub fn LLVMRustDIBuilderCreateTypedef<'a>(
1979 Builder: &DIBuilder<'a>,
1980 Type: &'a DIBasicType,
1981 Name: *const c_char,
1985 Scope: Option<&'a DIScope>,
1986 ) -> &'a DIDerivedType;
1988 pub fn LLVMRustDIBuilderCreatePointerType<'a>(
1989 Builder: &DIBuilder<'a>,
1990 PointeeTy: &'a DIType,
1993 AddressSpace: c_uint,
1994 Name: *const c_char,
1996 ) -> &'a DIDerivedType;
1998 pub fn LLVMRustDIBuilderCreateStructType<'a>(
1999 Builder: &DIBuilder<'a>,
2000 Scope: Option<&'a DIDescriptor>,
2001 Name: *const c_char,
2008 DerivedFrom: Option<&'a DIType>,
2009 Elements: &'a DIArray,
2010 RunTimeLang: c_uint,
2011 VTableHolder: Option<&'a DIType>,
2012 UniqueId: *const c_char,
2013 UniqueIdLen: size_t,
2014 ) -> &'a DICompositeType;
2016 pub fn LLVMRustDIBuilderCreateMemberType<'a>(
2017 Builder: &DIBuilder<'a>,
2018 Scope: &'a DIDescriptor,
2019 Name: *const c_char,
2028 ) -> &'a DIDerivedType;
2030 pub fn LLVMRustDIBuilderCreateVariantMemberType<'a>(
2031 Builder: &DIBuilder<'a>,
2033 Name: *const c_char,
2040 Discriminant: Option<&'a Value>,
2045 pub fn LLVMRustDIBuilderCreateStaticMemberType<'a>(
2046 Builder: &DIBuilder<'a>,
2047 Scope: &'a DIDescriptor,
2048 Name: *const c_char,
2054 val: Option<&'a Value>,
2056 ) -> &'a DIDerivedType;
2058 pub fn LLVMRustDIBuilderCreateLexicalBlock<'a>(
2059 Builder: &DIBuilder<'a>,
2064 ) -> &'a DILexicalBlock;
2066 pub fn LLVMRustDIBuilderCreateLexicalBlockFile<'a>(
2067 Builder: &DIBuilder<'a>,
2070 ) -> &'a DILexicalBlock;
2072 pub fn LLVMRustDIBuilderCreateStaticVariable<'a>(
2073 Builder: &DIBuilder<'a>,
2074 Context: Option<&'a DIScope>,
2075 Name: *const c_char,
2077 LinkageName: *const c_char,
2078 LinkageNameLen: size_t,
2082 isLocalToUnit: bool,
2084 Decl: Option<&'a DIDescriptor>,
2086 ) -> &'a DIGlobalVariableExpression;
2088 pub fn LLVMRustDIBuilderCreateVariable<'a>(
2089 Builder: &DIBuilder<'a>,
2091 Scope: &'a DIDescriptor,
2092 Name: *const c_char,
2097 AlwaysPreserve: bool,
2101 ) -> &'a DIVariable;
2103 pub fn LLVMRustDIBuilderCreateArrayType<'a>(
2104 Builder: &DIBuilder<'a>,
2108 Subscripts: &'a DIArray,
2111 pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
2112 Builder: &DIBuilder<'a>,
2115 ) -> &'a DISubrange;
2117 pub fn LLVMRustDIBuilderGetOrCreateArray<'a>(
2118 Builder: &DIBuilder<'a>,
2119 Ptr: *const Option<&'a DIDescriptor>,
2123 pub fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>(
2124 Builder: &DIBuilder<'a>,
2126 VarInfo: &'a DIVariable,
2127 AddrOps: *const u64,
2128 AddrOpsCount: c_uint,
2130 InsertAtEnd: &'a BasicBlock,
2133 pub fn LLVMRustDIBuilderCreateEnumerator<'a>(
2134 Builder: &DIBuilder<'a>,
2135 Name: *const c_char,
2140 ) -> &'a DIEnumerator;
2142 pub fn LLVMRustDIBuilderCreateEnumerationType<'a>(
2143 Builder: &DIBuilder<'a>,
2145 Name: *const c_char,
2151 Elements: &'a DIArray,
2152 ClassType: &'a DIType,
2156 pub fn LLVMRustDIBuilderCreateUnionType<'a>(
2157 Builder: &DIBuilder<'a>,
2158 Scope: Option<&'a DIScope>,
2159 Name: *const c_char,
2166 Elements: Option<&'a DIArray>,
2167 RunTimeLang: c_uint,
2168 UniqueId: *const c_char,
2169 UniqueIdLen: size_t,
2172 pub fn LLVMRustDIBuilderCreateVariantPart<'a>(
2173 Builder: &DIBuilder<'a>,
2175 Name: *const c_char,
2182 Discriminator: Option<&'a DIDerivedType>,
2183 Elements: &'a DIArray,
2184 UniqueId: *const c_char,
2185 UniqueIdLen: size_t,
2186 ) -> &'a DIDerivedType;
2188 pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
2190 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter<'a>(
2191 Builder: &DIBuilder<'a>,
2192 Scope: Option<&'a DIScope>,
2193 Name: *const c_char,
2196 ) -> &'a DITemplateTypeParameter;
2198 pub fn LLVMRustDIBuilderCreateNameSpace<'a>(
2199 Builder: &DIBuilder<'a>,
2200 Scope: Option<&'a DIScope>,
2201 Name: *const c_char,
2203 ExportSymbols: bool,
2204 ) -> &'a DINameSpace;
2206 pub fn LLVMRustDICompositeTypeReplaceArrays<'a>(
2207 Builder: &DIBuilder<'a>,
2208 CompositeType: &'a DIType,
2209 Elements: Option<&'a DIArray>,
2210 Params: Option<&'a DIArray>,
2213 pub fn LLVMRustDIBuilderCreateDebugLocation<'a>(
2217 InlinedAt: Option<&'a DILocation>,
2218 ) -> &'a DILocation;
2219 pub fn LLVMRustDIBuilderCreateOpDeref() -> u64;
2220 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64;
2221 pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64;
2223 #[allow(improper_ctypes)]
2224 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2225 #[allow(improper_ctypes)]
2226 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2228 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2230 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2232 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
2233 pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2234 pub fn LLVMRustGetTargetFeature(
2237 Feature: &mut *const c_char,
2238 Desc: &mut *const c_char,
2241 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2242 pub fn LLVMRustCreateTargetMachine(
2243 Triple: *const c_char,
2245 Features: *const c_char,
2249 Level: CodeGenOptLevel,
2251 FunctionSections: bool,
2253 UniqueSectionNames: bool,
2254 TrapUnreachable: bool,
2257 EmitStackSizeSection: bool,
2258 RelaxELFRelocations: bool,
2260 SplitDwarfFile: *const c_char,
2261 ) -> Option<&'static mut TargetMachine>;
2262 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
2263 pub fn LLVMRustAddLibraryInfo<'a>(
2264 PM: &PassManager<'a>,
2266 DisableSimplifyLibCalls: bool,
2268 pub fn LLVMRustWriteOutputFile<'a>(
2269 T: &'a TargetMachine,
2270 PM: &PassManager<'a>,
2272 Output: *const c_char,
2273 DwoOutput: *const c_char,
2275 ) -> LLVMRustResult;
2276 pub fn LLVMRustOptimize<'a>(
2278 TM: &'a TargetMachine,
2279 OptLevel: PassBuilderOptLevel,
2281 NoPrepopulatePasses: bool,
2283 UseThinLTOBuffers: bool,
2284 MergeFunctions: bool,
2287 LoopVectorize: bool,
2288 DisableSimplifyLibCalls: bool,
2289 EmitLifetimeMarkers: bool,
2290 SanitizerOptions: Option<&SanitizerOptions>,
2291 PGOGenPath: *const c_char,
2292 PGOUsePath: *const c_char,
2293 InstrumentCoverage: bool,
2294 InstrProfileOutput: *const c_char,
2295 InstrumentGCOV: bool,
2296 PGOSampleUsePath: *const c_char,
2297 DebugInfoForProfiling: bool,
2298 llvm_selfprofiler: *mut c_void,
2299 begin_callback: SelfProfileBeforePassCallback,
2300 end_callback: SelfProfileAfterPassCallback,
2301 ExtraPasses: *const c_char,
2302 ExtraPassesLen: size_t,
2303 LLVMPlugins: *const c_char,
2304 LLVMPluginsLen: size_t,
2305 ) -> LLVMRustResult;
2306 pub fn LLVMRustPrintModule(
2308 Output: *const c_char,
2309 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2310 ) -> LLVMRustResult;
2311 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2312 pub fn LLVMRustPrintPasses();
2313 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2314 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2316 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2317 pub fn LLVMRustArchiveIteratorNew(AR: &Archive) -> &mut ArchiveIterator<'_>;
2318 pub fn LLVMRustArchiveIteratorNext<'a>(
2319 AIR: &ArchiveIterator<'a>,
2320 ) -> Option<&'a mut ArchiveChild<'a>>;
2321 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2322 pub fn LLVMRustArchiveChildFree<'a>(ACR: &'a mut ArchiveChild<'a>);
2323 pub fn LLVMRustArchiveIteratorFree<'a>(AIR: &'a mut ArchiveIterator<'a>);
2324 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2326 #[allow(improper_ctypes)]
2327 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2329 #[allow(improper_ctypes)]
2330 pub fn LLVMRustUnpackOptimizationDiagnostic<'a>(
2331 DI: &'a DiagnosticInfo,
2332 pass_name_out: &RustString,
2333 function_out: &mut Option<&'a Value>,
2334 loc_line_out: &mut c_uint,
2335 loc_column_out: &mut c_uint,
2336 loc_filename_out: &RustString,
2337 message_out: &RustString,
2340 pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>(
2341 DI: &'a DiagnosticInfo,
2342 level_out: &mut DiagnosticLevel,
2343 cookie_out: &mut c_uint,
2344 message_out: &mut Option<&'a Twine>,
2347 #[allow(improper_ctypes)]
2348 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2349 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2351 pub fn LLVMRustGetSMDiagnostic<'a>(
2352 DI: &'a DiagnosticInfo,
2353 cookie_out: &mut c_uint,
2354 ) -> &'a SMDiagnostic;
2356 #[allow(improper_ctypes)]
2357 pub fn LLVMRustUnpackSMDiagnostic(
2359 message_out: &RustString,
2360 buffer_out: &RustString,
2361 level_out: &mut DiagnosticLevel,
2362 loc_out: &mut c_uint,
2363 ranges_out: *mut c_uint,
2364 num_ranges: &mut usize,
2367 pub fn LLVMRustWriteArchive(
2370 Members: *const &RustArchiveMember<'_>,
2373 ) -> LLVMRustResult;
2374 pub fn LLVMRustArchiveMemberNew<'a>(
2375 Filename: *const c_char,
2376 Name: *const c_char,
2377 Child: Option<&ArchiveChild<'a>>,
2378 ) -> &'a mut RustArchiveMember<'a>;
2379 pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>);
2381 pub fn LLVMRustWriteImportLibrary(
2382 ImportName: *const c_char,
2383 Path: *const c_char,
2384 Exports: *const LLVMRustCOFFShortExport,
2388 ) -> LLVMRustResult;
2390 pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
2392 pub fn LLVMRustBuildOperandBundleDef<'a>(
2393 Name: *const c_char,
2394 Inputs: *const &'a Value,
2396 ) -> &'a mut OperandBundleDef<'a>;
2397 pub fn LLVMRustFreeOperandBundleDef<'a>(Bundle: &'a mut OperandBundleDef<'a>);
2399 pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
2401 pub fn LLVMRustSetComdat<'a>(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2402 pub fn LLVMRustSetModulePICLevel(M: &Module);
2403 pub fn LLVMRustSetModulePIELevel(M: &Module);
2404 pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2405 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2406 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2407 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2408 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2409 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2411 pub fn LLVMRustThinLTOBufferCreate(M: &Module, is_thin: bool) -> &'static mut ThinLTOBuffer;
2412 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2413 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2414 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2415 pub fn LLVMRustCreateThinLTOData(
2416 Modules: *const ThinLTOModule,
2418 PreservedSymbols: *const *const c_char,
2419 PreservedSymbolsLen: c_uint,
2420 ) -> Option<&'static mut ThinLTOData>;
2421 pub fn LLVMRustPrepareThinLTORename(
2424 Target: &TargetMachine,
2426 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2427 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2428 pub fn LLVMRustPrepareThinLTOImport(
2431 Target: &TargetMachine,
2433 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2434 pub fn LLVMRustParseBitcodeForLTO(
2438 Identifier: *const c_char,
2439 ) -> Option<&Module>;
2440 pub fn LLVMRustGetBitcodeSliceFromObjectData(
2443 out_len: &mut usize,
2445 pub fn LLVMRustThinLTOGetDICompileUnit(
2447 CU1: &mut *mut c_void,
2448 CU2: &mut *mut c_void,
2450 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2452 pub fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>;
2453 pub fn LLVMRustLinkerAdd(
2454 linker: &Linker<'_>,
2455 bytecode: *const c_char,
2456 bytecode_len: usize,
2458 pub fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>);
2459 #[allow(improper_ctypes)]
2460 pub fn LLVMRustComputeLTOCacheKey(
2461 key_out: &RustString,
2462 mod_id: *const c_char,
2466 pub fn LLVMRustContextGetDiagnosticHandler(Context: &Context) -> Option<&DiagnosticHandler>;
2467 pub fn LLVMRustContextSetDiagnosticHandler(
2469 diagnostic_handler: Option<&DiagnosticHandler>,
2471 pub fn LLVMRustContextConfigureDiagnosticHandler(
2473 diagnostic_handler_callback: DiagnosticHandlerTy,
2474 diagnostic_handler_context: *mut c_void,
2475 remark_all_passes: bool,
2476 remark_passes: *const *const c_char,
2477 remark_passes_len: usize,
2480 #[allow(improper_ctypes)]
2481 pub fn LLVMRustGetMangledName(V: &Value, out: &RustString);
2483 pub fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32;
2485 pub fn LLVMRustIsBitcode(ptr: *const u8, len: usize) -> bool;
2487 pub fn LLVMRustGetSymbols(
2491 callback: GetSymbolsCallback,
2492 error_callback: GetSymbolsErrorCallback,