1 #![allow(non_camel_case_types)]
2 #![allow(non_upper_case_globals)]
4 use super::debuginfo::{
5 DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
6 DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DINameSpace, DISPFlags, DIScope,
7 DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind,
10 use libc::{c_char, c_int, c_uint, size_t};
11 use libc::{c_ulonglong, c_void};
13 use std::marker::PhantomData;
15 use super::RustString;
17 pub type Bool = c_uint;
19 pub const True: Bool = 1 as Bool;
20 pub const False: Bool = 0 as Bool;
22 #[derive(Copy, Clone, PartialEq)]
24 #[allow(dead_code)] // Variants constructed by C++.
25 pub enum LLVMRustResult {
29 // Consts for the LLVM CallConv type, pre-cast to usize.
31 /// LLVM CallingConv::ID. Should we wrap this?
32 #[derive(Copy, Clone, PartialEq, Debug)]
38 X86StdcallCallConv = 64,
39 X86FastcallCallConv = 65,
40 ArmAapcsCallConv = 67,
56 AvailableExternallyLinkage = 1,
57 LinkOnceAnyLinkage = 2,
58 LinkOnceODRLinkage = 3,
64 ExternalWeakLinkage = 9,
76 /// LLVMDLLStorageClass
77 #[derive(Copy, Clone)]
79 pub enum DLLStorageClass {
82 DllImport = 1, // Function to be imported from DLL.
84 DllExport = 2, // Function to be accessible from DLL.
87 /// Matches LLVMRustAttribute in rustllvm.h
88 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
89 /// though it is not ABI compatible (since it's a C++ enum)
91 #[derive(Copy, Clone, Debug)]
106 OptimizeForSize = 13,
114 SanitizeAddress = 21,
122 #[derive(Copy, Clone)]
124 pub enum IntPredicate {
138 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
140 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
141 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
142 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
143 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
144 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
145 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
146 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
147 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
148 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
149 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
154 /// LLVMRealPredicate
155 #[derive(Copy, Clone)]
157 pub enum RealPredicate {
158 RealPredicateFalse = 0,
173 RealPredicateTrue = 15,
177 pub fn from_generic(realpred: rustc_codegen_ssa::common::RealPredicate) -> Self {
179 rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
180 RealPredicate::RealPredicateFalse
182 rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
183 rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
184 rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
185 rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
186 rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
187 rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
188 rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
189 rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
190 rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
191 rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
192 rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
193 rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
194 rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
195 rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
196 rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
197 RealPredicate::RealPredicateTrue
204 #[derive(Copy, Clone, PartialEq, Debug)]
227 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
229 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
230 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
231 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
232 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
233 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
234 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
235 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
236 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
237 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
238 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
239 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
240 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
241 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
242 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
243 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
244 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
245 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
250 /// LLVMAtomicRmwBinOp
251 #[derive(Copy, Clone)]
253 pub enum AtomicRmwBinOp {
267 impl AtomicRmwBinOp {
268 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
270 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
271 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
272 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
273 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
274 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
275 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
276 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
277 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
278 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
279 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
280 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
285 /// LLVMAtomicOrdering
286 #[derive(Copy, Clone)]
288 pub enum AtomicOrdering {
293 // Consume = 3, // Not specified yet.
297 SequentiallyConsistent = 7,
300 impl AtomicOrdering {
301 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
303 rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
304 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
305 rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
306 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
307 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
308 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
309 AtomicOrdering::AcquireRelease
311 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
312 AtomicOrdering::SequentiallyConsistent
318 /// LLVMRustSynchronizationScope
319 #[derive(Copy, Clone)]
321 pub enum SynchronizationScope {
322 // FIXME: figure out if this variant is needed at all.
329 impl SynchronizationScope {
330 pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
332 rustc_codegen_ssa::common::SynchronizationScope::Other => SynchronizationScope::Other,
333 rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
334 SynchronizationScope::SingleThread
336 rustc_codegen_ssa::common::SynchronizationScope::CrossThread => {
337 SynchronizationScope::CrossThread
344 #[derive(Copy, Clone)]
347 // FIXME: figure out if this variant is needed at all.
355 #[derive(Copy, Clone)]
357 pub enum MetadataType {
364 MD_invariant_load = 6,
368 MD_mem_parallel_loop_access = 10,
372 /// LLVMRustAsmDialect
373 #[derive(Copy, Clone)]
375 pub enum AsmDialect {
376 // FIXME: figure out if this variant is needed at all.
384 pub fn from_generic(asm: rustc_ast::ast::AsmDialect) -> Self {
386 rustc_ast::ast::AsmDialect::Att => AsmDialect::Att,
387 rustc_ast::ast::AsmDialect::Intel => AsmDialect::Intel,
392 /// LLVMRustCodeGenOptLevel
393 #[derive(Copy, Clone, PartialEq)]
395 pub enum CodeGenOptLevel {
396 // FIXME: figure out if this variant is needed at all.
405 /// LLVMRustPassBuilderOptLevel
407 pub enum PassBuilderOptLevel {
427 /// LLVMRustSanitizerOptions
429 pub struct SanitizerOptions {
430 pub sanitize_memory: bool,
431 pub sanitize_thread: bool,
432 pub sanitize_address: bool,
433 pub sanitize_recover: bool,
434 pub sanitize_memory_track_origins: c_int,
438 #[derive(Copy, Clone, PartialEq)]
450 /// LLVMRustCodeModel
451 #[derive(Copy, Clone)]
454 // FIXME: figure out if this variant is needed at all.
464 /// LLVMRustDiagnosticKind
465 #[derive(Copy, Clone)]
467 #[allow(dead_code)] // Variants constructed by C++.
468 pub enum DiagnosticKind {
472 DebugMetadataVersion,
475 OptimizationRemarkMissed,
476 OptimizationRemarkAnalysis,
477 OptimizationRemarkAnalysisFPCommute,
478 OptimizationRemarkAnalysisAliasing,
479 OptimizationRemarkOther,
485 /// LLVMRustArchiveKind
486 #[derive(Copy, Clone)]
488 pub enum ArchiveKind {
489 // FIXME: figure out if this variant is needed at all.
499 #[derive(Copy, Clone, PartialEq, Debug)]
501 #[allow(dead_code)] // Variants constructed by C++.
508 /// LLVMRustThinLTOData
510 pub type ThinLTOData;
513 /// LLVMRustThinLTOBuffer
515 pub type ThinLTOBuffer;
518 // LLVMRustModuleNameCallback
519 pub type ThinLTOModuleNameCallback =
520 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
522 /// LLVMRustThinLTOModule
524 pub struct ThinLTOModule {
525 pub identifier: *const c_char,
530 /// LLVMThreadLocalMode
531 #[derive(Copy, Clone)]
533 pub enum ThreadLocalMode {
545 struct InvariantOpaque<'a> {
546 _marker: PhantomData<&'a mut &'a ()>,
550 // Opaque pointer types
564 pub type ConstantInt;
573 pub struct Builder<'a>(InvariantOpaque<'a>);
575 pub type MemoryBuffer;
578 pub struct PassManager<'a>(InvariantOpaque<'a>);
580 pub type PassManagerBuilder;
586 pub struct SectionIterator<'a>(InvariantOpaque<'a>);
591 pub type TargetMachine;
597 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
599 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
604 pub type DiagnosticInfo;
607 pub type SMDiagnostic;
610 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
612 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
614 pub struct Linker<'a>(InvariantOpaque<'a>);
616 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
617 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
620 use super::{InvariantOpaque, Metadata};
621 use bitflags::bitflags;
624 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
626 pub type DIDescriptor = Metadata;
627 pub type DIScope = DIDescriptor;
628 pub type DIFile = DIScope;
629 pub type DILexicalBlock = DIScope;
630 pub type DISubprogram = DIScope;
631 pub type DINameSpace = DIScope;
632 pub type DIType = DIDescriptor;
633 pub type DIBasicType = DIType;
634 pub type DIDerivedType = DIType;
635 pub type DICompositeType = DIDerivedType;
636 pub type DIVariable = DIDescriptor;
637 pub type DIGlobalVariableExpression = DIDescriptor;
638 pub type DIArray = DIDescriptor;
639 pub type DISubrange = DIDescriptor;
640 pub type DIEnumerator = DIDescriptor;
641 pub type DITemplateTypeParameter = DIDescriptor;
643 // These values **must** match with LLVMRustDIFlags!!
647 pub struct DIFlags: u32 {
649 const FlagPrivate = 1;
650 const FlagProtected = 2;
651 const FlagPublic = 3;
652 const FlagFwdDecl = (1 << 2);
653 const FlagAppleBlock = (1 << 3);
654 const FlagBlockByrefStruct = (1 << 4);
655 const FlagVirtual = (1 << 5);
656 const FlagArtificial = (1 << 6);
657 const FlagExplicit = (1 << 7);
658 const FlagPrototyped = (1 << 8);
659 const FlagObjcClassComplete = (1 << 9);
660 const FlagObjectPointer = (1 << 10);
661 const FlagVector = (1 << 11);
662 const FlagStaticMember = (1 << 12);
663 const FlagLValueReference = (1 << 13);
664 const FlagRValueReference = (1 << 14);
665 const FlagExternalTypeRef = (1 << 15);
666 const FlagIntroducedVirtual = (1 << 18);
667 const FlagBitField = (1 << 19);
668 const FlagNoReturn = (1 << 20);
672 // These values **must** match with LLVMRustDISPFlags!!
676 pub struct DISPFlags: u32 {
677 const SPFlagZero = 0;
678 const SPFlagVirtual = 1;
679 const SPFlagPureVirtual = 2;
680 const SPFlagLocalToUnit = (1 << 2);
681 const SPFlagDefinition = (1 << 3);
682 const SPFlagOptimized = (1 << 4);
683 const SPFlagMainSubprogram = (1 << 5);
687 /// LLVMRustDebugEmissionKind
688 #[derive(Copy, Clone)]
690 pub enum DebugEmissionKind {
696 impl DebugEmissionKind {
697 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
698 use rustc_session::config::DebugInfo;
700 DebugInfo::None => DebugEmissionKind::NoDebug,
701 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
702 DebugInfo::Full => DebugEmissionKind::FullDebug,
709 pub type ModuleBuffer;
712 pub type SelfProfileBeforePassCallback =
713 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
714 pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
717 pub fn LLVMRustInstallFatalErrorHandler();
719 // Create and destroy contexts.
720 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
721 pub fn LLVMContextDispose(C: &'static mut Context);
722 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
725 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
726 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
727 pub fn LLVMCloneModule(M: &Module) -> &Module;
729 /// Data layout. See Module::getDataLayout.
730 pub fn LLVMGetDataLayout(M: &Module) -> *const c_char;
731 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
733 /// See Module::setModuleInlineAsm.
734 pub fn LLVMSetModuleInlineAsm(M: &Module, Asm: *const c_char);
735 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
737 /// See llvm::LLVMTypeKind::getTypeID.
738 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
740 // Operations on integer types
741 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
742 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
743 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
744 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
745 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
746 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
748 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
750 // Operations on real types
751 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
752 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
754 // Operations on function types
755 pub fn LLVMFunctionType(
756 ReturnType: &'a Type,
757 ParamTypes: *const &'a Type,
761 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
762 pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
764 // Operations on struct types
765 pub fn LLVMStructTypeInContext(
767 ElementTypes: *const &'a Type,
768 ElementCount: c_uint,
772 // Operations on array, pointer, and vector types (sequence types)
773 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
774 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
775 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
777 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
778 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
780 // Operations on other types
781 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
782 pub fn LLVMX86MMXTypeInContext(C: &Context) -> &Type;
783 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
785 // Operations on all values
786 pub fn LLVMTypeOf(Val: &Value) -> &Type;
787 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
788 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
789 pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
790 pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
792 // Operations on constants of any type
793 pub fn LLVMConstNull(Ty: &Type) -> &Value;
794 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
796 // Operations on metadata
797 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
798 pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
799 pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
801 // Operations on scalar constants
802 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
803 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
804 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
805 pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
806 pub fn LLVMRustConstInt128Get(
807 ConstantVal: &ConstantInt,
813 // Operations on composite constants
814 pub fn LLVMConstStringInContext(
818 DontNullTerminate: Bool,
820 pub fn LLVMConstStructInContext(
822 ConstantVals: *const &'a Value,
827 pub fn LLVMConstArray(
829 ConstantVals: *const &'a Value,
832 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
834 // Constant expressions
835 pub fn LLVMConstInBoundsGEP(
836 ConstantVal: &'a Value,
837 ConstantIndices: *const &'a Value,
840 pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
841 pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
842 pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
843 pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
844 pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
845 pub fn LLVMConstExtractValue(
847 IdxList: *const c_uint,
851 // Operations on global variables, functions, and aliases (globals)
852 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
853 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
854 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
855 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
856 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
857 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
858 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
859 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
860 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
862 // Operations on global variables
863 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
864 pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
865 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
866 pub fn LLVMRustGetOrInsertGlobal(
872 pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
873 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
874 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
875 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
876 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
877 pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
878 pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
879 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
880 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
881 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
882 pub fn LLVMRustGetNamedValue(
887 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
889 // Operations on functions
890 pub fn LLVMRustGetOrInsertFunction(
894 FunctionTy: &'a Type,
896 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
897 pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
898 pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
899 pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
900 pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
901 pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
902 pub fn LLVMRustAddFunctionAttrStringValue(
906 Value: *const c_char,
908 pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
910 // Operations on parameters
911 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
912 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
913 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
915 // Operations on basic blocks
916 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
917 pub fn LLVMAppendBasicBlockInContext(
922 pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
924 // Operations on instructions
925 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
926 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
928 // Operations on call sites
929 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
930 pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
931 pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
932 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
933 pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
934 pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
936 // Operations on load/store instructions (only)
937 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
939 // Operations on phi nodes
940 pub fn LLVMAddIncoming(
942 IncomingValues: *const &'a Value,
943 IncomingBlocks: *const &'a BasicBlock,
947 // Instruction builders
948 pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
949 pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
950 pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
951 pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
954 pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
957 pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
958 pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
959 pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
960 pub fn LLVMBuildCondBr(
963 Then: &'a BasicBlock,
964 Else: &'a BasicBlock,
966 pub fn LLVMBuildSwitch(
969 Else: &'a BasicBlock,
972 pub fn LLVMRustBuildInvoke(
975 Args: *const &'a Value,
977 Then: &'a BasicBlock,
978 Catch: &'a BasicBlock,
979 Bundle: Option<&OperandBundleDef<'a>>,
982 pub fn LLVMBuildLandingPad(
989 pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
990 pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
992 pub fn LLVMRustBuildCleanupPad(
994 ParentPad: Option<&'a Value>,
996 Args: *const &'a Value,
998 ) -> Option<&'a Value>;
999 pub fn LLVMRustBuildCleanupRet(
1001 CleanupPad: &'a Value,
1002 UnwindBB: Option<&'a BasicBlock>,
1003 ) -> Option<&'a Value>;
1004 pub fn LLVMRustBuildCatchPad(
1006 ParentPad: &'a Value,
1008 Args: *const &'a Value,
1009 Name: *const c_char,
1010 ) -> Option<&'a Value>;
1011 pub fn LLVMRustBuildCatchRet(
1015 ) -> Option<&'a Value>;
1016 pub fn LLVMRustBuildCatchSwitch(
1017 Builder: &Builder<'a>,
1018 ParentPad: Option<&'a Value>,
1019 BB: Option<&'a BasicBlock>,
1020 NumHandlers: c_uint,
1021 Name: *const c_char,
1022 ) -> Option<&'a Value>;
1023 pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1024 pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
1026 // Add a case to the switch instruction
1027 pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1029 // Add a clause to the landing pad instruction
1030 pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
1032 // Set the cleanup on a landing pad instruction
1033 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1036 pub fn LLVMBuildAdd(
1040 Name: *const c_char,
1042 pub fn LLVMBuildFAdd(
1046 Name: *const c_char,
1048 pub fn LLVMBuildSub(
1052 Name: *const c_char,
1054 pub fn LLVMBuildFSub(
1058 Name: *const c_char,
1060 pub fn LLVMBuildMul(
1064 Name: *const c_char,
1066 pub fn LLVMBuildFMul(
1070 Name: *const c_char,
1072 pub fn LLVMBuildUDiv(
1076 Name: *const c_char,
1078 pub fn LLVMBuildExactUDiv(
1082 Name: *const c_char,
1084 pub fn LLVMBuildSDiv(
1088 Name: *const c_char,
1090 pub fn LLVMBuildExactSDiv(
1094 Name: *const c_char,
1096 pub fn LLVMBuildFDiv(
1100 Name: *const c_char,
1102 pub fn LLVMBuildURem(
1106 Name: *const c_char,
1108 pub fn LLVMBuildSRem(
1112 Name: *const c_char,
1114 pub fn LLVMBuildFRem(
1118 Name: *const c_char,
1120 pub fn LLVMBuildShl(
1124 Name: *const c_char,
1126 pub fn LLVMBuildLShr(
1130 Name: *const c_char,
1132 pub fn LLVMBuildAShr(
1136 Name: *const c_char,
1138 pub fn LLVMBuildNSWAdd(
1142 Name: *const c_char,
1144 pub fn LLVMBuildNUWAdd(
1148 Name: *const c_char,
1150 pub fn LLVMBuildNSWSub(
1154 Name: *const c_char,
1156 pub fn LLVMBuildNUWSub(
1160 Name: *const c_char,
1162 pub fn LLVMBuildNSWMul(
1166 Name: *const c_char,
1168 pub fn LLVMBuildNUWMul(
1172 Name: *const c_char,
1174 pub fn LLVMBuildAnd(
1178 Name: *const c_char,
1184 Name: *const c_char,
1186 pub fn LLVMBuildXor(
1190 Name: *const c_char,
1192 pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1193 pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1194 pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1195 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: &Value);
1198 pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1199 pub fn LLVMBuildArrayAlloca(
1203 Name: *const c_char,
1205 pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
1207 pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1209 pub fn LLVMBuildGEP(
1212 Indices: *const &'a Value,
1214 Name: *const c_char,
1216 pub fn LLVMBuildInBoundsGEP(
1219 Indices: *const &'a Value,
1221 Name: *const c_char,
1223 pub fn LLVMBuildStructGEP(
1227 Name: *const c_char,
1231 pub fn LLVMBuildTrunc(
1235 Name: *const c_char,
1237 pub fn LLVMBuildZExt(
1241 Name: *const c_char,
1243 pub fn LLVMBuildSExt(
1247 Name: *const c_char,
1249 pub fn LLVMBuildFPToUI(
1253 Name: *const c_char,
1255 pub fn LLVMBuildFPToSI(
1259 Name: *const c_char,
1261 pub fn LLVMBuildUIToFP(
1265 Name: *const c_char,
1267 pub fn LLVMBuildSIToFP(
1271 Name: *const c_char,
1273 pub fn LLVMBuildFPTrunc(
1277 Name: *const c_char,
1279 pub fn LLVMBuildFPExt(
1283 Name: *const c_char,
1285 pub fn LLVMBuildPtrToInt(
1289 Name: *const c_char,
1291 pub fn LLVMBuildIntToPtr(
1295 Name: *const c_char,
1297 pub fn LLVMBuildBitCast(
1301 Name: *const c_char,
1303 pub fn LLVMBuildPointerCast(
1307 Name: *const c_char,
1309 pub fn LLVMRustBuildIntCast(
1317 pub fn LLVMBuildICmp(
1322 Name: *const c_char,
1324 pub fn LLVMBuildFCmp(
1329 Name: *const c_char,
1332 // Miscellaneous instructions
1333 pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1334 pub fn LLVMRustBuildCall(
1337 Args: *const &'a Value,
1339 Bundle: Option<&OperandBundleDef<'a>>,
1341 pub fn LLVMRustBuildMemCpy(
1350 pub fn LLVMRustBuildMemMove(
1359 pub fn LLVMRustBuildMemSet(
1367 pub fn LLVMBuildSelect(
1372 Name: *const c_char,
1374 pub fn LLVMBuildVAArg(
1378 Name: *const c_char,
1380 pub fn LLVMBuildExtractElement(
1384 Name: *const c_char,
1386 pub fn LLVMBuildInsertElement(
1391 Name: *const c_char,
1393 pub fn LLVMBuildShuffleVector(
1398 Name: *const c_char,
1400 pub fn LLVMBuildExtractValue(
1404 Name: *const c_char,
1406 pub fn LLVMBuildInsertValue(
1411 Name: *const c_char,
1414 pub fn LLVMRustBuildVectorReduceFAdd(
1419 pub fn LLVMRustBuildVectorReduceFMul(
1424 pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1425 pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1426 pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1427 pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1428 pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1429 pub fn LLVMRustBuildVectorReduceMin(
1434 pub fn LLVMRustBuildVectorReduceMax(
1439 pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1441 pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1444 pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1445 pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1447 // Atomic Operations
1448 pub fn LLVMRustBuildAtomicLoad(
1450 PointerVal: &'a Value,
1451 Name: *const c_char,
1452 Order: AtomicOrdering,
1455 pub fn LLVMRustBuildAtomicStore(
1459 Order: AtomicOrdering,
1462 pub fn LLVMRustBuildAtomicCmpXchg(
1467 Order: AtomicOrdering,
1468 FailureOrder: AtomicOrdering,
1472 pub fn LLVMBuildAtomicRMW(
1477 Order: AtomicOrdering,
1478 SingleThreaded: Bool,
1481 pub fn LLVMRustBuildAtomicFence(
1483 Order: AtomicOrdering,
1484 Scope: SynchronizationScope,
1487 /// Writes a module to the specified path. Returns 0 on success.
1488 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1490 /// Creates a pass manager.
1491 pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1493 /// Creates a function-by-function pass manager
1494 pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1496 /// Disposes a pass manager.
1497 pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1499 /// Runs a pass manager on a module.
1500 pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1502 pub fn LLVMInitializePasses();
1504 pub fn LLVMTimeTraceProfilerInitialize();
1506 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1508 pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>);
1510 pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1511 pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1512 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1513 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1514 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1515 PMB: &PassManagerBuilder,
1518 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1519 PMB: &PassManagerBuilder,
1520 PM: &PassManager<'_>,
1523 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1524 PMB: &PassManagerBuilder,
1525 PM: &PassManager<'_>,
1527 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1528 PMB: &PassManagerBuilder,
1529 PM: &PassManager<'_>,
1533 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1534 PMB: &PassManagerBuilder,
1535 PM: &PassManager<'_>,
1538 // Stuff that's in rustllvm/ because it's not upstream yet.
1540 /// Opens an object file.
1541 pub fn LLVMCreateObjectFile(
1542 MemBuf: &'static mut MemoryBuffer,
1543 ) -> Option<&'static mut ObjectFile>;
1544 /// Closes an object file.
1545 pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1547 /// Enumerates the sections in an object file.
1548 pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1549 /// Destroys a section iterator.
1550 pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1551 /// Returns `true` if the section iterator is at the end of the section
1553 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1554 /// Moves the section iterator to point to the next section.
1555 pub fn LLVMMoveToNextSection(SI: &SectionIterator<'_>);
1556 /// Returns the current section size.
1557 pub fn LLVMGetSectionSize(SI: &SectionIterator<'_>) -> c_ulonglong;
1558 /// Returns the current section contents as a string buffer.
1559 pub fn LLVMGetSectionContents(SI: &SectionIterator<'_>) -> *const c_char;
1561 /// Reads the given file and returns it as a memory buffer. Use
1562 /// LLVMDisposeMemoryBuffer() to get rid of it.
1563 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1564 Path: *const c_char,
1565 ) -> Option<&'static mut MemoryBuffer>;
1567 pub fn LLVMStartMultithreaded() -> Bool;
1569 /// Returns a string describing the last error caused by an LLVMRust* call.
1570 pub fn LLVMRustGetLastError() -> *const c_char;
1572 /// Print the pass timings since static dtors aren't picking them up.
1573 pub fn LLVMRustPrintPassTimings();
1575 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1577 pub fn LLVMStructSetBody(
1579 ElementTypes: *const &'a Type,
1580 ElementCount: c_uint,
1584 /// Prepares inline assembly.
1585 pub fn LLVMRustInlineAsm(
1587 AsmString: *const c_char,
1588 AsmStringLen: size_t,
1589 Constraints: *const c_char,
1590 ConstraintsLen: size_t,
1593 Dialect: AsmDialect,
1595 pub fn LLVMRustInlineAsmVerify(
1597 Constraints: *const c_char,
1598 ConstraintsLen: size_t,
1601 pub fn LLVMRustDebugMetadataVersion() -> u32;
1602 pub fn LLVMRustVersionMajor() -> u32;
1603 pub fn LLVMRustVersionMinor() -> u32;
1605 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1607 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1609 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1611 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1613 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1615 pub fn LLVMRustDIBuilderCreateCompileUnit(
1616 Builder: &DIBuilder<'a>,
1619 Producer: *const c_char,
1620 ProducerLen: size_t,
1622 Flags: *const c_char,
1624 SplitName: *const c_char,
1625 SplitNameLen: size_t,
1626 kind: DebugEmissionKind,
1627 ) -> &'a DIDescriptor;
1629 pub fn LLVMRustDIBuilderCreateFile(
1630 Builder: &DIBuilder<'a>,
1631 Filename: *const c_char,
1632 FilenameLen: size_t,
1633 Directory: *const c_char,
1634 DirectoryLen: size_t,
1637 pub fn LLVMRustDIBuilderCreateSubroutineType(
1638 Builder: &DIBuilder<'a>,
1640 ParameterTypes: &'a DIArray,
1641 ) -> &'a DICompositeType;
1643 pub fn LLVMRustDIBuilderCreateFunction(
1644 Builder: &DIBuilder<'a>,
1645 Scope: &'a DIDescriptor,
1646 Name: *const c_char,
1648 LinkageName: *const c_char,
1649 LinkageNameLen: size_t,
1657 TParam: &'a DIArray,
1658 Decl: Option<&'a DIDescriptor>,
1659 ) -> &'a DISubprogram;
1661 pub fn LLVMRustDIBuilderCreateBasicType(
1662 Builder: &DIBuilder<'a>,
1663 Name: *const c_char,
1668 ) -> &'a DIBasicType;
1670 pub fn LLVMRustDIBuilderCreatePointerType(
1671 Builder: &DIBuilder<'a>,
1672 PointeeTy: &'a DIType,
1675 AddressSpace: c_uint,
1676 Name: *const c_char,
1678 ) -> &'a DIDerivedType;
1680 pub fn LLVMRustDIBuilderCreateStructType(
1681 Builder: &DIBuilder<'a>,
1682 Scope: Option<&'a DIDescriptor>,
1683 Name: *const c_char,
1690 DerivedFrom: Option<&'a DIType>,
1691 Elements: &'a DIArray,
1692 RunTimeLang: c_uint,
1693 VTableHolder: Option<&'a DIType>,
1694 UniqueId: *const c_char,
1695 UniqueIdLen: size_t,
1696 ) -> &'a DICompositeType;
1698 pub fn LLVMRustDIBuilderCreateMemberType(
1699 Builder: &DIBuilder<'a>,
1700 Scope: &'a DIDescriptor,
1701 Name: *const c_char,
1710 ) -> &'a DIDerivedType;
1712 pub fn LLVMRustDIBuilderCreateVariantMemberType(
1713 Builder: &DIBuilder<'a>,
1715 Name: *const c_char,
1722 Discriminant: Option<&'a Value>,
1727 pub fn LLVMRustDIBuilderCreateLexicalBlock(
1728 Builder: &DIBuilder<'a>,
1733 ) -> &'a DILexicalBlock;
1735 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(
1736 Builder: &DIBuilder<'a>,
1739 ) -> &'a DILexicalBlock;
1741 pub fn LLVMRustDIBuilderCreateStaticVariable(
1742 Builder: &DIBuilder<'a>,
1743 Context: Option<&'a DIScope>,
1744 Name: *const c_char,
1746 LinkageName: *const c_char,
1747 LinkageNameLen: size_t,
1751 isLocalToUnit: bool,
1753 Decl: Option<&'a DIDescriptor>,
1755 ) -> &'a DIGlobalVariableExpression;
1757 pub fn LLVMRustDIBuilderCreateVariable(
1758 Builder: &DIBuilder<'a>,
1760 Scope: &'a DIDescriptor,
1761 Name: *const c_char,
1766 AlwaysPreserve: bool,
1770 ) -> &'a DIVariable;
1772 pub fn LLVMRustDIBuilderCreateArrayType(
1773 Builder: &DIBuilder<'a>,
1777 Subscripts: &'a DIArray,
1780 pub fn LLVMRustDIBuilderGetOrCreateSubrange(
1781 Builder: &DIBuilder<'a>,
1784 ) -> &'a DISubrange;
1786 pub fn LLVMRustDIBuilderGetOrCreateArray(
1787 Builder: &DIBuilder<'a>,
1788 Ptr: *const Option<&'a DIDescriptor>,
1792 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(
1793 Builder: &DIBuilder<'a>,
1795 VarInfo: &'a DIVariable,
1796 AddrOps: *const i64,
1797 AddrOpsCount: c_uint,
1799 InsertAtEnd: &'a BasicBlock,
1802 pub fn LLVMRustDIBuilderCreateEnumerator(
1803 Builder: &DIBuilder<'a>,
1804 Name: *const c_char,
1808 ) -> &'a DIEnumerator;
1810 pub fn LLVMRustDIBuilderCreateEnumerationType(
1811 Builder: &DIBuilder<'a>,
1813 Name: *const c_char,
1819 Elements: &'a DIArray,
1820 ClassType: &'a DIType,
1824 pub fn LLVMRustDIBuilderCreateUnionType(
1825 Builder: &DIBuilder<'a>,
1827 Name: *const c_char,
1834 Elements: Option<&'a DIArray>,
1835 RunTimeLang: c_uint,
1836 UniqueId: *const c_char,
1837 UniqueIdLen: size_t,
1840 pub fn LLVMRustDIBuilderCreateVariantPart(
1841 Builder: &DIBuilder<'a>,
1843 Name: *const c_char,
1850 Discriminator: Option<&'a DIDerivedType>,
1851 Elements: &'a DIArray,
1852 UniqueId: *const c_char,
1853 UniqueIdLen: size_t,
1854 ) -> &'a DIDerivedType;
1856 pub fn LLVMSetUnnamedAddr(GlobalVar: &Value, UnnamedAddr: Bool);
1858 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
1859 Builder: &DIBuilder<'a>,
1860 Scope: Option<&'a DIScope>,
1861 Name: *const c_char,
1867 ) -> &'a DITemplateTypeParameter;
1869 pub fn LLVMRustDIBuilderCreateNameSpace(
1870 Builder: &DIBuilder<'a>,
1871 Scope: Option<&'a DIScope>,
1872 Name: *const c_char,
1874 ExportSymbols: bool,
1875 ) -> &'a DINameSpace;
1877 pub fn LLVMRustDICompositeTypeReplaceArrays(
1878 Builder: &DIBuilder<'a>,
1879 CompositeType: &'a DIType,
1880 Elements: Option<&'a DIArray>,
1881 Params: Option<&'a DIArray>,
1884 pub fn LLVMRustDIBuilderCreateDebugLocation(
1885 Context: &'a Context,
1889 InlinedAt: Option<&'a Metadata>,
1891 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1892 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
1894 #[allow(improper_ctypes)]
1895 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
1896 #[allow(improper_ctypes)]
1897 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
1899 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
1901 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
1902 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
1903 pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
1904 pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
1905 pub fn LLVMRustCreateMemorySanitizerPass(
1906 TrackOrigins: c_int,
1908 ) -> &'static mut Pass;
1909 pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
1910 pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
1911 pub fn LLVMRustAddLastExtensionPasses(
1912 PMB: &PassManagerBuilder,
1913 Passes: *const &'static mut Pass,
1917 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
1919 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
1920 pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
1922 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
1923 pub fn LLVMRustCreateTargetMachine(
1924 Triple: *const c_char,
1926 Features: *const c_char,
1930 Level: CodeGenOptLevel,
1932 PositionIndependentExecutable: bool,
1933 FunctionSections: bool,
1935 TrapUnreachable: bool,
1938 EmitStackSizeSection: bool,
1939 RelaxELFRelocations: bool,
1940 ) -> Option<&'static mut TargetMachine>;
1941 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
1942 pub fn LLVMRustAddBuilderLibraryInfo(
1943 PMB: &'a PassManagerBuilder,
1945 DisableSimplifyLibCalls: bool,
1947 pub fn LLVMRustConfigurePassManagerBuilder(
1948 PMB: &PassManagerBuilder,
1949 OptLevel: CodeGenOptLevel,
1950 MergeFunctions: bool,
1952 LoopVectorize: bool,
1953 PrepareForThinLTO: bool,
1954 PGOGenPath: *const c_char,
1955 PGOUsePath: *const c_char,
1957 pub fn LLVMRustAddLibraryInfo(
1958 PM: &PassManager<'a>,
1960 DisableSimplifyLibCalls: bool,
1962 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
1963 pub fn LLVMRustWriteOutputFile(
1964 T: &'a TargetMachine,
1965 PM: &PassManager<'a>,
1967 Output: *const c_char,
1969 ) -> LLVMRustResult;
1970 pub fn LLVMRustOptimizeWithNewPassManager(
1972 TM: &'a TargetMachine,
1973 OptLevel: PassBuilderOptLevel,
1975 NoPrepopulatePasses: bool,
1977 UseThinLTOBuffers: bool,
1978 MergeFunctions: bool,
1981 LoopVectorize: bool,
1982 DisableSimplifyLibCalls: bool,
1983 SanitizerOptions: Option<&SanitizerOptions>,
1984 PGOGenPath: *const c_char,
1985 PGOUsePath: *const c_char,
1986 llvm_selfprofiler: *mut c_void,
1987 begin_callback: SelfProfileBeforePassCallback,
1988 end_callback: SelfProfileAfterPassCallback,
1990 pub fn LLVMRustPrintModule(
1992 Output: *const c_char,
1993 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
1994 ) -> LLVMRustResult;
1995 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1996 pub fn LLVMRustPrintPasses();
1997 pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
1998 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
1999 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
2000 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2001 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
2003 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2004 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
2005 pub fn LLVMRustArchiveIteratorNext(
2006 AIR: &ArchiveIterator<'a>,
2007 ) -> Option<&'a mut ArchiveChild<'a>>;
2008 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2009 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2010 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
2011 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
2012 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2014 #[allow(improper_ctypes)]
2015 pub fn LLVMRustGetSectionName(
2016 SI: &SectionIterator<'_>,
2017 data: &mut Option<std::ptr::NonNull<c_char>>,
2020 #[allow(improper_ctypes)]
2021 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2023 pub fn LLVMContextSetDiagnosticHandler(
2025 Handler: DiagnosticHandler,
2026 DiagnosticContext: *mut c_void,
2029 #[allow(improper_ctypes)]
2030 pub fn LLVMRustUnpackOptimizationDiagnostic(
2031 DI: &'a DiagnosticInfo,
2032 pass_name_out: &RustString,
2033 function_out: &mut Option<&'a Value>,
2034 loc_line_out: &mut c_uint,
2035 loc_column_out: &mut c_uint,
2036 loc_filename_out: &RustString,
2037 message_out: &RustString,
2040 pub fn LLVMRustUnpackInlineAsmDiagnostic(
2041 DI: &'a DiagnosticInfo,
2042 cookie_out: &mut c_uint,
2043 message_out: &mut Option<&'a Twine>,
2044 instruction_out: &mut Option<&'a Value>,
2047 #[allow(improper_ctypes)]
2048 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2049 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2051 pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2053 H: InlineAsmDiagHandler,
2057 #[allow(improper_ctypes)]
2058 pub fn LLVMRustWriteSMDiagnosticToString(d: &SMDiagnostic, s: &RustString);
2060 pub fn LLVMRustWriteArchive(
2063 Members: *const &RustArchiveMember<'_>,
2066 ) -> LLVMRustResult;
2067 pub fn LLVMRustArchiveMemberNew(
2068 Filename: *const c_char,
2069 Name: *const c_char,
2070 Child: Option<&ArchiveChild<'a>>,
2071 ) -> &'a mut RustArchiveMember<'a>;
2072 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
2074 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
2076 pub fn LLVMRustBuildOperandBundleDef(
2077 Name: *const c_char,
2078 Inputs: *const &'a Value,
2080 ) -> &'a mut OperandBundleDef<'a>;
2081 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
2083 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
2085 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2086 pub fn LLVMRustUnsetComdat(V: &Value);
2087 pub fn LLVMRustSetModulePICLevel(M: &Module);
2088 pub fn LLVMRustSetModulePIELevel(M: &Module);
2089 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2090 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2091 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2092 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2093 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2095 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
2096 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2097 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2098 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2099 pub fn LLVMRustCreateThinLTOData(
2100 Modules: *const ThinLTOModule,
2102 PreservedSymbols: *const *const c_char,
2103 PreservedSymbolsLen: c_uint,
2104 ) -> Option<&'static mut ThinLTOData>;
2105 pub fn LLVMRustPrepareThinLTORename(Data: &ThinLTOData, Module: &Module) -> bool;
2106 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2107 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2108 pub fn LLVMRustPrepareThinLTOImport(Data: &ThinLTOData, Module: &Module) -> bool;
2109 pub fn LLVMRustGetThinLTOModuleImports(
2110 Data: *const ThinLTOData,
2111 ModuleNameCallback: ThinLTOModuleNameCallback,
2112 CallbackPayload: *mut c_void,
2114 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2115 pub fn LLVMRustParseBitcodeForLTO(
2119 Identifier: *const c_char,
2120 ) -> Option<&Module>;
2121 pub fn LLVMRustThinLTOGetDICompileUnit(
2123 CU1: &mut *mut c_void,
2124 CU2: &mut *mut c_void,
2126 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2128 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
2129 pub fn LLVMRustLinkerAdd(
2130 linker: &Linker<'_>,
2131 bytecode: *const c_char,
2132 bytecode_len: usize,
2134 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);