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 // Consts for the LLVM CallConv type, pre-cast to usize.
66 /// LLVM CallingConv::ID. Should we wrap this?
67 #[derive(Copy, Clone, PartialEq, Debug)]
73 X86StdcallCallConv = 64,
74 X86FastcallCallConv = 65,
75 ArmAapcsCallConv = 67,
83 AvrNonBlockingInterrupt = 84,
89 #[derive(Copy, Clone, PartialEq)]
93 AvailableExternallyLinkage = 1,
94 LinkOnceAnyLinkage = 2,
95 LinkOnceODRLinkage = 3,
101 ExternalWeakLinkage = 9,
105 // LLVMRustVisibility
107 #[derive(Copy, Clone, PartialEq)]
108 pub enum Visibility {
116 pub enum UnnamedAddr {
122 /// LLVMDLLStorageClass
123 #[derive(Copy, Clone)]
125 pub enum DLLStorageClass {
128 DllImport = 1, // Function to be imported from DLL.
130 DllExport = 2, // Function to be accessible from DLL.
133 /// Matches LLVMRustAttribute in LLVMWrapper.h
134 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
135 /// though it is not ABI compatible (since it's a C++ enum)
137 #[derive(Copy, Clone, Debug)]
152 OptimizeForSize = 13,
160 SanitizeAddress = 21,
166 InaccessibleMemOnly = 27,
167 SanitizeHWAddress = 28,
172 #[derive(Copy, Clone)]
174 pub enum IntPredicate {
188 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
190 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
191 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
192 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
193 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
194 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
195 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
196 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
197 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
198 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
199 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
204 /// LLVMRealPredicate
205 #[derive(Copy, Clone)]
207 pub enum RealPredicate {
208 RealPredicateFalse = 0,
223 RealPredicateTrue = 15,
227 pub fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self {
229 rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
230 RealPredicate::RealPredicateFalse
232 rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
233 rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
234 rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
235 rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
236 rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
237 rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
238 rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
239 rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
240 rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
241 rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
242 rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
243 rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
244 rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
245 rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
246 rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
247 RealPredicate::RealPredicateTrue
254 #[derive(Copy, Clone, PartialEq, Debug)]
280 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
282 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
283 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
284 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
285 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
286 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
287 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
288 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
289 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
290 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
291 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
292 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
293 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
294 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
295 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
296 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
297 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
298 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
299 TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
300 TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
301 TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX,
306 /// LLVMAtomicRmwBinOp
307 #[derive(Copy, Clone)]
309 pub enum AtomicRmwBinOp {
323 impl AtomicRmwBinOp {
324 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
326 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
327 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
328 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
329 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
330 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
331 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
332 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
333 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
334 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
335 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
336 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
341 /// LLVMAtomicOrdering
342 #[derive(Copy, Clone)]
344 pub enum AtomicOrdering {
349 // Consume = 3, // Not specified yet.
353 SequentiallyConsistent = 7,
356 impl AtomicOrdering {
357 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
359 rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
360 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
361 rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
362 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
363 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
364 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
365 AtomicOrdering::AcquireRelease
367 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
368 AtomicOrdering::SequentiallyConsistent
374 /// LLVMRustSynchronizationScope
375 #[derive(Copy, Clone)]
377 pub enum SynchronizationScope {
382 impl SynchronizationScope {
383 pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
385 rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
386 SynchronizationScope::SingleThread
388 rustc_codegen_ssa::common::SynchronizationScope::CrossThread => {
389 SynchronizationScope::CrossThread
396 #[derive(Copy, Clone)]
404 #[derive(Copy, Clone)]
406 pub enum MetadataType {
413 MD_invariant_load = 6,
417 MD_mem_parallel_loop_access = 10,
421 /// LLVMRustAsmDialect
422 #[derive(Copy, Clone)]
424 pub enum AsmDialect {
430 pub fn from_generic(asm: rustc_ast::LlvmAsmDialect) -> Self {
432 rustc_ast::LlvmAsmDialect::Att => AsmDialect::Att,
433 rustc_ast::LlvmAsmDialect::Intel => AsmDialect::Intel,
438 /// LLVMRustCodeGenOptLevel
439 #[derive(Copy, Clone, PartialEq)]
441 pub enum CodeGenOptLevel {
448 /// LLVMRustPassBuilderOptLevel
450 pub enum PassBuilderOptLevel {
470 /// LLVMRustSanitizerOptions
472 pub struct SanitizerOptions {
473 pub sanitize_address: bool,
474 pub sanitize_address_recover: bool,
475 pub sanitize_memory: bool,
476 pub sanitize_memory_recover: bool,
477 pub sanitize_memory_track_origins: c_int,
478 pub sanitize_thread: bool,
479 pub sanitize_hwaddress: bool,
480 pub sanitize_hwaddress_recover: bool,
484 #[derive(Copy, Clone, PartialEq)]
486 pub enum RelocModel {
495 /// LLVMRustCodeModel
496 #[derive(Copy, Clone)]
507 /// LLVMRustDiagnosticKind
508 #[derive(Copy, Clone)]
510 #[allow(dead_code)] // Variants constructed by C++.
511 pub enum DiagnosticKind {
515 DebugMetadataVersion,
518 OptimizationRemarkMissed,
519 OptimizationRemarkAnalysis,
520 OptimizationRemarkAnalysisFPCommute,
521 OptimizationRemarkAnalysisAliasing,
522 OptimizationRemarkOther,
530 /// LLVMRustDiagnosticLevel
531 #[derive(Copy, Clone)]
533 #[allow(dead_code)] // Variants constructed by C++.
534 pub enum DiagnosticLevel {
541 /// LLVMRustArchiveKind
542 #[derive(Copy, Clone)]
544 pub enum ArchiveKind {
552 #[derive(Copy, Clone, PartialEq, Debug)]
554 #[allow(dead_code)] // Variants constructed by C++.
561 /// LLVMRustThinLTOData
563 pub type ThinLTOData;
566 /// LLVMRustThinLTOBuffer
568 pub type ThinLTOBuffer;
571 // LLVMRustModuleNameCallback
572 pub type ThinLTOModuleNameCallback =
573 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
575 /// LLVMRustThinLTOModule
577 pub struct ThinLTOModule {
578 pub identifier: *const c_char,
583 /// LLVMThreadLocalMode
584 #[derive(Copy, Clone)]
586 pub enum ThreadLocalMode {
594 /// LLVMRustChecksumKind
595 #[derive(Copy, Clone)]
597 pub enum ChecksumKind {
608 struct InvariantOpaque<'a> {
609 _marker: PhantomData<&'a mut &'a ()>,
613 // Opaque pointer types
627 pub type ConstantInt;
636 pub struct Builder<'a>(InvariantOpaque<'a>);
638 pub type MemoryBuffer;
641 pub struct PassManager<'a>(InvariantOpaque<'a>);
643 pub type PassManagerBuilder;
649 pub type TargetMachine;
655 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
657 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
662 pub type DiagnosticInfo;
665 pub type SMDiagnostic;
668 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
670 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
672 pub struct Linker<'a>(InvariantOpaque<'a>);
674 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
675 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
677 pub mod coverageinfo {
678 use super::coverage_map;
680 /// Aligns with [llvm::coverage::CounterMappingRegion::RegionKind](https://github.com/rust-lang/llvm-project/blob/rustc/11.0-2020-10-12/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L206-L222)
681 #[derive(Copy, Clone, Debug)]
683 pub enum RegionKind {
684 /// A CodeRegion associates some code with a counter
687 /// An ExpansionRegion represents a file expansion region that associates
688 /// a source range with the expansion of a virtual source file, such as
689 /// for a macro instantiation or #include file.
692 /// A SkippedRegion represents a source range with code that was skipped
693 /// by a preprocessor or similar means.
696 /// A GapRegion is like a CodeRegion, but its count is only set as the
697 /// line execution count when its the only region in the line.
701 /// This struct provides LLVM's representation of a "CoverageMappingRegion", encoded into the
702 /// coverage map, in accordance with the
703 /// [LLVM Code Coverage Mapping Format](https://github.com/rust-lang/llvm-project/blob/rustc/11.0-2020-10-12/llvm/docs/CoverageMappingFormat.rst#llvm-code-coverage-mapping-format).
704 /// The struct composes fields representing the `Counter` type and value(s) (injected counter
705 /// ID, or expression type and operands), the source file (an indirect index into a "filenames
706 /// array", encoded separately), and source location (start and end positions of the represented
709 /// Matches LLVMRustCounterMappingRegion.
710 #[derive(Copy, Clone, Debug)]
712 pub struct CounterMappingRegion {
713 /// The counter type and type-dependent counter data, if any.
714 counter: coverage_map::Counter,
716 /// An indirect reference to the source filename. In the LLVM Coverage Mapping Format, the
717 /// file_id is an index into a function-specific `virtual_file_mapping` array of indexes
718 /// that, in turn, are used to look up the filename for this region.
721 /// If the `RegionKind` is an `ExpansionRegion`, the `expanded_file_id` can be used to find
722 /// the mapping regions created as a result of macro expansion, by checking if their file id
723 /// matches the expanded file id.
724 expanded_file_id: u32,
726 /// 1-based starting line of the mapping region.
729 /// 1-based starting column of the mapping region.
732 /// 1-based ending line of the mapping region.
735 /// 1-based ending column of the mapping region. If the high bit is set, the current
736 /// mapping region is a gap area.
742 impl CounterMappingRegion {
743 crate fn code_region(
744 counter: coverage_map::Counter,
759 kind: RegionKind::CodeRegion,
763 // This function might be used in the future; the LLVM API is still evolving, as is coverage
766 crate fn expansion_region(
768 expanded_file_id: u32,
775 counter: coverage_map::Counter::zero(),
782 kind: RegionKind::ExpansionRegion,
786 // This function might be used in the future; the LLVM API is still evolving, as is coverage
789 crate fn skipped_region(
797 counter: coverage_map::Counter::zero(),
804 kind: RegionKind::SkippedRegion,
808 // This function might be used in the future; the LLVM API is still evolving, as is coverage
812 counter: coverage_map::Counter,
826 end_col: (1_u32 << 31) | end_col,
827 kind: RegionKind::GapRegion,
834 use super::{InvariantOpaque, Metadata};
835 use bitflags::bitflags;
838 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
840 pub type DIDescriptor = Metadata;
841 pub type DILocation = Metadata;
842 pub type DIScope = DIDescriptor;
843 pub type DIFile = DIScope;
844 pub type DILexicalBlock = DIScope;
845 pub type DISubprogram = DIScope;
846 pub type DINameSpace = DIScope;
847 pub type DIType = DIDescriptor;
848 pub type DIBasicType = DIType;
849 pub type DIDerivedType = DIType;
850 pub type DICompositeType = DIDerivedType;
851 pub type DIVariable = DIDescriptor;
852 pub type DIGlobalVariableExpression = DIDescriptor;
853 pub type DIArray = DIDescriptor;
854 pub type DISubrange = DIDescriptor;
855 pub type DIEnumerator = DIDescriptor;
856 pub type DITemplateTypeParameter = DIDescriptor;
858 // These values **must** match with LLVMRustDIFlags!!
862 pub struct DIFlags: u32 {
864 const FlagPrivate = 1;
865 const FlagProtected = 2;
866 const FlagPublic = 3;
867 const FlagFwdDecl = (1 << 2);
868 const FlagAppleBlock = (1 << 3);
869 const FlagBlockByrefStruct = (1 << 4);
870 const FlagVirtual = (1 << 5);
871 const FlagArtificial = (1 << 6);
872 const FlagExplicit = (1 << 7);
873 const FlagPrototyped = (1 << 8);
874 const FlagObjcClassComplete = (1 << 9);
875 const FlagObjectPointer = (1 << 10);
876 const FlagVector = (1 << 11);
877 const FlagStaticMember = (1 << 12);
878 const FlagLValueReference = (1 << 13);
879 const FlagRValueReference = (1 << 14);
880 const FlagExternalTypeRef = (1 << 15);
881 const FlagIntroducedVirtual = (1 << 18);
882 const FlagBitField = (1 << 19);
883 const FlagNoReturn = (1 << 20);
887 // These values **must** match with LLVMRustDISPFlags!!
891 pub struct DISPFlags: u32 {
892 const SPFlagZero = 0;
893 const SPFlagVirtual = 1;
894 const SPFlagPureVirtual = 2;
895 const SPFlagLocalToUnit = (1 << 2);
896 const SPFlagDefinition = (1 << 3);
897 const SPFlagOptimized = (1 << 4);
898 const SPFlagMainSubprogram = (1 << 5);
902 /// LLVMRustDebugEmissionKind
903 #[derive(Copy, Clone)]
905 pub enum DebugEmissionKind {
911 impl DebugEmissionKind {
912 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
913 use rustc_session::config::DebugInfo;
915 DebugInfo::None => DebugEmissionKind::NoDebug,
916 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
917 DebugInfo::Full => DebugEmissionKind::FullDebug,
924 pub type ModuleBuffer;
927 pub type SelfProfileBeforePassCallback =
928 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
929 pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
932 pub fn LLVMRustInstallFatalErrorHandler();
934 // Create and destroy contexts.
935 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
936 pub fn LLVMContextDispose(C: &'static mut Context);
937 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
940 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
941 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
942 pub fn LLVMCloneModule(M: &Module) -> &Module;
944 /// Data layout. See Module::getDataLayout.
945 pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
946 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
948 /// See Module::setModuleInlineAsm.
949 pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
950 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
952 /// See llvm::LLVMTypeKind::getTypeID.
953 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
955 // Operations on integer types
956 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
957 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
958 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
959 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
960 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
961 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
963 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
965 // Operations on real types
966 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
967 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
969 // Operations on function types
970 pub fn LLVMFunctionType(
971 ReturnType: &'a Type,
972 ParamTypes: *const &'a Type,
976 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
977 pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
979 // Operations on struct types
980 pub fn LLVMStructTypeInContext(
982 ElementTypes: *const &'a Type,
983 ElementCount: c_uint,
987 // Operations on array, pointer, and vector types (sequence types)
988 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
989 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
990 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
992 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
993 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
995 // Operations on other types
996 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
997 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
999 // Operations on all values
1000 pub fn LLVMTypeOf(Val: &Value) -> &Type;
1001 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
1002 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
1003 pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
1004 pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
1006 // Operations on constants of any type
1007 pub fn LLVMConstNull(Ty: &Type) -> &Value;
1008 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
1010 // Operations on metadata
1011 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
1012 pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
1013 pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
1015 // Operations on scalar constants
1016 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
1017 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
1018 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
1019 pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
1020 pub fn LLVMRustConstInt128Get(
1021 ConstantVal: &ConstantInt,
1027 // Operations on composite constants
1028 pub fn LLVMConstStringInContext(
1032 DontNullTerminate: Bool,
1034 pub fn LLVMConstStructInContext(
1036 ConstantVals: *const &'a Value,
1041 pub fn LLVMConstArray(
1042 ElementTy: &'a Type,
1043 ConstantVals: *const &'a Value,
1046 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
1048 // Constant expressions
1049 pub fn LLVMRustConstInBoundsGEP2(
1051 ConstantVal: &'a Value,
1052 ConstantIndices: *const &'a Value,
1055 pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1056 pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1057 pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1058 pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1059 pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1060 pub fn LLVMConstExtractValue(
1061 AggConstant: &Value,
1062 IdxList: *const c_uint,
1066 // Operations on global variables, functions, and aliases (globals)
1067 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
1068 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
1069 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
1070 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
1071 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
1072 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
1073 pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
1074 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
1075 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1076 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1078 // Operations on global variables
1079 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
1080 pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1081 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
1082 pub fn LLVMRustGetOrInsertGlobal(
1084 Name: *const c_char,
1088 pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
1089 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1090 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1091 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
1092 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1093 pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
1094 pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
1095 pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
1096 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1097 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1098 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1099 pub fn LLVMRustGetNamedValue(
1101 Name: *const c_char,
1103 ) -> Option<&Value>;
1104 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1106 // Operations on functions
1107 pub fn LLVMRustGetOrInsertFunction(
1109 Name: *const c_char,
1111 FunctionTy: &'a Type,
1113 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1114 pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
1115 pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
1116 pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
1117 pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
1118 pub fn LLVMRustAddStructRetAttr(Fn: &Value, index: c_uint, ty: &Type);
1119 pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
1120 pub fn LLVMRustAddFunctionAttrStringValue(
1123 Name: *const c_char,
1124 Value: *const c_char,
1126 pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
1128 // Operations on parameters
1129 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1130 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
1131 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1133 // Operations on basic blocks
1134 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1135 pub fn LLVMAppendBasicBlockInContext(
1138 Name: *const c_char,
1139 ) -> &'a BasicBlock;
1141 // Operations on instructions
1142 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1143 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1145 // Operations on call sites
1146 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1147 pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
1148 pub fn LLVMRustAddCallSiteAttrString(Instr: &Value, index: c_uint, Name: *const c_char);
1149 pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
1150 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1151 pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1152 pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1153 pub fn LLVMRustAddStructRetCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1155 // Operations on load/store instructions (only)
1156 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1158 // Operations on phi nodes
1159 pub fn LLVMAddIncoming(
1161 IncomingValues: *const &'a Value,
1162 IncomingBlocks: *const &'a BasicBlock,
1166 // Instruction builders
1167 pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
1168 pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
1169 pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
1170 pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
1173 pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
1176 pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
1177 pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1178 pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1179 pub fn LLVMBuildCondBr(
1182 Then: &'a BasicBlock,
1183 Else: &'a BasicBlock,
1185 pub fn LLVMBuildSwitch(
1188 Else: &'a BasicBlock,
1191 pub fn LLVMRustBuildInvoke(
1195 Args: *const &'a Value,
1197 Then: &'a BasicBlock,
1198 Catch: &'a BasicBlock,
1199 Bundle: Option<&OperandBundleDef<'a>>,
1200 Name: *const c_char,
1202 pub fn LLVMBuildLandingPad(
1205 PersFn: Option<&'a Value>,
1207 Name: *const c_char,
1209 pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1210 pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
1212 pub fn LLVMRustBuildCleanupPad(
1214 ParentPad: Option<&'a Value>,
1216 Args: *const &'a Value,
1217 Name: *const c_char,
1218 ) -> Option<&'a Value>;
1219 pub fn LLVMRustBuildCleanupRet(
1221 CleanupPad: &'a Value,
1222 UnwindBB: Option<&'a BasicBlock>,
1223 ) -> Option<&'a Value>;
1224 pub fn LLVMRustBuildCatchPad(
1226 ParentPad: &'a Value,
1228 Args: *const &'a Value,
1229 Name: *const c_char,
1230 ) -> Option<&'a Value>;
1231 pub fn LLVMRustBuildCatchRet(
1235 ) -> Option<&'a Value>;
1236 pub fn LLVMRustBuildCatchSwitch(
1237 Builder: &Builder<'a>,
1238 ParentPad: Option<&'a Value>,
1239 BB: Option<&'a BasicBlock>,
1240 NumHandlers: c_uint,
1241 Name: *const c_char,
1242 ) -> Option<&'a Value>;
1243 pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1244 pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
1246 // Add a case to the switch instruction
1247 pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1249 // Add a clause to the landing pad instruction
1250 pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
1252 // Set the cleanup on a landing pad instruction
1253 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1256 pub fn LLVMBuildAdd(
1260 Name: *const c_char,
1262 pub fn LLVMBuildFAdd(
1266 Name: *const c_char,
1268 pub fn LLVMBuildSub(
1272 Name: *const c_char,
1274 pub fn LLVMBuildFSub(
1278 Name: *const c_char,
1280 pub fn LLVMBuildMul(
1284 Name: *const c_char,
1286 pub fn LLVMBuildFMul(
1290 Name: *const c_char,
1292 pub fn LLVMBuildUDiv(
1296 Name: *const c_char,
1298 pub fn LLVMBuildExactUDiv(
1302 Name: *const c_char,
1304 pub fn LLVMBuildSDiv(
1308 Name: *const c_char,
1310 pub fn LLVMBuildExactSDiv(
1314 Name: *const c_char,
1316 pub fn LLVMBuildFDiv(
1320 Name: *const c_char,
1322 pub fn LLVMBuildURem(
1326 Name: *const c_char,
1328 pub fn LLVMBuildSRem(
1332 Name: *const c_char,
1334 pub fn LLVMBuildFRem(
1338 Name: *const c_char,
1340 pub fn LLVMBuildShl(
1344 Name: *const c_char,
1346 pub fn LLVMBuildLShr(
1350 Name: *const c_char,
1352 pub fn LLVMBuildAShr(
1356 Name: *const c_char,
1358 pub fn LLVMBuildNSWAdd(
1362 Name: *const c_char,
1364 pub fn LLVMBuildNUWAdd(
1368 Name: *const c_char,
1370 pub fn LLVMBuildNSWSub(
1374 Name: *const c_char,
1376 pub fn LLVMBuildNUWSub(
1380 Name: *const c_char,
1382 pub fn LLVMBuildNSWMul(
1386 Name: *const c_char,
1388 pub fn LLVMBuildNUWMul(
1392 Name: *const c_char,
1394 pub fn LLVMBuildAnd(
1398 Name: *const c_char,
1404 Name: *const c_char,
1406 pub fn LLVMBuildXor(
1410 Name: *const c_char,
1412 pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1413 pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1414 pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1415 pub fn LLVMRustSetFastMath(Instr: &Value);
1418 pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1419 pub fn LLVMBuildArrayAlloca(
1423 Name: *const c_char,
1425 pub fn LLVMBuildLoad2(
1428 PointerVal: &'a Value,
1429 Name: *const c_char,
1432 pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1434 pub fn LLVMBuildGEP2(
1438 Indices: *const &'a Value,
1440 Name: *const c_char,
1442 pub fn LLVMBuildInBoundsGEP2(
1446 Indices: *const &'a Value,
1448 Name: *const c_char,
1450 pub fn LLVMBuildStructGEP2(
1455 Name: *const c_char,
1459 pub fn LLVMBuildTrunc(
1463 Name: *const c_char,
1465 pub fn LLVMBuildZExt(
1469 Name: *const c_char,
1471 pub fn LLVMBuildSExt(
1475 Name: *const c_char,
1477 pub fn LLVMBuildFPToUI(
1481 Name: *const c_char,
1483 pub fn LLVMBuildFPToSI(
1487 Name: *const c_char,
1489 pub fn LLVMBuildUIToFP(
1493 Name: *const c_char,
1495 pub fn LLVMBuildSIToFP(
1499 Name: *const c_char,
1501 pub fn LLVMBuildFPTrunc(
1505 Name: *const c_char,
1507 pub fn LLVMBuildFPExt(
1511 Name: *const c_char,
1513 pub fn LLVMBuildPtrToInt(
1517 Name: *const c_char,
1519 pub fn LLVMBuildIntToPtr(
1523 Name: *const c_char,
1525 pub fn LLVMBuildBitCast(
1529 Name: *const c_char,
1531 pub fn LLVMBuildPointerCast(
1535 Name: *const c_char,
1537 pub fn LLVMRustBuildIntCast(
1545 pub fn LLVMBuildICmp(
1550 Name: *const c_char,
1552 pub fn LLVMBuildFCmp(
1557 Name: *const c_char,
1560 // Miscellaneous instructions
1561 pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1562 pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &'a Value;
1563 pub fn LLVMRustBuildCall(
1567 Args: *const &'a Value,
1569 Bundle: Option<&OperandBundleDef<'a>>,
1571 pub fn LLVMRustBuildMemCpy(
1580 pub fn LLVMRustBuildMemMove(
1589 pub fn LLVMRustBuildMemSet(
1597 pub fn LLVMBuildSelect(
1602 Name: *const c_char,
1604 pub fn LLVMBuildVAArg(
1608 Name: *const c_char,
1610 pub fn LLVMBuildExtractElement(
1614 Name: *const c_char,
1616 pub fn LLVMBuildInsertElement(
1621 Name: *const c_char,
1623 pub fn LLVMBuildShuffleVector(
1628 Name: *const c_char,
1630 pub fn LLVMBuildExtractValue(
1634 Name: *const c_char,
1636 pub fn LLVMBuildInsertValue(
1641 Name: *const c_char,
1644 pub fn LLVMRustBuildVectorReduceFAdd(
1649 pub fn LLVMRustBuildVectorReduceFMul(
1654 pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1655 pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1656 pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1657 pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1658 pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1659 pub fn LLVMRustBuildVectorReduceMin(
1664 pub fn LLVMRustBuildVectorReduceMax(
1669 pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1671 pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1674 pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1675 pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1677 // Atomic Operations
1678 pub fn LLVMRustBuildAtomicLoad(
1680 ElementType: &'a Type,
1681 PointerVal: &'a Value,
1682 Name: *const c_char,
1683 Order: AtomicOrdering,
1686 pub fn LLVMRustBuildAtomicStore(
1690 Order: AtomicOrdering,
1693 pub fn LLVMRustBuildAtomicCmpXchg(
1698 Order: AtomicOrdering,
1699 FailureOrder: AtomicOrdering,
1703 pub fn LLVMBuildAtomicRMW(
1708 Order: AtomicOrdering,
1709 SingleThreaded: Bool,
1712 pub fn LLVMRustBuildAtomicFence(
1714 Order: AtomicOrdering,
1715 Scope: SynchronizationScope,
1718 /// Writes a module to the specified path. Returns 0 on success.
1719 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1721 /// Creates a pass manager.
1722 pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1724 /// Creates a function-by-function pass manager
1725 pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1727 /// Disposes a pass manager.
1728 pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1730 /// Runs a pass manager on a module.
1731 pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1733 pub fn LLVMInitializePasses();
1735 pub fn LLVMTimeTraceProfilerInitialize();
1737 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1739 pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>);
1741 pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1742 pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1743 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1744 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1745 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1746 PMB: &PassManagerBuilder,
1749 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1750 PMB: &PassManagerBuilder,
1751 PM: &PassManager<'_>,
1754 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1755 PMB: &PassManagerBuilder,
1756 PM: &PassManager<'_>,
1758 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1759 PMB: &PassManagerBuilder,
1760 PM: &PassManager<'_>,
1764 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1765 PMB: &PassManagerBuilder,
1766 PM: &PassManager<'_>,
1769 pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
1771 pub fn LLVMDisposeMessage(message: *mut c_char);
1773 pub fn LLVMStartMultithreaded() -> Bool;
1775 /// Returns a string describing the last error caused by an LLVMRust* call.
1776 pub fn LLVMRustGetLastError() -> *const c_char;
1778 /// Print the pass timings since static dtors aren't picking them up.
1779 pub fn LLVMRustPrintPassTimings();
1781 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1783 pub fn LLVMStructSetBody(
1785 ElementTypes: *const &'a Type,
1786 ElementCount: c_uint,
1790 /// Prepares inline assembly.
1791 pub fn LLVMRustInlineAsm(
1793 AsmString: *const c_char,
1794 AsmStringLen: size_t,
1795 Constraints: *const c_char,
1796 ConstraintsLen: size_t,
1799 Dialect: AsmDialect,
1801 pub fn LLVMRustInlineAsmVerify(
1803 Constraints: *const c_char,
1804 ConstraintsLen: size_t,
1807 #[allow(improper_ctypes)]
1808 pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1809 Filenames: *const *const c_char,
1810 FilenamesLen: size_t,
1811 BufferOut: &RustString,
1814 #[allow(improper_ctypes)]
1815 pub fn LLVMRustCoverageWriteMappingToBuffer(
1816 VirtualFileMappingIDs: *const c_uint,
1817 NumVirtualFileMappingIDs: c_uint,
1818 Expressions: *const coverage_map::CounterExpression,
1819 NumExpressions: c_uint,
1820 MappingRegions: *const coverageinfo::CounterMappingRegion,
1821 NumMappingRegions: c_uint,
1822 BufferOut: &RustString,
1825 pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &'a Value, FuncName: *const c_char)
1827 pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64;
1828 pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
1830 #[allow(improper_ctypes)]
1831 pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
1833 #[allow(improper_ctypes)]
1834 pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
1836 #[allow(improper_ctypes)]
1837 pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1839 pub fn LLVMRustCoverageMappingVersion() -> u32;
1840 pub fn LLVMRustDebugMetadataVersion() -> u32;
1841 pub fn LLVMRustVersionMajor() -> u32;
1842 pub fn LLVMRustVersionMinor() -> u32;
1843 pub fn LLVMRustVersionPatch() -> u32;
1845 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1847 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1849 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1851 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1853 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1855 pub fn LLVMRustDIBuilderCreateCompileUnit(
1856 Builder: &DIBuilder<'a>,
1859 Producer: *const c_char,
1860 ProducerLen: size_t,
1862 Flags: *const c_char,
1864 SplitName: *const c_char,
1865 SplitNameLen: size_t,
1866 kind: DebugEmissionKind,
1868 SplitDebugInlining: bool,
1869 ) -> &'a DIDescriptor;
1871 pub fn LLVMRustDIBuilderCreateFile(
1872 Builder: &DIBuilder<'a>,
1873 Filename: *const c_char,
1874 FilenameLen: size_t,
1875 Directory: *const c_char,
1876 DirectoryLen: size_t,
1877 CSKind: ChecksumKind,
1878 Checksum: *const c_char,
1879 ChecksumLen: size_t,
1882 pub fn LLVMRustDIBuilderCreateSubroutineType(
1883 Builder: &DIBuilder<'a>,
1884 ParameterTypes: &'a DIArray,
1885 ) -> &'a DICompositeType;
1887 pub fn LLVMRustDIBuilderCreateFunction(
1888 Builder: &DIBuilder<'a>,
1889 Scope: &'a DIDescriptor,
1890 Name: *const c_char,
1892 LinkageName: *const c_char,
1893 LinkageNameLen: size_t,
1900 MaybeFn: Option<&'a Value>,
1901 TParam: &'a DIArray,
1902 Decl: Option<&'a DIDescriptor>,
1903 ) -> &'a DISubprogram;
1905 pub fn LLVMRustDIBuilderCreateBasicType(
1906 Builder: &DIBuilder<'a>,
1907 Name: *const c_char,
1911 ) -> &'a DIBasicType;
1913 pub fn LLVMRustDIBuilderCreateTypedef(
1914 Builder: &DIBuilder<'a>,
1915 Type: &'a DIBasicType,
1916 Name: *const c_char,
1920 Scope: Option<&'a DIScope>,
1921 ) -> &'a DIDerivedType;
1923 pub fn LLVMRustDIBuilderCreatePointerType(
1924 Builder: &DIBuilder<'a>,
1925 PointeeTy: &'a DIType,
1928 AddressSpace: c_uint,
1929 Name: *const c_char,
1931 ) -> &'a DIDerivedType;
1933 pub fn LLVMRustDIBuilderCreateStructType(
1934 Builder: &DIBuilder<'a>,
1935 Scope: Option<&'a DIDescriptor>,
1936 Name: *const c_char,
1943 DerivedFrom: Option<&'a DIType>,
1944 Elements: &'a DIArray,
1945 RunTimeLang: c_uint,
1946 VTableHolder: Option<&'a DIType>,
1947 UniqueId: *const c_char,
1948 UniqueIdLen: size_t,
1949 ) -> &'a DICompositeType;
1951 pub fn LLVMRustDIBuilderCreateMemberType(
1952 Builder: &DIBuilder<'a>,
1953 Scope: &'a DIDescriptor,
1954 Name: *const c_char,
1963 ) -> &'a DIDerivedType;
1965 pub fn LLVMRustDIBuilderCreateVariantMemberType(
1966 Builder: &DIBuilder<'a>,
1968 Name: *const c_char,
1975 Discriminant: Option<&'a Value>,
1980 pub fn LLVMRustDIBuilderCreateLexicalBlock(
1981 Builder: &DIBuilder<'a>,
1986 ) -> &'a DILexicalBlock;
1988 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(
1989 Builder: &DIBuilder<'a>,
1992 ) -> &'a DILexicalBlock;
1994 pub fn LLVMRustDIBuilderCreateStaticVariable(
1995 Builder: &DIBuilder<'a>,
1996 Context: Option<&'a DIScope>,
1997 Name: *const c_char,
1999 LinkageName: *const c_char,
2000 LinkageNameLen: size_t,
2004 isLocalToUnit: bool,
2006 Decl: Option<&'a DIDescriptor>,
2008 ) -> &'a DIGlobalVariableExpression;
2010 pub fn LLVMRustDIBuilderCreateVariable(
2011 Builder: &DIBuilder<'a>,
2013 Scope: &'a DIDescriptor,
2014 Name: *const c_char,
2019 AlwaysPreserve: bool,
2023 ) -> &'a DIVariable;
2025 pub fn LLVMRustDIBuilderCreateArrayType(
2026 Builder: &DIBuilder<'a>,
2030 Subscripts: &'a DIArray,
2033 pub fn LLVMRustDIBuilderGetOrCreateSubrange(
2034 Builder: &DIBuilder<'a>,
2037 ) -> &'a DISubrange;
2039 pub fn LLVMRustDIBuilderGetOrCreateArray(
2040 Builder: &DIBuilder<'a>,
2041 Ptr: *const Option<&'a DIDescriptor>,
2045 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(
2046 Builder: &DIBuilder<'a>,
2048 VarInfo: &'a DIVariable,
2049 AddrOps: *const i64,
2050 AddrOpsCount: c_uint,
2052 InsertAtEnd: &'a BasicBlock,
2055 pub fn LLVMRustDIBuilderCreateEnumerator(
2056 Builder: &DIBuilder<'a>,
2057 Name: *const c_char,
2061 ) -> &'a DIEnumerator;
2063 pub fn LLVMRustDIBuilderCreateEnumerationType(
2064 Builder: &DIBuilder<'a>,
2066 Name: *const c_char,
2072 Elements: &'a DIArray,
2073 ClassType: &'a DIType,
2077 pub fn LLVMRustDIBuilderCreateUnionType(
2078 Builder: &DIBuilder<'a>,
2079 Scope: Option<&'a DIScope>,
2080 Name: *const c_char,
2087 Elements: Option<&'a DIArray>,
2088 RunTimeLang: c_uint,
2089 UniqueId: *const c_char,
2090 UniqueIdLen: size_t,
2093 pub fn LLVMRustDIBuilderCreateVariantPart(
2094 Builder: &DIBuilder<'a>,
2096 Name: *const c_char,
2103 Discriminator: Option<&'a DIDerivedType>,
2104 Elements: &'a DIArray,
2105 UniqueId: *const c_char,
2106 UniqueIdLen: size_t,
2107 ) -> &'a DIDerivedType;
2109 pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
2111 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
2112 Builder: &DIBuilder<'a>,
2113 Scope: Option<&'a DIScope>,
2114 Name: *const c_char,
2117 ) -> &'a DITemplateTypeParameter;
2119 pub fn LLVMRustDIBuilderCreateNameSpace(
2120 Builder: &DIBuilder<'a>,
2121 Scope: Option<&'a DIScope>,
2122 Name: *const c_char,
2124 ExportSymbols: bool,
2125 ) -> &'a DINameSpace;
2127 pub fn LLVMRustDICompositeTypeReplaceArrays(
2128 Builder: &DIBuilder<'a>,
2129 CompositeType: &'a DIType,
2130 Elements: Option<&'a DIArray>,
2131 Params: Option<&'a DIArray>,
2134 pub fn LLVMRustDIBuilderCreateDebugLocation(
2138 InlinedAt: Option<&'a DILocation>,
2139 ) -> &'a DILocation;
2140 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
2141 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
2143 #[allow(improper_ctypes)]
2144 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2145 #[allow(improper_ctypes)]
2146 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2148 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2150 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
2151 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
2152 pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
2153 pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2154 pub fn LLVMRustCreateMemorySanitizerPass(
2155 TrackOrigins: c_int,
2157 ) -> &'static mut Pass;
2158 pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
2159 pub fn LLVMRustCreateHWAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2160 pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
2161 pub fn LLVMRustAddLastExtensionPasses(
2162 PMB: &PassManagerBuilder,
2163 Passes: *const &'static mut Pass,
2167 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2169 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
2170 pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2171 pub fn LLVMRustGetTargetFeature(
2174 Feature: &mut *const c_char,
2175 Desc: &mut *const c_char,
2178 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2179 pub fn LLVMRustCreateTargetMachine(
2180 Triple: *const c_char,
2182 Features: *const c_char,
2186 Level: CodeGenOptLevel,
2188 FunctionSections: bool,
2190 TrapUnreachable: bool,
2193 EmitStackSizeSection: bool,
2194 RelaxELFRelocations: bool,
2196 SplitDwarfFile: *const c_char,
2197 ) -> Option<&'static mut TargetMachine>;
2198 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
2199 pub fn LLVMRustAddBuilderLibraryInfo(
2200 PMB: &'a PassManagerBuilder,
2202 DisableSimplifyLibCalls: bool,
2204 pub fn LLVMRustConfigurePassManagerBuilder(
2205 PMB: &PassManagerBuilder,
2206 OptLevel: CodeGenOptLevel,
2207 MergeFunctions: bool,
2209 LoopVectorize: bool,
2210 PrepareForThinLTO: bool,
2211 PGOGenPath: *const c_char,
2212 PGOUsePath: *const c_char,
2213 PGOSampleUsePath: *const c_char,
2215 pub fn LLVMRustAddLibraryInfo(
2216 PM: &PassManager<'a>,
2218 DisableSimplifyLibCalls: bool,
2220 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
2221 pub fn LLVMRustWriteOutputFile(
2222 T: &'a TargetMachine,
2223 PM: &PassManager<'a>,
2225 Output: *const c_char,
2226 DwoOutput: *const c_char,
2228 ) -> LLVMRustResult;
2229 pub fn LLVMRustOptimizeWithNewPassManager(
2231 TM: &'a TargetMachine,
2232 OptLevel: PassBuilderOptLevel,
2234 NoPrepopulatePasses: bool,
2236 UseThinLTOBuffers: bool,
2237 MergeFunctions: bool,
2240 LoopVectorize: bool,
2241 DisableSimplifyLibCalls: bool,
2242 EmitLifetimeMarkers: bool,
2243 SanitizerOptions: Option<&SanitizerOptions>,
2244 PGOGenPath: *const c_char,
2245 PGOUsePath: *const c_char,
2246 InstrumentCoverage: bool,
2247 InstrumentGCOV: bool,
2248 PGOSampleUsePath: *const c_char,
2249 DebugInfoForProfiling: bool,
2250 llvm_selfprofiler: *mut c_void,
2251 begin_callback: SelfProfileBeforePassCallback,
2252 end_callback: SelfProfileAfterPassCallback,
2253 ExtraPasses: *const c_char,
2254 ExtraPassesLen: size_t,
2255 ) -> LLVMRustResult;
2256 pub fn LLVMRustPrintModule(
2258 Output: *const c_char,
2259 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2260 ) -> LLVMRustResult;
2261 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2262 pub fn LLVMRustPrintPasses();
2263 pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
2264 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2265 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
2266 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2267 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
2269 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2270 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
2271 pub fn LLVMRustArchiveIteratorNext(
2272 AIR: &ArchiveIterator<'a>,
2273 ) -> Option<&'a mut ArchiveChild<'a>>;
2274 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2275 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2276 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
2277 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
2278 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2280 #[allow(improper_ctypes)]
2281 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2283 pub fn LLVMContextSetDiagnosticHandler(
2285 Handler: DiagnosticHandler,
2286 DiagnosticContext: *mut c_void,
2289 #[allow(improper_ctypes)]
2290 pub fn LLVMRustUnpackOptimizationDiagnostic(
2291 DI: &'a DiagnosticInfo,
2292 pass_name_out: &RustString,
2293 function_out: &mut Option<&'a Value>,
2294 loc_line_out: &mut c_uint,
2295 loc_column_out: &mut c_uint,
2296 loc_filename_out: &RustString,
2297 message_out: &RustString,
2300 pub fn LLVMRustUnpackInlineAsmDiagnostic(
2301 DI: &'a DiagnosticInfo,
2302 level_out: &mut DiagnosticLevel,
2303 cookie_out: &mut c_uint,
2304 message_out: &mut Option<&'a Twine>,
2307 #[allow(improper_ctypes)]
2308 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2309 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2311 pub fn LLVMRustGetSMDiagnostic(
2312 DI: &'a DiagnosticInfo,
2313 cookie_out: &mut c_uint,
2314 ) -> &'a SMDiagnostic;
2316 pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2318 H: InlineAsmDiagHandler,
2322 #[allow(improper_ctypes)]
2323 pub fn LLVMRustUnpackSMDiagnostic(
2325 message_out: &RustString,
2326 buffer_out: &RustString,
2327 level_out: &mut DiagnosticLevel,
2328 loc_out: &mut c_uint,
2329 ranges_out: *mut c_uint,
2330 num_ranges: &mut usize,
2333 pub fn LLVMRustWriteArchive(
2336 Members: *const &RustArchiveMember<'_>,
2339 ) -> LLVMRustResult;
2340 pub fn LLVMRustArchiveMemberNew(
2341 Filename: *const c_char,
2342 Name: *const c_char,
2343 Child: Option<&ArchiveChild<'a>>,
2344 ) -> &'a mut RustArchiveMember<'a>;
2345 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
2347 pub fn LLVMRustWriteImportLibrary(
2348 ImportName: *const c_char,
2349 Path: *const c_char,
2350 Exports: *const LLVMRustCOFFShortExport,
2354 ) -> LLVMRustResult;
2356 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
2358 pub fn LLVMRustBuildOperandBundleDef(
2359 Name: *const c_char,
2360 Inputs: *const &'a Value,
2362 ) -> &'a mut OperandBundleDef<'a>;
2363 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
2365 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
2367 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2368 pub fn LLVMRustUnsetComdat(V: &Value);
2369 pub fn LLVMRustSetModulePICLevel(M: &Module);
2370 pub fn LLVMRustSetModulePIELevel(M: &Module);
2371 pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2372 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2373 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2374 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2375 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2376 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2378 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
2379 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2380 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2381 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2382 pub fn LLVMRustCreateThinLTOData(
2383 Modules: *const ThinLTOModule,
2385 PreservedSymbols: *const *const c_char,
2386 PreservedSymbolsLen: c_uint,
2387 ) -> Option<&'static mut ThinLTOData>;
2388 pub fn LLVMRustPrepareThinLTORename(
2391 Target: &TargetMachine,
2393 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2394 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2395 pub fn LLVMRustPrepareThinLTOImport(
2398 Target: &TargetMachine,
2400 pub fn LLVMRustGetThinLTOModuleImports(
2401 Data: *const ThinLTOData,
2402 ModuleNameCallback: ThinLTOModuleNameCallback,
2403 CallbackPayload: *mut c_void,
2405 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2406 pub fn LLVMRustParseBitcodeForLTO(
2410 Identifier: *const c_char,
2411 ) -> Option<&Module>;
2412 pub fn LLVMRustGetBitcodeSliceFromObjectData(
2415 out_len: &mut usize,
2417 pub fn LLVMRustLTOGetDICompileUnit(M: &Module, CU1: &mut *mut c_void, CU2: &mut *mut c_void);
2418 pub fn LLVMRustLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2420 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
2421 pub fn LLVMRustLinkerAdd(
2422 linker: &Linker<'_>,
2423 bytecode: *const c_char,
2424 bytecode_len: usize,
2426 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);
2427 #[allow(improper_ctypes)]
2428 pub fn LLVMRustComputeLTOCacheKey(
2429 key_out: &RustString,
2430 mod_id: *const c_char,