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 {
85 // Consts for the LLVM CallConv type, pre-cast to usize.
87 /// LLVM CallingConv::ID. Should we wrap this?
88 #[derive(Copy, Clone, PartialEq, Debug)]
94 X86StdcallCallConv = 64,
95 X86FastcallCallConv = 65,
96 ArmAapcsCallConv = 67,
104 AvrNonBlockingInterrupt = 84,
110 #[derive(Copy, Clone, PartialEq)]
114 AvailableExternallyLinkage = 1,
115 LinkOnceAnyLinkage = 2,
116 LinkOnceODRLinkage = 3,
119 AppendingLinkage = 6,
122 ExternalWeakLinkage = 9,
126 // LLVMRustVisibility
128 #[derive(Copy, Clone, PartialEq)]
129 pub enum Visibility {
137 pub enum UnnamedAddr {
143 /// LLVMDLLStorageClass
144 #[derive(Copy, Clone)]
146 pub enum DLLStorageClass {
149 DllImport = 1, // Function to be imported from DLL.
151 DllExport = 2, // Function to be accessible from DLL.
154 /// Matches LLVMRustAttribute in LLVMWrapper.h
155 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
156 /// though it is not ABI compatible (since it's a C++ enum)
158 #[derive(Copy, Clone, Debug)]
159 pub enum AttributeKind {
173 OptimizeForSize = 13,
181 SanitizeAddress = 21,
187 SanitizeHWAddress = 28,
189 StackProtectReq = 30,
190 StackProtectStrong = 31,
195 ShadowCallStack = 36,
197 AllocatedPointer = 38,
202 #[derive(Copy, Clone)]
204 pub enum IntPredicate {
218 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
220 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
221 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
222 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
223 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
224 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
225 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
226 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
227 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
228 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
229 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
234 /// LLVMRealPredicate
235 #[derive(Copy, Clone)]
237 pub enum RealPredicate {
238 RealPredicateFalse = 0,
253 RealPredicateTrue = 15,
257 pub fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self {
259 rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
260 RealPredicate::RealPredicateFalse
262 rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
263 rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
264 rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
265 rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
266 rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
267 rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
268 rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
269 rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
270 rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
271 rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
272 rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
273 rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
274 rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
275 rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
276 rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
277 RealPredicate::RealPredicateTrue
284 #[derive(Copy, Clone, PartialEq, Debug)]
310 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
312 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
313 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
314 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
315 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
316 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
317 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
318 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
319 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
320 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
321 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
322 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
323 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
324 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
325 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
326 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
327 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
328 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
329 TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
330 TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
331 TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX,
336 /// LLVMAtomicRmwBinOp
337 #[derive(Copy, Clone)]
339 pub enum AtomicRmwBinOp {
353 impl AtomicRmwBinOp {
354 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
356 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
357 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
358 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
359 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
360 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
361 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
362 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
363 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
364 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
365 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
366 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
371 /// LLVMAtomicOrdering
372 #[derive(Copy, Clone)]
374 pub enum AtomicOrdering {
379 // Consume = 3, // Not specified yet.
383 SequentiallyConsistent = 7,
386 impl AtomicOrdering {
387 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
389 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
390 rustc_codegen_ssa::common::AtomicOrdering::Relaxed => AtomicOrdering::Monotonic,
391 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
392 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
393 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
394 AtomicOrdering::AcquireRelease
396 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
397 AtomicOrdering::SequentiallyConsistent
404 #[derive(Copy, Clone)]
412 #[derive(Copy, Clone)]
414 pub enum MetadataType {
421 MD_invariant_load = 6,
425 MD_mem_parallel_loop_access = 10,
429 MD_vcall_visibility = 28,
434 /// LLVMRustAsmDialect
435 #[derive(Copy, Clone, PartialEq)]
437 pub enum AsmDialect {
442 /// LLVMRustCodeGenOptLevel
443 #[derive(Copy, Clone, PartialEq)]
445 pub enum CodeGenOptLevel {
452 /// LLVMRustPassBuilderOptLevel
454 pub enum PassBuilderOptLevel {
474 /// LLVMRustSanitizerOptions
476 pub struct SanitizerOptions {
477 pub sanitize_address: bool,
478 pub sanitize_address_recover: bool,
479 pub sanitize_memory: bool,
480 pub sanitize_memory_recover: bool,
481 pub sanitize_memory_track_origins: c_int,
482 pub sanitize_thread: bool,
483 pub sanitize_hwaddress: bool,
484 pub sanitize_hwaddress_recover: bool,
488 #[derive(Copy, Clone, PartialEq)]
490 pub enum RelocModel {
499 /// LLVMRustCodeModel
500 #[derive(Copy, Clone)]
511 /// LLVMRustDiagnosticKind
512 #[derive(Copy, Clone)]
514 #[allow(dead_code)] // Variants constructed by C++.
515 pub enum DiagnosticKind {
519 DebugMetadataVersion,
522 OptimizationRemarkMissed,
523 OptimizationRemarkAnalysis,
524 OptimizationRemarkAnalysisFPCommute,
525 OptimizationRemarkAnalysisAliasing,
526 OptimizationRemarkOther,
534 /// LLVMRustDiagnosticLevel
535 #[derive(Copy, Clone)]
537 #[allow(dead_code)] // Variants constructed by C++.
538 pub enum DiagnosticLevel {
545 /// LLVMRustArchiveKind
546 #[derive(Copy, Clone)]
548 pub enum ArchiveKind {
555 // LLVMRustThinLTOData
557 pub type ThinLTOData;
560 // LLVMRustThinLTOBuffer
562 pub type ThinLTOBuffer;
565 /// LLVMRustThinLTOModule
567 pub struct ThinLTOModule {
568 pub identifier: *const c_char,
573 /// LLVMThreadLocalMode
574 #[derive(Copy, Clone)]
576 pub enum ThreadLocalMode {
584 /// LLVMRustChecksumKind
585 #[derive(Copy, Clone)]
587 pub enum ChecksumKind {
594 /// LLVMRustMemoryEffects
595 #[derive(Copy, Clone)]
597 pub enum MemoryEffects {
607 struct InvariantOpaque<'a> {
608 _marker: PhantomData<&'a mut &'a ()>,
612 // Opaque pointer types
626 pub type ConstantInt;
638 pub struct Builder<'a>(InvariantOpaque<'a>);
640 pub struct PassManager<'a>(InvariantOpaque<'a>);
642 pub type PassManagerBuilder;
648 pub type TargetMachine;
654 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
656 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
661 pub type DiagnosticInfo;
664 pub type SMDiagnostic;
667 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
669 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
671 pub struct Linker<'a>(InvariantOpaque<'a>);
674 pub type DiagnosticHandler;
677 pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
678 pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
680 pub mod coverageinfo {
681 use super::coverage_map;
683 /// 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)
684 #[derive(Copy, Clone, Debug)]
686 pub enum RegionKind {
687 /// A CodeRegion associates some code with a counter
690 /// An ExpansionRegion represents a file expansion region that associates
691 /// a source range with the expansion of a virtual source file, such as
692 /// for a macro instantiation or #include file.
695 /// A SkippedRegion represents a source range with code that was skipped
696 /// by a preprocessor or similar means.
699 /// A GapRegion is like a CodeRegion, but its count is only set as the
700 /// line execution count when its the only region in the line.
703 /// A BranchRegion represents leaf-level boolean expressions and is
704 /// associated with two counters, each representing the number of times the
705 /// expression evaluates to true or false.
709 /// This struct provides LLVM's representation of a "CoverageMappingRegion", encoded into the
710 /// coverage map, in accordance with the
711 /// [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).
712 /// The struct composes fields representing the `Counter` type and value(s) (injected counter
713 /// ID, or expression type and operands), the source file (an indirect index into a "filenames
714 /// array", encoded separately), and source location (start and end positions of the represented
717 /// Matches LLVMRustCounterMappingRegion.
718 #[derive(Copy, Clone, Debug)]
720 pub struct CounterMappingRegion {
721 /// The counter type and type-dependent counter data, if any.
722 counter: coverage_map::Counter,
724 /// If the `RegionKind` is a `BranchRegion`, this represents the counter
725 /// for the false branch of the region.
726 false_counter: coverage_map::Counter,
728 /// An indirect reference to the source filename. In the LLVM Coverage Mapping Format, the
729 /// file_id is an index into a function-specific `virtual_file_mapping` array of indexes
730 /// that, in turn, are used to look up the filename for this region.
733 /// If the `RegionKind` is an `ExpansionRegion`, the `expanded_file_id` can be used to find
734 /// the mapping regions created as a result of macro expansion, by checking if their file id
735 /// matches the expanded file id.
736 expanded_file_id: u32,
738 /// 1-based starting line of the mapping region.
741 /// 1-based starting column of the mapping region.
744 /// 1-based ending line of the mapping region.
747 /// 1-based ending column of the mapping region. If the high bit is set, the current
748 /// mapping region is a gap area.
754 impl CounterMappingRegion {
755 pub(crate) fn code_region(
756 counter: coverage_map::Counter,
765 false_counter: coverage_map::Counter::zero(),
772 kind: RegionKind::CodeRegion,
776 // This function might be used in the future; the LLVM API is still evolving, as is coverage
779 pub(crate) fn branch_region(
780 counter: coverage_map::Counter,
781 false_counter: coverage_map::Counter,
797 kind: RegionKind::BranchRegion,
801 // This function might be used in the future; the LLVM API is still evolving, as is coverage
804 pub(crate) fn expansion_region(
806 expanded_file_id: u32,
813 counter: coverage_map::Counter::zero(),
814 false_counter: coverage_map::Counter::zero(),
821 kind: RegionKind::ExpansionRegion,
825 // This function might be used in the future; the LLVM API is still evolving, as is coverage
828 pub(crate) fn skipped_region(
836 counter: coverage_map::Counter::zero(),
837 false_counter: coverage_map::Counter::zero(),
844 kind: RegionKind::SkippedRegion,
848 // This function might be used in the future; the LLVM API is still evolving, as is coverage
851 pub(crate) fn gap_region(
852 counter: coverage_map::Counter,
861 false_counter: coverage_map::Counter::zero(),
867 end_col: (1_u32 << 31) | end_col,
868 kind: RegionKind::GapRegion,
875 use super::{InvariantOpaque, Metadata};
876 use bitflags::bitflags;
879 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
881 pub type DIDescriptor = Metadata;
882 pub type DILocation = Metadata;
883 pub type DIScope = DIDescriptor;
884 pub type DIFile = DIScope;
885 pub type DILexicalBlock = DIScope;
886 pub type DISubprogram = DIScope;
887 pub type DINameSpace = DIScope;
888 pub type DIType = DIDescriptor;
889 pub type DIBasicType = DIType;
890 pub type DIDerivedType = DIType;
891 pub type DICompositeType = DIDerivedType;
892 pub type DIVariable = DIDescriptor;
893 pub type DIGlobalVariableExpression = DIDescriptor;
894 pub type DIArray = DIDescriptor;
895 pub type DISubrange = DIDescriptor;
896 pub type DIEnumerator = DIDescriptor;
897 pub type DITemplateTypeParameter = DIDescriptor;
899 // These values **must** match with LLVMRustDIFlags!!
903 pub struct DIFlags: u32 {
905 const FlagPrivate = 1;
906 const FlagProtected = 2;
907 const FlagPublic = 3;
908 const FlagFwdDecl = (1 << 2);
909 const FlagAppleBlock = (1 << 3);
910 const FlagBlockByrefStruct = (1 << 4);
911 const FlagVirtual = (1 << 5);
912 const FlagArtificial = (1 << 6);
913 const FlagExplicit = (1 << 7);
914 const FlagPrototyped = (1 << 8);
915 const FlagObjcClassComplete = (1 << 9);
916 const FlagObjectPointer = (1 << 10);
917 const FlagVector = (1 << 11);
918 const FlagStaticMember = (1 << 12);
919 const FlagLValueReference = (1 << 13);
920 const FlagRValueReference = (1 << 14);
921 const FlagExternalTypeRef = (1 << 15);
922 const FlagIntroducedVirtual = (1 << 18);
923 const FlagBitField = (1 << 19);
924 const FlagNoReturn = (1 << 20);
928 // These values **must** match with LLVMRustDISPFlags!!
932 pub struct DISPFlags: u32 {
933 const SPFlagZero = 0;
934 const SPFlagVirtual = 1;
935 const SPFlagPureVirtual = 2;
936 const SPFlagLocalToUnit = (1 << 2);
937 const SPFlagDefinition = (1 << 3);
938 const SPFlagOptimized = (1 << 4);
939 const SPFlagMainSubprogram = (1 << 5);
943 /// LLVMRustDebugEmissionKind
944 #[derive(Copy, Clone)]
946 pub enum DebugEmissionKind {
952 impl DebugEmissionKind {
953 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
954 use rustc_session::config::DebugInfo;
956 DebugInfo::None => DebugEmissionKind::NoDebug,
957 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
958 DebugInfo::Full => DebugEmissionKind::FullDebug,
964 use bitflags::bitflags;
965 // These values **must** match with LLVMRustAllocKindFlags
969 pub struct AllocKindFlags : u64 {
972 const Realloc = 1 << 1;
974 const Uninitialized = 1 << 3;
975 const Zeroed = 1 << 4;
976 const Aligned = 1 << 5;
981 pub type ModuleBuffer;
984 pub type SelfProfileBeforePassCallback =
985 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
986 pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
988 pub type GetSymbolsCallback = unsafe extern "C" fn(*mut c_void, *const c_char) -> *mut c_void;
989 pub type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) -> *mut c_void;
992 pub fn LLVMRustInstallFatalErrorHandler();
993 pub fn LLVMRustDisableSystemDialogsOnCrash();
995 // Create and destroy contexts.
996 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
997 pub fn LLVMContextDispose(C: &'static mut Context);
998 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
1001 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
1002 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
1003 pub fn LLVMCloneModule(M: &Module) -> &Module;
1005 /// Data layout. See Module::getDataLayout.
1006 pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
1007 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
1009 /// See Module::setModuleInlineAsm.
1010 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
1012 /// See llvm::LLVMTypeKind::getTypeID.
1013 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
1015 // Operations on integer types
1016 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
1017 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
1018 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
1019 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
1020 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
1021 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
1023 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
1025 // Operations on real types
1026 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
1027 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
1029 // Operations on function types
1030 pub fn LLVMFunctionType<'a>(
1031 ReturnType: &'a Type,
1032 ParamTypes: *const &'a Type,
1036 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
1037 pub fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type);
1039 // Operations on struct types
1040 pub fn LLVMStructTypeInContext<'a>(
1042 ElementTypes: *const &'a Type,
1043 ElementCount: c_uint,
1047 // Operations on array, pointer, and vector types (sequence types)
1048 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
1049 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
1050 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
1052 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
1053 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
1055 // Operations on other types
1056 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
1057 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
1059 // Operations on all values
1060 pub fn LLVMTypeOf(Val: &Value) -> &Type;
1061 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
1062 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
1063 pub fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value);
1064 pub fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Node: &'a Value);
1065 pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
1066 pub fn LLVMRustGlobalAddMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
1067 pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
1068 pub fn LLVMIsAFunction(Val: &Value) -> Option<&Value>;
1070 // Operations on constants of any type
1071 pub fn LLVMConstNull(Ty: &Type) -> &Value;
1072 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
1074 // Operations on metadata
1075 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
1076 pub fn LLVMMDNodeInContext<'a>(
1078 Vals: *const &'a Value,
1081 pub fn LLVMMDNodeInContext2<'a>(
1083 Vals: *const &'a Metadata,
1086 pub fn LLVMAddNamedMetadataOperand<'a>(M: &'a Module, Name: *const c_char, Val: &'a Value);
1088 // Operations on scalar constants
1089 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
1090 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
1091 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
1092 pub fn LLVMRustConstIntGetZExtValue(ConstantVal: &ConstantInt, Value: &mut u64) -> bool;
1093 pub fn LLVMRustConstInt128Get(
1094 ConstantVal: &ConstantInt,
1100 // Operations on composite constants
1101 pub fn LLVMConstStringInContext(
1105 DontNullTerminate: Bool,
1107 pub fn LLVMConstStructInContext<'a>(
1109 ConstantVals: *const &'a Value,
1114 pub fn LLVMConstArray<'a>(
1115 ElementTy: &'a Type,
1116 ConstantVals: *const &'a Value,
1119 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
1121 // Constant expressions
1122 pub fn LLVMRustConstInBoundsGEP2<'a>(
1124 ConstantVal: &'a Value,
1125 ConstantIndices: *const &'a Value,
1128 pub fn LLVMConstZExt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1129 pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1130 pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1131 pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1132 pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1133 pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
1135 // Operations on global variables, functions, and aliases (globals)
1136 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
1137 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
1138 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
1139 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
1140 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
1141 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
1142 pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
1143 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
1144 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1145 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1147 // Operations on global variables
1148 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
1149 pub fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1150 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
1151 pub fn LLVMRustGetOrInsertGlobal<'a>(
1153 Name: *const c_char,
1157 pub fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value;
1158 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1159 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1160 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
1161 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1162 pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
1163 pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
1164 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1165 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1166 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1167 pub fn LLVMRustGetNamedValue(
1169 Name: *const c_char,
1171 ) -> Option<&Value>;
1172 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1174 // Operations on attributes
1175 pub fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute;
1176 pub fn LLVMCreateStringAttribute(
1178 Name: *const c_char,
1180 Value: *const c_char,
1183 pub fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute;
1184 pub fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute;
1185 pub fn LLVMRustCreateDereferenceableOrNullAttr(C: &Context, bytes: u64) -> &Attribute;
1186 pub fn LLVMRustCreateByValAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1187 pub fn LLVMRustCreateStructRetAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1188 pub fn LLVMRustCreateElementTypeAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1189 pub fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute;
1190 pub fn LLVMRustCreateAllocSizeAttr(C: &Context, size_arg: u32) -> &Attribute;
1191 pub fn LLVMRustCreateAllocKindAttr(C: &Context, size_arg: u64) -> &Attribute;
1192 pub fn LLVMRustCreateMemoryEffectsAttr(C: &Context, effects: MemoryEffects) -> &Attribute;
1194 // Operations on functions
1195 pub fn LLVMRustGetOrInsertFunction<'a>(
1197 Name: *const c_char,
1199 FunctionTy: &'a Type,
1201 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1202 pub fn LLVMRustAddFunctionAttributes<'a>(
1205 Attrs: *const &'a Attribute,
1209 // Operations on parameters
1210 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1211 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
1212 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1214 // Operations on basic blocks
1215 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1216 pub fn LLVMAppendBasicBlockInContext<'a>(
1219 Name: *const c_char,
1220 ) -> &'a BasicBlock;
1222 // Operations on instructions
1223 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1224 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1226 // Operations on call sites
1227 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1228 pub fn LLVMRustAddCallSiteAttributes<'a>(
1231 Attrs: *const &'a Attribute,
1235 // Operations on load/store instructions (only)
1236 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1238 // Operations on phi nodes
1239 pub fn LLVMAddIncoming<'a>(
1241 IncomingValues: *const &'a Value,
1242 IncomingBlocks: *const &'a BasicBlock,
1246 // Instruction builders
1247 pub fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>;
1248 pub fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock);
1249 pub fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock;
1250 pub fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);
1253 pub fn LLVMSetCurrentDebugLocation<'a>(Builder: &Builder<'a>, L: &'a Value);
1256 pub fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;
1257 pub fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1258 pub fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1259 pub fn LLVMBuildCondBr<'a>(
1262 Then: &'a BasicBlock,
1263 Else: &'a BasicBlock,
1265 pub fn LLVMBuildSwitch<'a>(
1268 Else: &'a BasicBlock,
1271 pub fn LLVMRustBuildInvoke<'a>(
1275 Args: *const &'a Value,
1277 Then: &'a BasicBlock,
1278 Catch: &'a BasicBlock,
1279 OpBundles: *const Option<&OperandBundleDef<'a>>,
1280 NumOpBundles: c_uint,
1281 Name: *const c_char,
1283 pub fn LLVMBuildLandingPad<'a>(
1286 PersFn: Option<&'a Value>,
1288 Name: *const c_char,
1290 pub fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1291 pub fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value;
1293 pub fn LLVMRustBuildCleanupPad<'a>(
1295 ParentPad: Option<&'a Value>,
1297 Args: *const &'a Value,
1298 Name: *const c_char,
1299 ) -> Option<&'a Value>;
1300 pub fn LLVMRustBuildCleanupRet<'a>(
1302 CleanupPad: &'a Value,
1303 UnwindBB: Option<&'a BasicBlock>,
1304 ) -> Option<&'a Value>;
1305 pub fn LLVMRustBuildCatchPad<'a>(
1307 ParentPad: &'a Value,
1309 Args: *const &'a Value,
1310 Name: *const c_char,
1311 ) -> Option<&'a Value>;
1312 pub fn LLVMRustBuildCatchRet<'a>(
1316 ) -> Option<&'a Value>;
1317 pub fn LLVMRustBuildCatchSwitch<'a>(
1318 Builder: &Builder<'a>,
1319 ParentPad: Option<&'a Value>,
1320 BB: Option<&'a BasicBlock>,
1321 NumHandlers: c_uint,
1322 Name: *const c_char,
1323 ) -> Option<&'a Value>;
1324 pub fn LLVMRustAddHandler<'a>(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1325 pub fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value);
1327 // Add a case to the switch instruction
1328 pub fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1330 // Add a clause to the landing pad instruction
1331 pub fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value);
1333 // Set the cleanup on a landing pad instruction
1334 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1337 pub fn LLVMBuildAdd<'a>(
1341 Name: *const c_char,
1343 pub fn LLVMBuildFAdd<'a>(
1347 Name: *const c_char,
1349 pub fn LLVMBuildSub<'a>(
1353 Name: *const c_char,
1355 pub fn LLVMBuildFSub<'a>(
1359 Name: *const c_char,
1361 pub fn LLVMBuildMul<'a>(
1365 Name: *const c_char,
1367 pub fn LLVMBuildFMul<'a>(
1371 Name: *const c_char,
1373 pub fn LLVMBuildUDiv<'a>(
1377 Name: *const c_char,
1379 pub fn LLVMBuildExactUDiv<'a>(
1383 Name: *const c_char,
1385 pub fn LLVMBuildSDiv<'a>(
1389 Name: *const c_char,
1391 pub fn LLVMBuildExactSDiv<'a>(
1395 Name: *const c_char,
1397 pub fn LLVMBuildFDiv<'a>(
1401 Name: *const c_char,
1403 pub fn LLVMBuildURem<'a>(
1407 Name: *const c_char,
1409 pub fn LLVMBuildSRem<'a>(
1413 Name: *const c_char,
1415 pub fn LLVMBuildFRem<'a>(
1419 Name: *const c_char,
1421 pub fn LLVMBuildShl<'a>(
1425 Name: *const c_char,
1427 pub fn LLVMBuildLShr<'a>(
1431 Name: *const c_char,
1433 pub fn LLVMBuildAShr<'a>(
1437 Name: *const c_char,
1439 pub fn LLVMBuildNSWAdd<'a>(
1443 Name: *const c_char,
1445 pub fn LLVMBuildNUWAdd<'a>(
1449 Name: *const c_char,
1451 pub fn LLVMBuildNSWSub<'a>(
1455 Name: *const c_char,
1457 pub fn LLVMBuildNUWSub<'a>(
1461 Name: *const c_char,
1463 pub fn LLVMBuildNSWMul<'a>(
1467 Name: *const c_char,
1469 pub fn LLVMBuildNUWMul<'a>(
1473 Name: *const c_char,
1475 pub fn LLVMBuildAnd<'a>(
1479 Name: *const c_char,
1481 pub fn LLVMBuildOr<'a>(
1485 Name: *const c_char,
1487 pub fn LLVMBuildXor<'a>(
1491 Name: *const c_char,
1493 pub fn LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1494 pub fn LLVMBuildFNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1495 pub fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1496 pub fn LLVMRustSetFastMath(Instr: &Value);
1499 pub fn LLVMBuildAlloca<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1500 pub fn LLVMBuildArrayAlloca<'a>(
1504 Name: *const c_char,
1506 pub fn LLVMBuildLoad2<'a>(
1509 PointerVal: &'a Value,
1510 Name: *const c_char,
1513 pub fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1515 pub fn LLVMBuildGEP2<'a>(
1519 Indices: *const &'a Value,
1521 Name: *const c_char,
1523 pub fn LLVMBuildInBoundsGEP2<'a>(
1527 Indices: *const &'a Value,
1529 Name: *const c_char,
1531 pub fn LLVMBuildStructGEP2<'a>(
1536 Name: *const c_char,
1540 pub fn LLVMBuildTrunc<'a>(
1544 Name: *const c_char,
1546 pub fn LLVMBuildZExt<'a>(
1550 Name: *const c_char,
1552 pub fn LLVMBuildSExt<'a>(
1556 Name: *const c_char,
1558 pub fn LLVMBuildFPToUI<'a>(
1562 Name: *const c_char,
1564 pub fn LLVMBuildFPToSI<'a>(
1568 Name: *const c_char,
1570 pub fn LLVMBuildUIToFP<'a>(
1574 Name: *const c_char,
1576 pub fn LLVMBuildSIToFP<'a>(
1580 Name: *const c_char,
1582 pub fn LLVMBuildFPTrunc<'a>(
1586 Name: *const c_char,
1588 pub fn LLVMBuildFPExt<'a>(
1592 Name: *const c_char,
1594 pub fn LLVMBuildPtrToInt<'a>(
1598 Name: *const c_char,
1600 pub fn LLVMBuildIntToPtr<'a>(
1604 Name: *const c_char,
1606 pub fn LLVMBuildBitCast<'a>(
1610 Name: *const c_char,
1612 pub fn LLVMBuildPointerCast<'a>(
1616 Name: *const c_char,
1618 pub fn LLVMRustBuildIntCast<'a>(
1626 pub fn LLVMBuildICmp<'a>(
1631 Name: *const c_char,
1633 pub fn LLVMBuildFCmp<'a>(
1638 Name: *const c_char,
1641 // Miscellaneous instructions
1642 pub fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1643 pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &Value;
1644 pub fn LLVMRustBuildCall<'a>(
1648 Args: *const &'a Value,
1650 OpBundles: *const Option<&OperandBundleDef<'a>>,
1651 NumOpBundles: c_uint,
1653 pub fn LLVMRustBuildMemCpy<'a>(
1662 pub fn LLVMRustBuildMemMove<'a>(
1671 pub fn LLVMRustBuildMemSet<'a>(
1679 pub fn LLVMBuildSelect<'a>(
1684 Name: *const c_char,
1686 pub fn LLVMBuildVAArg<'a>(
1690 Name: *const c_char,
1692 pub fn LLVMBuildExtractElement<'a>(
1696 Name: *const c_char,
1698 pub fn LLVMBuildInsertElement<'a>(
1703 Name: *const c_char,
1705 pub fn LLVMBuildShuffleVector<'a>(
1710 Name: *const c_char,
1712 pub fn LLVMBuildExtractValue<'a>(
1716 Name: *const c_char,
1718 pub fn LLVMBuildInsertValue<'a>(
1723 Name: *const c_char,
1726 pub fn LLVMRustBuildVectorReduceFAdd<'a>(
1731 pub fn LLVMRustBuildVectorReduceFMul<'a>(
1736 pub fn LLVMRustBuildVectorReduceAdd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1737 pub fn LLVMRustBuildVectorReduceMul<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1738 pub fn LLVMRustBuildVectorReduceAnd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1739 pub fn LLVMRustBuildVectorReduceOr<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1740 pub fn LLVMRustBuildVectorReduceXor<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1741 pub fn LLVMRustBuildVectorReduceMin<'a>(
1746 pub fn LLVMRustBuildVectorReduceMax<'a>(
1751 pub fn LLVMRustBuildVectorReduceFMin<'a>(
1756 pub fn LLVMRustBuildVectorReduceFMax<'a>(
1762 pub fn LLVMRustBuildMinNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1763 pub fn LLVMRustBuildMaxNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1765 // Atomic Operations
1766 pub fn LLVMRustBuildAtomicLoad<'a>(
1768 ElementType: &'a Type,
1769 PointerVal: &'a Value,
1770 Name: *const c_char,
1771 Order: AtomicOrdering,
1774 pub fn LLVMRustBuildAtomicStore<'a>(
1778 Order: AtomicOrdering,
1781 pub fn LLVMBuildAtomicCmpXchg<'a>(
1786 Order: AtomicOrdering,
1787 FailureOrder: AtomicOrdering,
1788 SingleThreaded: Bool,
1791 pub fn LLVMSetWeak(CmpXchgInst: &Value, IsWeak: Bool);
1793 pub fn LLVMBuildAtomicRMW<'a>(
1798 Order: AtomicOrdering,
1799 SingleThreaded: Bool,
1802 pub fn LLVMBuildFence<'a>(
1804 Order: AtomicOrdering,
1805 SingleThreaded: Bool,
1806 Name: *const c_char,
1809 /// Writes a module to the specified path. Returns 0 on success.
1810 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1812 /// Creates a legacy pass manager -- only used for final codegen.
1813 pub fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>;
1815 pub fn LLVMInitializePasses();
1817 pub fn LLVMTimeTraceProfilerInitialize();
1819 pub fn LLVMTimeTraceProfilerFinishThread();
1821 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1823 pub fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>);
1825 pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
1827 pub fn LLVMDisposeMessage(message: *mut c_char);
1829 pub fn LLVMIsMultithreaded() -> Bool;
1831 /// Returns a string describing the last error caused by an LLVMRust* call.
1832 pub fn LLVMRustGetLastError() -> *const c_char;
1834 /// Print the pass timings since static dtors aren't picking them up.
1835 pub fn LLVMRustPrintPassTimings();
1837 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1839 pub fn LLVMStructSetBody<'a>(
1841 ElementTypes: *const &'a Type,
1842 ElementCount: c_uint,
1846 /// Prepares inline assembly.
1847 pub fn LLVMRustInlineAsm(
1849 AsmString: *const c_char,
1850 AsmStringLen: size_t,
1851 Constraints: *const c_char,
1852 ConstraintsLen: size_t,
1855 Dialect: AsmDialect,
1858 pub fn LLVMRustInlineAsmVerify(
1860 Constraints: *const c_char,
1861 ConstraintsLen: size_t,
1864 #[allow(improper_ctypes)]
1865 pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1866 Filenames: *const *const c_char,
1867 FilenamesLen: size_t,
1868 BufferOut: &RustString,
1871 #[allow(improper_ctypes)]
1872 pub fn LLVMRustCoverageWriteMappingToBuffer(
1873 VirtualFileMappingIDs: *const c_uint,
1874 NumVirtualFileMappingIDs: c_uint,
1875 Expressions: *const coverage_map::CounterExpression,
1876 NumExpressions: c_uint,
1877 MappingRegions: *const coverageinfo::CounterMappingRegion,
1878 NumMappingRegions: c_uint,
1879 BufferOut: &RustString,
1882 pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &Value, FuncName: *const c_char) -> &Value;
1883 pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64;
1884 pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
1886 #[allow(improper_ctypes)]
1887 pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
1889 #[allow(improper_ctypes)]
1890 pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
1892 #[allow(improper_ctypes)]
1893 pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1895 pub fn LLVMRustCoverageMappingVersion() -> u32;
1896 pub fn LLVMRustDebugMetadataVersion() -> u32;
1897 pub fn LLVMRustVersionMajor() -> u32;
1898 pub fn LLVMRustVersionMinor() -> u32;
1899 pub fn LLVMRustVersionPatch() -> u32;
1901 /// Add LLVM module flags.
1903 /// In order for Rust-C LTO to work, module flags must be compatible with Clang. What
1904 /// "compatible" means depends on the merge behaviors involved.
1905 pub fn LLVMRustAddModuleFlag(
1907 merge_behavior: LLVMModFlagBehavior,
1908 name: *const c_char,
1911 pub fn LLVMRustHasModuleFlag(M: &Module, name: *const c_char, len: size_t) -> bool;
1913 pub fn LLVMRustMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1915 pub fn LLVMRustDIBuilderCreate(M: &Module) -> &mut DIBuilder<'_>;
1917 pub fn LLVMRustDIBuilderDispose<'a>(Builder: &'a mut DIBuilder<'a>);
1919 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1921 pub fn LLVMRustDIBuilderCreateCompileUnit<'a>(
1922 Builder: &DIBuilder<'a>,
1925 Producer: *const c_char,
1926 ProducerLen: size_t,
1928 Flags: *const c_char,
1930 SplitName: *const c_char,
1931 SplitNameLen: size_t,
1932 kind: DebugEmissionKind,
1934 SplitDebugInlining: bool,
1935 ) -> &'a DIDescriptor;
1937 pub fn LLVMRustDIBuilderCreateFile<'a>(
1938 Builder: &DIBuilder<'a>,
1939 Filename: *const c_char,
1940 FilenameLen: size_t,
1941 Directory: *const c_char,
1942 DirectoryLen: size_t,
1943 CSKind: ChecksumKind,
1944 Checksum: *const c_char,
1945 ChecksumLen: size_t,
1948 pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
1949 Builder: &DIBuilder<'a>,
1950 ParameterTypes: &'a DIArray,
1951 ) -> &'a DICompositeType;
1953 pub fn LLVMRustDIBuilderCreateFunction<'a>(
1954 Builder: &DIBuilder<'a>,
1955 Scope: &'a DIDescriptor,
1956 Name: *const c_char,
1958 LinkageName: *const c_char,
1959 LinkageNameLen: size_t,
1966 MaybeFn: Option<&'a Value>,
1967 TParam: &'a DIArray,
1968 Decl: Option<&'a DIDescriptor>,
1969 ) -> &'a DISubprogram;
1971 pub fn LLVMRustDIBuilderCreateBasicType<'a>(
1972 Builder: &DIBuilder<'a>,
1973 Name: *const c_char,
1977 ) -> &'a DIBasicType;
1979 pub fn LLVMRustDIBuilderCreateTypedef<'a>(
1980 Builder: &DIBuilder<'a>,
1981 Type: &'a DIBasicType,
1982 Name: *const c_char,
1986 Scope: Option<&'a DIScope>,
1987 ) -> &'a DIDerivedType;
1989 pub fn LLVMRustDIBuilderCreatePointerType<'a>(
1990 Builder: &DIBuilder<'a>,
1991 PointeeTy: &'a DIType,
1994 AddressSpace: c_uint,
1995 Name: *const c_char,
1997 ) -> &'a DIDerivedType;
1999 pub fn LLVMRustDIBuilderCreateStructType<'a>(
2000 Builder: &DIBuilder<'a>,
2001 Scope: Option<&'a DIDescriptor>,
2002 Name: *const c_char,
2009 DerivedFrom: Option<&'a DIType>,
2010 Elements: &'a DIArray,
2011 RunTimeLang: c_uint,
2012 VTableHolder: Option<&'a DIType>,
2013 UniqueId: *const c_char,
2014 UniqueIdLen: size_t,
2015 ) -> &'a DICompositeType;
2017 pub fn LLVMRustDIBuilderCreateMemberType<'a>(
2018 Builder: &DIBuilder<'a>,
2019 Scope: &'a DIDescriptor,
2020 Name: *const c_char,
2029 ) -> &'a DIDerivedType;
2031 pub fn LLVMRustDIBuilderCreateVariantMemberType<'a>(
2032 Builder: &DIBuilder<'a>,
2034 Name: *const c_char,
2041 Discriminant: Option<&'a Value>,
2046 pub fn LLVMRustDIBuilderCreateStaticMemberType<'a>(
2047 Builder: &DIBuilder<'a>,
2048 Scope: &'a DIDescriptor,
2049 Name: *const c_char,
2055 val: Option<&'a Value>,
2057 ) -> &'a DIDerivedType;
2059 pub fn LLVMRustDIBuilderCreateLexicalBlock<'a>(
2060 Builder: &DIBuilder<'a>,
2065 ) -> &'a DILexicalBlock;
2067 pub fn LLVMRustDIBuilderCreateLexicalBlockFile<'a>(
2068 Builder: &DIBuilder<'a>,
2071 ) -> &'a DILexicalBlock;
2073 pub fn LLVMRustDIBuilderCreateStaticVariable<'a>(
2074 Builder: &DIBuilder<'a>,
2075 Context: Option<&'a DIScope>,
2076 Name: *const c_char,
2078 LinkageName: *const c_char,
2079 LinkageNameLen: size_t,
2083 isLocalToUnit: bool,
2085 Decl: Option<&'a DIDescriptor>,
2087 ) -> &'a DIGlobalVariableExpression;
2089 pub fn LLVMRustDIBuilderCreateVariable<'a>(
2090 Builder: &DIBuilder<'a>,
2092 Scope: &'a DIDescriptor,
2093 Name: *const c_char,
2098 AlwaysPreserve: bool,
2102 ) -> &'a DIVariable;
2104 pub fn LLVMRustDIBuilderCreateArrayType<'a>(
2105 Builder: &DIBuilder<'a>,
2109 Subscripts: &'a DIArray,
2112 pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
2113 Builder: &DIBuilder<'a>,
2116 ) -> &'a DISubrange;
2118 pub fn LLVMRustDIBuilderGetOrCreateArray<'a>(
2119 Builder: &DIBuilder<'a>,
2120 Ptr: *const Option<&'a DIDescriptor>,
2124 pub fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>(
2125 Builder: &DIBuilder<'a>,
2127 VarInfo: &'a DIVariable,
2128 AddrOps: *const u64,
2129 AddrOpsCount: c_uint,
2131 InsertAtEnd: &'a BasicBlock,
2134 pub fn LLVMRustDIBuilderCreateEnumerator<'a>(
2135 Builder: &DIBuilder<'a>,
2136 Name: *const c_char,
2141 ) -> &'a DIEnumerator;
2143 pub fn LLVMRustDIBuilderCreateEnumerationType<'a>(
2144 Builder: &DIBuilder<'a>,
2146 Name: *const c_char,
2152 Elements: &'a DIArray,
2153 ClassType: &'a DIType,
2157 pub fn LLVMRustDIBuilderCreateUnionType<'a>(
2158 Builder: &DIBuilder<'a>,
2159 Scope: Option<&'a DIScope>,
2160 Name: *const c_char,
2167 Elements: Option<&'a DIArray>,
2168 RunTimeLang: c_uint,
2169 UniqueId: *const c_char,
2170 UniqueIdLen: size_t,
2173 pub fn LLVMRustDIBuilderCreateVariantPart<'a>(
2174 Builder: &DIBuilder<'a>,
2176 Name: *const c_char,
2183 Discriminator: Option<&'a DIDerivedType>,
2184 Elements: &'a DIArray,
2185 UniqueId: *const c_char,
2186 UniqueIdLen: size_t,
2187 ) -> &'a DIDerivedType;
2189 pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
2191 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter<'a>(
2192 Builder: &DIBuilder<'a>,
2193 Scope: Option<&'a DIScope>,
2194 Name: *const c_char,
2197 ) -> &'a DITemplateTypeParameter;
2199 pub fn LLVMRustDIBuilderCreateNameSpace<'a>(
2200 Builder: &DIBuilder<'a>,
2201 Scope: Option<&'a DIScope>,
2202 Name: *const c_char,
2204 ExportSymbols: bool,
2205 ) -> &'a DINameSpace;
2207 pub fn LLVMRustDICompositeTypeReplaceArrays<'a>(
2208 Builder: &DIBuilder<'a>,
2209 CompositeType: &'a DIType,
2210 Elements: Option<&'a DIArray>,
2211 Params: Option<&'a DIArray>,
2214 pub fn LLVMRustDIBuilderCreateDebugLocation<'a>(
2218 InlinedAt: Option<&'a DILocation>,
2219 ) -> &'a DILocation;
2220 pub fn LLVMRustDIBuilderCreateOpDeref() -> u64;
2221 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64;
2222 pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64;
2224 #[allow(improper_ctypes)]
2225 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2226 #[allow(improper_ctypes)]
2227 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2229 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2231 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2233 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
2234 pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2235 pub fn LLVMRustGetTargetFeature(
2238 Feature: &mut *const c_char,
2239 Desc: &mut *const c_char,
2242 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2243 pub fn LLVMRustCreateTargetMachine(
2244 Triple: *const c_char,
2246 Features: *const c_char,
2250 Level: CodeGenOptLevel,
2252 FunctionSections: bool,
2254 UniqueSectionNames: bool,
2255 TrapUnreachable: bool,
2258 EmitStackSizeSection: bool,
2259 RelaxELFRelocations: bool,
2261 SplitDwarfFile: *const c_char,
2262 ) -> Option<&'static mut TargetMachine>;
2263 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
2264 pub fn LLVMRustAddLibraryInfo<'a>(
2265 PM: &PassManager<'a>,
2267 DisableSimplifyLibCalls: bool,
2269 pub fn LLVMRustWriteOutputFile<'a>(
2270 T: &'a TargetMachine,
2271 PM: &PassManager<'a>,
2273 Output: *const c_char,
2274 DwoOutput: *const c_char,
2276 ) -> LLVMRustResult;
2277 pub fn LLVMRustOptimize<'a>(
2279 TM: &'a TargetMachine,
2280 OptLevel: PassBuilderOptLevel,
2282 NoPrepopulatePasses: bool,
2284 UseThinLTOBuffers: bool,
2285 MergeFunctions: bool,
2288 LoopVectorize: bool,
2289 DisableSimplifyLibCalls: bool,
2290 EmitLifetimeMarkers: bool,
2291 SanitizerOptions: Option<&SanitizerOptions>,
2292 PGOGenPath: *const c_char,
2293 PGOUsePath: *const c_char,
2294 InstrumentCoverage: bool,
2295 InstrProfileOutput: *const c_char,
2296 InstrumentGCOV: bool,
2297 PGOSampleUsePath: *const c_char,
2298 DebugInfoForProfiling: bool,
2299 llvm_selfprofiler: *mut c_void,
2300 begin_callback: SelfProfileBeforePassCallback,
2301 end_callback: SelfProfileAfterPassCallback,
2302 ExtraPasses: *const c_char,
2303 ExtraPassesLen: size_t,
2304 LLVMPlugins: *const c_char,
2305 LLVMPluginsLen: size_t,
2306 ) -> LLVMRustResult;
2307 pub fn LLVMRustPrintModule(
2309 Output: *const c_char,
2310 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2311 ) -> LLVMRustResult;
2312 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2313 pub fn LLVMRustPrintPasses();
2314 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2315 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2317 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2318 pub fn LLVMRustArchiveIteratorNew(AR: &Archive) -> &mut ArchiveIterator<'_>;
2319 pub fn LLVMRustArchiveIteratorNext<'a>(
2320 AIR: &ArchiveIterator<'a>,
2321 ) -> Option<&'a mut ArchiveChild<'a>>;
2322 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2323 pub fn LLVMRustArchiveChildFree<'a>(ACR: &'a mut ArchiveChild<'a>);
2324 pub fn LLVMRustArchiveIteratorFree<'a>(AIR: &'a mut ArchiveIterator<'a>);
2325 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2327 #[allow(improper_ctypes)]
2328 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2330 #[allow(improper_ctypes)]
2331 pub fn LLVMRustUnpackOptimizationDiagnostic<'a>(
2332 DI: &'a DiagnosticInfo,
2333 pass_name_out: &RustString,
2334 function_out: &mut Option<&'a Value>,
2335 loc_line_out: &mut c_uint,
2336 loc_column_out: &mut c_uint,
2337 loc_filename_out: &RustString,
2338 message_out: &RustString,
2341 pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>(
2342 DI: &'a DiagnosticInfo,
2343 level_out: &mut DiagnosticLevel,
2344 cookie_out: &mut c_uint,
2345 message_out: &mut Option<&'a Twine>,
2348 #[allow(improper_ctypes)]
2349 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2350 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2352 pub fn LLVMRustGetSMDiagnostic<'a>(
2353 DI: &'a DiagnosticInfo,
2354 cookie_out: &mut c_uint,
2355 ) -> &'a SMDiagnostic;
2357 #[allow(improper_ctypes)]
2358 pub fn LLVMRustUnpackSMDiagnostic(
2360 message_out: &RustString,
2361 buffer_out: &RustString,
2362 level_out: &mut DiagnosticLevel,
2363 loc_out: &mut c_uint,
2364 ranges_out: *mut c_uint,
2365 num_ranges: &mut usize,
2368 pub fn LLVMRustWriteArchive(
2371 Members: *const &RustArchiveMember<'_>,
2374 ) -> LLVMRustResult;
2375 pub fn LLVMRustArchiveMemberNew<'a>(
2376 Filename: *const c_char,
2377 Name: *const c_char,
2378 Child: Option<&ArchiveChild<'a>>,
2379 ) -> &'a mut RustArchiveMember<'a>;
2380 pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>);
2382 pub fn LLVMRustWriteImportLibrary(
2383 ImportName: *const c_char,
2384 Path: *const c_char,
2385 Exports: *const LLVMRustCOFFShortExport,
2389 ) -> LLVMRustResult;
2391 pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
2393 pub fn LLVMRustBuildOperandBundleDef(
2394 Name: *const c_char,
2395 Inputs: *const &'_ Value,
2397 ) -> &mut OperandBundleDef<'_>;
2398 pub fn LLVMRustFreeOperandBundleDef<'a>(Bundle: &'a mut OperandBundleDef<'a>);
2400 pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
2402 pub fn LLVMRustSetComdat<'a>(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2403 pub fn LLVMRustSetModulePICLevel(M: &Module);
2404 pub fn LLVMRustSetModulePIELevel(M: &Module);
2405 pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2406 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2407 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2408 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2409 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2410 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2412 pub fn LLVMRustThinLTOBufferCreate(M: &Module, is_thin: bool) -> &'static mut ThinLTOBuffer;
2413 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2414 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2415 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2416 pub fn LLVMRustCreateThinLTOData(
2417 Modules: *const ThinLTOModule,
2419 PreservedSymbols: *const *const c_char,
2420 PreservedSymbolsLen: c_uint,
2421 ) -> Option<&'static mut ThinLTOData>;
2422 pub fn LLVMRustPrepareThinLTORename(
2425 Target: &TargetMachine,
2427 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2428 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2429 pub fn LLVMRustPrepareThinLTOImport(
2432 Target: &TargetMachine,
2434 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2435 pub fn LLVMRustParseBitcodeForLTO(
2439 Identifier: *const c_char,
2440 ) -> Option<&Module>;
2441 pub fn LLVMRustGetBitcodeSliceFromObjectData(
2444 out_len: &mut usize,
2446 pub fn LLVMRustThinLTOGetDICompileUnit(
2448 CU1: &mut *mut c_void,
2449 CU2: &mut *mut c_void,
2451 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2453 pub fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>;
2454 pub fn LLVMRustLinkerAdd(
2455 linker: &Linker<'_>,
2456 bytecode: *const c_char,
2457 bytecode_len: usize,
2459 pub fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>);
2460 #[allow(improper_ctypes)]
2461 pub fn LLVMRustComputeLTOCacheKey(
2462 key_out: &RustString,
2463 mod_id: *const c_char,
2467 pub fn LLVMRustContextGetDiagnosticHandler(Context: &Context) -> Option<&DiagnosticHandler>;
2468 pub fn LLVMRustContextSetDiagnosticHandler(
2470 diagnostic_handler: Option<&DiagnosticHandler>,
2472 pub fn LLVMRustContextConfigureDiagnosticHandler(
2474 diagnostic_handler_callback: DiagnosticHandlerTy,
2475 diagnostic_handler_context: *mut c_void,
2476 remark_all_passes: bool,
2477 remark_passes: *const *const c_char,
2478 remark_passes_len: usize,
2481 #[allow(improper_ctypes)]
2482 pub fn LLVMRustGetMangledName(V: &Value, out: &RustString);
2484 pub fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32;
2486 pub fn LLVMRustIsBitcode(ptr: *const u8, len: usize) -> bool;
2488 pub fn LLVMRustGetSymbols(
2492 callback: GetSymbolsCallback,
2493 error_callback: GetSymbolsErrorCallback,