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 {
32 // Consts for the LLVM CallConv type, pre-cast to usize.
34 /// LLVM CallingConv::ID. Should we wrap this?
35 #[derive(Copy, Clone, PartialEq, Debug)]
41 X86StdcallCallConv = 64,
42 X86FastcallCallConv = 65,
43 ArmAapcsCallConv = 67,
51 AvrNonBlockingInterrupt = 84,
57 #[derive(Copy, Clone, PartialEq)]
61 AvailableExternallyLinkage = 1,
62 LinkOnceAnyLinkage = 2,
63 LinkOnceODRLinkage = 3,
69 ExternalWeakLinkage = 9,
75 #[derive(Copy, Clone)]
84 pub enum UnnamedAddr {
90 /// LLVMDLLStorageClass
91 #[derive(Copy, Clone)]
93 pub enum DLLStorageClass {
96 DllImport = 1, // Function to be imported from DLL.
98 DllExport = 2, // Function to be accessible from DLL.
101 /// Matches LLVMRustAttribute in LLVMWrapper.h
102 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
103 /// though it is not ABI compatible (since it's a C++ enum)
105 #[derive(Copy, Clone, Debug)]
120 OptimizeForSize = 13,
128 SanitizeAddress = 21,
134 InaccessibleMemOnly = 27,
135 SanitizeHWAddress = 28,
140 #[derive(Copy, Clone)]
142 pub enum IntPredicate {
156 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
158 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
159 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
160 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
161 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
162 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
163 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
164 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
165 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
166 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
167 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
172 /// LLVMRealPredicate
173 #[derive(Copy, Clone)]
175 pub enum RealPredicate {
176 RealPredicateFalse = 0,
191 RealPredicateTrue = 15,
195 #[derive(Copy, Clone, PartialEq, Debug)]
221 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
223 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
224 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
225 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
226 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
227 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
228 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
229 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
230 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
231 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
232 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
233 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
234 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
235 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
236 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
237 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
238 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
239 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
240 TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
241 TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
242 TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX,
247 /// LLVMAtomicRmwBinOp
248 #[derive(Copy, Clone)]
250 pub enum AtomicRmwBinOp {
264 impl AtomicRmwBinOp {
265 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
267 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
268 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
269 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
270 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
271 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
272 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
273 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
274 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
275 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
276 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
277 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
282 /// LLVMAtomicOrdering
283 #[derive(Copy, Clone)]
285 pub enum AtomicOrdering {
290 // Consume = 3, // Not specified yet.
294 SequentiallyConsistent = 7,
297 impl AtomicOrdering {
298 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
300 rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
301 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
302 rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
303 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
304 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
305 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
306 AtomicOrdering::AcquireRelease
308 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
309 AtomicOrdering::SequentiallyConsistent
315 /// LLVMRustSynchronizationScope
316 #[derive(Copy, Clone)]
318 pub enum SynchronizationScope {
323 impl SynchronizationScope {
324 pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
326 rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
327 SynchronizationScope::SingleThread
329 rustc_codegen_ssa::common::SynchronizationScope::CrossThread => {
330 SynchronizationScope::CrossThread
337 #[derive(Copy, Clone)]
345 #[derive(Copy, Clone)]
347 pub enum MetadataType {
354 MD_invariant_load = 6,
358 MD_mem_parallel_loop_access = 10,
362 /// LLVMRustAsmDialect
363 #[derive(Copy, Clone)]
365 pub enum AsmDialect {
371 pub fn from_generic(asm: rustc_ast::LlvmAsmDialect) -> Self {
373 rustc_ast::LlvmAsmDialect::Att => AsmDialect::Att,
374 rustc_ast::LlvmAsmDialect::Intel => AsmDialect::Intel,
379 /// LLVMRustCodeGenOptLevel
380 #[derive(Copy, Clone, PartialEq)]
382 pub enum CodeGenOptLevel {
389 /// LLVMRustPassBuilderOptLevel
391 pub enum PassBuilderOptLevel {
411 /// LLVMRustSanitizerOptions
413 pub struct SanitizerOptions {
414 pub sanitize_address: bool,
415 pub sanitize_address_recover: bool,
416 pub sanitize_memory: bool,
417 pub sanitize_memory_recover: bool,
418 pub sanitize_memory_track_origins: c_int,
419 pub sanitize_thread: bool,
420 pub sanitize_hwaddress: bool,
421 pub sanitize_hwaddress_recover: bool,
425 #[derive(Copy, Clone, PartialEq)]
427 pub enum RelocModel {
436 /// LLVMRustCodeModel
437 #[derive(Copy, Clone)]
448 /// LLVMRustDiagnosticKind
449 #[derive(Copy, Clone)]
451 #[allow(dead_code)] // Variants constructed by C++.
452 pub enum DiagnosticKind {
456 DebugMetadataVersion,
459 OptimizationRemarkMissed,
460 OptimizationRemarkAnalysis,
461 OptimizationRemarkAnalysisFPCommute,
462 OptimizationRemarkAnalysisAliasing,
463 OptimizationRemarkOther,
470 /// LLVMRustDiagnosticLevel
471 #[derive(Copy, Clone)]
473 #[allow(dead_code)] // Variants constructed by C++.
474 pub enum DiagnosticLevel {
481 /// LLVMRustArchiveKind
482 #[derive(Copy, Clone)]
484 pub enum ArchiveKind {
492 #[derive(Copy, Clone, PartialEq, Debug)]
494 #[allow(dead_code)] // Variants constructed by C++.
501 /// LLVMRustThinLTOData
503 pub type ThinLTOData;
506 /// LLVMRustThinLTOBuffer
508 pub type ThinLTOBuffer;
511 // LLVMRustModuleNameCallback
512 pub type ThinLTOModuleNameCallback =
513 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
515 /// LLVMRustThinLTOModule
517 pub struct ThinLTOModule {
518 pub identifier: *const c_char,
523 /// LLVMThreadLocalMode
524 #[derive(Copy, Clone)]
526 pub enum ThreadLocalMode {
534 /// LLVMRustChecksumKind
535 #[derive(Copy, Clone)]
537 pub enum ChecksumKind {
548 struct InvariantOpaque<'a> {
549 _marker: PhantomData<&'a mut &'a ()>,
553 // Opaque pointer types
567 pub type ConstantInt;
576 pub struct Builder<'a>(InvariantOpaque<'a>);
578 pub type MemoryBuffer;
581 pub struct PassManager<'a>(InvariantOpaque<'a>);
583 pub type PassManagerBuilder;
589 pub struct SectionIterator<'a>(InvariantOpaque<'a>);
594 pub type TargetMachine;
600 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
602 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
607 pub type DiagnosticInfo;
610 pub type SMDiagnostic;
613 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
615 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
617 pub struct Linker<'a>(InvariantOpaque<'a>);
619 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
620 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
622 pub mod coverageinfo {
623 use super::coverage_map;
625 /// 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)
626 #[derive(Copy, Clone, Debug)]
628 pub enum RegionKind {
629 /// A CodeRegion associates some code with a counter
632 /// An ExpansionRegion represents a file expansion region that associates
633 /// a source range with the expansion of a virtual source file, such as
634 /// for a macro instantiation or #include file.
637 /// A SkippedRegion represents a source range with code that was skipped
638 /// by a preprocessor or similar means.
641 /// A GapRegion is like a CodeRegion, but its count is only set as the
642 /// line execution count when its the only region in the line.
646 /// This struct provides LLVM's representation of a "CoverageMappingRegion", encoded into the
647 /// coverage map, in accordance with the
648 /// [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).
649 /// The struct composes fields representing the `Counter` type and value(s) (injected counter
650 /// ID, or expression type and operands), the source file (an indirect index into a "filenames
651 /// array", encoded separately), and source location (start and end positions of the represented
654 /// Matches LLVMRustCounterMappingRegion.
655 #[derive(Copy, Clone, Debug)]
657 pub struct CounterMappingRegion {
658 /// The counter type and type-dependent counter data, if any.
659 counter: coverage_map::Counter,
661 /// An indirect reference to the source filename. In the LLVM Coverage Mapping Format, the
662 /// file_id is an index into a function-specific `virtual_file_mapping` array of indexes
663 /// that, in turn, are used to look up the filename for this region.
666 /// If the `RegionKind` is an `ExpansionRegion`, the `expanded_file_id` can be used to find
667 /// the mapping regions created as a result of macro expansion, by checking if their file id
668 /// matches the expanded file id.
669 expanded_file_id: u32,
671 /// 1-based starting line of the mapping region.
674 /// 1-based starting column of the mapping region.
677 /// 1-based ending line of the mapping region.
680 /// 1-based ending column of the mapping region. If the high bit is set, the current
681 /// mapping region is a gap area.
687 impl CounterMappingRegion {
688 crate fn code_region(
689 counter: coverage_map::Counter,
704 kind: RegionKind::CodeRegion,
708 // This function might be used in the future; the LLVM API is still evolving, as is coverage
711 crate fn expansion_region(
713 expanded_file_id: u32,
720 counter: coverage_map::Counter::zero(),
727 kind: RegionKind::ExpansionRegion,
731 // This function might be used in the future; the LLVM API is still evolving, as is coverage
734 crate fn skipped_region(
742 counter: coverage_map::Counter::zero(),
749 kind: RegionKind::SkippedRegion,
753 // This function might be used in the future; the LLVM API is still evolving, as is coverage
757 counter: coverage_map::Counter,
771 end_col: ((1 as u32) << 31) | end_col,
772 kind: RegionKind::GapRegion,
779 use super::{InvariantOpaque, Metadata};
780 use bitflags::bitflags;
783 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
785 pub type DIDescriptor = Metadata;
786 pub type DILocation = Metadata;
787 pub type DIScope = DIDescriptor;
788 pub type DIFile = DIScope;
789 pub type DILexicalBlock = DIScope;
790 pub type DISubprogram = DIScope;
791 pub type DINameSpace = DIScope;
792 pub type DIType = DIDescriptor;
793 pub type DIBasicType = DIType;
794 pub type DIDerivedType = DIType;
795 pub type DICompositeType = DIDerivedType;
796 pub type DIVariable = DIDescriptor;
797 pub type DIGlobalVariableExpression = DIDescriptor;
798 pub type DIArray = DIDescriptor;
799 pub type DISubrange = DIDescriptor;
800 pub type DIEnumerator = DIDescriptor;
801 pub type DITemplateTypeParameter = DIDescriptor;
803 // These values **must** match with LLVMRustDIFlags!!
807 pub struct DIFlags: u32 {
809 const FlagPrivate = 1;
810 const FlagProtected = 2;
811 const FlagPublic = 3;
812 const FlagFwdDecl = (1 << 2);
813 const FlagAppleBlock = (1 << 3);
814 const FlagBlockByrefStruct = (1 << 4);
815 const FlagVirtual = (1 << 5);
816 const FlagArtificial = (1 << 6);
817 const FlagExplicit = (1 << 7);
818 const FlagPrototyped = (1 << 8);
819 const FlagObjcClassComplete = (1 << 9);
820 const FlagObjectPointer = (1 << 10);
821 const FlagVector = (1 << 11);
822 const FlagStaticMember = (1 << 12);
823 const FlagLValueReference = (1 << 13);
824 const FlagRValueReference = (1 << 14);
825 const FlagExternalTypeRef = (1 << 15);
826 const FlagIntroducedVirtual = (1 << 18);
827 const FlagBitField = (1 << 19);
828 const FlagNoReturn = (1 << 20);
832 // These values **must** match with LLVMRustDISPFlags!!
836 pub struct DISPFlags: u32 {
837 const SPFlagZero = 0;
838 const SPFlagVirtual = 1;
839 const SPFlagPureVirtual = 2;
840 const SPFlagLocalToUnit = (1 << 2);
841 const SPFlagDefinition = (1 << 3);
842 const SPFlagOptimized = (1 << 4);
843 const SPFlagMainSubprogram = (1 << 5);
847 /// LLVMRustDebugEmissionKind
848 #[derive(Copy, Clone)]
850 pub enum DebugEmissionKind {
856 impl DebugEmissionKind {
857 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
858 use rustc_session::config::DebugInfo;
860 DebugInfo::None => DebugEmissionKind::NoDebug,
861 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
862 DebugInfo::Full => DebugEmissionKind::FullDebug,
869 pub type ModuleBuffer;
872 pub type SelfProfileBeforePassCallback =
873 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
874 pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
877 pub fn LLVMRustInstallFatalErrorHandler();
879 // Create and destroy contexts.
880 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
881 pub fn LLVMContextDispose(C: &'static mut Context);
882 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
885 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
886 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
887 pub fn LLVMCloneModule(M: &Module) -> &Module;
889 /// Data layout. See Module::getDataLayout.
890 pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
891 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
893 /// See Module::setModuleInlineAsm.
894 pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
895 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
897 /// See llvm::LLVMTypeKind::getTypeID.
898 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
900 // Operations on integer types
901 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
902 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
903 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
904 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
905 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
906 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
908 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
910 // Operations on real types
911 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
912 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
914 // Operations on function types
915 pub fn LLVMFunctionType(
916 ReturnType: &'a Type,
917 ParamTypes: *const &'a Type,
921 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
922 pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
924 // Operations on struct types
925 pub fn LLVMStructTypeInContext(
927 ElementTypes: *const &'a Type,
928 ElementCount: c_uint,
932 // Operations on array, pointer, and vector types (sequence types)
933 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
934 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
935 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
937 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
938 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
940 // Operations on other types
941 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
942 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
944 // Operations on all values
945 pub fn LLVMTypeOf(Val: &Value) -> &Type;
946 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
947 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
948 pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
949 pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
951 // Operations on constants of any type
952 pub fn LLVMConstNull(Ty: &Type) -> &Value;
953 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
955 // Operations on metadata
956 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
957 pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
958 pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
960 // Operations on scalar constants
961 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
962 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
963 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
964 pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
965 pub fn LLVMRustConstInt128Get(
966 ConstantVal: &ConstantInt,
972 // Operations on composite constants
973 pub fn LLVMConstStringInContext(
977 DontNullTerminate: Bool,
979 pub fn LLVMConstStructInContext(
981 ConstantVals: *const &'a Value,
986 pub fn LLVMConstArray(
988 ConstantVals: *const &'a Value,
991 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
993 // Constant expressions
994 pub fn LLVMConstInBoundsGEP(
995 ConstantVal: &'a Value,
996 ConstantIndices: *const &'a Value,
999 pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1000 pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1001 pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1002 pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1003 pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1004 pub fn LLVMConstExtractValue(
1005 AggConstant: &Value,
1006 IdxList: *const c_uint,
1010 // Operations on global variables, functions, and aliases (globals)
1011 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
1012 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
1013 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
1014 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
1015 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
1016 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
1017 pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
1018 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
1019 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1020 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1022 // Operations on global variables
1023 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
1024 pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1025 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
1026 pub fn LLVMRustGetOrInsertGlobal(
1028 Name: *const c_char,
1032 pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
1033 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1034 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1035 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
1036 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1037 pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
1038 pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
1039 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1040 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1041 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1042 pub fn LLVMRustGetNamedValue(
1044 Name: *const c_char,
1046 ) -> Option<&Value>;
1047 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1049 // Operations on functions
1050 pub fn LLVMRustGetOrInsertFunction(
1052 Name: *const c_char,
1054 FunctionTy: &'a Type,
1056 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1057 pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
1058 pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
1059 pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
1060 pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
1061 pub fn LLVMRustAddStructRetAttr(Fn: &Value, index: c_uint, ty: &Type);
1062 pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
1063 pub fn LLVMRustAddFunctionAttrStringValue(
1066 Name: *const c_char,
1067 Value: *const c_char,
1069 pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
1071 // Operations on parameters
1072 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1073 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
1074 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1076 // Operations on basic blocks
1077 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1078 pub fn LLVMAppendBasicBlockInContext(
1081 Name: *const c_char,
1082 ) -> &'a BasicBlock;
1084 // Operations on instructions
1085 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1086 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1088 // Operations on call sites
1089 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1090 pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
1091 pub fn LLVMRustAddCallSiteAttrString(Instr: &Value, index: c_uint, Name: *const c_char);
1092 pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
1093 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1094 pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1095 pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1096 pub fn LLVMRustAddStructRetCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1098 // Operations on load/store instructions (only)
1099 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1101 // Operations on phi nodes
1102 pub fn LLVMAddIncoming(
1104 IncomingValues: *const &'a Value,
1105 IncomingBlocks: *const &'a BasicBlock,
1109 // Instruction builders
1110 pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
1111 pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
1112 pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
1113 pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
1116 pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
1119 pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
1120 pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1121 pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1122 pub fn LLVMBuildCondBr(
1125 Then: &'a BasicBlock,
1126 Else: &'a BasicBlock,
1128 pub fn LLVMBuildSwitch(
1131 Else: &'a BasicBlock,
1134 pub fn LLVMRustBuildInvoke(
1137 Args: *const &'a Value,
1139 Then: &'a BasicBlock,
1140 Catch: &'a BasicBlock,
1141 Bundle: Option<&OperandBundleDef<'a>>,
1142 Name: *const c_char,
1144 pub fn LLVMBuildLandingPad(
1149 Name: *const c_char,
1151 pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1152 pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
1154 pub fn LLVMRustBuildCleanupPad(
1156 ParentPad: Option<&'a Value>,
1158 Args: *const &'a Value,
1159 Name: *const c_char,
1160 ) -> Option<&'a Value>;
1161 pub fn LLVMRustBuildCleanupRet(
1163 CleanupPad: &'a Value,
1164 UnwindBB: Option<&'a BasicBlock>,
1165 ) -> Option<&'a Value>;
1166 pub fn LLVMRustBuildCatchPad(
1168 ParentPad: &'a Value,
1170 Args: *const &'a Value,
1171 Name: *const c_char,
1172 ) -> Option<&'a Value>;
1173 pub fn LLVMRustBuildCatchRet(
1177 ) -> Option<&'a Value>;
1178 pub fn LLVMRustBuildCatchSwitch(
1179 Builder: &Builder<'a>,
1180 ParentPad: Option<&'a Value>,
1181 BB: Option<&'a BasicBlock>,
1182 NumHandlers: c_uint,
1183 Name: *const c_char,
1184 ) -> Option<&'a Value>;
1185 pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1186 pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
1188 // Add a case to the switch instruction
1189 pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1191 // Add a clause to the landing pad instruction
1192 pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
1194 // Set the cleanup on a landing pad instruction
1195 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1198 pub fn LLVMBuildAdd(
1202 Name: *const c_char,
1204 pub fn LLVMBuildFAdd(
1208 Name: *const c_char,
1210 pub fn LLVMBuildSub(
1214 Name: *const c_char,
1216 pub fn LLVMBuildFSub(
1220 Name: *const c_char,
1222 pub fn LLVMBuildMul(
1226 Name: *const c_char,
1228 pub fn LLVMBuildFMul(
1232 Name: *const c_char,
1234 pub fn LLVMBuildUDiv(
1238 Name: *const c_char,
1240 pub fn LLVMBuildExactUDiv(
1244 Name: *const c_char,
1246 pub fn LLVMBuildSDiv(
1250 Name: *const c_char,
1252 pub fn LLVMBuildExactSDiv(
1256 Name: *const c_char,
1258 pub fn LLVMBuildFDiv(
1262 Name: *const c_char,
1264 pub fn LLVMBuildURem(
1268 Name: *const c_char,
1270 pub fn LLVMBuildSRem(
1274 Name: *const c_char,
1276 pub fn LLVMBuildFRem(
1280 Name: *const c_char,
1282 pub fn LLVMBuildShl(
1286 Name: *const c_char,
1288 pub fn LLVMBuildLShr(
1292 Name: *const c_char,
1294 pub fn LLVMBuildAShr(
1298 Name: *const c_char,
1300 pub fn LLVMBuildNSWAdd(
1304 Name: *const c_char,
1306 pub fn LLVMBuildNUWAdd(
1310 Name: *const c_char,
1312 pub fn LLVMBuildNSWSub(
1316 Name: *const c_char,
1318 pub fn LLVMBuildNUWSub(
1322 Name: *const c_char,
1324 pub fn LLVMBuildNSWMul(
1328 Name: *const c_char,
1330 pub fn LLVMBuildNUWMul(
1334 Name: *const c_char,
1336 pub fn LLVMBuildAnd(
1340 Name: *const c_char,
1346 Name: *const c_char,
1348 pub fn LLVMBuildXor(
1352 Name: *const c_char,
1354 pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1355 pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1356 pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1357 pub fn LLVMRustSetFastMath(Instr: &Value);
1360 pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1361 pub fn LLVMBuildArrayAlloca(
1365 Name: *const c_char,
1367 pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
1369 pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1371 pub fn LLVMBuildGEP(
1374 Indices: *const &'a Value,
1376 Name: *const c_char,
1378 pub fn LLVMBuildInBoundsGEP(
1381 Indices: *const &'a Value,
1383 Name: *const c_char,
1385 pub fn LLVMBuildStructGEP(
1389 Name: *const c_char,
1393 pub fn LLVMBuildTrunc(
1397 Name: *const c_char,
1399 pub fn LLVMBuildZExt(
1403 Name: *const c_char,
1405 pub fn LLVMBuildSExt(
1409 Name: *const c_char,
1411 pub fn LLVMBuildFPToUI(
1415 Name: *const c_char,
1417 pub fn LLVMBuildFPToSI(
1421 Name: *const c_char,
1423 pub fn LLVMBuildUIToFP(
1427 Name: *const c_char,
1429 pub fn LLVMBuildSIToFP(
1433 Name: *const c_char,
1435 pub fn LLVMBuildFPTrunc(
1439 Name: *const c_char,
1441 pub fn LLVMBuildFPExt(
1445 Name: *const c_char,
1447 pub fn LLVMBuildPtrToInt(
1451 Name: *const c_char,
1453 pub fn LLVMBuildIntToPtr(
1457 Name: *const c_char,
1459 pub fn LLVMBuildBitCast(
1463 Name: *const c_char,
1465 pub fn LLVMBuildPointerCast(
1469 Name: *const c_char,
1471 pub fn LLVMRustBuildIntCast(
1479 pub fn LLVMBuildICmp(
1484 Name: *const c_char,
1486 pub fn LLVMBuildFCmp(
1491 Name: *const c_char,
1494 // Miscellaneous instructions
1495 pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1496 pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &'a Value;
1497 pub fn LLVMRustBuildCall(
1500 Args: *const &'a Value,
1502 Bundle: Option<&OperandBundleDef<'a>>,
1504 pub fn LLVMRustBuildMemCpy(
1513 pub fn LLVMRustBuildMemMove(
1522 pub fn LLVMRustBuildMemSet(
1530 pub fn LLVMBuildSelect(
1535 Name: *const c_char,
1537 pub fn LLVMBuildVAArg(
1541 Name: *const c_char,
1543 pub fn LLVMBuildExtractElement(
1547 Name: *const c_char,
1549 pub fn LLVMBuildInsertElement(
1554 Name: *const c_char,
1556 pub fn LLVMBuildShuffleVector(
1561 Name: *const c_char,
1563 pub fn LLVMBuildExtractValue(
1567 Name: *const c_char,
1569 pub fn LLVMBuildInsertValue(
1574 Name: *const c_char,
1577 pub fn LLVMRustBuildVectorReduceFAdd(
1582 pub fn LLVMRustBuildVectorReduceFMul(
1587 pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1588 pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1589 pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1590 pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1591 pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1592 pub fn LLVMRustBuildVectorReduceMin(
1597 pub fn LLVMRustBuildVectorReduceMax(
1602 pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1604 pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1607 pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1608 pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1610 // Atomic Operations
1611 pub fn LLVMRustBuildAtomicLoad(
1613 PointerVal: &'a Value,
1614 Name: *const c_char,
1615 Order: AtomicOrdering,
1618 pub fn LLVMRustBuildAtomicStore(
1622 Order: AtomicOrdering,
1625 pub fn LLVMRustBuildAtomicCmpXchg(
1630 Order: AtomicOrdering,
1631 FailureOrder: AtomicOrdering,
1635 pub fn LLVMBuildAtomicRMW(
1640 Order: AtomicOrdering,
1641 SingleThreaded: Bool,
1644 pub fn LLVMRustBuildAtomicFence(
1646 Order: AtomicOrdering,
1647 Scope: SynchronizationScope,
1650 /// Writes a module to the specified path. Returns 0 on success.
1651 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1653 /// Creates a pass manager.
1654 pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1656 /// Creates a function-by-function pass manager
1657 pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1659 /// Disposes a pass manager.
1660 pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1662 /// Runs a pass manager on a module.
1663 pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1665 pub fn LLVMInitializePasses();
1667 pub fn LLVMTimeTraceProfilerInitialize();
1669 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1671 pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>);
1673 pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1674 pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1675 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1676 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1677 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1678 PMB: &PassManagerBuilder,
1681 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1682 PMB: &PassManagerBuilder,
1683 PM: &PassManager<'_>,
1686 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1687 PMB: &PassManagerBuilder,
1688 PM: &PassManager<'_>,
1690 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1691 PMB: &PassManagerBuilder,
1692 PM: &PassManager<'_>,
1696 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1697 PMB: &PassManagerBuilder,
1698 PM: &PassManager<'_>,
1701 pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
1703 pub fn LLVMDisposeMessage(message: *mut c_char);
1705 // Stuff that's in llvm-wrapper/ because it's not upstream yet.
1707 /// Opens an object file.
1708 pub fn LLVMCreateObjectFile(
1709 MemBuf: &'static mut MemoryBuffer,
1710 ) -> Option<&'static mut ObjectFile>;
1711 /// Closes an object file.
1712 pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1714 /// Enumerates the sections in an object file.
1715 pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1716 /// Destroys a section iterator.
1717 pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1718 /// Returns `true` if the section iterator is at the end of the section
1720 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1721 /// Moves the section iterator to point to the next section.
1722 pub fn LLVMMoveToNextSection(SI: &SectionIterator<'_>);
1723 /// Returns the current section size.
1724 pub fn LLVMGetSectionSize(SI: &SectionIterator<'_>) -> c_ulonglong;
1725 /// Returns the current section contents as a string buffer.
1726 pub fn LLVMGetSectionContents(SI: &SectionIterator<'_>) -> *const c_char;
1728 /// Reads the given file and returns it as a memory buffer. Use
1729 /// LLVMDisposeMemoryBuffer() to get rid of it.
1730 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1731 Path: *const c_char,
1732 ) -> Option<&'static mut MemoryBuffer>;
1734 pub fn LLVMStartMultithreaded() -> Bool;
1736 /// Returns a string describing the last error caused by an LLVMRust* call.
1737 pub fn LLVMRustGetLastError() -> *const c_char;
1739 /// Print the pass timings since static dtors aren't picking them up.
1740 pub fn LLVMRustPrintPassTimings();
1742 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1744 pub fn LLVMStructSetBody(
1746 ElementTypes: *const &'a Type,
1747 ElementCount: c_uint,
1751 /// Prepares inline assembly.
1752 pub fn LLVMRustInlineAsm(
1754 AsmString: *const c_char,
1755 AsmStringLen: size_t,
1756 Constraints: *const c_char,
1757 ConstraintsLen: size_t,
1760 Dialect: AsmDialect,
1762 pub fn LLVMRustInlineAsmVerify(
1764 Constraints: *const c_char,
1765 ConstraintsLen: size_t,
1768 #[allow(improper_ctypes)]
1769 pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1770 Filenames: *const *const c_char,
1771 FilenamesLen: size_t,
1772 BufferOut: &RustString,
1775 #[allow(improper_ctypes)]
1776 pub fn LLVMRustCoverageWriteMappingToBuffer(
1777 VirtualFileMappingIDs: *const c_uint,
1778 NumVirtualFileMappingIDs: c_uint,
1779 Expressions: *const coverage_map::CounterExpression,
1780 NumExpressions: c_uint,
1781 MappingRegions: *const coverageinfo::CounterMappingRegion,
1782 NumMappingRegions: c_uint,
1783 BufferOut: &RustString,
1786 pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &'a Value, FuncName: *const c_char)
1788 pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64;
1789 pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
1791 #[allow(improper_ctypes)]
1792 pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
1794 #[allow(improper_ctypes)]
1795 pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
1797 #[allow(improper_ctypes)]
1798 pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1800 pub fn LLVMRustCoverageMappingVersion() -> u32;
1801 pub fn LLVMRustDebugMetadataVersion() -> u32;
1802 pub fn LLVMRustVersionMajor() -> u32;
1803 pub fn LLVMRustVersionMinor() -> u32;
1804 pub fn LLVMRustVersionPatch() -> u32;
1806 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1808 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1810 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1812 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1814 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1816 pub fn LLVMRustDIBuilderCreateCompileUnit(
1817 Builder: &DIBuilder<'a>,
1820 Producer: *const c_char,
1821 ProducerLen: size_t,
1823 Flags: *const c_char,
1825 SplitName: *const c_char,
1826 SplitNameLen: size_t,
1827 kind: DebugEmissionKind,
1829 SplitDebugInlining: bool,
1830 ) -> &'a DIDescriptor;
1832 pub fn LLVMRustDIBuilderCreateFile(
1833 Builder: &DIBuilder<'a>,
1834 Filename: *const c_char,
1835 FilenameLen: size_t,
1836 Directory: *const c_char,
1837 DirectoryLen: size_t,
1838 CSKind: ChecksumKind,
1839 Checksum: *const c_char,
1840 ChecksumLen: size_t,
1843 pub fn LLVMRustDIBuilderCreateSubroutineType(
1844 Builder: &DIBuilder<'a>,
1845 ParameterTypes: &'a DIArray,
1846 ) -> &'a DICompositeType;
1848 pub fn LLVMRustDIBuilderCreateFunction(
1849 Builder: &DIBuilder<'a>,
1850 Scope: &'a DIDescriptor,
1851 Name: *const c_char,
1853 LinkageName: *const c_char,
1854 LinkageNameLen: size_t,
1861 MaybeFn: Option<&'a Value>,
1862 TParam: &'a DIArray,
1863 Decl: Option<&'a DIDescriptor>,
1864 ) -> &'a DISubprogram;
1866 pub fn LLVMRustDIBuilderCreateBasicType(
1867 Builder: &DIBuilder<'a>,
1868 Name: *const c_char,
1872 ) -> &'a DIBasicType;
1874 pub fn LLVMRustDIBuilderCreateTypedef(
1875 Builder: &DIBuilder<'a>,
1876 Type: &'a DIBasicType,
1877 Name: *const c_char,
1881 Scope: Option<&'a DIScope>,
1882 ) -> &'a DIDerivedType;
1884 pub fn LLVMRustDIBuilderCreatePointerType(
1885 Builder: &DIBuilder<'a>,
1886 PointeeTy: &'a DIType,
1889 AddressSpace: c_uint,
1890 Name: *const c_char,
1892 ) -> &'a DIDerivedType;
1894 pub fn LLVMRustDIBuilderCreateStructType(
1895 Builder: &DIBuilder<'a>,
1896 Scope: Option<&'a DIDescriptor>,
1897 Name: *const c_char,
1904 DerivedFrom: Option<&'a DIType>,
1905 Elements: &'a DIArray,
1906 RunTimeLang: c_uint,
1907 VTableHolder: Option<&'a DIType>,
1908 UniqueId: *const c_char,
1909 UniqueIdLen: size_t,
1910 ) -> &'a DICompositeType;
1912 pub fn LLVMRustDIBuilderCreateMemberType(
1913 Builder: &DIBuilder<'a>,
1914 Scope: &'a DIDescriptor,
1915 Name: *const c_char,
1924 ) -> &'a DIDerivedType;
1926 pub fn LLVMRustDIBuilderCreateVariantMemberType(
1927 Builder: &DIBuilder<'a>,
1929 Name: *const c_char,
1936 Discriminant: Option<&'a Value>,
1941 pub fn LLVMRustDIBuilderCreateLexicalBlock(
1942 Builder: &DIBuilder<'a>,
1947 ) -> &'a DILexicalBlock;
1949 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(
1950 Builder: &DIBuilder<'a>,
1953 ) -> &'a DILexicalBlock;
1955 pub fn LLVMRustDIBuilderCreateStaticVariable(
1956 Builder: &DIBuilder<'a>,
1957 Context: Option<&'a DIScope>,
1958 Name: *const c_char,
1960 LinkageName: *const c_char,
1961 LinkageNameLen: size_t,
1965 isLocalToUnit: bool,
1967 Decl: Option<&'a DIDescriptor>,
1969 ) -> &'a DIGlobalVariableExpression;
1971 pub fn LLVMRustDIBuilderCreateVariable(
1972 Builder: &DIBuilder<'a>,
1974 Scope: &'a DIDescriptor,
1975 Name: *const c_char,
1980 AlwaysPreserve: bool,
1984 ) -> &'a DIVariable;
1986 pub fn LLVMRustDIBuilderCreateArrayType(
1987 Builder: &DIBuilder<'a>,
1991 Subscripts: &'a DIArray,
1994 pub fn LLVMRustDIBuilderGetOrCreateSubrange(
1995 Builder: &DIBuilder<'a>,
1998 ) -> &'a DISubrange;
2000 pub fn LLVMRustDIBuilderGetOrCreateArray(
2001 Builder: &DIBuilder<'a>,
2002 Ptr: *const Option<&'a DIDescriptor>,
2006 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(
2007 Builder: &DIBuilder<'a>,
2009 VarInfo: &'a DIVariable,
2010 AddrOps: *const i64,
2011 AddrOpsCount: c_uint,
2013 InsertAtEnd: &'a BasicBlock,
2016 pub fn LLVMRustDIBuilderCreateEnumerator(
2017 Builder: &DIBuilder<'a>,
2018 Name: *const c_char,
2022 ) -> &'a DIEnumerator;
2024 pub fn LLVMRustDIBuilderCreateEnumerationType(
2025 Builder: &DIBuilder<'a>,
2027 Name: *const c_char,
2033 Elements: &'a DIArray,
2034 ClassType: &'a DIType,
2038 pub fn LLVMRustDIBuilderCreateUnionType(
2039 Builder: &DIBuilder<'a>,
2041 Name: *const c_char,
2048 Elements: Option<&'a DIArray>,
2049 RunTimeLang: c_uint,
2050 UniqueId: *const c_char,
2051 UniqueIdLen: size_t,
2054 pub fn LLVMRustDIBuilderCreateVariantPart(
2055 Builder: &DIBuilder<'a>,
2057 Name: *const c_char,
2064 Discriminator: Option<&'a DIDerivedType>,
2065 Elements: &'a DIArray,
2066 UniqueId: *const c_char,
2067 UniqueIdLen: size_t,
2068 ) -> &'a DIDerivedType;
2070 pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
2072 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
2073 Builder: &DIBuilder<'a>,
2074 Scope: Option<&'a DIScope>,
2075 Name: *const c_char,
2078 ) -> &'a DITemplateTypeParameter;
2080 pub fn LLVMRustDIBuilderCreateNameSpace(
2081 Builder: &DIBuilder<'a>,
2082 Scope: Option<&'a DIScope>,
2083 Name: *const c_char,
2085 ExportSymbols: bool,
2086 ) -> &'a DINameSpace;
2088 pub fn LLVMRustDICompositeTypeReplaceArrays(
2089 Builder: &DIBuilder<'a>,
2090 CompositeType: &'a DIType,
2091 Elements: Option<&'a DIArray>,
2092 Params: Option<&'a DIArray>,
2095 pub fn LLVMRustDIBuilderCreateDebugLocation(
2099 InlinedAt: Option<&'a DILocation>,
2100 ) -> &'a DILocation;
2101 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
2102 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
2104 #[allow(improper_ctypes)]
2105 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2106 #[allow(improper_ctypes)]
2107 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2109 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2111 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
2112 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
2113 pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
2114 pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2115 pub fn LLVMRustCreateMemorySanitizerPass(
2116 TrackOrigins: c_int,
2118 ) -> &'static mut Pass;
2119 pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
2120 pub fn LLVMRustCreateHWAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2121 pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
2122 pub fn LLVMRustAddLastExtensionPasses(
2123 PMB: &PassManagerBuilder,
2124 Passes: *const &'static mut Pass,
2128 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2130 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
2131 pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2132 pub fn LLVMRustGetTargetFeature(
2135 Feature: &mut *const c_char,
2136 Desc: &mut *const c_char,
2139 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2140 pub fn LLVMRustCreateTargetMachine(
2141 Triple: *const c_char,
2143 Features: *const c_char,
2147 Level: CodeGenOptLevel,
2149 FunctionSections: bool,
2151 TrapUnreachable: bool,
2154 EmitStackSizeSection: bool,
2155 RelaxELFRelocations: bool,
2157 SplitDwarfFile: *const c_char,
2158 ) -> Option<&'static mut TargetMachine>;
2159 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
2160 pub fn LLVMRustAddBuilderLibraryInfo(
2161 PMB: &'a PassManagerBuilder,
2163 DisableSimplifyLibCalls: bool,
2165 pub fn LLVMRustConfigurePassManagerBuilder(
2166 PMB: &PassManagerBuilder,
2167 OptLevel: CodeGenOptLevel,
2168 MergeFunctions: bool,
2170 LoopVectorize: bool,
2171 PrepareForThinLTO: bool,
2172 PGOGenPath: *const c_char,
2173 PGOUsePath: *const c_char,
2175 pub fn LLVMRustAddLibraryInfo(
2176 PM: &PassManager<'a>,
2178 DisableSimplifyLibCalls: bool,
2180 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
2181 pub fn LLVMRustWriteOutputFile(
2182 T: &'a TargetMachine,
2183 PM: &PassManager<'a>,
2185 Output: *const c_char,
2186 DwoOutput: *const c_char,
2188 ) -> LLVMRustResult;
2189 pub fn LLVMRustOptimizeWithNewPassManager(
2191 TM: &'a TargetMachine,
2192 OptLevel: PassBuilderOptLevel,
2194 NoPrepopulatePasses: bool,
2196 UseThinLTOBuffers: bool,
2197 MergeFunctions: bool,
2200 LoopVectorize: bool,
2201 DisableSimplifyLibCalls: bool,
2202 EmitLifetimeMarkers: bool,
2203 SanitizerOptions: Option<&SanitizerOptions>,
2204 PGOGenPath: *const c_char,
2205 PGOUsePath: *const c_char,
2206 InstrumentCoverage: bool,
2207 InstrumentGCOV: bool,
2208 llvm_selfprofiler: *mut c_void,
2209 begin_callback: SelfProfileBeforePassCallback,
2210 end_callback: SelfProfileAfterPassCallback,
2211 ExtraPasses: *const c_char,
2212 ExtraPassesLen: size_t,
2213 ) -> LLVMRustResult;
2214 pub fn LLVMRustPrintModule(
2216 Output: *const c_char,
2217 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2218 ) -> LLVMRustResult;
2219 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2220 pub fn LLVMRustPrintPasses();
2221 pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
2222 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2223 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
2224 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2225 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
2227 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2228 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
2229 pub fn LLVMRustArchiveIteratorNext(
2230 AIR: &ArchiveIterator<'a>,
2231 ) -> Option<&'a mut ArchiveChild<'a>>;
2232 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2233 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2234 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
2235 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
2236 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2238 #[allow(improper_ctypes)]
2239 pub fn LLVMRustGetSectionName(
2240 SI: &SectionIterator<'_>,
2241 data: &mut Option<std::ptr::NonNull<c_char>>,
2244 #[allow(improper_ctypes)]
2245 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2247 pub fn LLVMContextSetDiagnosticHandler(
2249 Handler: DiagnosticHandler,
2250 DiagnosticContext: *mut c_void,
2253 #[allow(improper_ctypes)]
2254 pub fn LLVMRustUnpackOptimizationDiagnostic(
2255 DI: &'a DiagnosticInfo,
2256 pass_name_out: &RustString,
2257 function_out: &mut Option<&'a Value>,
2258 loc_line_out: &mut c_uint,
2259 loc_column_out: &mut c_uint,
2260 loc_filename_out: &RustString,
2261 message_out: &RustString,
2264 pub fn LLVMRustUnpackInlineAsmDiagnostic(
2265 DI: &'a DiagnosticInfo,
2266 level_out: &mut DiagnosticLevel,
2267 cookie_out: &mut c_uint,
2268 message_out: &mut Option<&'a Twine>,
2269 instruction_out: &mut Option<&'a Value>,
2272 #[allow(improper_ctypes)]
2273 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2274 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2276 pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2278 H: InlineAsmDiagHandler,
2282 #[allow(improper_ctypes)]
2283 pub fn LLVMRustUnpackSMDiagnostic(
2285 message_out: &RustString,
2286 buffer_out: &RustString,
2287 level_out: &mut DiagnosticLevel,
2288 loc_out: &mut c_uint,
2289 ranges_out: *mut c_uint,
2290 num_ranges: &mut usize,
2293 pub fn LLVMRustWriteArchive(
2296 Members: *const &RustArchiveMember<'_>,
2299 ) -> LLVMRustResult;
2300 pub fn LLVMRustArchiveMemberNew(
2301 Filename: *const c_char,
2302 Name: *const c_char,
2303 Child: Option<&ArchiveChild<'a>>,
2304 ) -> &'a mut RustArchiveMember<'a>;
2305 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
2307 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
2309 pub fn LLVMRustBuildOperandBundleDef(
2310 Name: *const c_char,
2311 Inputs: *const &'a Value,
2313 ) -> &'a mut OperandBundleDef<'a>;
2314 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
2316 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
2318 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2319 pub fn LLVMRustUnsetComdat(V: &Value);
2320 pub fn LLVMRustSetModulePICLevel(M: &Module);
2321 pub fn LLVMRustSetModulePIELevel(M: &Module);
2322 pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2323 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2324 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2325 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2326 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2327 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2329 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
2330 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2331 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2332 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2333 pub fn LLVMRustCreateThinLTOData(
2334 Modules: *const ThinLTOModule,
2336 PreservedSymbols: *const *const c_char,
2337 PreservedSymbolsLen: c_uint,
2338 ) -> Option<&'static mut ThinLTOData>;
2339 pub fn LLVMRustPrepareThinLTORename(
2342 Target: &TargetMachine,
2344 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2345 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2346 pub fn LLVMRustPrepareThinLTOImport(
2349 Target: &TargetMachine,
2351 pub fn LLVMRustGetThinLTOModuleImports(
2352 Data: *const ThinLTOData,
2353 ModuleNameCallback: ThinLTOModuleNameCallback,
2354 CallbackPayload: *mut c_void,
2356 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2357 pub fn LLVMRustParseBitcodeForLTO(
2361 Identifier: *const c_char,
2362 ) -> Option<&Module>;
2363 pub fn LLVMRustGetBitcodeSliceFromObjectData(
2366 out_len: &mut usize,
2368 pub fn LLVMRustThinLTOGetDICompileUnit(
2370 CU1: &mut *mut c_void,
2371 CU2: &mut *mut c_void,
2373 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2375 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
2376 pub fn LLVMRustLinkerAdd(
2377 linker: &Linker<'_>,
2378 bytecode: *const c_char,
2379 bytecode_len: usize,
2381 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);
2382 #[allow(improper_ctypes)]
2383 pub fn LLVMRustComputeLTOCacheKey(
2384 key_out: &RustString,
2385 mod_id: *const c_char,