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,
61 AvailableExternallyLinkage = 1,
62 LinkOnceAnyLinkage = 2,
63 LinkOnceODRLinkage = 3,
69 ExternalWeakLinkage = 9,
83 pub enum UnnamedAddr {
89 /// LLVMDLLStorageClass
90 #[derive(Copy, Clone)]
92 pub enum DLLStorageClass {
95 DllImport = 1, // Function to be imported from DLL.
97 DllExport = 2, // Function to be accessible from DLL.
100 /// Matches LLVMRustAttribute in LLVMWrapper.h
101 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
102 /// though it is not ABI compatible (since it's a C++ enum)
104 #[derive(Copy, Clone, Debug)]
119 OptimizeForSize = 13,
127 SanitizeAddress = 21,
133 InaccessibleMemOnly = 27,
134 SanitizeHWAddress = 28,
139 #[derive(Copy, Clone)]
141 pub enum IntPredicate {
155 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
157 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
158 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
159 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
160 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
161 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
162 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
163 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
164 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
165 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
166 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
171 /// LLVMRealPredicate
172 #[derive(Copy, Clone)]
174 pub enum RealPredicate {
175 RealPredicateFalse = 0,
190 RealPredicateTrue = 15,
194 #[derive(Copy, Clone, PartialEq, Debug)]
220 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
222 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
223 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
224 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
225 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
226 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
227 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
228 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
229 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
230 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
231 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
232 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
233 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
234 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
235 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
236 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
237 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
238 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
239 TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
240 TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
241 TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX,
246 /// LLVMAtomicRmwBinOp
247 #[derive(Copy, Clone)]
249 pub enum AtomicRmwBinOp {
263 impl AtomicRmwBinOp {
264 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
266 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
267 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
268 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
269 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
270 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
271 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
272 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
273 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
274 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
275 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
276 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
281 /// LLVMAtomicOrdering
282 #[derive(Copy, Clone)]
284 pub enum AtomicOrdering {
289 // Consume = 3, // Not specified yet.
293 SequentiallyConsistent = 7,
296 impl AtomicOrdering {
297 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
299 rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
300 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
301 rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
302 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
303 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
304 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
305 AtomicOrdering::AcquireRelease
307 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
308 AtomicOrdering::SequentiallyConsistent
314 /// LLVMRustSynchronizationScope
315 #[derive(Copy, Clone)]
317 pub enum SynchronizationScope {
322 impl SynchronizationScope {
323 pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
325 rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
326 SynchronizationScope::SingleThread
328 rustc_codegen_ssa::common::SynchronizationScope::CrossThread => {
329 SynchronizationScope::CrossThread
336 #[derive(Copy, Clone)]
344 #[derive(Copy, Clone)]
346 pub enum MetadataType {
353 MD_invariant_load = 6,
357 MD_mem_parallel_loop_access = 10,
361 /// LLVMRustAsmDialect
362 #[derive(Copy, Clone)]
364 pub enum AsmDialect {
370 pub fn from_generic(asm: rustc_ast::LlvmAsmDialect) -> Self {
372 rustc_ast::LlvmAsmDialect::Att => AsmDialect::Att,
373 rustc_ast::LlvmAsmDialect::Intel => AsmDialect::Intel,
378 /// LLVMRustCodeGenOptLevel
379 #[derive(Copy, Clone, PartialEq)]
381 pub enum CodeGenOptLevel {
388 /// LLVMRustPassBuilderOptLevel
390 pub enum PassBuilderOptLevel {
410 /// LLVMRustSanitizerOptions
412 pub struct SanitizerOptions {
413 pub sanitize_address: bool,
414 pub sanitize_address_recover: bool,
415 pub sanitize_memory: bool,
416 pub sanitize_memory_recover: bool,
417 pub sanitize_memory_track_origins: c_int,
418 pub sanitize_thread: bool,
419 pub sanitize_hwaddress: bool,
420 pub sanitize_hwaddress_recover: bool,
424 #[derive(Copy, Clone, PartialEq)]
426 pub enum RelocModel {
435 /// LLVMRustCodeModel
436 #[derive(Copy, Clone)]
447 /// LLVMRustDiagnosticKind
448 #[derive(Copy, Clone)]
450 #[allow(dead_code)] // Variants constructed by C++.
451 pub enum DiagnosticKind {
455 DebugMetadataVersion,
458 OptimizationRemarkMissed,
459 OptimizationRemarkAnalysis,
460 OptimizationRemarkAnalysisFPCommute,
461 OptimizationRemarkAnalysisAliasing,
462 OptimizationRemarkOther,
469 /// LLVMRustDiagnosticLevel
470 #[derive(Copy, Clone)]
472 #[allow(dead_code)] // Variants constructed by C++.
473 pub enum DiagnosticLevel {
480 /// LLVMRustArchiveKind
481 #[derive(Copy, Clone)]
483 pub enum ArchiveKind {
491 #[derive(Copy, Clone, PartialEq, Debug)]
493 #[allow(dead_code)] // Variants constructed by C++.
500 /// LLVMRustThinLTOData
502 pub type ThinLTOData;
505 /// LLVMRustThinLTOBuffer
507 pub type ThinLTOBuffer;
510 // LLVMRustModuleNameCallback
511 pub type ThinLTOModuleNameCallback =
512 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
514 /// LLVMRustThinLTOModule
516 pub struct ThinLTOModule {
517 pub identifier: *const c_char,
522 /// LLVMThreadLocalMode
523 #[derive(Copy, Clone)]
525 pub enum ThreadLocalMode {
533 /// LLVMRustChecksumKind
534 #[derive(Copy, Clone)]
536 pub enum ChecksumKind {
547 struct InvariantOpaque<'a> {
548 _marker: PhantomData<&'a mut &'a ()>,
552 // Opaque pointer types
566 pub type ConstantInt;
575 pub struct Builder<'a>(InvariantOpaque<'a>);
577 pub type MemoryBuffer;
580 pub struct PassManager<'a>(InvariantOpaque<'a>);
582 pub type PassManagerBuilder;
588 pub struct SectionIterator<'a>(InvariantOpaque<'a>);
593 pub type TargetMachine;
599 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
601 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
606 pub type DiagnosticInfo;
609 pub type SMDiagnostic;
612 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
614 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
616 pub struct Linker<'a>(InvariantOpaque<'a>);
618 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
619 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
621 pub mod coverageinfo {
622 use super::coverage_map;
624 /// 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)
625 #[derive(Copy, Clone, Debug)]
627 pub enum RegionKind {
628 /// A CodeRegion associates some code with a counter
631 /// An ExpansionRegion represents a file expansion region that associates
632 /// a source range with the expansion of a virtual source file, such as
633 /// for a macro instantiation or #include file.
636 /// A SkippedRegion represents a source range with code that was skipped
637 /// by a preprocessor or similar means.
640 /// A GapRegion is like a CodeRegion, but its count is only set as the
641 /// line execution count when its the only region in the line.
645 /// This struct provides LLVM's representation of a "CoverageMappingRegion", encoded into the
646 /// coverage map, in accordance with the
647 /// [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).
648 /// The struct composes fields representing the `Counter` type and value(s) (injected counter
649 /// ID, or expression type and operands), the source file (an indirect index into a "filenames
650 /// array", encoded separately), and source location (start and end positions of the represented
653 /// Matches LLVMRustCounterMappingRegion.
654 #[derive(Copy, Clone, Debug)]
656 pub struct CounterMappingRegion {
657 /// The counter type and type-dependent counter data, if any.
658 counter: coverage_map::Counter,
660 /// An indirect reference to the source filename. In the LLVM Coverage Mapping Format, the
661 /// file_id is an index into a function-specific `virtual_file_mapping` array of indexes
662 /// that, in turn, are used to look up the filename for this region.
665 /// If the `RegionKind` is an `ExpansionRegion`, the `expanded_file_id` can be used to find
666 /// the mapping regions created as a result of macro expansion, by checking if their file id
667 /// matches the expanded file id.
668 expanded_file_id: u32,
670 /// 1-based starting line of the mapping region.
673 /// 1-based starting column of the mapping region.
676 /// 1-based ending line of the mapping region.
679 /// 1-based ending column of the mapping region. If the high bit is set, the current
680 /// mapping region is a gap area.
686 impl CounterMappingRegion {
687 crate fn code_region(
688 counter: coverage_map::Counter,
703 kind: RegionKind::CodeRegion,
707 // This function might be used in the future; the LLVM API is still evolving, as is coverage
710 crate fn expansion_region(
712 expanded_file_id: u32,
719 counter: coverage_map::Counter::zero(),
726 kind: RegionKind::ExpansionRegion,
730 // This function might be used in the future; the LLVM API is still evolving, as is coverage
733 crate fn skipped_region(
741 counter: coverage_map::Counter::zero(),
748 kind: RegionKind::SkippedRegion,
752 // This function might be used in the future; the LLVM API is still evolving, as is coverage
756 counter: coverage_map::Counter,
770 end_col: ((1 as u32) << 31) | end_col,
771 kind: RegionKind::GapRegion,
778 use super::{InvariantOpaque, Metadata};
779 use bitflags::bitflags;
782 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
784 pub type DIDescriptor = Metadata;
785 pub type DILocation = Metadata;
786 pub type DIScope = DIDescriptor;
787 pub type DIFile = DIScope;
788 pub type DILexicalBlock = DIScope;
789 pub type DISubprogram = DIScope;
790 pub type DINameSpace = DIScope;
791 pub type DIType = DIDescriptor;
792 pub type DIBasicType = DIType;
793 pub type DIDerivedType = DIType;
794 pub type DICompositeType = DIDerivedType;
795 pub type DIVariable = DIDescriptor;
796 pub type DIGlobalVariableExpression = DIDescriptor;
797 pub type DIArray = DIDescriptor;
798 pub type DISubrange = DIDescriptor;
799 pub type DIEnumerator = DIDescriptor;
800 pub type DITemplateTypeParameter = DIDescriptor;
802 // These values **must** match with LLVMRustDIFlags!!
806 pub struct DIFlags: u32 {
808 const FlagPrivate = 1;
809 const FlagProtected = 2;
810 const FlagPublic = 3;
811 const FlagFwdDecl = (1 << 2);
812 const FlagAppleBlock = (1 << 3);
813 const FlagBlockByrefStruct = (1 << 4);
814 const FlagVirtual = (1 << 5);
815 const FlagArtificial = (1 << 6);
816 const FlagExplicit = (1 << 7);
817 const FlagPrototyped = (1 << 8);
818 const FlagObjcClassComplete = (1 << 9);
819 const FlagObjectPointer = (1 << 10);
820 const FlagVector = (1 << 11);
821 const FlagStaticMember = (1 << 12);
822 const FlagLValueReference = (1 << 13);
823 const FlagRValueReference = (1 << 14);
824 const FlagExternalTypeRef = (1 << 15);
825 const FlagIntroducedVirtual = (1 << 18);
826 const FlagBitField = (1 << 19);
827 const FlagNoReturn = (1 << 20);
831 // These values **must** match with LLVMRustDISPFlags!!
835 pub struct DISPFlags: u32 {
836 const SPFlagZero = 0;
837 const SPFlagVirtual = 1;
838 const SPFlagPureVirtual = 2;
839 const SPFlagLocalToUnit = (1 << 2);
840 const SPFlagDefinition = (1 << 3);
841 const SPFlagOptimized = (1 << 4);
842 const SPFlagMainSubprogram = (1 << 5);
846 /// LLVMRustDebugEmissionKind
847 #[derive(Copy, Clone)]
849 pub enum DebugEmissionKind {
855 impl DebugEmissionKind {
856 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
857 use rustc_session::config::DebugInfo;
859 DebugInfo::None => DebugEmissionKind::NoDebug,
860 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
861 DebugInfo::Full => DebugEmissionKind::FullDebug,
868 pub type ModuleBuffer;
871 pub type SelfProfileBeforePassCallback =
872 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
873 pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
876 pub fn LLVMRustInstallFatalErrorHandler();
878 // Create and destroy contexts.
879 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
880 pub fn LLVMContextDispose(C: &'static mut Context);
881 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
884 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
885 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
886 pub fn LLVMCloneModule(M: &Module) -> &Module;
888 /// Data layout. See Module::getDataLayout.
889 pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
890 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
892 /// See Module::setModuleInlineAsm.
893 pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
894 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
896 /// See llvm::LLVMTypeKind::getTypeID.
897 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
899 // Operations on integer types
900 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
901 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
902 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
903 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
904 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
905 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
907 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
909 // Operations on real types
910 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
911 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
913 // Operations on function types
914 pub fn LLVMFunctionType(
915 ReturnType: &'a Type,
916 ParamTypes: *const &'a Type,
920 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
921 pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
923 // Operations on struct types
924 pub fn LLVMStructTypeInContext(
926 ElementTypes: *const &'a Type,
927 ElementCount: c_uint,
931 // Operations on array, pointer, and vector types (sequence types)
932 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
933 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
934 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
936 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
937 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
939 // Operations on other types
940 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
941 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
943 // Operations on all values
944 pub fn LLVMTypeOf(Val: &Value) -> &Type;
945 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
946 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
947 pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
948 pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
950 // Operations on constants of any type
951 pub fn LLVMConstNull(Ty: &Type) -> &Value;
952 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
954 // Operations on metadata
955 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
956 pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
957 pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
959 // Operations on scalar constants
960 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
961 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
962 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
963 pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
964 pub fn LLVMRustConstInt128Get(
965 ConstantVal: &ConstantInt,
971 // Operations on composite constants
972 pub fn LLVMConstStringInContext(
976 DontNullTerminate: Bool,
978 pub fn LLVMConstStructInContext(
980 ConstantVals: *const &'a Value,
985 pub fn LLVMConstArray(
987 ConstantVals: *const &'a Value,
990 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
992 // Constant expressions
993 pub fn LLVMConstInBoundsGEP(
994 ConstantVal: &'a Value,
995 ConstantIndices: *const &'a Value,
998 pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
999 pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1000 pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1001 pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1002 pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1003 pub fn LLVMConstExtractValue(
1004 AggConstant: &Value,
1005 IdxList: *const c_uint,
1009 // Operations on global variables, functions, and aliases (globals)
1010 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
1011 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
1012 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
1013 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
1014 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
1015 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
1016 pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
1017 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
1018 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1019 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1021 // Operations on global variables
1022 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
1023 pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1024 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
1025 pub fn LLVMRustGetOrInsertGlobal(
1027 Name: *const c_char,
1031 pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
1032 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1033 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1034 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
1035 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1036 pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
1037 pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
1038 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1039 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1040 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1041 pub fn LLVMRustGetNamedValue(
1043 Name: *const c_char,
1045 ) -> Option<&Value>;
1046 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1048 // Operations on functions
1049 pub fn LLVMRustGetOrInsertFunction(
1051 Name: *const c_char,
1053 FunctionTy: &'a Type,
1055 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1056 pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
1057 pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
1058 pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
1059 pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
1060 pub fn LLVMRustAddStructRetAttr(Fn: &Value, index: c_uint, ty: &Type);
1061 pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
1062 pub fn LLVMRustAddFunctionAttrStringValue(
1065 Name: *const c_char,
1066 Value: *const c_char,
1068 pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
1070 // Operations on parameters
1071 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1072 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
1073 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1075 // Operations on basic blocks
1076 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1077 pub fn LLVMAppendBasicBlockInContext(
1080 Name: *const c_char,
1081 ) -> &'a BasicBlock;
1083 // Operations on instructions
1084 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1085 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1087 // Operations on call sites
1088 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1089 pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
1090 pub fn LLVMRustAddCallSiteAttrString(Instr: &Value, index: c_uint, Name: *const c_char);
1091 pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
1092 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1093 pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1094 pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1095 pub fn LLVMRustAddStructRetCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1097 // Operations on load/store instructions (only)
1098 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1100 // Operations on phi nodes
1101 pub fn LLVMAddIncoming(
1103 IncomingValues: *const &'a Value,
1104 IncomingBlocks: *const &'a BasicBlock,
1108 // Instruction builders
1109 pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
1110 pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
1111 pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
1112 pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
1115 pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
1118 pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
1119 pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1120 pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1121 pub fn LLVMBuildCondBr(
1124 Then: &'a BasicBlock,
1125 Else: &'a BasicBlock,
1127 pub fn LLVMBuildSwitch(
1130 Else: &'a BasicBlock,
1133 pub fn LLVMRustBuildInvoke(
1136 Args: *const &'a Value,
1138 Then: &'a BasicBlock,
1139 Catch: &'a BasicBlock,
1140 Bundle: Option<&OperandBundleDef<'a>>,
1141 Name: *const c_char,
1143 pub fn LLVMBuildLandingPad(
1148 Name: *const c_char,
1150 pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1151 pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
1153 pub fn LLVMRustBuildCleanupPad(
1155 ParentPad: Option<&'a Value>,
1157 Args: *const &'a Value,
1158 Name: *const c_char,
1159 ) -> Option<&'a Value>;
1160 pub fn LLVMRustBuildCleanupRet(
1162 CleanupPad: &'a Value,
1163 UnwindBB: Option<&'a BasicBlock>,
1164 ) -> Option<&'a Value>;
1165 pub fn LLVMRustBuildCatchPad(
1167 ParentPad: &'a Value,
1169 Args: *const &'a Value,
1170 Name: *const c_char,
1171 ) -> Option<&'a Value>;
1172 pub fn LLVMRustBuildCatchRet(
1176 ) -> Option<&'a Value>;
1177 pub fn LLVMRustBuildCatchSwitch(
1178 Builder: &Builder<'a>,
1179 ParentPad: Option<&'a Value>,
1180 BB: Option<&'a BasicBlock>,
1181 NumHandlers: c_uint,
1182 Name: *const c_char,
1183 ) -> Option<&'a Value>;
1184 pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1185 pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
1187 // Add a case to the switch instruction
1188 pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1190 // Add a clause to the landing pad instruction
1191 pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
1193 // Set the cleanup on a landing pad instruction
1194 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1197 pub fn LLVMBuildAdd(
1201 Name: *const c_char,
1203 pub fn LLVMBuildFAdd(
1207 Name: *const c_char,
1209 pub fn LLVMBuildSub(
1213 Name: *const c_char,
1215 pub fn LLVMBuildFSub(
1219 Name: *const c_char,
1221 pub fn LLVMBuildMul(
1225 Name: *const c_char,
1227 pub fn LLVMBuildFMul(
1231 Name: *const c_char,
1233 pub fn LLVMBuildUDiv(
1237 Name: *const c_char,
1239 pub fn LLVMBuildExactUDiv(
1243 Name: *const c_char,
1245 pub fn LLVMBuildSDiv(
1249 Name: *const c_char,
1251 pub fn LLVMBuildExactSDiv(
1255 Name: *const c_char,
1257 pub fn LLVMBuildFDiv(
1261 Name: *const c_char,
1263 pub fn LLVMBuildURem(
1267 Name: *const c_char,
1269 pub fn LLVMBuildSRem(
1273 Name: *const c_char,
1275 pub fn LLVMBuildFRem(
1279 Name: *const c_char,
1281 pub fn LLVMBuildShl(
1285 Name: *const c_char,
1287 pub fn LLVMBuildLShr(
1291 Name: *const c_char,
1293 pub fn LLVMBuildAShr(
1297 Name: *const c_char,
1299 pub fn LLVMBuildNSWAdd(
1303 Name: *const c_char,
1305 pub fn LLVMBuildNUWAdd(
1309 Name: *const c_char,
1311 pub fn LLVMBuildNSWSub(
1315 Name: *const c_char,
1317 pub fn LLVMBuildNUWSub(
1321 Name: *const c_char,
1323 pub fn LLVMBuildNSWMul(
1327 Name: *const c_char,
1329 pub fn LLVMBuildNUWMul(
1333 Name: *const c_char,
1335 pub fn LLVMBuildAnd(
1339 Name: *const c_char,
1345 Name: *const c_char,
1347 pub fn LLVMBuildXor(
1351 Name: *const c_char,
1353 pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1354 pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1355 pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1356 pub fn LLVMRustSetFastMath(Instr: &Value);
1359 pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1360 pub fn LLVMBuildArrayAlloca(
1364 Name: *const c_char,
1366 pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
1368 pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1370 pub fn LLVMBuildGEP(
1373 Indices: *const &'a Value,
1375 Name: *const c_char,
1377 pub fn LLVMBuildInBoundsGEP(
1380 Indices: *const &'a Value,
1382 Name: *const c_char,
1384 pub fn LLVMBuildStructGEP(
1388 Name: *const c_char,
1392 pub fn LLVMBuildTrunc(
1396 Name: *const c_char,
1398 pub fn LLVMBuildZExt(
1402 Name: *const c_char,
1404 pub fn LLVMBuildSExt(
1408 Name: *const c_char,
1410 pub fn LLVMBuildFPToUI(
1414 Name: *const c_char,
1416 pub fn LLVMBuildFPToSI(
1420 Name: *const c_char,
1422 pub fn LLVMBuildUIToFP(
1426 Name: *const c_char,
1428 pub fn LLVMBuildSIToFP(
1432 Name: *const c_char,
1434 pub fn LLVMBuildFPTrunc(
1438 Name: *const c_char,
1440 pub fn LLVMBuildFPExt(
1444 Name: *const c_char,
1446 pub fn LLVMBuildPtrToInt(
1450 Name: *const c_char,
1452 pub fn LLVMBuildIntToPtr(
1456 Name: *const c_char,
1458 pub fn LLVMBuildBitCast(
1462 Name: *const c_char,
1464 pub fn LLVMBuildPointerCast(
1468 Name: *const c_char,
1470 pub fn LLVMRustBuildIntCast(
1478 pub fn LLVMBuildICmp(
1483 Name: *const c_char,
1485 pub fn LLVMBuildFCmp(
1490 Name: *const c_char,
1493 // Miscellaneous instructions
1494 pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1495 pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &'a Value;
1496 pub fn LLVMRustBuildCall(
1499 Args: *const &'a Value,
1501 Bundle: Option<&OperandBundleDef<'a>>,
1503 pub fn LLVMRustBuildMemCpy(
1512 pub fn LLVMRustBuildMemMove(
1521 pub fn LLVMRustBuildMemSet(
1529 pub fn LLVMBuildSelect(
1534 Name: *const c_char,
1536 pub fn LLVMBuildVAArg(
1540 Name: *const c_char,
1542 pub fn LLVMBuildExtractElement(
1546 Name: *const c_char,
1548 pub fn LLVMBuildInsertElement(
1553 Name: *const c_char,
1555 pub fn LLVMBuildShuffleVector(
1560 Name: *const c_char,
1562 pub fn LLVMBuildExtractValue(
1566 Name: *const c_char,
1568 pub fn LLVMBuildInsertValue(
1573 Name: *const c_char,
1576 pub fn LLVMRustBuildVectorReduceFAdd(
1581 pub fn LLVMRustBuildVectorReduceFMul(
1586 pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1587 pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1588 pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1589 pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1590 pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1591 pub fn LLVMRustBuildVectorReduceMin(
1596 pub fn LLVMRustBuildVectorReduceMax(
1601 pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1603 pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1606 pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1607 pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1609 // Atomic Operations
1610 pub fn LLVMRustBuildAtomicLoad(
1612 PointerVal: &'a Value,
1613 Name: *const c_char,
1614 Order: AtomicOrdering,
1617 pub fn LLVMRustBuildAtomicStore(
1621 Order: AtomicOrdering,
1624 pub fn LLVMRustBuildAtomicCmpXchg(
1629 Order: AtomicOrdering,
1630 FailureOrder: AtomicOrdering,
1634 pub fn LLVMBuildAtomicRMW(
1639 Order: AtomicOrdering,
1640 SingleThreaded: Bool,
1643 pub fn LLVMRustBuildAtomicFence(
1645 Order: AtomicOrdering,
1646 Scope: SynchronizationScope,
1649 /// Writes a module to the specified path. Returns 0 on success.
1650 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1652 /// Creates a pass manager.
1653 pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1655 /// Creates a function-by-function pass manager
1656 pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1658 /// Disposes a pass manager.
1659 pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1661 /// Runs a pass manager on a module.
1662 pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1664 pub fn LLVMInitializePasses();
1666 pub fn LLVMTimeTraceProfilerInitialize();
1668 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1670 pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>);
1672 pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1673 pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1674 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1675 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1676 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1677 PMB: &PassManagerBuilder,
1680 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1681 PMB: &PassManagerBuilder,
1682 PM: &PassManager<'_>,
1685 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1686 PMB: &PassManagerBuilder,
1687 PM: &PassManager<'_>,
1689 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1690 PMB: &PassManagerBuilder,
1691 PM: &PassManager<'_>,
1695 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1696 PMB: &PassManagerBuilder,
1697 PM: &PassManager<'_>,
1700 pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
1702 pub fn LLVMDisposeMessage(message: *mut c_char);
1704 // Stuff that's in llvm-wrapper/ because it's not upstream yet.
1706 /// Opens an object file.
1707 pub fn LLVMCreateObjectFile(
1708 MemBuf: &'static mut MemoryBuffer,
1709 ) -> Option<&'static mut ObjectFile>;
1710 /// Closes an object file.
1711 pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1713 /// Enumerates the sections in an object file.
1714 pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1715 /// Destroys a section iterator.
1716 pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1717 /// Returns `true` if the section iterator is at the end of the section
1719 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1720 /// Moves the section iterator to point to the next section.
1721 pub fn LLVMMoveToNextSection(SI: &SectionIterator<'_>);
1722 /// Returns the current section size.
1723 pub fn LLVMGetSectionSize(SI: &SectionIterator<'_>) -> c_ulonglong;
1724 /// Returns the current section contents as a string buffer.
1725 pub fn LLVMGetSectionContents(SI: &SectionIterator<'_>) -> *const c_char;
1727 /// Reads the given file and returns it as a memory buffer. Use
1728 /// LLVMDisposeMemoryBuffer() to get rid of it.
1729 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1730 Path: *const c_char,
1731 ) -> Option<&'static mut MemoryBuffer>;
1733 pub fn LLVMStartMultithreaded() -> Bool;
1735 /// Returns a string describing the last error caused by an LLVMRust* call.
1736 pub fn LLVMRustGetLastError() -> *const c_char;
1738 /// Print the pass timings since static dtors aren't picking them up.
1739 pub fn LLVMRustPrintPassTimings();
1741 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1743 pub fn LLVMStructSetBody(
1745 ElementTypes: *const &'a Type,
1746 ElementCount: c_uint,
1750 /// Prepares inline assembly.
1751 pub fn LLVMRustInlineAsm(
1753 AsmString: *const c_char,
1754 AsmStringLen: size_t,
1755 Constraints: *const c_char,
1756 ConstraintsLen: size_t,
1759 Dialect: AsmDialect,
1761 pub fn LLVMRustInlineAsmVerify(
1763 Constraints: *const c_char,
1764 ConstraintsLen: size_t,
1767 #[allow(improper_ctypes)]
1768 pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1769 Filenames: *const *const c_char,
1770 FilenamesLen: size_t,
1771 BufferOut: &RustString,
1774 #[allow(improper_ctypes)]
1775 pub fn LLVMRustCoverageWriteMappingToBuffer(
1776 VirtualFileMappingIDs: *const c_uint,
1777 NumVirtualFileMappingIDs: c_uint,
1778 Expressions: *const coverage_map::CounterExpression,
1779 NumExpressions: c_uint,
1780 MappingRegions: *const coverageinfo::CounterMappingRegion,
1781 NumMappingRegions: c_uint,
1782 BufferOut: &RustString,
1785 pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &'a Value, FuncName: *const c_char)
1787 pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64;
1788 pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
1790 #[allow(improper_ctypes)]
1791 pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
1793 #[allow(improper_ctypes)]
1794 pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
1796 #[allow(improper_ctypes)]
1797 pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1799 pub fn LLVMRustCoverageMappingVersion() -> u32;
1800 pub fn LLVMRustDebugMetadataVersion() -> u32;
1801 pub fn LLVMRustVersionMajor() -> u32;
1802 pub fn LLVMRustVersionMinor() -> u32;
1803 pub fn LLVMRustVersionPatch() -> u32;
1805 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1807 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1809 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1811 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1813 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1815 pub fn LLVMRustDIBuilderCreateCompileUnit(
1816 Builder: &DIBuilder<'a>,
1819 Producer: *const c_char,
1820 ProducerLen: size_t,
1822 Flags: *const c_char,
1824 SplitName: *const c_char,
1825 SplitNameLen: size_t,
1826 kind: DebugEmissionKind,
1828 SplitDebugInlining: bool,
1829 ) -> &'a DIDescriptor;
1831 pub fn LLVMRustDIBuilderCreateFile(
1832 Builder: &DIBuilder<'a>,
1833 Filename: *const c_char,
1834 FilenameLen: size_t,
1835 Directory: *const c_char,
1836 DirectoryLen: size_t,
1837 CSKind: ChecksumKind,
1838 Checksum: *const c_char,
1839 ChecksumLen: size_t,
1842 pub fn LLVMRustDIBuilderCreateSubroutineType(
1843 Builder: &DIBuilder<'a>,
1844 ParameterTypes: &'a DIArray,
1845 ) -> &'a DICompositeType;
1847 pub fn LLVMRustDIBuilderCreateFunction(
1848 Builder: &DIBuilder<'a>,
1849 Scope: &'a DIDescriptor,
1850 Name: *const c_char,
1852 LinkageName: *const c_char,
1853 LinkageNameLen: size_t,
1860 MaybeFn: Option<&'a Value>,
1861 TParam: &'a DIArray,
1862 Decl: Option<&'a DIDescriptor>,
1863 ) -> &'a DISubprogram;
1865 pub fn LLVMRustDIBuilderCreateBasicType(
1866 Builder: &DIBuilder<'a>,
1867 Name: *const c_char,
1871 ) -> &'a DIBasicType;
1873 pub fn LLVMRustDIBuilderCreateTypedef(
1874 Builder: &DIBuilder<'a>,
1875 Type: &'a DIBasicType,
1876 Name: *const c_char,
1880 Scope: Option<&'a DIScope>,
1881 ) -> &'a DIDerivedType;
1883 pub fn LLVMRustDIBuilderCreatePointerType(
1884 Builder: &DIBuilder<'a>,
1885 PointeeTy: &'a DIType,
1888 AddressSpace: c_uint,
1889 Name: *const c_char,
1891 ) -> &'a DIDerivedType;
1893 pub fn LLVMRustDIBuilderCreateStructType(
1894 Builder: &DIBuilder<'a>,
1895 Scope: Option<&'a DIDescriptor>,
1896 Name: *const c_char,
1903 DerivedFrom: Option<&'a DIType>,
1904 Elements: &'a DIArray,
1905 RunTimeLang: c_uint,
1906 VTableHolder: Option<&'a DIType>,
1907 UniqueId: *const c_char,
1908 UniqueIdLen: size_t,
1909 ) -> &'a DICompositeType;
1911 pub fn LLVMRustDIBuilderCreateMemberType(
1912 Builder: &DIBuilder<'a>,
1913 Scope: &'a DIDescriptor,
1914 Name: *const c_char,
1923 ) -> &'a DIDerivedType;
1925 pub fn LLVMRustDIBuilderCreateVariantMemberType(
1926 Builder: &DIBuilder<'a>,
1928 Name: *const c_char,
1935 Discriminant: Option<&'a Value>,
1940 pub fn LLVMRustDIBuilderCreateLexicalBlock(
1941 Builder: &DIBuilder<'a>,
1946 ) -> &'a DILexicalBlock;
1948 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(
1949 Builder: &DIBuilder<'a>,
1952 ) -> &'a DILexicalBlock;
1954 pub fn LLVMRustDIBuilderCreateStaticVariable(
1955 Builder: &DIBuilder<'a>,
1956 Context: Option<&'a DIScope>,
1957 Name: *const c_char,
1959 LinkageName: *const c_char,
1960 LinkageNameLen: size_t,
1964 isLocalToUnit: bool,
1966 Decl: Option<&'a DIDescriptor>,
1968 ) -> &'a DIGlobalVariableExpression;
1970 pub fn LLVMRustDIBuilderCreateVariable(
1971 Builder: &DIBuilder<'a>,
1973 Scope: &'a DIDescriptor,
1974 Name: *const c_char,
1979 AlwaysPreserve: bool,
1983 ) -> &'a DIVariable;
1985 pub fn LLVMRustDIBuilderCreateArrayType(
1986 Builder: &DIBuilder<'a>,
1990 Subscripts: &'a DIArray,
1993 pub fn LLVMRustDIBuilderGetOrCreateSubrange(
1994 Builder: &DIBuilder<'a>,
1997 ) -> &'a DISubrange;
1999 pub fn LLVMRustDIBuilderGetOrCreateArray(
2000 Builder: &DIBuilder<'a>,
2001 Ptr: *const Option<&'a DIDescriptor>,
2005 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(
2006 Builder: &DIBuilder<'a>,
2008 VarInfo: &'a DIVariable,
2009 AddrOps: *const i64,
2010 AddrOpsCount: c_uint,
2012 InsertAtEnd: &'a BasicBlock,
2015 pub fn LLVMRustDIBuilderCreateEnumerator(
2016 Builder: &DIBuilder<'a>,
2017 Name: *const c_char,
2021 ) -> &'a DIEnumerator;
2023 pub fn LLVMRustDIBuilderCreateEnumerationType(
2024 Builder: &DIBuilder<'a>,
2026 Name: *const c_char,
2032 Elements: &'a DIArray,
2033 ClassType: &'a DIType,
2037 pub fn LLVMRustDIBuilderCreateUnionType(
2038 Builder: &DIBuilder<'a>,
2040 Name: *const c_char,
2047 Elements: Option<&'a DIArray>,
2048 RunTimeLang: c_uint,
2049 UniqueId: *const c_char,
2050 UniqueIdLen: size_t,
2053 pub fn LLVMRustDIBuilderCreateVariantPart(
2054 Builder: &DIBuilder<'a>,
2056 Name: *const c_char,
2063 Discriminator: Option<&'a DIDerivedType>,
2064 Elements: &'a DIArray,
2065 UniqueId: *const c_char,
2066 UniqueIdLen: size_t,
2067 ) -> &'a DIDerivedType;
2069 pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
2071 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
2072 Builder: &DIBuilder<'a>,
2073 Scope: Option<&'a DIScope>,
2074 Name: *const c_char,
2077 ) -> &'a DITemplateTypeParameter;
2079 pub fn LLVMRustDIBuilderCreateNameSpace(
2080 Builder: &DIBuilder<'a>,
2081 Scope: Option<&'a DIScope>,
2082 Name: *const c_char,
2084 ExportSymbols: bool,
2085 ) -> &'a DINameSpace;
2087 pub fn LLVMRustDICompositeTypeReplaceArrays(
2088 Builder: &DIBuilder<'a>,
2089 CompositeType: &'a DIType,
2090 Elements: Option<&'a DIArray>,
2091 Params: Option<&'a DIArray>,
2094 pub fn LLVMRustDIBuilderCreateDebugLocation(
2098 InlinedAt: Option<&'a DILocation>,
2099 ) -> &'a DILocation;
2100 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
2101 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
2103 #[allow(improper_ctypes)]
2104 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2105 #[allow(improper_ctypes)]
2106 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2108 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2110 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
2111 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
2112 pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
2113 pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2114 pub fn LLVMRustCreateMemorySanitizerPass(
2115 TrackOrigins: c_int,
2117 ) -> &'static mut Pass;
2118 pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
2119 pub fn LLVMRustCreateHWAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2120 pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
2121 pub fn LLVMRustAddLastExtensionPasses(
2122 PMB: &PassManagerBuilder,
2123 Passes: *const &'static mut Pass,
2127 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2129 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
2130 pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2131 pub fn LLVMRustGetTargetFeature(
2134 Feature: &mut *const c_char,
2135 Desc: &mut *const c_char,
2138 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2139 pub fn LLVMRustCreateTargetMachine(
2140 Triple: *const c_char,
2142 Features: *const c_char,
2146 Level: CodeGenOptLevel,
2148 FunctionSections: bool,
2150 TrapUnreachable: bool,
2153 EmitStackSizeSection: bool,
2154 RelaxELFRelocations: bool,
2156 SplitDwarfFile: *const c_char,
2157 ) -> Option<&'static mut TargetMachine>;
2158 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
2159 pub fn LLVMRustAddBuilderLibraryInfo(
2160 PMB: &'a PassManagerBuilder,
2162 DisableSimplifyLibCalls: bool,
2164 pub fn LLVMRustConfigurePassManagerBuilder(
2165 PMB: &PassManagerBuilder,
2166 OptLevel: CodeGenOptLevel,
2167 MergeFunctions: bool,
2169 LoopVectorize: bool,
2170 PrepareForThinLTO: bool,
2171 PGOGenPath: *const c_char,
2172 PGOUsePath: *const c_char,
2174 pub fn LLVMRustAddLibraryInfo(
2175 PM: &PassManager<'a>,
2177 DisableSimplifyLibCalls: bool,
2179 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
2180 pub fn LLVMRustWriteOutputFile(
2181 T: &'a TargetMachine,
2182 PM: &PassManager<'a>,
2184 Output: *const c_char,
2185 DwoOutput: *const c_char,
2187 ) -> LLVMRustResult;
2188 pub fn LLVMRustOptimizeWithNewPassManager(
2190 TM: &'a TargetMachine,
2191 OptLevel: PassBuilderOptLevel,
2193 NoPrepopulatePasses: bool,
2195 UseThinLTOBuffers: bool,
2196 MergeFunctions: bool,
2199 LoopVectorize: bool,
2200 DisableSimplifyLibCalls: bool,
2201 EmitLifetimeMarkers: bool,
2202 SanitizerOptions: Option<&SanitizerOptions>,
2203 PGOGenPath: *const c_char,
2204 PGOUsePath: *const c_char,
2205 InstrumentCoverage: bool,
2206 InstrumentGCOV: bool,
2207 llvm_selfprofiler: *mut c_void,
2208 begin_callback: SelfProfileBeforePassCallback,
2209 end_callback: SelfProfileAfterPassCallback,
2210 ExtraPasses: *const c_char,
2211 ExtraPassesLen: size_t,
2212 ) -> LLVMRustResult;
2213 pub fn LLVMRustPrintModule(
2215 Output: *const c_char,
2216 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2217 ) -> LLVMRustResult;
2218 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2219 pub fn LLVMRustPrintPasses();
2220 pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
2221 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2222 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
2223 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2224 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
2226 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2227 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
2228 pub fn LLVMRustArchiveIteratorNext(
2229 AIR: &ArchiveIterator<'a>,
2230 ) -> Option<&'a mut ArchiveChild<'a>>;
2231 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2232 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2233 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
2234 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
2235 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2237 #[allow(improper_ctypes)]
2238 pub fn LLVMRustGetSectionName(
2239 SI: &SectionIterator<'_>,
2240 data: &mut Option<std::ptr::NonNull<c_char>>,
2243 #[allow(improper_ctypes)]
2244 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2246 pub fn LLVMContextSetDiagnosticHandler(
2248 Handler: DiagnosticHandler,
2249 DiagnosticContext: *mut c_void,
2252 #[allow(improper_ctypes)]
2253 pub fn LLVMRustUnpackOptimizationDiagnostic(
2254 DI: &'a DiagnosticInfo,
2255 pass_name_out: &RustString,
2256 function_out: &mut Option<&'a Value>,
2257 loc_line_out: &mut c_uint,
2258 loc_column_out: &mut c_uint,
2259 loc_filename_out: &RustString,
2260 message_out: &RustString,
2263 pub fn LLVMRustUnpackInlineAsmDiagnostic(
2264 DI: &'a DiagnosticInfo,
2265 level_out: &mut DiagnosticLevel,
2266 cookie_out: &mut c_uint,
2267 message_out: &mut Option<&'a Twine>,
2268 instruction_out: &mut Option<&'a Value>,
2271 #[allow(improper_ctypes)]
2272 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2273 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2275 pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2277 H: InlineAsmDiagHandler,
2281 #[allow(improper_ctypes)]
2282 pub fn LLVMRustUnpackSMDiagnostic(
2284 message_out: &RustString,
2285 buffer_out: &RustString,
2286 level_out: &mut DiagnosticLevel,
2287 loc_out: &mut c_uint,
2288 ranges_out: *mut c_uint,
2289 num_ranges: &mut usize,
2292 pub fn LLVMRustWriteArchive(
2295 Members: *const &RustArchiveMember<'_>,
2298 ) -> LLVMRustResult;
2299 pub fn LLVMRustArchiveMemberNew(
2300 Filename: *const c_char,
2301 Name: *const c_char,
2302 Child: Option<&ArchiveChild<'a>>,
2303 ) -> &'a mut RustArchiveMember<'a>;
2304 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
2306 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
2308 pub fn LLVMRustBuildOperandBundleDef(
2309 Name: *const c_char,
2310 Inputs: *const &'a Value,
2312 ) -> &'a mut OperandBundleDef<'a>;
2313 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
2315 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
2317 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2318 pub fn LLVMRustUnsetComdat(V: &Value);
2319 pub fn LLVMRustSetModulePICLevel(M: &Module);
2320 pub fn LLVMRustSetModulePIELevel(M: &Module);
2321 pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2322 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2323 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2324 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2325 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2326 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2328 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
2329 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2330 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2331 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2332 pub fn LLVMRustCreateThinLTOData(
2333 Modules: *const ThinLTOModule,
2335 PreservedSymbols: *const *const c_char,
2336 PreservedSymbolsLen: c_uint,
2337 ) -> Option<&'static mut ThinLTOData>;
2338 pub fn LLVMRustPrepareThinLTORename(
2341 Target: &TargetMachine,
2343 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2344 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2345 pub fn LLVMRustPrepareThinLTOImport(
2348 Target: &TargetMachine,
2350 pub fn LLVMRustGetThinLTOModuleImports(
2351 Data: *const ThinLTOData,
2352 ModuleNameCallback: ThinLTOModuleNameCallback,
2353 CallbackPayload: *mut c_void,
2355 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2356 pub fn LLVMRustParseBitcodeForLTO(
2360 Identifier: *const c_char,
2361 ) -> Option<&Module>;
2362 pub fn LLVMRustGetBitcodeSliceFromObjectData(
2365 out_len: &mut usize,
2367 pub fn LLVMRustThinLTOGetDICompileUnit(
2369 CU1: &mut *mut c_void,
2370 CU2: &mut *mut c_void,
2372 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2374 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
2375 pub fn LLVMRustLinkerAdd(
2376 linker: &Linker<'_>,
2377 bytecode: *const c_char,
2378 bytecode_len: usize,
2380 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);
2381 #[allow(improper_ctypes)]
2382 pub fn LLVMRustComputeLTOCacheKey(
2383 key_out: &RustString,
2384 mod_id: *const c_char,