1 #![allow(non_camel_case_types)]
2 #![allow(non_upper_case_globals)]
4 use rustc_codegen_ssa::coverageinfo::map as coverage_map;
6 use super::debuginfo::{
7 DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
8 DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace,
9 DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable,
13 use libc::{c_char, c_int, c_uint, size_t};
14 use libc::{c_ulonglong, c_void};
16 use std::marker::PhantomData;
18 use super::RustString;
20 pub type Bool = c_uint;
22 pub const True: Bool = 1 as Bool;
23 pub const False: Bool = 0 as Bool;
25 #[derive(Copy, Clone, PartialEq)]
27 #[allow(dead_code)] // Variants constructed by C++.
28 pub enum LLVMRustResult {
33 // Rust version of the C struct with the same name in rustc_llvm/llvm-wrapper/RustWrapper.cpp.
35 pub struct LLVMRustCOFFShortExport {
36 pub name: *const c_char,
37 pub ordinal_present: bool,
38 // value of `ordinal` only important when `ordinal_present` is true
42 impl LLVMRustCOFFShortExport {
43 pub fn new(name: *const c_char, ordinal: Option<u16>) -> LLVMRustCOFFShortExport {
44 LLVMRustCOFFShortExport {
46 ordinal_present: ordinal.is_some(),
47 ordinal: ordinal.unwrap_or(0),
52 /// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h.
54 /// We include only architectures supported on Windows.
55 #[derive(Copy, Clone, PartialEq)]
57 pub enum LLVMMachineType {
64 // Consts for the LLVM CallConv type, pre-cast to usize.
66 /// LLVM CallingConv::ID. Should we wrap this?
67 #[derive(Copy, Clone, PartialEq, Debug)]
73 X86StdcallCallConv = 64,
74 X86FastcallCallConv = 65,
75 ArmAapcsCallConv = 67,
83 AvrNonBlockingInterrupt = 84,
89 #[derive(Copy, Clone, PartialEq)]
93 AvailableExternallyLinkage = 1,
94 LinkOnceAnyLinkage = 2,
95 LinkOnceODRLinkage = 3,
101 ExternalWeakLinkage = 9,
105 // LLVMRustVisibility
107 #[derive(Copy, Clone, PartialEq)]
108 pub enum Visibility {
116 pub enum UnnamedAddr {
122 /// LLVMDLLStorageClass
123 #[derive(Copy, Clone)]
125 pub enum DLLStorageClass {
128 DllImport = 1, // Function to be imported from DLL.
130 DllExport = 2, // Function to be accessible from DLL.
133 /// Matches LLVMRustAttribute in LLVMWrapper.h
134 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
135 /// though it is not ABI compatible (since it's a C++ enum)
137 #[derive(Copy, Clone, Debug)]
152 OptimizeForSize = 13,
160 SanitizeAddress = 21,
166 InaccessibleMemOnly = 27,
167 SanitizeHWAddress = 28,
172 #[derive(Copy, Clone)]
174 pub enum IntPredicate {
188 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
190 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
191 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
192 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
193 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
194 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
195 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
196 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
197 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
198 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
199 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
204 /// LLVMRealPredicate
205 #[derive(Copy, Clone)]
207 pub enum RealPredicate {
208 RealPredicateFalse = 0,
223 RealPredicateTrue = 15,
227 pub fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self {
229 rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
230 RealPredicate::RealPredicateFalse
232 rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
233 rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
234 rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
235 rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
236 rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
237 rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
238 rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
239 rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
240 rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
241 rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
242 rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
243 rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
244 rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
245 rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
246 rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
247 RealPredicate::RealPredicateTrue
254 #[derive(Copy, Clone, PartialEq, Debug)]
280 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
282 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
283 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
284 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
285 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
286 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
287 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
288 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
289 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
290 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
291 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
292 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
293 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
294 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
295 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
296 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
297 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
298 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
299 TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
300 TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
301 TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX,
306 /// LLVMAtomicRmwBinOp
307 #[derive(Copy, Clone)]
309 pub enum AtomicRmwBinOp {
323 impl AtomicRmwBinOp {
324 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
326 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
327 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
328 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
329 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
330 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
331 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
332 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
333 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
334 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
335 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
336 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
341 /// LLVMAtomicOrdering
342 #[derive(Copy, Clone)]
344 pub enum AtomicOrdering {
349 // Consume = 3, // Not specified yet.
353 SequentiallyConsistent = 7,
356 impl AtomicOrdering {
357 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
359 rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
360 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
361 rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
362 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
363 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
364 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
365 AtomicOrdering::AcquireRelease
367 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
368 AtomicOrdering::SequentiallyConsistent
374 /// LLVMRustSynchronizationScope
375 #[derive(Copy, Clone)]
377 pub enum SynchronizationScope {
382 impl SynchronizationScope {
383 pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
385 rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
386 SynchronizationScope::SingleThread
388 rustc_codegen_ssa::common::SynchronizationScope::CrossThread => {
389 SynchronizationScope::CrossThread
396 #[derive(Copy, Clone)]
404 #[derive(Copy, Clone)]
406 pub enum MetadataType {
413 MD_invariant_load = 6,
417 MD_mem_parallel_loop_access = 10,
422 /// LLVMRustAsmDialect
423 #[derive(Copy, Clone)]
425 pub enum AsmDialect {
431 pub fn from_generic(asm: rustc_ast::LlvmAsmDialect) -> Self {
433 rustc_ast::LlvmAsmDialect::Att => AsmDialect::Att,
434 rustc_ast::LlvmAsmDialect::Intel => AsmDialect::Intel,
439 /// LLVMRustCodeGenOptLevel
440 #[derive(Copy, Clone, PartialEq)]
442 pub enum CodeGenOptLevel {
449 /// LLVMRustPassBuilderOptLevel
451 pub enum PassBuilderOptLevel {
471 /// LLVMRustSanitizerOptions
473 pub struct SanitizerOptions {
474 pub sanitize_address: bool,
475 pub sanitize_address_recover: bool,
476 pub sanitize_memory: bool,
477 pub sanitize_memory_recover: bool,
478 pub sanitize_memory_track_origins: c_int,
479 pub sanitize_thread: bool,
480 pub sanitize_hwaddress: bool,
481 pub sanitize_hwaddress_recover: bool,
485 #[derive(Copy, Clone, PartialEq)]
487 pub enum RelocModel {
496 /// LLVMRustCodeModel
497 #[derive(Copy, Clone)]
508 /// LLVMRustDiagnosticKind
509 #[derive(Copy, Clone)]
511 #[allow(dead_code)] // Variants constructed by C++.
512 pub enum DiagnosticKind {
516 DebugMetadataVersion,
519 OptimizationRemarkMissed,
520 OptimizationRemarkAnalysis,
521 OptimizationRemarkAnalysisFPCommute,
522 OptimizationRemarkAnalysisAliasing,
523 OptimizationRemarkOther,
531 /// LLVMRustDiagnosticLevel
532 #[derive(Copy, Clone)]
534 #[allow(dead_code)] // Variants constructed by C++.
535 pub enum DiagnosticLevel {
542 /// LLVMRustArchiveKind
543 #[derive(Copy, Clone)]
545 pub enum ArchiveKind {
553 #[derive(Copy, Clone, PartialEq, Debug)]
555 #[allow(dead_code)] // Variants constructed by C++.
562 /// LLVMRustThinLTOData
564 pub type ThinLTOData;
567 /// LLVMRustThinLTOBuffer
569 pub type ThinLTOBuffer;
572 // LLVMRustModuleNameCallback
573 pub type ThinLTOModuleNameCallback =
574 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
576 /// LLVMRustThinLTOModule
578 pub struct ThinLTOModule {
579 pub identifier: *const c_char,
584 /// LLVMThreadLocalMode
585 #[derive(Copy, Clone)]
587 pub enum ThreadLocalMode {
595 /// LLVMRustChecksumKind
596 #[derive(Copy, Clone)]
598 pub enum ChecksumKind {
609 struct InvariantOpaque<'a> {
610 _marker: PhantomData<&'a mut &'a ()>,
614 // Opaque pointer types
628 pub type ConstantInt;
637 pub struct Builder<'a>(InvariantOpaque<'a>);
639 pub type MemoryBuffer;
642 pub struct PassManager<'a>(InvariantOpaque<'a>);
644 pub type PassManagerBuilder;
650 pub type TargetMachine;
656 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
658 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
663 pub type DiagnosticInfo;
666 pub type SMDiagnostic;
669 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
671 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
673 pub struct Linker<'a>(InvariantOpaque<'a>);
675 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
676 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
678 pub mod coverageinfo {
679 use super::coverage_map;
681 /// 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)
682 #[derive(Copy, Clone, Debug)]
684 pub enum RegionKind {
685 /// A CodeRegion associates some code with a counter
688 /// An ExpansionRegion represents a file expansion region that associates
689 /// a source range with the expansion of a virtual source file, such as
690 /// for a macro instantiation or #include file.
693 /// A SkippedRegion represents a source range with code that was skipped
694 /// by a preprocessor or similar means.
697 /// A GapRegion is like a CodeRegion, but its count is only set as the
698 /// line execution count when its the only region in the line.
702 /// This struct provides LLVM's representation of a "CoverageMappingRegion", encoded into the
703 /// coverage map, in accordance with the
704 /// [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).
705 /// The struct composes fields representing the `Counter` type and value(s) (injected counter
706 /// ID, or expression type and operands), the source file (an indirect index into a "filenames
707 /// array", encoded separately), and source location (start and end positions of the represented
710 /// Matches LLVMRustCounterMappingRegion.
711 #[derive(Copy, Clone, Debug)]
713 pub struct CounterMappingRegion {
714 /// The counter type and type-dependent counter data, if any.
715 counter: coverage_map::Counter,
717 /// An indirect reference to the source filename. In the LLVM Coverage Mapping Format, the
718 /// file_id is an index into a function-specific `virtual_file_mapping` array of indexes
719 /// that, in turn, are used to look up the filename for this region.
722 /// If the `RegionKind` is an `ExpansionRegion`, the `expanded_file_id` can be used to find
723 /// the mapping regions created as a result of macro expansion, by checking if their file id
724 /// matches the expanded file id.
725 expanded_file_id: u32,
727 /// 1-based starting line of the mapping region.
730 /// 1-based starting column of the mapping region.
733 /// 1-based ending line of the mapping region.
736 /// 1-based ending column of the mapping region. If the high bit is set, the current
737 /// mapping region is a gap area.
743 impl CounterMappingRegion {
744 crate fn code_region(
745 counter: coverage_map::Counter,
760 kind: RegionKind::CodeRegion,
764 // This function might be used in the future; the LLVM API is still evolving, as is coverage
767 crate fn expansion_region(
769 expanded_file_id: u32,
776 counter: coverage_map::Counter::zero(),
783 kind: RegionKind::ExpansionRegion,
787 // This function might be used in the future; the LLVM API is still evolving, as is coverage
790 crate fn skipped_region(
798 counter: coverage_map::Counter::zero(),
805 kind: RegionKind::SkippedRegion,
809 // This function might be used in the future; the LLVM API is still evolving, as is coverage
813 counter: coverage_map::Counter,
827 end_col: (1_u32 << 31) | end_col,
828 kind: RegionKind::GapRegion,
835 use super::{InvariantOpaque, Metadata};
836 use bitflags::bitflags;
839 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
841 pub type DIDescriptor = Metadata;
842 pub type DILocation = Metadata;
843 pub type DIScope = DIDescriptor;
844 pub type DIFile = DIScope;
845 pub type DILexicalBlock = DIScope;
846 pub type DISubprogram = DIScope;
847 pub type DINameSpace = DIScope;
848 pub type DIType = DIDescriptor;
849 pub type DIBasicType = DIType;
850 pub type DIDerivedType = DIType;
851 pub type DICompositeType = DIDerivedType;
852 pub type DIVariable = DIDescriptor;
853 pub type DIGlobalVariableExpression = DIDescriptor;
854 pub type DIArray = DIDescriptor;
855 pub type DISubrange = DIDescriptor;
856 pub type DIEnumerator = DIDescriptor;
857 pub type DITemplateTypeParameter = DIDescriptor;
859 // These values **must** match with LLVMRustDIFlags!!
863 pub struct DIFlags: u32 {
865 const FlagPrivate = 1;
866 const FlagProtected = 2;
867 const FlagPublic = 3;
868 const FlagFwdDecl = (1 << 2);
869 const FlagAppleBlock = (1 << 3);
870 const FlagBlockByrefStruct = (1 << 4);
871 const FlagVirtual = (1 << 5);
872 const FlagArtificial = (1 << 6);
873 const FlagExplicit = (1 << 7);
874 const FlagPrototyped = (1 << 8);
875 const FlagObjcClassComplete = (1 << 9);
876 const FlagObjectPointer = (1 << 10);
877 const FlagVector = (1 << 11);
878 const FlagStaticMember = (1 << 12);
879 const FlagLValueReference = (1 << 13);
880 const FlagRValueReference = (1 << 14);
881 const FlagExternalTypeRef = (1 << 15);
882 const FlagIntroducedVirtual = (1 << 18);
883 const FlagBitField = (1 << 19);
884 const FlagNoReturn = (1 << 20);
888 // These values **must** match with LLVMRustDISPFlags!!
892 pub struct DISPFlags: u32 {
893 const SPFlagZero = 0;
894 const SPFlagVirtual = 1;
895 const SPFlagPureVirtual = 2;
896 const SPFlagLocalToUnit = (1 << 2);
897 const SPFlagDefinition = (1 << 3);
898 const SPFlagOptimized = (1 << 4);
899 const SPFlagMainSubprogram = (1 << 5);
903 /// LLVMRustDebugEmissionKind
904 #[derive(Copy, Clone)]
906 pub enum DebugEmissionKind {
912 impl DebugEmissionKind {
913 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
914 use rustc_session::config::DebugInfo;
916 DebugInfo::None => DebugEmissionKind::NoDebug,
917 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
918 DebugInfo::Full => DebugEmissionKind::FullDebug,
925 pub type ModuleBuffer;
928 pub type SelfProfileBeforePassCallback =
929 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
930 pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
933 pub fn LLVMRustInstallFatalErrorHandler();
935 // Create and destroy contexts.
936 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
937 pub fn LLVMContextDispose(C: &'static mut Context);
938 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
941 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
942 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
943 pub fn LLVMCloneModule(M: &Module) -> &Module;
945 /// Data layout. See Module::getDataLayout.
946 pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
947 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
949 /// See Module::setModuleInlineAsm.
950 pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
951 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
953 /// See llvm::LLVMTypeKind::getTypeID.
954 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
956 // Operations on integer types
957 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
958 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
959 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
960 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
961 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
962 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
964 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
966 // Operations on real types
967 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
968 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
970 // Operations on function types
971 pub fn LLVMFunctionType(
972 ReturnType: &'a Type,
973 ParamTypes: *const &'a Type,
977 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
978 pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
980 // Operations on struct types
981 pub fn LLVMStructTypeInContext(
983 ElementTypes: *const &'a Type,
984 ElementCount: c_uint,
988 // Operations on array, pointer, and vector types (sequence types)
989 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
990 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
991 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
993 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
994 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
996 // Operations on other types
997 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
998 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
1000 // Operations on all values
1001 pub fn LLVMTypeOf(Val: &Value) -> &Type;
1002 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
1003 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
1004 pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
1005 pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
1006 pub fn LLVMGlobalSetMetadata(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
1007 pub fn LLVMValueAsMetadata(Node: &'a Value) -> &Metadata;
1009 // Operations on constants of any type
1010 pub fn LLVMConstNull(Ty: &Type) -> &Value;
1011 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
1013 // Operations on metadata
1014 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
1015 pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
1016 pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
1018 // Operations on scalar constants
1019 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
1020 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
1021 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
1022 pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
1023 pub fn LLVMRustConstInt128Get(
1024 ConstantVal: &ConstantInt,
1030 // Operations on composite constants
1031 pub fn LLVMConstStringInContext(
1035 DontNullTerminate: Bool,
1037 pub fn LLVMConstStructInContext(
1039 ConstantVals: *const &'a Value,
1044 pub fn LLVMConstArray(
1045 ElementTy: &'a Type,
1046 ConstantVals: *const &'a Value,
1049 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
1051 // Constant expressions
1052 pub fn LLVMRustConstInBoundsGEP2(
1054 ConstantVal: &'a Value,
1055 ConstantIndices: *const &'a Value,
1058 pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1059 pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1060 pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1061 pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1062 pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1063 pub fn LLVMConstExtractValue(
1064 AggConstant: &Value,
1065 IdxList: *const c_uint,
1069 // Operations on global variables, functions, and aliases (globals)
1070 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
1071 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
1072 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
1073 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
1074 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
1075 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
1076 pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
1077 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
1078 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1079 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1081 // Operations on global variables
1082 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
1083 pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1084 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
1085 pub fn LLVMRustGetOrInsertGlobal(
1087 Name: *const c_char,
1091 pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
1092 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1093 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1094 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
1095 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1096 pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
1097 pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
1098 pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
1099 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1100 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1101 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1102 pub fn LLVMRustGetNamedValue(
1104 Name: *const c_char,
1106 ) -> Option<&Value>;
1107 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1109 // Operations on functions
1110 pub fn LLVMRustGetOrInsertFunction(
1112 Name: *const c_char,
1114 FunctionTy: &'a Type,
1116 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1117 pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
1118 pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
1119 pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
1120 pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
1121 pub fn LLVMRustAddStructRetAttr(Fn: &Value, index: c_uint, ty: &Type);
1122 pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
1123 pub fn LLVMRustAddFunctionAttrStringValue(
1126 Name: *const c_char,
1127 Value: *const c_char,
1129 pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
1131 // Operations on parameters
1132 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1133 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
1134 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1136 // Operations on basic blocks
1137 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1138 pub fn LLVMAppendBasicBlockInContext(
1141 Name: *const c_char,
1142 ) -> &'a BasicBlock;
1144 // Operations on instructions
1145 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1146 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1148 // Operations on call sites
1149 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1150 pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
1151 pub fn LLVMRustAddCallSiteAttrString(Instr: &Value, index: c_uint, Name: *const c_char);
1152 pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
1153 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1154 pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1155 pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1156 pub fn LLVMRustAddStructRetCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1158 // Operations on load/store instructions (only)
1159 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1161 // Operations on phi nodes
1162 pub fn LLVMAddIncoming(
1164 IncomingValues: *const &'a Value,
1165 IncomingBlocks: *const &'a BasicBlock,
1169 // Instruction builders
1170 pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
1171 pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
1172 pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
1173 pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
1176 pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
1179 pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
1180 pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1181 pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1182 pub fn LLVMBuildCondBr(
1185 Then: &'a BasicBlock,
1186 Else: &'a BasicBlock,
1188 pub fn LLVMBuildSwitch(
1191 Else: &'a BasicBlock,
1194 pub fn LLVMRustBuildInvoke(
1198 Args: *const &'a Value,
1200 Then: &'a BasicBlock,
1201 Catch: &'a BasicBlock,
1202 Bundle: Option<&OperandBundleDef<'a>>,
1203 Name: *const c_char,
1205 pub fn LLVMBuildLandingPad(
1208 PersFn: Option<&'a Value>,
1210 Name: *const c_char,
1212 pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1213 pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
1215 pub fn LLVMRustBuildCleanupPad(
1217 ParentPad: Option<&'a Value>,
1219 Args: *const &'a Value,
1220 Name: *const c_char,
1221 ) -> Option<&'a Value>;
1222 pub fn LLVMRustBuildCleanupRet(
1224 CleanupPad: &'a Value,
1225 UnwindBB: Option<&'a BasicBlock>,
1226 ) -> Option<&'a Value>;
1227 pub fn LLVMRustBuildCatchPad(
1229 ParentPad: &'a Value,
1231 Args: *const &'a Value,
1232 Name: *const c_char,
1233 ) -> Option<&'a Value>;
1234 pub fn LLVMRustBuildCatchRet(
1238 ) -> Option<&'a Value>;
1239 pub fn LLVMRustBuildCatchSwitch(
1240 Builder: &Builder<'a>,
1241 ParentPad: Option<&'a Value>,
1242 BB: Option<&'a BasicBlock>,
1243 NumHandlers: c_uint,
1244 Name: *const c_char,
1245 ) -> Option<&'a Value>;
1246 pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1247 pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
1249 // Add a case to the switch instruction
1250 pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1252 // Add a clause to the landing pad instruction
1253 pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
1255 // Set the cleanup on a landing pad instruction
1256 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1259 pub fn LLVMBuildAdd(
1263 Name: *const c_char,
1265 pub fn LLVMBuildFAdd(
1269 Name: *const c_char,
1271 pub fn LLVMBuildSub(
1275 Name: *const c_char,
1277 pub fn LLVMBuildFSub(
1281 Name: *const c_char,
1283 pub fn LLVMBuildMul(
1287 Name: *const c_char,
1289 pub fn LLVMBuildFMul(
1293 Name: *const c_char,
1295 pub fn LLVMBuildUDiv(
1299 Name: *const c_char,
1301 pub fn LLVMBuildExactUDiv(
1305 Name: *const c_char,
1307 pub fn LLVMBuildSDiv(
1311 Name: *const c_char,
1313 pub fn LLVMBuildExactSDiv(
1317 Name: *const c_char,
1319 pub fn LLVMBuildFDiv(
1323 Name: *const c_char,
1325 pub fn LLVMBuildURem(
1329 Name: *const c_char,
1331 pub fn LLVMBuildSRem(
1335 Name: *const c_char,
1337 pub fn LLVMBuildFRem(
1341 Name: *const c_char,
1343 pub fn LLVMBuildShl(
1347 Name: *const c_char,
1349 pub fn LLVMBuildLShr(
1353 Name: *const c_char,
1355 pub fn LLVMBuildAShr(
1359 Name: *const c_char,
1361 pub fn LLVMBuildNSWAdd(
1365 Name: *const c_char,
1367 pub fn LLVMBuildNUWAdd(
1371 Name: *const c_char,
1373 pub fn LLVMBuildNSWSub(
1377 Name: *const c_char,
1379 pub fn LLVMBuildNUWSub(
1383 Name: *const c_char,
1385 pub fn LLVMBuildNSWMul(
1389 Name: *const c_char,
1391 pub fn LLVMBuildNUWMul(
1395 Name: *const c_char,
1397 pub fn LLVMBuildAnd(
1401 Name: *const c_char,
1407 Name: *const c_char,
1409 pub fn LLVMBuildXor(
1413 Name: *const c_char,
1415 pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1416 pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1417 pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1418 pub fn LLVMRustSetFastMath(Instr: &Value);
1421 pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1422 pub fn LLVMBuildArrayAlloca(
1426 Name: *const c_char,
1428 pub fn LLVMBuildLoad2(
1431 PointerVal: &'a Value,
1432 Name: *const c_char,
1435 pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1437 pub fn LLVMBuildGEP2(
1441 Indices: *const &'a Value,
1443 Name: *const c_char,
1445 pub fn LLVMBuildInBoundsGEP2(
1449 Indices: *const &'a Value,
1451 Name: *const c_char,
1453 pub fn LLVMBuildStructGEP2(
1458 Name: *const c_char,
1462 pub fn LLVMBuildTrunc(
1466 Name: *const c_char,
1468 pub fn LLVMBuildZExt(
1472 Name: *const c_char,
1474 pub fn LLVMBuildSExt(
1478 Name: *const c_char,
1480 pub fn LLVMBuildFPToUI(
1484 Name: *const c_char,
1486 pub fn LLVMBuildFPToSI(
1490 Name: *const c_char,
1492 pub fn LLVMBuildUIToFP(
1496 Name: *const c_char,
1498 pub fn LLVMBuildSIToFP(
1502 Name: *const c_char,
1504 pub fn LLVMBuildFPTrunc(
1508 Name: *const c_char,
1510 pub fn LLVMBuildFPExt(
1514 Name: *const c_char,
1516 pub fn LLVMBuildPtrToInt(
1520 Name: *const c_char,
1522 pub fn LLVMBuildIntToPtr(
1526 Name: *const c_char,
1528 pub fn LLVMBuildBitCast(
1532 Name: *const c_char,
1534 pub fn LLVMBuildPointerCast(
1538 Name: *const c_char,
1540 pub fn LLVMRustBuildIntCast(
1548 pub fn LLVMBuildICmp(
1553 Name: *const c_char,
1555 pub fn LLVMBuildFCmp(
1560 Name: *const c_char,
1563 // Miscellaneous instructions
1564 pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1565 pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &'a Value;
1566 pub fn LLVMRustBuildCall(
1570 Args: *const &'a Value,
1572 Bundle: Option<&OperandBundleDef<'a>>,
1574 pub fn LLVMRustBuildMemCpy(
1583 pub fn LLVMRustBuildMemMove(
1592 pub fn LLVMRustBuildMemSet(
1600 pub fn LLVMBuildSelect(
1605 Name: *const c_char,
1607 pub fn LLVMBuildVAArg(
1611 Name: *const c_char,
1613 pub fn LLVMBuildExtractElement(
1617 Name: *const c_char,
1619 pub fn LLVMBuildInsertElement(
1624 Name: *const c_char,
1626 pub fn LLVMBuildShuffleVector(
1631 Name: *const c_char,
1633 pub fn LLVMBuildExtractValue(
1637 Name: *const c_char,
1639 pub fn LLVMBuildInsertValue(
1644 Name: *const c_char,
1647 pub fn LLVMRustBuildVectorReduceFAdd(
1652 pub fn LLVMRustBuildVectorReduceFMul(
1657 pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1658 pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1659 pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1660 pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1661 pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1662 pub fn LLVMRustBuildVectorReduceMin(
1667 pub fn LLVMRustBuildVectorReduceMax(
1672 pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1674 pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1677 pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1678 pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1680 // Atomic Operations
1681 pub fn LLVMRustBuildAtomicLoad(
1683 ElementType: &'a Type,
1684 PointerVal: &'a Value,
1685 Name: *const c_char,
1686 Order: AtomicOrdering,
1689 pub fn LLVMRustBuildAtomicStore(
1693 Order: AtomicOrdering,
1696 pub fn LLVMRustBuildAtomicCmpXchg(
1701 Order: AtomicOrdering,
1702 FailureOrder: AtomicOrdering,
1706 pub fn LLVMBuildAtomicRMW(
1711 Order: AtomicOrdering,
1712 SingleThreaded: Bool,
1715 pub fn LLVMRustBuildAtomicFence(
1717 Order: AtomicOrdering,
1718 Scope: SynchronizationScope,
1721 /// Writes a module to the specified path. Returns 0 on success.
1722 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1724 /// Creates a pass manager.
1725 pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1727 /// Creates a function-by-function pass manager
1728 pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1730 /// Disposes a pass manager.
1731 pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1733 /// Runs a pass manager on a module.
1734 pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1736 pub fn LLVMInitializePasses();
1738 pub fn LLVMTimeTraceProfilerInitialize();
1740 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1742 pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>);
1744 pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1745 pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1746 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1747 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1748 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1749 PMB: &PassManagerBuilder,
1752 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1753 PMB: &PassManagerBuilder,
1754 PM: &PassManager<'_>,
1757 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1758 PMB: &PassManagerBuilder,
1759 PM: &PassManager<'_>,
1761 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1762 PMB: &PassManagerBuilder,
1763 PM: &PassManager<'_>,
1767 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1768 PMB: &PassManagerBuilder,
1769 PM: &PassManager<'_>,
1772 pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
1774 pub fn LLVMDisposeMessage(message: *mut c_char);
1776 pub fn LLVMIsMultithreaded() -> Bool;
1778 /// Returns a string describing the last error caused by an LLVMRust* call.
1779 pub fn LLVMRustGetLastError() -> *const c_char;
1781 /// Print the pass timings since static dtors aren't picking them up.
1782 pub fn LLVMRustPrintPassTimings();
1784 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1786 pub fn LLVMStructSetBody(
1788 ElementTypes: *const &'a Type,
1789 ElementCount: c_uint,
1793 /// Prepares inline assembly.
1794 pub fn LLVMRustInlineAsm(
1796 AsmString: *const c_char,
1797 AsmStringLen: size_t,
1798 Constraints: *const c_char,
1799 ConstraintsLen: size_t,
1802 Dialect: AsmDialect,
1804 pub fn LLVMRustInlineAsmVerify(
1806 Constraints: *const c_char,
1807 ConstraintsLen: size_t,
1810 #[allow(improper_ctypes)]
1811 pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1812 Filenames: *const *const c_char,
1813 FilenamesLen: size_t,
1814 BufferOut: &RustString,
1817 #[allow(improper_ctypes)]
1818 pub fn LLVMRustCoverageWriteMappingToBuffer(
1819 VirtualFileMappingIDs: *const c_uint,
1820 NumVirtualFileMappingIDs: c_uint,
1821 Expressions: *const coverage_map::CounterExpression,
1822 NumExpressions: c_uint,
1823 MappingRegions: *const coverageinfo::CounterMappingRegion,
1824 NumMappingRegions: c_uint,
1825 BufferOut: &RustString,
1828 pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &'a Value, FuncName: *const c_char)
1830 pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64;
1831 pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
1833 #[allow(improper_ctypes)]
1834 pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
1836 #[allow(improper_ctypes)]
1837 pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
1839 #[allow(improper_ctypes)]
1840 pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1842 pub fn LLVMRustCoverageMappingVersion() -> u32;
1843 pub fn LLVMRustDebugMetadataVersion() -> u32;
1844 pub fn LLVMRustVersionMajor() -> u32;
1845 pub fn LLVMRustVersionMinor() -> u32;
1846 pub fn LLVMRustVersionPatch() -> u32;
1848 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1850 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1852 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1854 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1856 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1858 pub fn LLVMRustDIBuilderCreateCompileUnit(
1859 Builder: &DIBuilder<'a>,
1862 Producer: *const c_char,
1863 ProducerLen: size_t,
1865 Flags: *const c_char,
1867 SplitName: *const c_char,
1868 SplitNameLen: size_t,
1869 kind: DebugEmissionKind,
1871 SplitDebugInlining: bool,
1872 ) -> &'a DIDescriptor;
1874 pub fn LLVMRustDIBuilderCreateFile(
1875 Builder: &DIBuilder<'a>,
1876 Filename: *const c_char,
1877 FilenameLen: size_t,
1878 Directory: *const c_char,
1879 DirectoryLen: size_t,
1880 CSKind: ChecksumKind,
1881 Checksum: *const c_char,
1882 ChecksumLen: size_t,
1885 pub fn LLVMRustDIBuilderCreateSubroutineType(
1886 Builder: &DIBuilder<'a>,
1887 ParameterTypes: &'a DIArray,
1888 ) -> &'a DICompositeType;
1890 pub fn LLVMRustDIBuilderCreateFunction(
1891 Builder: &DIBuilder<'a>,
1892 Scope: &'a DIDescriptor,
1893 Name: *const c_char,
1895 LinkageName: *const c_char,
1896 LinkageNameLen: size_t,
1903 MaybeFn: Option<&'a Value>,
1904 TParam: &'a DIArray,
1905 Decl: Option<&'a DIDescriptor>,
1906 ) -> &'a DISubprogram;
1908 pub fn LLVMRustDIBuilderCreateBasicType(
1909 Builder: &DIBuilder<'a>,
1910 Name: *const c_char,
1914 ) -> &'a DIBasicType;
1916 pub fn LLVMRustDIBuilderCreateTypedef(
1917 Builder: &DIBuilder<'a>,
1918 Type: &'a DIBasicType,
1919 Name: *const c_char,
1923 Scope: Option<&'a DIScope>,
1924 ) -> &'a DIDerivedType;
1926 pub fn LLVMRustDIBuilderCreatePointerType(
1927 Builder: &DIBuilder<'a>,
1928 PointeeTy: &'a DIType,
1931 AddressSpace: c_uint,
1932 Name: *const c_char,
1934 ) -> &'a DIDerivedType;
1936 pub fn LLVMRustDIBuilderCreateStructType(
1937 Builder: &DIBuilder<'a>,
1938 Scope: Option<&'a DIDescriptor>,
1939 Name: *const c_char,
1946 DerivedFrom: Option<&'a DIType>,
1947 Elements: &'a DIArray,
1948 RunTimeLang: c_uint,
1949 VTableHolder: Option<&'a DIType>,
1950 UniqueId: *const c_char,
1951 UniqueIdLen: size_t,
1952 ) -> &'a DICompositeType;
1954 pub fn LLVMRustDIBuilderCreateMemberType(
1955 Builder: &DIBuilder<'a>,
1956 Scope: &'a DIDescriptor,
1957 Name: *const c_char,
1966 ) -> &'a DIDerivedType;
1968 pub fn LLVMRustDIBuilderCreateVariantMemberType(
1969 Builder: &DIBuilder<'a>,
1971 Name: *const c_char,
1978 Discriminant: Option<&'a Value>,
1983 pub fn LLVMRustDIBuilderCreateLexicalBlock(
1984 Builder: &DIBuilder<'a>,
1989 ) -> &'a DILexicalBlock;
1991 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(
1992 Builder: &DIBuilder<'a>,
1995 ) -> &'a DILexicalBlock;
1997 pub fn LLVMRustDIBuilderCreateStaticVariable(
1998 Builder: &DIBuilder<'a>,
1999 Context: Option<&'a DIScope>,
2000 Name: *const c_char,
2002 LinkageName: *const c_char,
2003 LinkageNameLen: size_t,
2007 isLocalToUnit: bool,
2009 Decl: Option<&'a DIDescriptor>,
2011 ) -> &'a DIGlobalVariableExpression;
2013 pub fn LLVMRustDIBuilderCreateVariable(
2014 Builder: &DIBuilder<'a>,
2016 Scope: &'a DIDescriptor,
2017 Name: *const c_char,
2022 AlwaysPreserve: bool,
2026 ) -> &'a DIVariable;
2028 pub fn LLVMRustDIBuilderCreateArrayType(
2029 Builder: &DIBuilder<'a>,
2033 Subscripts: &'a DIArray,
2036 pub fn LLVMRustDIBuilderGetOrCreateSubrange(
2037 Builder: &DIBuilder<'a>,
2040 ) -> &'a DISubrange;
2042 pub fn LLVMRustDIBuilderGetOrCreateArray(
2043 Builder: &DIBuilder<'a>,
2044 Ptr: *const Option<&'a DIDescriptor>,
2048 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(
2049 Builder: &DIBuilder<'a>,
2051 VarInfo: &'a DIVariable,
2052 AddrOps: *const i64,
2053 AddrOpsCount: c_uint,
2055 InsertAtEnd: &'a BasicBlock,
2058 pub fn LLVMRustDIBuilderCreateEnumerator(
2059 Builder: &DIBuilder<'a>,
2060 Name: *const c_char,
2064 ) -> &'a DIEnumerator;
2066 pub fn LLVMRustDIBuilderCreateEnumerationType(
2067 Builder: &DIBuilder<'a>,
2069 Name: *const c_char,
2075 Elements: &'a DIArray,
2076 ClassType: &'a DIType,
2080 pub fn LLVMRustDIBuilderCreateUnionType(
2081 Builder: &DIBuilder<'a>,
2082 Scope: Option<&'a DIScope>,
2083 Name: *const c_char,
2090 Elements: Option<&'a DIArray>,
2091 RunTimeLang: c_uint,
2092 UniqueId: *const c_char,
2093 UniqueIdLen: size_t,
2096 pub fn LLVMRustDIBuilderCreateVariantPart(
2097 Builder: &DIBuilder<'a>,
2099 Name: *const c_char,
2106 Discriminator: Option<&'a DIDerivedType>,
2107 Elements: &'a DIArray,
2108 UniqueId: *const c_char,
2109 UniqueIdLen: size_t,
2110 ) -> &'a DIDerivedType;
2112 pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
2114 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
2115 Builder: &DIBuilder<'a>,
2116 Scope: Option<&'a DIScope>,
2117 Name: *const c_char,
2120 ) -> &'a DITemplateTypeParameter;
2122 pub fn LLVMRustDIBuilderCreateNameSpace(
2123 Builder: &DIBuilder<'a>,
2124 Scope: Option<&'a DIScope>,
2125 Name: *const c_char,
2127 ExportSymbols: bool,
2128 ) -> &'a DINameSpace;
2130 pub fn LLVMRustDICompositeTypeReplaceArrays(
2131 Builder: &DIBuilder<'a>,
2132 CompositeType: &'a DIType,
2133 Elements: Option<&'a DIArray>,
2134 Params: Option<&'a DIArray>,
2137 pub fn LLVMRustDIBuilderCreateDebugLocation(
2141 InlinedAt: Option<&'a DILocation>,
2142 ) -> &'a DILocation;
2143 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
2144 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
2146 #[allow(improper_ctypes)]
2147 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2148 #[allow(improper_ctypes)]
2149 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2151 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2153 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
2154 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
2155 pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
2156 pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2157 pub fn LLVMRustCreateMemorySanitizerPass(
2158 TrackOrigins: c_int,
2160 ) -> &'static mut Pass;
2161 pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
2162 pub fn LLVMRustCreateHWAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2163 pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
2164 pub fn LLVMRustAddLastExtensionPasses(
2165 PMB: &PassManagerBuilder,
2166 Passes: *const &'static mut Pass,
2170 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2172 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
2173 pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2174 pub fn LLVMRustGetTargetFeature(
2177 Feature: &mut *const c_char,
2178 Desc: &mut *const c_char,
2181 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2182 pub fn LLVMRustCreateTargetMachine(
2183 Triple: *const c_char,
2185 Features: *const c_char,
2189 Level: CodeGenOptLevel,
2191 FunctionSections: bool,
2193 UniqueSectionNames: bool,
2194 TrapUnreachable: bool,
2197 EmitStackSizeSection: bool,
2198 RelaxELFRelocations: bool,
2200 SplitDwarfFile: *const c_char,
2201 ) -> Option<&'static mut TargetMachine>;
2202 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
2203 pub fn LLVMRustAddBuilderLibraryInfo(
2204 PMB: &'a PassManagerBuilder,
2206 DisableSimplifyLibCalls: bool,
2208 pub fn LLVMRustConfigurePassManagerBuilder(
2209 PMB: &PassManagerBuilder,
2210 OptLevel: CodeGenOptLevel,
2211 MergeFunctions: bool,
2213 LoopVectorize: bool,
2214 PrepareForThinLTO: bool,
2215 PGOGenPath: *const c_char,
2216 PGOUsePath: *const c_char,
2217 PGOSampleUsePath: *const c_char,
2219 pub fn LLVMRustAddLibraryInfo(
2220 PM: &PassManager<'a>,
2222 DisableSimplifyLibCalls: bool,
2224 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
2225 pub fn LLVMRustWriteOutputFile(
2226 T: &'a TargetMachine,
2227 PM: &PassManager<'a>,
2229 Output: *const c_char,
2230 DwoOutput: *const c_char,
2232 ) -> LLVMRustResult;
2233 pub fn LLVMRustOptimizeWithNewPassManager(
2235 TM: &'a TargetMachine,
2236 OptLevel: PassBuilderOptLevel,
2238 NoPrepopulatePasses: bool,
2240 UseThinLTOBuffers: bool,
2241 MergeFunctions: bool,
2244 LoopVectorize: bool,
2245 DisableSimplifyLibCalls: bool,
2246 EmitLifetimeMarkers: bool,
2247 SanitizerOptions: Option<&SanitizerOptions>,
2248 PGOGenPath: *const c_char,
2249 PGOUsePath: *const c_char,
2250 InstrumentCoverage: bool,
2251 InstrumentGCOV: bool,
2252 PGOSampleUsePath: *const c_char,
2253 DebugInfoForProfiling: bool,
2254 llvm_selfprofiler: *mut c_void,
2255 begin_callback: SelfProfileBeforePassCallback,
2256 end_callback: SelfProfileAfterPassCallback,
2257 ExtraPasses: *const c_char,
2258 ExtraPassesLen: size_t,
2259 ) -> LLVMRustResult;
2260 pub fn LLVMRustPrintModule(
2262 Output: *const c_char,
2263 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2264 ) -> LLVMRustResult;
2265 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2266 pub fn LLVMRustPrintPasses();
2267 pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
2268 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2269 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
2270 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2271 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
2273 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2274 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
2275 pub fn LLVMRustArchiveIteratorNext(
2276 AIR: &ArchiveIterator<'a>,
2277 ) -> Option<&'a mut ArchiveChild<'a>>;
2278 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2279 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2280 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
2281 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
2282 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2284 #[allow(improper_ctypes)]
2285 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2287 pub fn LLVMContextSetDiagnosticHandler(
2289 Handler: DiagnosticHandler,
2290 DiagnosticContext: *mut c_void,
2293 #[allow(improper_ctypes)]
2294 pub fn LLVMRustUnpackOptimizationDiagnostic(
2295 DI: &'a DiagnosticInfo,
2296 pass_name_out: &RustString,
2297 function_out: &mut Option<&'a Value>,
2298 loc_line_out: &mut c_uint,
2299 loc_column_out: &mut c_uint,
2300 loc_filename_out: &RustString,
2301 message_out: &RustString,
2304 pub fn LLVMRustUnpackInlineAsmDiagnostic(
2305 DI: &'a DiagnosticInfo,
2306 level_out: &mut DiagnosticLevel,
2307 cookie_out: &mut c_uint,
2308 message_out: &mut Option<&'a Twine>,
2311 #[allow(improper_ctypes)]
2312 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2313 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2315 pub fn LLVMRustGetSMDiagnostic(
2316 DI: &'a DiagnosticInfo,
2317 cookie_out: &mut c_uint,
2318 ) -> &'a SMDiagnostic;
2320 pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2322 H: InlineAsmDiagHandler,
2326 #[allow(improper_ctypes)]
2327 pub fn LLVMRustUnpackSMDiagnostic(
2329 message_out: &RustString,
2330 buffer_out: &RustString,
2331 level_out: &mut DiagnosticLevel,
2332 loc_out: &mut c_uint,
2333 ranges_out: *mut c_uint,
2334 num_ranges: &mut usize,
2337 pub fn LLVMRustWriteArchive(
2340 Members: *const &RustArchiveMember<'_>,
2343 ) -> LLVMRustResult;
2344 pub fn LLVMRustArchiveMemberNew(
2345 Filename: *const c_char,
2346 Name: *const c_char,
2347 Child: Option<&ArchiveChild<'a>>,
2348 ) -> &'a mut RustArchiveMember<'a>;
2349 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
2351 pub fn LLVMRustWriteImportLibrary(
2352 ImportName: *const c_char,
2353 Path: *const c_char,
2354 Exports: *const LLVMRustCOFFShortExport,
2358 ) -> LLVMRustResult;
2360 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
2362 pub fn LLVMRustBuildOperandBundleDef(
2363 Name: *const c_char,
2364 Inputs: *const &'a Value,
2366 ) -> &'a mut OperandBundleDef<'a>;
2367 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
2369 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
2371 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2372 pub fn LLVMRustUnsetComdat(V: &Value);
2373 pub fn LLVMRustSetModulePICLevel(M: &Module);
2374 pub fn LLVMRustSetModulePIELevel(M: &Module);
2375 pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2376 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2377 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2378 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2379 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2380 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2382 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
2383 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2384 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2385 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2386 pub fn LLVMRustCreateThinLTOData(
2387 Modules: *const ThinLTOModule,
2389 PreservedSymbols: *const *const c_char,
2390 PreservedSymbolsLen: c_uint,
2391 ) -> Option<&'static mut ThinLTOData>;
2392 pub fn LLVMRustPrepareThinLTORename(
2395 Target: &TargetMachine,
2397 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2398 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2399 pub fn LLVMRustPrepareThinLTOImport(
2402 Target: &TargetMachine,
2404 pub fn LLVMRustGetThinLTOModuleImports(
2405 Data: *const ThinLTOData,
2406 ModuleNameCallback: ThinLTOModuleNameCallback,
2407 CallbackPayload: *mut c_void,
2409 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2410 pub fn LLVMRustParseBitcodeForLTO(
2414 Identifier: *const c_char,
2415 ) -> Option<&Module>;
2416 pub fn LLVMRustGetBitcodeSliceFromObjectData(
2419 out_len: &mut usize,
2421 pub fn LLVMRustLTOGetDICompileUnit(M: &Module, CU1: &mut *mut c_void, CU2: &mut *mut c_void);
2422 pub fn LLVMRustLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2424 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
2425 pub fn LLVMRustLinkerAdd(
2426 linker: &Linker<'_>,
2427 bytecode: *const c_char,
2428 bytecode_len: usize,
2430 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);
2431 #[allow(improper_ctypes)]
2432 pub fn LLVMRustComputeLTOCacheKey(
2433 key_out: &RustString,
2434 mod_id: *const c_char,