1#![allow(non_camel_case_types)]
14
15use std::fmt::{self, Debug};
16use std::marker::PhantomData;
17use std::num::NonZero;
18use std::ptr;
19
20use bitflags::bitflags;
21use libc::{c_char, c_int, c_uchar, c_uint, c_ulonglong, c_void, size_t};
22use rustc_macros::TryFromU32;
23use rustc_target::spec::SymbolVisibility;
24
25use super::RustString;
26use super::debuginfo::{
27 DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
28 DIFile, DIFlags, DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram,
29 DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
30};
31use crate::llvm;
32
33#[derive(Clone, Copy)]
39#[repr(transparent)]
40pub(crate) struct Bool {
41 value: c_int,
42}
43
44pub(crate) const TRUE: Bool = Bool::TRUE;
45pub(crate) const FALSE: Bool = Bool::FALSE;
46
47impl Bool {
48 pub(crate) const TRUE: Self = Self { value: 1 };
49 pub(crate) const FALSE: Self = Self { value: 0 };
50
51 pub(crate) const fn from_bool(rust_bool: bool) -> Self {
52 if rust_bool { Self::TRUE } else { Self::FALSE }
53 }
54
55 pub(crate) fn is_true(self) -> bool {
57 self.value != Self::FALSE.value
60 }
61}
62
63impl Debug for Bool {
64 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
65 match self.value {
66 0 => f.write_str("FALSE"),
67 1 => f.write_str("TRUE"),
68 v => write!(f, "TRUE ({v})"),
70 }
71 }
72}
73
74pub(crate) trait ToLlvmBool: Copy {
79 fn to_llvm_bool(self) -> llvm::Bool;
80}
81
82impl ToLlvmBool for bool {
83 #[inline(always)]
84 fn to_llvm_bool(self) -> llvm::Bool {
85 llvm::Bool::from_bool(self)
86 }
87}
88
89#[repr(transparent)]
96pub(crate) struct RawEnum<T> {
97 value: u32,
98 _rust_side_type: PhantomData<fn() -> T>,
100}
101
102impl<T: TryFrom<u32>> RawEnum<T> {
103 #[track_caller]
104 pub(crate) fn to_rust(self) -> T
105 where
106 T::Error: Debug,
107 {
108 T::try_from(self.value).expect("enum value returned by LLVM should be known")
110 }
111}
112
113#[derive(Copy, Clone, PartialEq)]
114#[repr(C)]
115#[allow(dead_code)] pub(crate) enum LLVMRustResult {
117 Success,
118 Failure,
119}
120
121#[derive(Copy, Clone, PartialEq)]
134#[repr(C)]
135pub(crate) enum ModuleFlagMergeBehavior {
136 Error = 1,
137 Warning = 2,
138 Require = 3,
139 Override = 4,
140 Append = 5,
141 AppendUnique = 6,
142 Max = 7,
143 Min = 8,
144}
145
146#[derive(Copy, Clone, PartialEq, Debug)]
150#[repr(C)]
151#[allow(dead_code)]
152pub(crate) enum TailCallKind {
153 None = 0,
154 Tail = 1,
155 MustTail = 2,
156 NoTail = 3,
157}
158
159#[derive(Copy, Clone, PartialEq, Debug, TryFromU32)]
163#[repr(C)]
164pub(crate) enum CallConv {
165 CCallConv = 0,
166 FastCallConv = 8,
167 ColdCallConv = 9,
168 PreserveMost = 14,
169 PreserveAll = 15,
170 Tail = 18,
171 X86StdcallCallConv = 64,
172 X86FastcallCallConv = 65,
173 ArmAapcsCallConv = 67,
174 Msp430Intr = 69,
175 X86_ThisCall = 70,
176 PtxKernel = 71,
177 X86_64_SysV = 78,
178 X86_64_Win64 = 79,
179 X86_VectorCall = 80,
180 X86_Intr = 83,
181 AvrNonBlockingInterrupt = 84,
182 AvrInterrupt = 85,
183 AmdgpuKernel = 91,
184}
185
186#[derive(Copy, Clone, PartialEq, TryFromU32)]
188#[repr(C)]
189pub(crate) enum Linkage {
190 ExternalLinkage = 0,
191 AvailableExternallyLinkage = 1,
192 LinkOnceAnyLinkage = 2,
193 LinkOnceODRLinkage = 3,
194 #[deprecated = "marked obsolete by LLVM"]
195 LinkOnceODRAutoHideLinkage = 4,
196 WeakAnyLinkage = 5,
197 WeakODRLinkage = 6,
198 AppendingLinkage = 7,
199 InternalLinkage = 8,
200 PrivateLinkage = 9,
201 #[deprecated = "marked obsolete by LLVM"]
202 DLLImportLinkage = 10,
203 #[deprecated = "marked obsolete by LLVM"]
204 DLLExportLinkage = 11,
205 ExternalWeakLinkage = 12,
206 #[deprecated = "marked obsolete by LLVM"]
207 GhostLinkage = 13,
208 CommonLinkage = 14,
209 LinkerPrivateLinkage = 15,
210 LinkerPrivateWeakLinkage = 16,
211}
212
213#[repr(C)]
215#[derive(Copy, Clone, PartialEq, TryFromU32)]
216pub(crate) enum Visibility {
217 Default = 0,
218 Hidden = 1,
219 Protected = 2,
220}
221
222impl Visibility {
223 pub(crate) fn from_generic(visibility: SymbolVisibility) -> Self {
224 match visibility {
225 SymbolVisibility::Hidden => Visibility::Hidden,
226 SymbolVisibility::Protected => Visibility::Protected,
227 SymbolVisibility::Interposable => Visibility::Default,
228 }
229 }
230}
231
232#[repr(C)]
234pub(crate) enum UnnamedAddr {
235 No,
236 #[expect(dead_code)]
237 Local,
238 Global,
239}
240
241#[derive(Copy, Clone)]
243#[repr(C)]
244pub(crate) enum DLLStorageClass {
245 #[allow(dead_code)]
246 Default = 0,
247 DllImport = 1, #[allow(dead_code)]
249 DllExport = 2, }
251
252#[repr(C)]
256#[derive(Copy, Clone, Debug)]
257#[expect(dead_code, reason = "Some variants are unused, but are kept to match the C++")]
258pub(crate) enum AttributeKind {
259 AlwaysInline = 0,
260 ByVal = 1,
261 Cold = 2,
262 InlineHint = 3,
263 MinSize = 4,
264 Naked = 5,
265 NoAlias = 6,
266 CapturesAddress = 7,
267 NoInline = 8,
268 NonNull = 9,
269 NoRedZone = 10,
270 NoReturn = 11,
271 NoUnwind = 12,
272 OptimizeForSize = 13,
273 ReadOnly = 14,
274 SExt = 15,
275 StructRet = 16,
276 UWTable = 17,
277 ZExt = 18,
278 InReg = 19,
279 SanitizeThread = 20,
280 SanitizeAddress = 21,
281 SanitizeMemory = 22,
282 NonLazyBind = 23,
283 OptimizeNone = 24,
284 ReadNone = 26,
285 SanitizeHWAddress = 28,
286 WillReturn = 29,
287 StackProtectReq = 30,
288 StackProtectStrong = 31,
289 StackProtect = 32,
290 NoUndef = 33,
291 SanitizeMemTag = 34,
292 NoCfCheck = 35,
293 ShadowCallStack = 36,
294 AllocSize = 37,
295 AllocatedPointer = 38,
296 AllocAlign = 39,
297 SanitizeSafeStack = 40,
298 FnRetThunkExtern = 41,
299 Writable = 42,
300 DeadOnUnwind = 43,
301 DeadOnReturn = 44,
302 CapturesReadOnly = 45,
303}
304
305#[derive(Copy, Clone)]
307#[repr(C)]
308pub(crate) enum IntPredicate {
309 IntEQ = 32,
310 IntNE = 33,
311 IntUGT = 34,
312 IntUGE = 35,
313 IntULT = 36,
314 IntULE = 37,
315 IntSGT = 38,
316 IntSGE = 39,
317 IntSLT = 40,
318 IntSLE = 41,
319}
320
321impl IntPredicate {
322 pub(crate) fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
323 use rustc_codegen_ssa::common::IntPredicate as Common;
324 match intpre {
325 Common::IntEQ => Self::IntEQ,
326 Common::IntNE => Self::IntNE,
327 Common::IntUGT => Self::IntUGT,
328 Common::IntUGE => Self::IntUGE,
329 Common::IntULT => Self::IntULT,
330 Common::IntULE => Self::IntULE,
331 Common::IntSGT => Self::IntSGT,
332 Common::IntSGE => Self::IntSGE,
333 Common::IntSLT => Self::IntSLT,
334 Common::IntSLE => Self::IntSLE,
335 }
336 }
337}
338
339#[derive(Copy, Clone)]
341#[repr(C)]
342pub(crate) enum RealPredicate {
343 RealPredicateFalse = 0,
344 RealOEQ = 1,
345 RealOGT = 2,
346 RealOGE = 3,
347 RealOLT = 4,
348 RealOLE = 5,
349 RealONE = 6,
350 RealORD = 7,
351 RealUNO = 8,
352 RealUEQ = 9,
353 RealUGT = 10,
354 RealUGE = 11,
355 RealULT = 12,
356 RealULE = 13,
357 RealUNE = 14,
358 RealPredicateTrue = 15,
359}
360
361impl RealPredicate {
362 pub(crate) fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self {
363 use rustc_codegen_ssa::common::RealPredicate as Common;
364 match realp {
365 Common::RealPredicateFalse => Self::RealPredicateFalse,
366 Common::RealOEQ => Self::RealOEQ,
367 Common::RealOGT => Self::RealOGT,
368 Common::RealOGE => Self::RealOGE,
369 Common::RealOLT => Self::RealOLT,
370 Common::RealOLE => Self::RealOLE,
371 Common::RealONE => Self::RealONE,
372 Common::RealORD => Self::RealORD,
373 Common::RealUNO => Self::RealUNO,
374 Common::RealUEQ => Self::RealUEQ,
375 Common::RealUGT => Self::RealUGT,
376 Common::RealUGE => Self::RealUGE,
377 Common::RealULT => Self::RealULT,
378 Common::RealULE => Self::RealULE,
379 Common::RealUNE => Self::RealUNE,
380 Common::RealPredicateTrue => Self::RealPredicateTrue,
381 }
382 }
383}
384
385#[derive(Copy, Clone, PartialEq, Debug, TryFromU32)]
393#[repr(C)]
394pub(crate) enum TypeKind {
395 Void = 0,
396 Half = 1,
397 Float = 2,
398 Double = 3,
399 X86_FP80 = 4,
400 FP128 = 5,
401 PPC_FP128 = 6,
402 Label = 7,
403 Integer = 8,
404 Function = 9,
405 Struct = 10,
406 Array = 11,
407 Pointer = 12,
408 Vector = 13,
409 Metadata = 14,
410 Token = 16,
411 ScalableVector = 17,
412 BFloat = 18,
413 X86_AMX = 19,
414}
415
416impl TypeKind {
417 pub(crate) fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
418 use rustc_codegen_ssa::common::TypeKind as Common;
419 match self {
420 Self::Void => Common::Void,
421 Self::Half => Common::Half,
422 Self::Float => Common::Float,
423 Self::Double => Common::Double,
424 Self::X86_FP80 => Common::X86_FP80,
425 Self::FP128 => Common::FP128,
426 Self::PPC_FP128 => Common::PPC_FP128,
427 Self::Label => Common::Label,
428 Self::Integer => Common::Integer,
429 Self::Function => Common::Function,
430 Self::Struct => Common::Struct,
431 Self::Array => Common::Array,
432 Self::Pointer => Common::Pointer,
433 Self::Vector => Common::Vector,
434 Self::Metadata => Common::Metadata,
435 Self::Token => Common::Token,
436 Self::ScalableVector => Common::ScalableVector,
437 Self::BFloat => Common::BFloat,
438 Self::X86_AMX => Common::X86_AMX,
439 }
440 }
441}
442
443#[derive(Copy, Clone)]
445#[repr(C)]
446pub(crate) enum AtomicRmwBinOp {
447 AtomicXchg = 0,
448 AtomicAdd = 1,
449 AtomicSub = 2,
450 AtomicAnd = 3,
451 AtomicNand = 4,
452 AtomicOr = 5,
453 AtomicXor = 6,
454 AtomicMax = 7,
455 AtomicMin = 8,
456 AtomicUMax = 9,
457 AtomicUMin = 10,
458}
459
460impl AtomicRmwBinOp {
461 pub(crate) fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
462 use rustc_codegen_ssa::common::AtomicRmwBinOp as Common;
463 match op {
464 Common::AtomicXchg => Self::AtomicXchg,
465 Common::AtomicAdd => Self::AtomicAdd,
466 Common::AtomicSub => Self::AtomicSub,
467 Common::AtomicAnd => Self::AtomicAnd,
468 Common::AtomicNand => Self::AtomicNand,
469 Common::AtomicOr => Self::AtomicOr,
470 Common::AtomicXor => Self::AtomicXor,
471 Common::AtomicMax => Self::AtomicMax,
472 Common::AtomicMin => Self::AtomicMin,
473 Common::AtomicUMax => Self::AtomicUMax,
474 Common::AtomicUMin => Self::AtomicUMin,
475 }
476 }
477}
478
479#[derive(Copy, Clone)]
481#[repr(C)]
482pub(crate) enum AtomicOrdering {
483 #[allow(dead_code)]
484 NotAtomic = 0,
485 #[allow(dead_code)]
486 Unordered = 1,
487 Monotonic = 2,
488 Acquire = 4,
490 Release = 5,
491 AcquireRelease = 6,
492 SequentiallyConsistent = 7,
493}
494
495impl AtomicOrdering {
496 pub(crate) fn from_generic(ao: rustc_middle::ty::AtomicOrdering) -> Self {
497 use rustc_middle::ty::AtomicOrdering as Common;
498 match ao {
499 Common::Relaxed => Self::Monotonic,
500 Common::Acquire => Self::Acquire,
501 Common::Release => Self::Release,
502 Common::AcqRel => Self::AcquireRelease,
503 Common::SeqCst => Self::SequentiallyConsistent,
504 }
505 }
506}
507
508#[derive(Copy, Clone)]
510#[repr(C)]
511pub(crate) enum FileType {
512 AssemblyFile,
513 ObjectFile,
514}
515
516#[derive(Copy, Clone)]
518#[repr(C)]
519#[expect(dead_code, reason = "Some variants are unused, but are kept to match LLVM-C")]
520pub(crate) enum MetadataType {
521 MD_dbg = 0,
522 MD_tbaa = 1,
523 MD_prof = 2,
524 MD_fpmath = 3,
525 MD_range = 4,
526 MD_tbaa_struct = 5,
527 MD_invariant_load = 6,
528 MD_alias_scope = 7,
529 MD_noalias = 8,
530 MD_nontemporal = 9,
531 MD_mem_parallel_loop_access = 10,
532 MD_nonnull = 11,
533 MD_unpredictable = 15,
534 MD_align = 17,
535 MD_type = 19,
536 MD_vcall_visibility = 28,
537 MD_noundef = 29,
538 MD_kcfi_type = 36,
539}
540
541#[derive(Copy, Clone, PartialEq)]
543#[repr(C)]
544pub(crate) enum AsmDialect {
545 Att,
546 Intel,
547}
548
549#[derive(Copy, Clone, PartialEq)]
551#[repr(C)]
552pub(crate) enum CodeGenOptLevel {
553 None,
554 Less,
555 Default,
556 Aggressive,
557}
558
559#[repr(C)]
561pub(crate) enum PassBuilderOptLevel {
562 O0,
563 O1,
564 O2,
565 O3,
566 Os,
567 Oz,
568}
569
570#[derive(PartialEq)]
572#[repr(C)]
573pub(crate) enum OptStage {
574 PreLinkNoLTO,
575 PreLinkThinLTO,
576 PreLinkFatLTO,
577 ThinLTO,
578 FatLTO,
579}
580
581#[repr(C)]
583pub(crate) struct SanitizerOptions {
584 pub sanitize_address: bool,
585 pub sanitize_address_recover: bool,
586 pub sanitize_cfi: bool,
587 pub sanitize_dataflow: bool,
588 pub sanitize_dataflow_abilist: *const *const c_char,
589 pub sanitize_dataflow_abilist_len: size_t,
590 pub sanitize_kcfi: bool,
591 pub sanitize_memory: bool,
592 pub sanitize_memory_recover: bool,
593 pub sanitize_memory_track_origins: c_int,
594 pub sanitize_thread: bool,
595 pub sanitize_hwaddress: bool,
596 pub sanitize_hwaddress_recover: bool,
597 pub sanitize_kernel_address: bool,
598 pub sanitize_kernel_address_recover: bool,
599}
600
601#[derive(Copy, Clone, PartialEq)]
603#[repr(C)]
604pub(crate) enum RelocModel {
605 Static,
606 PIC,
607 DynamicNoPic,
608 ROPI,
609 RWPI,
610 ROPI_RWPI,
611}
612
613#[derive(Copy, Clone, PartialEq)]
615#[repr(C)]
616pub(crate) enum FloatAbi {
617 Default,
618 Soft,
619 Hard,
620}
621
622#[derive(Copy, Clone)]
624#[repr(C)]
625pub(crate) enum CodeModel {
626 Tiny,
627 Small,
628 Kernel,
629 Medium,
630 Large,
631 None,
632}
633
634#[derive(Copy, Clone)]
636#[repr(C)]
637#[allow(dead_code)] pub(crate) enum DiagnosticKind {
639 Other,
640 InlineAsm,
641 StackSize,
642 DebugMetadataVersion,
643 SampleProfile,
644 OptimizationRemark,
645 OptimizationRemarkMissed,
646 OptimizationRemarkAnalysis,
647 OptimizationRemarkAnalysisFPCommute,
648 OptimizationRemarkAnalysisAliasing,
649 OptimizationRemarkOther,
650 OptimizationFailure,
651 PGOProfile,
652 Linker,
653 Unsupported,
654 SrcMgr,
655}
656
657#[derive(Copy, Clone)]
659#[repr(C)]
660#[allow(dead_code)] pub(crate) enum DiagnosticLevel {
662 Error,
663 Warning,
664 Note,
665 Remark,
666}
667
668unsafe extern "C" {
669 pub(crate) type ThinLTOData;
671
672 pub(crate) type ThinLTOBuffer;
674}
675
676#[repr(C)]
678pub(crate) struct ThinLTOModule {
679 pub identifier: *const c_char,
680 pub data: *const u8,
681 pub len: usize,
682}
683
684#[derive(Copy, Clone)]
686#[repr(C)]
687pub(crate) enum ThreadLocalMode {
688 #[expect(dead_code)]
689 NotThreadLocal,
690 GeneralDynamic,
691 LocalDynamic,
692 InitialExec,
693 LocalExec,
694}
695
696#[derive(Copy, Clone)]
698#[repr(C)]
699pub(crate) enum ChecksumKind {
700 None,
701 MD5,
702 SHA1,
703 SHA256,
704}
705
706#[derive(Copy, Clone)]
708#[repr(C)]
709pub(crate) enum MemoryEffects {
710 None,
711 ReadOnly,
712 InaccessibleMemOnly,
713}
714
715#[derive(Copy, Clone, PartialEq, Eq)]
717#[repr(C)]
718#[expect(dead_code, reason = "Some variants are unused, but are kept to match LLVM-C")]
719pub(crate) enum Opcode {
720 Ret = 1,
721 Br = 2,
722 Switch = 3,
723 IndirectBr = 4,
724 Invoke = 5,
725 Unreachable = 7,
726 CallBr = 67,
727 FNeg = 66,
728 Add = 8,
729 FAdd = 9,
730 Sub = 10,
731 FSub = 11,
732 Mul = 12,
733 FMul = 13,
734 UDiv = 14,
735 SDiv = 15,
736 FDiv = 16,
737 URem = 17,
738 SRem = 18,
739 FRem = 19,
740 Shl = 20,
741 LShr = 21,
742 AShr = 22,
743 And = 23,
744 Or = 24,
745 Xor = 25,
746 Alloca = 26,
747 Load = 27,
748 Store = 28,
749 GetElementPtr = 29,
750 Trunc = 30,
751 ZExt = 31,
752 SExt = 32,
753 FPToUI = 33,
754 FPToSI = 34,
755 UIToFP = 35,
756 SIToFP = 36,
757 FPTrunc = 37,
758 FPExt = 38,
759 PtrToInt = 39,
760 IntToPtr = 40,
761 BitCast = 41,
762 AddrSpaceCast = 60,
763 ICmp = 42,
764 FCmp = 43,
765 PHI = 44,
766 Call = 45,
767 Select = 46,
768 UserOp1 = 47,
769 UserOp2 = 48,
770 VAArg = 49,
771 ExtractElement = 50,
772 InsertElement = 51,
773 ShuffleVector = 52,
774 ExtractValue = 53,
775 InsertValue = 54,
776 Freeze = 68,
777 Fence = 55,
778 AtomicCmpXchg = 56,
779 AtomicRMW = 57,
780 Resume = 58,
781 LandingPad = 59,
782 CleanupRet = 61,
783 CatchRet = 62,
784 CatchPad = 63,
785 CleanupPad = 64,
786 CatchSwitch = 65,
787}
788
789unsafe extern "C" {
790 type Opaque;
791}
792#[repr(C)]
793struct InvariantOpaque<'a> {
794 _marker: PhantomData<&'a mut &'a ()>,
795 _opaque: Opaque,
796}
797
798unsafe extern "C" {
800 pub(crate) type Module;
801 pub(crate) type Context;
802 pub(crate) type Type;
803 pub(crate) type Value;
804 pub(crate) type ConstantInt;
805 pub(crate) type Attribute;
806 pub(crate) type Metadata;
807 pub(crate) type BasicBlock;
808 pub(crate) type Comdat;
809}
810#[repr(C)]
811pub(crate) struct Builder<'a>(InvariantOpaque<'a>);
812#[repr(C)]
813pub(crate) struct PassManager<'a>(InvariantOpaque<'a>);
814unsafe extern "C" {
815 pub type TargetMachine;
816}
817unsafe extern "C" {
818 pub(crate) type Twine;
819 pub(crate) type DiagnosticInfo;
820 pub(crate) type SMDiagnostic;
821}
822#[repr(C)]
824pub(crate) struct OperandBundle<'a>(InvariantOpaque<'a>);
825#[repr(C)]
826pub(crate) struct Linker<'a>(InvariantOpaque<'a>);
827
828unsafe extern "C" {
829 pub(crate) type DiagnosticHandler;
830}
831
832pub(crate) type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
833
834pub(crate) mod debuginfo {
835 use std::ptr;
836
837 use bitflags::bitflags;
838
839 use super::{InvariantOpaque, Metadata};
840 use crate::llvm::{self, Module};
841
842 #[repr(C)]
851 pub(crate) struct DIBuilder<'ll>(InvariantOpaque<'ll>);
852
853 pub(crate) struct DIBuilderBox<'ll> {
857 raw: ptr::NonNull<DIBuilder<'ll>>,
858 }
859
860 impl<'ll> DIBuilderBox<'ll> {
861 pub(crate) fn new(llmod: &'ll Module) -> Self {
862 let raw = unsafe { llvm::LLVMCreateDIBuilder(llmod) };
863 let raw = ptr::NonNull::new(raw).unwrap();
864 Self { raw }
865 }
866
867 pub(crate) fn as_ref(&self) -> &DIBuilder<'ll> {
868 unsafe { self.raw.as_ref() }
871 }
872 }
873
874 impl<'ll> Drop for DIBuilderBox<'ll> {
875 fn drop(&mut self) {
876 unsafe { llvm::LLVMDisposeDIBuilder(self.raw) };
877 }
878 }
879
880 pub(crate) type DIDescriptor = Metadata;
881 pub(crate) type DILocation = Metadata;
882 pub(crate) type DIScope = DIDescriptor;
883 pub(crate) type DIFile = DIScope;
884 pub(crate) type DILexicalBlock = DIScope;
885 pub(crate) type DISubprogram = DIScope;
886 pub(crate) type DIType = DIDescriptor;
887 pub(crate) type DIBasicType = DIType;
888 pub(crate) type DIDerivedType = DIType;
889 pub(crate) type DICompositeType = DIDerivedType;
890 pub(crate) type DIVariable = DIDescriptor;
891 pub(crate) type DIGlobalVariableExpression = DIDescriptor;
892 pub(crate) type DIArray = DIDescriptor;
893 pub(crate) type DISubrange = DIDescriptor;
894 pub(crate) type DIEnumerator = DIDescriptor;
895 pub(crate) type DITemplateTypeParameter = DIDescriptor;
896
897 bitflags! {
898 #[repr(transparent)]
903 #[derive(Clone, Copy, Default)]
904 pub(crate) struct DIFlags: u32 {
905 const FlagZero = 0;
906 const FlagPrivate = 1;
907 const FlagProtected = 2;
908 const FlagPublic = 3;
909 const FlagFwdDecl = (1 << 2);
910 const FlagAppleBlock = (1 << 3);
911 const FlagReservedBit4 = (1 << 4);
912 const FlagVirtual = (1 << 5);
913 const FlagArtificial = (1 << 6);
914 const FlagExplicit = (1 << 7);
915 const FlagPrototyped = (1 << 8);
916 const FlagObjcClassComplete = (1 << 9);
917 const FlagObjectPointer = (1 << 10);
918 const FlagVector = (1 << 11);
919 const FlagStaticMember = (1 << 12);
920 const FlagLValueReference = (1 << 13);
921 const FlagRValueReference = (1 << 14);
922 const FlagReserved = (1 << 15);
923 const FlagSingleInheritance = (1 << 16);
924 const FlagMultipleInheritance = (2 << 16);
925 const FlagVirtualInheritance = (3 << 16);
926 const FlagIntroducedVirtual = (1 << 18);
927 const FlagBitField = (1 << 19);
928 const FlagNoReturn = (1 << 20);
929 const FlagTypePassByValue = (1 << 22);
931 const FlagTypePassByReference = (1 << 23);
932 const FlagEnumClass = (1 << 24);
933 const FlagThunk = (1 << 25);
934 const FlagNonTrivial = (1 << 26);
935 const FlagBigEndian = (1 << 27);
936 const FlagLittleEndian = (1 << 28);
937 }
938 }
939
940 bitflags! {
942 #[repr(transparent)]
943 #[derive(Clone, Copy, Default)]
944 pub(crate) struct DISPFlags: u32 {
945 const SPFlagZero = 0;
946 const SPFlagVirtual = 1;
947 const SPFlagPureVirtual = 2;
948 const SPFlagLocalToUnit = (1 << 2);
949 const SPFlagDefinition = (1 << 3);
950 const SPFlagOptimized = (1 << 4);
951 const SPFlagMainSubprogram = (1 << 5);
952 }
953 }
954
955 #[derive(Copy, Clone)]
957 #[repr(C)]
958 pub(crate) enum DebugEmissionKind {
959 NoDebug,
960 FullDebug,
961 LineTablesOnly,
962 DebugDirectivesOnly,
963 }
964
965 impl DebugEmissionKind {
966 pub(crate) fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
967 use rustc_session::config::DebugInfo;
978 match kind {
979 DebugInfo::None => DebugEmissionKind::NoDebug,
980 DebugInfo::LineDirectivesOnly => DebugEmissionKind::DebugDirectivesOnly,
981 DebugInfo::LineTablesOnly => DebugEmissionKind::LineTablesOnly,
982 DebugInfo::Limited | DebugInfo::Full => DebugEmissionKind::FullDebug,
983 }
984 }
985 }
986
987 #[derive(Clone, Copy)]
989 #[repr(C)]
990 pub(crate) enum DebugNameTableKind {
991 Default,
992 #[expect(dead_code)]
993 Gnu,
994 None,
995 }
996}
997
998bitflags! {
1000 #[repr(transparent)]
1001 #[derive(Default)]
1002 pub(crate) struct AllocKindFlags : u64 {
1003 const Unknown = 0;
1004 const Alloc = 1;
1005 const Realloc = 1 << 1;
1006 const Free = 1 << 2;
1007 const Uninitialized = 1 << 3;
1008 const Zeroed = 1 << 4;
1009 const Aligned = 1 << 5;
1010 }
1011}
1012
1013bitflags! {
1015 #[repr(transparent)]
1016 #[derive(Default)]
1017 pub struct GEPNoWrapFlags : c_uint {
1018 const InBounds = 1 << 0;
1019 const NUSW = 1 << 1;
1020 const NUW = 1 << 2;
1021 }
1022}
1023
1024unsafe extern "C" {
1025 pub(crate) type ModuleBuffer;
1026}
1027
1028pub(crate) type SelfProfileBeforePassCallback =
1029 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
1030pub(crate) type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
1031
1032pub(crate) type GetSymbolsCallback =
1033 unsafe extern "C" fn(*mut c_void, *const c_char) -> *mut c_void;
1034pub(crate) type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) -> *mut c_void;
1035
1036#[derive(Copy, Clone)]
1037#[repr(transparent)]
1038pub(crate) struct MetadataKindId(c_uint);
1039
1040impl From<MetadataType> for MetadataKindId {
1041 fn from(value: MetadataType) -> Self {
1042 Self(value as c_uint)
1043 }
1044}
1045
1046unsafe extern "C" {
1047 pub(crate) fn LLVMContextDispose(C: &'static mut Context);
1049 pub(crate) fn LLVMGetMDKindIDInContext(
1050 C: &Context,
1051 Name: *const c_char,
1052 SLen: c_uint,
1053 ) -> MetadataKindId;
1054
1055 pub(crate) fn LLVMModuleCreateWithNameInContext(
1057 ModuleID: *const c_char,
1058 C: &Context,
1059 ) -> &Module;
1060 pub(crate) safe fn LLVMCloneModule(M: &Module) -> &Module;
1061
1062 pub(crate) fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
1064 pub(crate) fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
1065
1066 pub(crate) fn LLVMAppendModuleInlineAsm(
1068 M: &Module,
1069 Asm: *const c_uchar, Len: size_t,
1071 );
1072
1073 pub(crate) fn LLVMGetInlineAsm<'ll>(
1075 Ty: &'ll Type,
1076 AsmString: *const c_uchar, AsmStringSize: size_t,
1078 Constraints: *const c_uchar, ConstraintsSize: size_t,
1080 HasSideEffects: llvm::Bool,
1081 IsAlignStack: llvm::Bool,
1082 Dialect: AsmDialect,
1083 CanThrow: llvm::Bool,
1084 ) -> &'ll Value;
1085
1086 pub(crate) safe fn LLVMGetTypeKind(Ty: &Type) -> RawEnum<TypeKind>;
1087
1088 pub(crate) fn LLVMInt1TypeInContext(C: &Context) -> &Type;
1090 pub(crate) fn LLVMInt8TypeInContext(C: &Context) -> &Type;
1091 pub(crate) fn LLVMInt16TypeInContext(C: &Context) -> &Type;
1092 pub(crate) fn LLVMInt32TypeInContext(C: &Context) -> &Type;
1093 pub(crate) fn LLVMInt64TypeInContext(C: &Context) -> &Type;
1094 pub(crate) fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
1095
1096 pub(crate) fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
1097
1098 pub(crate) fn LLVMHalfTypeInContext(C: &Context) -> &Type;
1100 pub(crate) fn LLVMFloatTypeInContext(C: &Context) -> &Type;
1101 pub(crate) fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
1102 pub(crate) fn LLVMFP128TypeInContext(C: &Context) -> &Type;
1103
1104 pub(crate) fn LLVMFunctionType<'a>(
1106 ReturnType: &'a Type,
1107 ParamTypes: *const &'a Type,
1108 ParamCount: c_uint,
1109 IsVarArg: Bool,
1110 ) -> &'a Type;
1111 pub(crate) fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
1112 pub(crate) fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type);
1113
1114 pub(crate) fn LLVMStructTypeInContext<'a>(
1116 C: &'a Context,
1117 ElementTypes: *const &'a Type,
1118 ElementCount: c_uint,
1119 Packed: Bool,
1120 ) -> &'a Type;
1121
1122 pub(crate) fn LLVMPointerTypeInContext(C: &Context, AddressSpace: c_uint) -> &Type;
1124 pub(crate) fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
1125
1126 pub(crate) fn LLVMGetElementType(Ty: &Type) -> &Type;
1127 pub(crate) fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
1128
1129 pub(crate) fn LLVMVoidTypeInContext(C: &Context) -> &Type;
1131
1132 pub(crate) fn LLVMTypeOf(Val: &Value) -> &Type;
1134 pub(crate) fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
1135 pub(crate) fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
1136 pub(crate) fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value);
1137 pub(crate) safe fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: MetadataKindId, Node: &'a Value);
1138 pub(crate) fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
1139 pub(crate) safe fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
1140
1141 pub(crate) fn LLVMConstNull(Ty: &Type) -> &Value;
1143 pub(crate) fn LLVMGetUndef(Ty: &Type) -> &Value;
1144 pub(crate) fn LLVMGetPoison(Ty: &Type) -> &Value;
1145
1146 pub(crate) fn LLVMMDStringInContext2(
1148 C: &Context,
1149 Str: *const c_char,
1150 SLen: size_t,
1151 ) -> &Metadata;
1152 pub(crate) fn LLVMMDNodeInContext2<'a>(
1153 C: &'a Context,
1154 Vals: *const &'a Metadata,
1155 Count: size_t,
1156 ) -> &'a Metadata;
1157 pub(crate) fn LLVMAddNamedMetadataOperand<'a>(
1158 M: &'a Module,
1159 Name: *const c_char,
1160 Val: &'a Value,
1161 );
1162
1163 pub(crate) fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
1165 pub(crate) fn LLVMConstIntOfArbitraryPrecision(
1166 IntTy: &Type,
1167 Wn: c_uint,
1168 Ws: *const u64,
1169 ) -> &Value;
1170 pub(crate) fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
1171
1172 pub(crate) fn LLVMConstArray2<'a>(
1174 ElementTy: &'a Type,
1175 ConstantVals: *const &'a Value,
1176 Length: u64,
1177 ) -> &'a Value;
1178 pub(crate) fn LLVMArrayType2(ElementType: &Type, ElementCount: u64) -> &Type;
1179 pub(crate) fn LLVMConstStringInContext2(
1180 C: &Context,
1181 Str: *const c_char,
1182 Length: size_t,
1183 DontNullTerminate: Bool,
1184 ) -> &Value;
1185 pub(crate) fn LLVMConstStructInContext<'a>(
1186 C: &'a Context,
1187 ConstantVals: *const &'a Value,
1188 Count: c_uint,
1189 Packed: Bool,
1190 ) -> &'a Value;
1191 pub(crate) fn LLVMConstNamedStruct<'a>(
1192 StructTy: &'a Type,
1193 ConstantVals: *const &'a Value,
1194 Count: c_uint,
1195 ) -> &'a Value;
1196 pub(crate) fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
1197
1198 pub(crate) fn LLVMConstInBoundsGEP2<'a>(
1200 ty: &'a Type,
1201 ConstantVal: &'a Value,
1202 ConstantIndices: *const &'a Value,
1203 NumIndices: c_uint,
1204 ) -> &'a Value;
1205 pub(crate) fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1206 pub(crate) fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1207 pub(crate) fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1208 pub(crate) fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1209 pub(crate) fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
1210 pub(crate) fn LLVMGetConstOpcode(ConstantVal: &Value) -> Opcode;
1211 pub(crate) fn LLVMIsAConstantExpr(Val: &Value) -> Option<&Value>;
1212
1213 pub(crate) fn LLVMIsDeclaration(Global: &Value) -> Bool;
1215 pub(crate) fn LLVMGetLinkage(Global: &Value) -> RawEnum<Linkage>;
1216 pub(crate) fn LLVMSetLinkage(Global: &Value, RustLinkage: Linkage);
1217 pub(crate) fn LLVMSetSection(Global: &Value, Section: *const c_char);
1218 pub(crate) fn LLVMGetVisibility(Global: &Value) -> RawEnum<Visibility>;
1219 pub(crate) fn LLVMSetVisibility(Global: &Value, Viz: Visibility);
1220 pub(crate) fn LLVMGetAlignment(Global: &Value) -> c_uint;
1221 pub(crate) fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1222 pub(crate) fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1223 pub(crate) fn LLVMGlobalGetValueType(Global: &Value) -> &Type;
1224
1225 pub(crate) safe fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
1227 pub(crate) fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1228 pub(crate) fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
1229 pub(crate) fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1230 pub(crate) fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1231 pub(crate) fn LLVMDeleteGlobal(GlobalVar: &Value);
1232 pub(crate) safe fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1233 pub(crate) fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
1234 pub(crate) safe fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
1235 pub(crate) fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1236 pub(crate) safe fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1237 pub(crate) safe fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1238 pub(crate) safe fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1239 pub(crate) safe fn LLVMSetTailCallKind(CallInst: &Value, kind: TailCallKind);
1240
1241 pub(crate) fn LLVMCreateStringAttribute(
1243 C: &Context,
1244 Name: *const c_char,
1245 NameLen: c_uint,
1246 Value: *const c_char,
1247 ValueLen: c_uint,
1248 ) -> &Attribute;
1249
1250 pub(crate) fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1252
1253 pub(crate) fn LLVMLookupIntrinsicID(Name: *const c_char, NameLen: size_t) -> c_uint;
1255 pub(crate) fn LLVMGetIntrinsicDeclaration<'a>(
1256 Mod: &'a Module,
1257 ID: NonZero<c_uint>,
1258 ParamTypes: *const &'a Type,
1259 ParamCount: size_t,
1260 ) -> &'a Value;
1261
1262 pub(crate) fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1264 pub(crate) safe fn LLVMCountParams(Fn: &Value) -> c_uint;
1265 pub(crate) fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1266
1267 pub(crate) fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1269 pub(crate) fn LLVMAppendBasicBlockInContext<'a>(
1270 C: &'a Context,
1271 Fn: &'a Value,
1272 Name: *const c_char,
1273 ) -> &'a BasicBlock;
1274
1275 pub(crate) fn LLVMGetInstructionParent(Inst: &Value) -> &BasicBlock;
1277 pub(crate) fn LLVMGetCalledValue(CallInst: &Value) -> Option<&Value>;
1278 pub(crate) fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1279 pub(crate) fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1280 pub(crate) fn LLVMGetOperand(Val: &Value, Index: c_uint) -> Option<&Value>;
1281
1282 pub(crate) fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1284
1285 pub(crate) fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1287
1288 pub(crate) fn LLVMAddIncoming<'a>(
1290 PhiNode: &'a Value,
1291 IncomingValues: *const &'a Value,
1292 IncomingBlocks: *const &'a BasicBlock,
1293 Count: c_uint,
1294 );
1295
1296 pub(crate) fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>;
1298 pub(crate) fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock);
1299 pub(crate) fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock;
1300 pub(crate) fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);
1301
1302 pub(crate) fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: *const Metadata);
1304 pub(crate) fn LLVMGetCurrentDebugLocation2<'a>(Builder: &Builder<'a>) -> Option<&'a Metadata>;
1305
1306 pub(crate) safe fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;
1308 pub(crate) fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1309 pub(crate) fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1310 pub(crate) fn LLVMBuildCondBr<'a>(
1311 B: &Builder<'a>,
1312 If: &'a Value,
1313 Then: &'a BasicBlock,
1314 Else: &'a BasicBlock,
1315 ) -> &'a Value;
1316 pub(crate) fn LLVMBuildSwitch<'a>(
1317 B: &Builder<'a>,
1318 V: &'a Value,
1319 Else: &'a BasicBlock,
1320 NumCases: c_uint,
1321 ) -> &'a Value;
1322 pub(crate) fn LLVMBuildLandingPad<'a>(
1323 B: &Builder<'a>,
1324 Ty: &'a Type,
1325 PersFn: Option<&'a Value>,
1326 NumClauses: c_uint,
1327 Name: *const c_char,
1328 ) -> &'a Value;
1329 pub(crate) fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1330 pub(crate) fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value;
1331
1332 pub(crate) fn LLVMBuildCleanupPad<'a>(
1333 B: &Builder<'a>,
1334 ParentPad: Option<&'a Value>,
1335 Args: *const &'a Value,
1336 NumArgs: c_uint,
1337 Name: *const c_char,
1338 ) -> Option<&'a Value>;
1339 pub(crate) fn LLVMBuildCleanupRet<'a>(
1340 B: &Builder<'a>,
1341 CleanupPad: &'a Value,
1342 BB: Option<&'a BasicBlock>,
1343 ) -> Option<&'a Value>;
1344 pub(crate) fn LLVMBuildCatchPad<'a>(
1345 B: &Builder<'a>,
1346 ParentPad: &'a Value,
1347 Args: *const &'a Value,
1348 NumArgs: c_uint,
1349 Name: *const c_char,
1350 ) -> Option<&'a Value>;
1351 pub(crate) fn LLVMBuildCatchRet<'a>(
1352 B: &Builder<'a>,
1353 CatchPad: &'a Value,
1354 BB: &'a BasicBlock,
1355 ) -> Option<&'a Value>;
1356 pub(crate) fn LLVMBuildCatchSwitch<'a>(
1357 Builder: &Builder<'a>,
1358 ParentPad: Option<&'a Value>,
1359 UnwindBB: Option<&'a BasicBlock>,
1360 NumHandlers: c_uint,
1361 Name: *const c_char,
1362 ) -> Option<&'a Value>;
1363 pub(crate) fn LLVMAddHandler<'a>(CatchSwitch: &'a Value, Dest: &'a BasicBlock);
1364 pub(crate) fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value);
1365
1366 pub(crate) fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1368
1369 pub(crate) fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value);
1371
1372 pub(crate) fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1374
1375 pub(crate) fn LLVMBuildAdd<'a>(
1377 B: &Builder<'a>,
1378 LHS: &'a Value,
1379 RHS: &'a Value,
1380 Name: *const c_char,
1381 ) -> &'a Value;
1382 pub(crate) fn LLVMBuildFAdd<'a>(
1383 B: &Builder<'a>,
1384 LHS: &'a Value,
1385 RHS: &'a Value,
1386 Name: *const c_char,
1387 ) -> &'a Value;
1388 pub(crate) fn LLVMBuildSub<'a>(
1389 B: &Builder<'a>,
1390 LHS: &'a Value,
1391 RHS: &'a Value,
1392 Name: *const c_char,
1393 ) -> &'a Value;
1394 pub(crate) fn LLVMBuildFSub<'a>(
1395 B: &Builder<'a>,
1396 LHS: &'a Value,
1397 RHS: &'a Value,
1398 Name: *const c_char,
1399 ) -> &'a Value;
1400 pub(crate) fn LLVMBuildMul<'a>(
1401 B: &Builder<'a>,
1402 LHS: &'a Value,
1403 RHS: &'a Value,
1404 Name: *const c_char,
1405 ) -> &'a Value;
1406 pub(crate) fn LLVMBuildFMul<'a>(
1407 B: &Builder<'a>,
1408 LHS: &'a Value,
1409 RHS: &'a Value,
1410 Name: *const c_char,
1411 ) -> &'a Value;
1412 pub(crate) fn LLVMBuildUDiv<'a>(
1413 B: &Builder<'a>,
1414 LHS: &'a Value,
1415 RHS: &'a Value,
1416 Name: *const c_char,
1417 ) -> &'a Value;
1418 pub(crate) fn LLVMBuildExactUDiv<'a>(
1419 B: &Builder<'a>,
1420 LHS: &'a Value,
1421 RHS: &'a Value,
1422 Name: *const c_char,
1423 ) -> &'a Value;
1424 pub(crate) fn LLVMBuildSDiv<'a>(
1425 B: &Builder<'a>,
1426 LHS: &'a Value,
1427 RHS: &'a Value,
1428 Name: *const c_char,
1429 ) -> &'a Value;
1430 pub(crate) fn LLVMBuildExactSDiv<'a>(
1431 B: &Builder<'a>,
1432 LHS: &'a Value,
1433 RHS: &'a Value,
1434 Name: *const c_char,
1435 ) -> &'a Value;
1436 pub(crate) fn LLVMBuildFDiv<'a>(
1437 B: &Builder<'a>,
1438 LHS: &'a Value,
1439 RHS: &'a Value,
1440 Name: *const c_char,
1441 ) -> &'a Value;
1442 pub(crate) fn LLVMBuildURem<'a>(
1443 B: &Builder<'a>,
1444 LHS: &'a Value,
1445 RHS: &'a Value,
1446 Name: *const c_char,
1447 ) -> &'a Value;
1448 pub(crate) fn LLVMBuildSRem<'a>(
1449 B: &Builder<'a>,
1450 LHS: &'a Value,
1451 RHS: &'a Value,
1452 Name: *const c_char,
1453 ) -> &'a Value;
1454 pub(crate) fn LLVMBuildFRem<'a>(
1455 B: &Builder<'a>,
1456 LHS: &'a Value,
1457 RHS: &'a Value,
1458 Name: *const c_char,
1459 ) -> &'a Value;
1460 pub(crate) fn LLVMBuildShl<'a>(
1461 B: &Builder<'a>,
1462 LHS: &'a Value,
1463 RHS: &'a Value,
1464 Name: *const c_char,
1465 ) -> &'a Value;
1466 pub(crate) fn LLVMBuildLShr<'a>(
1467 B: &Builder<'a>,
1468 LHS: &'a Value,
1469 RHS: &'a Value,
1470 Name: *const c_char,
1471 ) -> &'a Value;
1472 pub(crate) fn LLVMBuildAShr<'a>(
1473 B: &Builder<'a>,
1474 LHS: &'a Value,
1475 RHS: &'a Value,
1476 Name: *const c_char,
1477 ) -> &'a Value;
1478 pub(crate) fn LLVMBuildNSWAdd<'a>(
1479 B: &Builder<'a>,
1480 LHS: &'a Value,
1481 RHS: &'a Value,
1482 Name: *const c_char,
1483 ) -> &'a Value;
1484 pub(crate) fn LLVMBuildNUWAdd<'a>(
1485 B: &Builder<'a>,
1486 LHS: &'a Value,
1487 RHS: &'a Value,
1488 Name: *const c_char,
1489 ) -> &'a Value;
1490 pub(crate) fn LLVMBuildNSWSub<'a>(
1491 B: &Builder<'a>,
1492 LHS: &'a Value,
1493 RHS: &'a Value,
1494 Name: *const c_char,
1495 ) -> &'a Value;
1496 pub(crate) fn LLVMBuildNUWSub<'a>(
1497 B: &Builder<'a>,
1498 LHS: &'a Value,
1499 RHS: &'a Value,
1500 Name: *const c_char,
1501 ) -> &'a Value;
1502 pub(crate) fn LLVMBuildNSWMul<'a>(
1503 B: &Builder<'a>,
1504 LHS: &'a Value,
1505 RHS: &'a Value,
1506 Name: *const c_char,
1507 ) -> &'a Value;
1508 pub(crate) fn LLVMBuildNUWMul<'a>(
1509 B: &Builder<'a>,
1510 LHS: &'a Value,
1511 RHS: &'a Value,
1512 Name: *const c_char,
1513 ) -> &'a Value;
1514 pub(crate) fn LLVMBuildAnd<'a>(
1515 B: &Builder<'a>,
1516 LHS: &'a Value,
1517 RHS: &'a Value,
1518 Name: *const c_char,
1519 ) -> &'a Value;
1520 pub(crate) fn LLVMBuildOr<'a>(
1521 B: &Builder<'a>,
1522 LHS: &'a Value,
1523 RHS: &'a Value,
1524 Name: *const c_char,
1525 ) -> &'a Value;
1526 pub(crate) fn LLVMBuildXor<'a>(
1527 B: &Builder<'a>,
1528 LHS: &'a Value,
1529 RHS: &'a Value,
1530 Name: *const c_char,
1531 ) -> &'a Value;
1532 pub(crate) fn LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char)
1533 -> &'a Value;
1534 pub(crate) fn LLVMBuildFNeg<'a>(
1535 B: &Builder<'a>,
1536 V: &'a Value,
1537 Name: *const c_char,
1538 ) -> &'a Value;
1539 pub(crate) fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char)
1540 -> &'a Value;
1541
1542 pub(crate) fn LLVMSetIsDisjoint(Instr: &Value, IsDisjoint: Bool);
1544 pub(crate) fn LLVMSetNUW(ArithInst: &Value, HasNUW: Bool);
1545 pub(crate) fn LLVMSetNSW(ArithInst: &Value, HasNSW: Bool);
1546
1547 pub(crate) fn LLVMBuildAlloca<'a>(
1549 B: &Builder<'a>,
1550 Ty: &'a Type,
1551 Name: *const c_char,
1552 ) -> &'a Value;
1553 pub(crate) fn LLVMBuildLoad2<'a>(
1554 B: &Builder<'a>,
1555 Ty: &'a Type,
1556 PointerVal: &'a Value,
1557 Name: *const c_char,
1558 ) -> &'a Value;
1559
1560 pub(crate) fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1561
1562 pub(crate) fn LLVMBuildGEPWithNoWrapFlags<'a>(
1563 B: &Builder<'a>,
1564 Ty: &'a Type,
1565 Pointer: &'a Value,
1566 Indices: *const &'a Value,
1567 NumIndices: c_uint,
1568 Name: *const c_char,
1569 Flags: GEPNoWrapFlags,
1570 ) -> &'a Value;
1571
1572 pub(crate) fn LLVMBuildTrunc<'a>(
1574 B: &Builder<'a>,
1575 Val: &'a Value,
1576 DestTy: &'a Type,
1577 Name: *const c_char,
1578 ) -> &'a Value;
1579 pub(crate) fn LLVMBuildZExt<'a>(
1580 B: &Builder<'a>,
1581 Val: &'a Value,
1582 DestTy: &'a Type,
1583 Name: *const c_char,
1584 ) -> &'a Value;
1585 pub(crate) fn LLVMBuildSExt<'a>(
1586 B: &Builder<'a>,
1587 Val: &'a Value,
1588 DestTy: &'a Type,
1589 Name: *const c_char,
1590 ) -> &'a Value;
1591 pub(crate) fn LLVMBuildFPToUI<'a>(
1592 B: &Builder<'a>,
1593 Val: &'a Value,
1594 DestTy: &'a Type,
1595 Name: *const c_char,
1596 ) -> &'a Value;
1597 pub(crate) fn LLVMBuildFPToSI<'a>(
1598 B: &Builder<'a>,
1599 Val: &'a Value,
1600 DestTy: &'a Type,
1601 Name: *const c_char,
1602 ) -> &'a Value;
1603 pub(crate) fn LLVMBuildUIToFP<'a>(
1604 B: &Builder<'a>,
1605 Val: &'a Value,
1606 DestTy: &'a Type,
1607 Name: *const c_char,
1608 ) -> &'a Value;
1609 pub(crate) fn LLVMBuildSIToFP<'a>(
1610 B: &Builder<'a>,
1611 Val: &'a Value,
1612 DestTy: &'a Type,
1613 Name: *const c_char,
1614 ) -> &'a Value;
1615 pub(crate) fn LLVMBuildFPTrunc<'a>(
1616 B: &Builder<'a>,
1617 Val: &'a Value,
1618 DestTy: &'a Type,
1619 Name: *const c_char,
1620 ) -> &'a Value;
1621 pub(crate) fn LLVMBuildFPExt<'a>(
1622 B: &Builder<'a>,
1623 Val: &'a Value,
1624 DestTy: &'a Type,
1625 Name: *const c_char,
1626 ) -> &'a Value;
1627 pub(crate) fn LLVMBuildPtrToInt<'a>(
1628 B: &Builder<'a>,
1629 Val: &'a Value,
1630 DestTy: &'a Type,
1631 Name: *const c_char,
1632 ) -> &'a Value;
1633 pub(crate) fn LLVMBuildIntToPtr<'a>(
1634 B: &Builder<'a>,
1635 Val: &'a Value,
1636 DestTy: &'a Type,
1637 Name: *const c_char,
1638 ) -> &'a Value;
1639 pub(crate) fn LLVMBuildBitCast<'a>(
1640 B: &Builder<'a>,
1641 Val: &'a Value,
1642 DestTy: &'a Type,
1643 Name: *const c_char,
1644 ) -> &'a Value;
1645 pub(crate) fn LLVMBuildPointerCast<'a>(
1646 B: &Builder<'a>,
1647 Val: &'a Value,
1648 DestTy: &'a Type,
1649 Name: *const c_char,
1650 ) -> &'a Value;
1651 pub(crate) fn LLVMBuildIntCast2<'a>(
1652 B: &Builder<'a>,
1653 Val: &'a Value,
1654 DestTy: &'a Type,
1655 IsSigned: Bool,
1656 Name: *const c_char,
1657 ) -> &'a Value;
1658
1659 pub(crate) fn LLVMBuildICmp<'a>(
1661 B: &Builder<'a>,
1662 Op: c_uint,
1663 LHS: &'a Value,
1664 RHS: &'a Value,
1665 Name: *const c_char,
1666 ) -> &'a Value;
1667 pub(crate) fn LLVMBuildFCmp<'a>(
1668 B: &Builder<'a>,
1669 Op: c_uint,
1670 LHS: &'a Value,
1671 RHS: &'a Value,
1672 Name: *const c_char,
1673 ) -> &'a Value;
1674
1675 pub(crate) fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char)
1677 -> &'a Value;
1678 pub(crate) fn LLVMBuildSelect<'a>(
1679 B: &Builder<'a>,
1680 If: &'a Value,
1681 Then: &'a Value,
1682 Else: &'a Value,
1683 Name: *const c_char,
1684 ) -> &'a Value;
1685 pub(crate) fn LLVMBuildVAArg<'a>(
1686 B: &Builder<'a>,
1687 list: &'a Value,
1688 Ty: &'a Type,
1689 Name: *const c_char,
1690 ) -> &'a Value;
1691 pub(crate) fn LLVMBuildExtractElement<'a>(
1692 B: &Builder<'a>,
1693 VecVal: &'a Value,
1694 Index: &'a Value,
1695 Name: *const c_char,
1696 ) -> &'a Value;
1697 pub(crate) fn LLVMBuildInsertElement<'a>(
1698 B: &Builder<'a>,
1699 VecVal: &'a Value,
1700 EltVal: &'a Value,
1701 Index: &'a Value,
1702 Name: *const c_char,
1703 ) -> &'a Value;
1704 pub(crate) fn LLVMBuildShuffleVector<'a>(
1705 B: &Builder<'a>,
1706 V1: &'a Value,
1707 V2: &'a Value,
1708 Mask: &'a Value,
1709 Name: *const c_char,
1710 ) -> &'a Value;
1711 pub(crate) fn LLVMBuildExtractValue<'a>(
1712 B: &Builder<'a>,
1713 AggVal: &'a Value,
1714 Index: c_uint,
1715 Name: *const c_char,
1716 ) -> &'a Value;
1717 pub(crate) fn LLVMBuildInsertValue<'a>(
1718 B: &Builder<'a>,
1719 AggVal: &'a Value,
1720 EltVal: &'a Value,
1721 Index: c_uint,
1722 Name: *const c_char,
1723 ) -> &'a Value;
1724
1725 pub(crate) fn LLVMBuildAtomicCmpXchg<'a>(
1727 B: &Builder<'a>,
1728 LHS: &'a Value,
1729 CMP: &'a Value,
1730 RHS: &'a Value,
1731 Order: AtomicOrdering,
1732 FailureOrder: AtomicOrdering,
1733 SingleThreaded: Bool,
1734 ) -> &'a Value;
1735
1736 pub(crate) fn LLVMSetWeak(CmpXchgInst: &Value, IsWeak: Bool);
1737
1738 pub(crate) fn LLVMBuildAtomicRMW<'a>(
1739 B: &Builder<'a>,
1740 Op: AtomicRmwBinOp,
1741 LHS: &'a Value,
1742 RHS: &'a Value,
1743 Order: AtomicOrdering,
1744 SingleThreaded: Bool,
1745 ) -> &'a Value;
1746
1747 pub(crate) fn LLVMBuildFence<'a>(
1748 B: &Builder<'a>,
1749 Order: AtomicOrdering,
1750 SingleThreaded: Bool,
1751 Name: *const c_char,
1752 ) -> &'a Value;
1753
1754 pub(crate) fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1756
1757 pub(crate) fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>;
1759
1760 pub(crate) fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>);
1761
1762 pub(crate) fn LLVMGetHostCPUFeatures() -> *mut c_char;
1763
1764 pub(crate) fn LLVMDisposeMessage(message: *mut c_char);
1765
1766 pub(crate) fn LLVMIsMultithreaded() -> Bool;
1767
1768 pub(crate) fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1769
1770 pub(crate) fn LLVMStructSetBody<'a>(
1771 StructTy: &'a Type,
1772 ElementTypes: *const &'a Type,
1773 ElementCount: c_uint,
1774 Packed: Bool,
1775 );
1776
1777 pub(crate) safe fn LLVMMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1778
1779 pub(crate) safe fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
1780
1781 pub(crate) fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
1782
1783 pub(crate) fn LLVMGetOrInsertComdat(M: &Module, Name: *const c_char) -> &Comdat;
1784 pub(crate) fn LLVMSetComdat(V: &Value, C: &Comdat);
1785
1786 pub(crate) fn LLVMCreateOperandBundle(
1787 Tag: *const c_char,
1788 TagLen: size_t,
1789 Args: *const &'_ Value,
1790 NumArgs: c_uint,
1791 ) -> *mut OperandBundle<'_>;
1792 pub(crate) fn LLVMDisposeOperandBundle(Bundle: ptr::NonNull<OperandBundle<'_>>);
1793
1794 pub(crate) fn LLVMBuildCallWithOperandBundles<'a>(
1795 B: &Builder<'a>,
1796 Ty: &'a Type,
1797 Fn: &'a Value,
1798 Args: *const &'a Value,
1799 NumArgs: c_uint,
1800 Bundles: *const &OperandBundle<'a>,
1801 NumBundles: c_uint,
1802 Name: *const c_char,
1803 ) -> &'a Value;
1804 pub(crate) fn LLVMBuildInvokeWithOperandBundles<'a>(
1805 B: &Builder<'a>,
1806 Ty: &'a Type,
1807 Fn: &'a Value,
1808 Args: *const &'a Value,
1809 NumArgs: c_uint,
1810 Then: &'a BasicBlock,
1811 Catch: &'a BasicBlock,
1812 Bundles: *const &OperandBundle<'a>,
1813 NumBundles: c_uint,
1814 Name: *const c_char,
1815 ) -> &'a Value;
1816 pub(crate) fn LLVMBuildCallBr<'a>(
1817 B: &Builder<'a>,
1818 Ty: &'a Type,
1819 Fn: &'a Value,
1820 DefaultDest: &'a BasicBlock,
1821 IndirectDests: *const &'a BasicBlock,
1822 NumIndirectDests: c_uint,
1823 Args: *const &'a Value,
1824 NumArgs: c_uint,
1825 Bundles: *const &OperandBundle<'a>,
1826 NumBundles: c_uint,
1827 Name: *const c_char,
1828 ) -> &'a Value;
1829}
1830
1831unsafe extern "C" {
1838 pub(crate) fn LLVMCreateDIBuilder<'ll>(M: &'ll Module) -> *mut DIBuilder<'ll>;
1839 pub(crate) fn LLVMDisposeDIBuilder<'ll>(Builder: ptr::NonNull<DIBuilder<'ll>>);
1840
1841 pub(crate) fn LLVMDIBuilderFinalize<'ll>(Builder: &DIBuilder<'ll>);
1842
1843 pub(crate) fn LLVMDIBuilderCreateNameSpace<'ll>(
1844 Builder: &DIBuilder<'ll>,
1845 ParentScope: Option<&'ll Metadata>,
1846 Name: *const c_uchar, NameLen: size_t,
1848 ExportSymbols: llvm::Bool,
1849 ) -> &'ll Metadata;
1850
1851 pub(crate) fn LLVMDIBuilderCreateLexicalBlock<'ll>(
1852 Builder: &DIBuilder<'ll>,
1853 Scope: &'ll Metadata,
1854 File: &'ll Metadata,
1855 Line: c_uint,
1856 Column: c_uint,
1857 ) -> &'ll Metadata;
1858
1859 pub(crate) fn LLVMDIBuilderCreateLexicalBlockFile<'ll>(
1860 Builder: &DIBuilder<'ll>,
1861 Scope: &'ll Metadata,
1862 File: &'ll Metadata,
1863 Discriminator: c_uint, ) -> &'ll Metadata;
1865
1866 pub(crate) fn LLVMDIBuilderCreateDebugLocation<'ll>(
1867 Ctx: &'ll Context,
1868 Line: c_uint,
1869 Column: c_uint,
1870 Scope: &'ll Metadata,
1871 InlinedAt: Option<&'ll Metadata>,
1872 ) -> &'ll Metadata;
1873}
1874
1875#[link(name = "llvm-wrapper", kind = "static")]
1876unsafe extern "C" {
1877 pub(crate) fn LLVMRustInstallErrorHandlers();
1878 pub(crate) fn LLVMRustDisableSystemDialogsOnCrash();
1879
1880 pub(crate) fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
1882
1883 pub(crate) fn LLVMRustGlobalAddMetadata<'a>(
1885 Val: &'a Value,
1886 KindID: c_uint,
1887 Metadata: &'a Metadata,
1888 );
1889 pub(crate) fn LLVMRustIsNonGVFunctionPointerTy(Val: &Value) -> bool;
1890
1891 pub(crate) fn LLVMRustConstIntGetZExtValue(ConstantVal: &ConstantInt, Value: &mut u64) -> bool;
1893 pub(crate) fn LLVMRustConstInt128Get(
1894 ConstantVal: &ConstantInt,
1895 SExt: bool,
1896 high: &mut u64,
1897 low: &mut u64,
1898 ) -> bool;
1899
1900 pub(crate) fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
1902
1903 pub(crate) fn LLVMRustGetOrInsertGlobal<'a>(
1905 M: &'a Module,
1906 Name: *const c_char,
1907 NameLen: size_t,
1908 T: &'a Type,
1909 ) -> &'a Value;
1910 pub(crate) fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value;
1911 pub(crate) fn LLVMRustGetNamedValue(
1912 M: &Module,
1913 Name: *const c_char,
1914 NameLen: size_t,
1915 ) -> Option<&Value>;
1916
1917 pub(crate) fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute;
1919 pub(crate) fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute;
1920 pub(crate) fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute;
1921 pub(crate) fn LLVMRustCreateDereferenceableOrNullAttr(C: &Context, bytes: u64) -> &Attribute;
1922 pub(crate) fn LLVMRustCreateByValAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1923 pub(crate) fn LLVMRustCreateStructRetAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1924 pub(crate) fn LLVMRustCreateElementTypeAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1925 pub(crate) fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute;
1926 pub(crate) fn LLVMRustCreateAllocSizeAttr(C: &Context, size_arg: u32) -> &Attribute;
1927 pub(crate) fn LLVMRustCreateAllocKindAttr(C: &Context, size_arg: u64) -> &Attribute;
1928 pub(crate) fn LLVMRustCreateMemoryEffectsAttr(
1929 C: &Context,
1930 effects: MemoryEffects,
1931 ) -> &Attribute;
1932 pub(crate) fn LLVMRustCreateRangeAttribute(
1939 C: &Context,
1940 NumBits: c_uint,
1941 LowerWords: *const u64,
1942 UpperWords: *const u64,
1943 ) -> &Attribute;
1944
1945 pub(crate) fn LLVMRustGetOrInsertFunction<'a>(
1947 M: &'a Module,
1948 Name: *const c_char,
1949 NameLen: size_t,
1950 FunctionTy: &'a Type,
1951 ) -> &'a Value;
1952 pub(crate) fn LLVMRustAddFunctionAttributes<'a>(
1953 Fn: &'a Value,
1954 index: c_uint,
1955 Attrs: *const &'a Attribute,
1956 AttrsLen: size_t,
1957 );
1958
1959 pub(crate) fn LLVMRustAddCallSiteAttributes<'a>(
1961 Instr: &'a Value,
1962 index: c_uint,
1963 Attrs: *const &'a Attribute,
1964 AttrsLen: size_t,
1965 );
1966
1967 pub(crate) fn LLVMRustSetFastMath(Instr: &Value);
1968 pub(crate) fn LLVMRustSetAlgebraicMath(Instr: &Value);
1969 pub(crate) fn LLVMRustSetAllowReassoc(Instr: &Value);
1970
1971 pub(crate) fn LLVMRustBuildMemCpy<'a>(
1973 B: &Builder<'a>,
1974 Dst: &'a Value,
1975 DstAlign: c_uint,
1976 Src: &'a Value,
1977 SrcAlign: c_uint,
1978 Size: &'a Value,
1979 IsVolatile: bool,
1980 ) -> &'a Value;
1981 pub(crate) fn LLVMRustBuildMemMove<'a>(
1982 B: &Builder<'a>,
1983 Dst: &'a Value,
1984 DstAlign: c_uint,
1985 Src: &'a Value,
1986 SrcAlign: c_uint,
1987 Size: &'a Value,
1988 IsVolatile: bool,
1989 ) -> &'a Value;
1990 pub(crate) fn LLVMRustBuildMemSet<'a>(
1991 B: &Builder<'a>,
1992 Dst: &'a Value,
1993 DstAlign: c_uint,
1994 Val: &'a Value,
1995 Size: &'a Value,
1996 IsVolatile: bool,
1997 ) -> &'a Value;
1998
1999 pub(crate) fn LLVMRustBuildVectorReduceFAdd<'a>(
2000 B: &Builder<'a>,
2001 Acc: &'a Value,
2002 Src: &'a Value,
2003 ) -> &'a Value;
2004 pub(crate) fn LLVMRustBuildVectorReduceFMul<'a>(
2005 B: &Builder<'a>,
2006 Acc: &'a Value,
2007 Src: &'a Value,
2008 ) -> &'a Value;
2009 pub(crate) fn LLVMRustBuildVectorReduceAdd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
2010 pub(crate) fn LLVMRustBuildVectorReduceMul<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
2011 pub(crate) fn LLVMRustBuildVectorReduceAnd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
2012 pub(crate) fn LLVMRustBuildVectorReduceOr<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
2013 pub(crate) fn LLVMRustBuildVectorReduceXor<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
2014 pub(crate) fn LLVMRustBuildVectorReduceMin<'a>(
2015 B: &Builder<'a>,
2016 Src: &'a Value,
2017 IsSigned: bool,
2018 ) -> &'a Value;
2019 pub(crate) fn LLVMRustBuildVectorReduceMax<'a>(
2020 B: &Builder<'a>,
2021 Src: &'a Value,
2022 IsSigned: bool,
2023 ) -> &'a Value;
2024 pub(crate) fn LLVMRustBuildVectorReduceFMin<'a>(
2025 B: &Builder<'a>,
2026 Src: &'a Value,
2027 IsNaN: bool,
2028 ) -> &'a Value;
2029 pub(crate) fn LLVMRustBuildVectorReduceFMax<'a>(
2030 B: &Builder<'a>,
2031 Src: &'a Value,
2032 IsNaN: bool,
2033 ) -> &'a Value;
2034
2035 pub(crate) fn LLVMRustBuildMinNum<'a>(
2036 B: &Builder<'a>,
2037 LHS: &'a Value,
2038 RHS: &'a Value,
2039 ) -> &'a Value;
2040 pub(crate) fn LLVMRustBuildMaxNum<'a>(
2041 B: &Builder<'a>,
2042 LHS: &'a Value,
2043 RHS: &'a Value,
2044 ) -> &'a Value;
2045
2046 pub(crate) fn LLVMRustBuildAtomicLoad<'a>(
2048 B: &Builder<'a>,
2049 ElementType: &'a Type,
2050 PointerVal: &'a Value,
2051 Name: *const c_char,
2052 Order: AtomicOrdering,
2053 ) -> &'a Value;
2054
2055 pub(crate) fn LLVMRustBuildAtomicStore<'a>(
2056 B: &Builder<'a>,
2057 Val: &'a Value,
2058 Ptr: &'a Value,
2059 Order: AtomicOrdering,
2060 ) -> &'a Value;
2061
2062 pub(crate) fn LLVMRustTimeTraceProfilerInitialize();
2063
2064 pub(crate) fn LLVMRustTimeTraceProfilerFinishThread();
2065
2066 pub(crate) fn LLVMRustTimeTraceProfilerFinish(FileName: *const c_char);
2067
2068 pub(crate) fn LLVMRustGetLastError() -> *const c_char;
2070
2071 pub(crate) fn LLVMRustPrintPassTimings(OutStr: &RustString);
2073
2074 pub(crate) fn LLVMRustPrintStatistics(OutStr: &RustString);
2076
2077 pub(crate) fn LLVMRustInlineAsmVerify(
2078 Ty: &Type,
2079 Constraints: *const c_uchar, ConstraintsLen: size_t,
2081 ) -> bool;
2082
2083 pub(crate) fn LLVMRustCoverageWriteFilenamesToBuffer(
2084 Filenames: *const *const c_char,
2085 FilenamesLen: size_t,
2086 Lengths: *const size_t,
2087 LengthsLen: size_t,
2088 BufferOut: &RustString,
2089 );
2090
2091 pub(crate) fn LLVMRustCoverageWriteFunctionMappingsToBuffer(
2092 VirtualFileMappingIDs: *const c_uint,
2093 NumVirtualFileMappingIDs: size_t,
2094 Expressions: *const crate::coverageinfo::ffi::CounterExpression,
2095 NumExpressions: size_t,
2096 CodeRegions: *const crate::coverageinfo::ffi::CodeRegion,
2097 NumCodeRegions: size_t,
2098 ExpansionRegions: *const crate::coverageinfo::ffi::ExpansionRegion,
2099 NumExpansionRegions: size_t,
2100 BranchRegions: *const crate::coverageinfo::ffi::BranchRegion,
2101 NumBranchRegions: size_t,
2102 BufferOut: &RustString,
2103 );
2104
2105 pub(crate) fn LLVMRustCoverageCreatePGOFuncNameVar(
2106 F: &Value,
2107 FuncName: *const c_char,
2108 FuncNameLen: size_t,
2109 ) -> &Value;
2110 pub(crate) fn LLVMRustCoverageHashBytes(Bytes: *const c_char, NumBytes: size_t) -> u64;
2111
2112 pub(crate) fn LLVMRustCoverageWriteCovmapSectionNameToString(M: &Module, OutStr: &RustString);
2113
2114 pub(crate) fn LLVMRustCoverageWriteCovfunSectionNameToString(M: &Module, OutStr: &RustString);
2115
2116 pub(crate) fn LLVMRustCoverageWriteCovmapVarNameToString(OutStr: &RustString);
2117
2118 pub(crate) fn LLVMRustCoverageMappingVersion() -> u32;
2119 pub(crate) fn LLVMRustDebugMetadataVersion() -> u32;
2120 pub(crate) fn LLVMRustVersionMajor() -> u32;
2121 pub(crate) fn LLVMRustVersionMinor() -> u32;
2122 pub(crate) fn LLVMRustVersionPatch() -> u32;
2123
2124 pub(crate) fn LLVMRustAddModuleFlagU32(
2129 M: &Module,
2130 MergeBehavior: ModuleFlagMergeBehavior,
2131 Name: *const c_char,
2132 NameLen: size_t,
2133 Value: u32,
2134 );
2135
2136 pub(crate) fn LLVMRustAddModuleFlagString(
2137 M: &Module,
2138 MergeBehavior: ModuleFlagMergeBehavior,
2139 Name: *const c_char,
2140 NameLen: size_t,
2141 Value: *const c_char,
2142 ValueLen: size_t,
2143 );
2144
2145 pub(crate) fn LLVMRustDIBuilderCreateCompileUnit<'a>(
2146 Builder: &DIBuilder<'a>,
2147 Lang: c_uint,
2148 File: &'a DIFile,
2149 Producer: *const c_char,
2150 ProducerLen: size_t,
2151 isOptimized: bool,
2152 Flags: *const c_char,
2153 RuntimeVer: c_uint,
2154 SplitName: *const c_char,
2155 SplitNameLen: size_t,
2156 kind: DebugEmissionKind,
2157 DWOId: u64,
2158 SplitDebugInlining: bool,
2159 DebugNameTableKind: DebugNameTableKind,
2160 ) -> &'a DIDescriptor;
2161
2162 pub(crate) fn LLVMRustDIBuilderCreateFile<'a>(
2163 Builder: &DIBuilder<'a>,
2164 Filename: *const c_char,
2165 FilenameLen: size_t,
2166 Directory: *const c_char,
2167 DirectoryLen: size_t,
2168 CSKind: ChecksumKind,
2169 Checksum: *const c_char,
2170 ChecksumLen: size_t,
2171 Source: *const c_char,
2172 SourceLen: size_t,
2173 ) -> &'a DIFile;
2174
2175 pub(crate) fn LLVMRustDIBuilderCreateSubroutineType<'a>(
2176 Builder: &DIBuilder<'a>,
2177 ParameterTypes: &'a DIArray,
2178 ) -> &'a DICompositeType;
2179
2180 pub(crate) fn LLVMRustDIBuilderCreateFunction<'a>(
2181 Builder: &DIBuilder<'a>,
2182 Scope: &'a DIDescriptor,
2183 Name: *const c_char,
2184 NameLen: size_t,
2185 LinkageName: *const c_char,
2186 LinkageNameLen: size_t,
2187 File: &'a DIFile,
2188 LineNo: c_uint,
2189 Ty: &'a DIType,
2190 ScopeLine: c_uint,
2191 Flags: DIFlags,
2192 SPFlags: DISPFlags,
2193 MaybeFn: Option<&'a Value>,
2194 TParam: &'a DIArray,
2195 Decl: Option<&'a DIDescriptor>,
2196 ) -> &'a DISubprogram;
2197
2198 pub(crate) fn LLVMRustDIBuilderCreateMethod<'a>(
2199 Builder: &DIBuilder<'a>,
2200 Scope: &'a DIDescriptor,
2201 Name: *const c_char,
2202 NameLen: size_t,
2203 LinkageName: *const c_char,
2204 LinkageNameLen: size_t,
2205 File: &'a DIFile,
2206 LineNo: c_uint,
2207 Ty: &'a DIType,
2208 Flags: DIFlags,
2209 SPFlags: DISPFlags,
2210 TParam: &'a DIArray,
2211 ) -> &'a DISubprogram;
2212
2213 pub(crate) fn LLVMRustDIBuilderCreateBasicType<'a>(
2214 Builder: &DIBuilder<'a>,
2215 Name: *const c_char,
2216 NameLen: size_t,
2217 SizeInBits: u64,
2218 Encoding: c_uint,
2219 ) -> &'a DIBasicType;
2220
2221 pub(crate) fn LLVMRustDIBuilderCreateTypedef<'a>(
2222 Builder: &DIBuilder<'a>,
2223 Type: &'a DIBasicType,
2224 Name: *const c_char,
2225 NameLen: size_t,
2226 File: &'a DIFile,
2227 LineNo: c_uint,
2228 Scope: Option<&'a DIScope>,
2229 ) -> &'a DIDerivedType;
2230
2231 pub(crate) fn LLVMRustDIBuilderCreatePointerType<'a>(
2232 Builder: &DIBuilder<'a>,
2233 PointeeTy: &'a DIType,
2234 SizeInBits: u64,
2235 AlignInBits: u32,
2236 AddressSpace: c_uint,
2237 Name: *const c_char,
2238 NameLen: size_t,
2239 ) -> &'a DIDerivedType;
2240
2241 pub(crate) fn LLVMRustDIBuilderCreateStructType<'a>(
2242 Builder: &DIBuilder<'a>,
2243 Scope: Option<&'a DIDescriptor>,
2244 Name: *const c_char,
2245 NameLen: size_t,
2246 File: &'a DIFile,
2247 LineNumber: c_uint,
2248 SizeInBits: u64,
2249 AlignInBits: u32,
2250 Flags: DIFlags,
2251 DerivedFrom: Option<&'a DIType>,
2252 Elements: &'a DIArray,
2253 RunTimeLang: c_uint,
2254 VTableHolder: Option<&'a DIType>,
2255 UniqueId: *const c_char,
2256 UniqueIdLen: size_t,
2257 ) -> &'a DICompositeType;
2258
2259 pub(crate) fn LLVMRustDIBuilderCreateMemberType<'a>(
2260 Builder: &DIBuilder<'a>,
2261 Scope: &'a DIDescriptor,
2262 Name: *const c_char,
2263 NameLen: size_t,
2264 File: &'a DIFile,
2265 LineNo: c_uint,
2266 SizeInBits: u64,
2267 AlignInBits: u32,
2268 OffsetInBits: u64,
2269 Flags: DIFlags,
2270 Ty: &'a DIType,
2271 ) -> &'a DIDerivedType;
2272
2273 pub(crate) fn LLVMRustDIBuilderCreateVariantMemberType<'a>(
2274 Builder: &DIBuilder<'a>,
2275 Scope: &'a DIScope,
2276 Name: *const c_char,
2277 NameLen: size_t,
2278 File: &'a DIFile,
2279 LineNumber: c_uint,
2280 SizeInBits: u64,
2281 AlignInBits: u32,
2282 OffsetInBits: u64,
2283 Discriminant: Option<&'a Value>,
2284 Flags: DIFlags,
2285 Ty: &'a DIType,
2286 ) -> &'a DIType;
2287
2288 pub(crate) fn LLVMRustDIBuilderCreateStaticMemberType<'a>(
2289 Builder: &DIBuilder<'a>,
2290 Scope: &'a DIDescriptor,
2291 Name: *const c_char,
2292 NameLen: size_t,
2293 File: &'a DIFile,
2294 LineNo: c_uint,
2295 Ty: &'a DIType,
2296 Flags: DIFlags,
2297 val: Option<&'a Value>,
2298 AlignInBits: u32,
2299 ) -> &'a DIDerivedType;
2300
2301 pub(crate) fn LLVMRustDIBuilderCreateQualifiedType<'a>(
2302 Builder: &DIBuilder<'a>,
2303 Tag: c_uint,
2304 Type: &'a DIType,
2305 ) -> &'a DIDerivedType;
2306
2307 pub(crate) fn LLVMRustDIBuilderCreateStaticVariable<'a>(
2308 Builder: &DIBuilder<'a>,
2309 Context: Option<&'a DIScope>,
2310 Name: *const c_char,
2311 NameLen: size_t,
2312 LinkageName: *const c_char,
2313 LinkageNameLen: size_t,
2314 File: &'a DIFile,
2315 LineNo: c_uint,
2316 Ty: &'a DIType,
2317 isLocalToUnit: bool,
2318 Val: &'a Value,
2319 Decl: Option<&'a DIDescriptor>,
2320 AlignInBits: u32,
2321 ) -> &'a DIGlobalVariableExpression;
2322
2323 pub(crate) fn LLVMRustDIBuilderCreateVariable<'a>(
2324 Builder: &DIBuilder<'a>,
2325 Tag: c_uint,
2326 Scope: &'a DIDescriptor,
2327 Name: *const c_char,
2328 NameLen: size_t,
2329 File: &'a DIFile,
2330 LineNo: c_uint,
2331 Ty: &'a DIType,
2332 AlwaysPreserve: bool,
2333 Flags: DIFlags,
2334 ArgNo: c_uint,
2335 AlignInBits: u32,
2336 ) -> &'a DIVariable;
2337
2338 pub(crate) fn LLVMRustDIBuilderCreateArrayType<'a>(
2339 Builder: &DIBuilder<'a>,
2340 Size: u64,
2341 AlignInBits: u32,
2342 Ty: &'a DIType,
2343 Subscripts: &'a DIArray,
2344 ) -> &'a DIType;
2345
2346 pub(crate) fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
2347 Builder: &DIBuilder<'a>,
2348 Lo: i64,
2349 Count: i64,
2350 ) -> &'a DISubrange;
2351
2352 pub(crate) fn LLVMRustDIBuilderGetOrCreateArray<'a>(
2353 Builder: &DIBuilder<'a>,
2354 Ptr: *const Option<&'a DIDescriptor>,
2355 Count: c_uint,
2356 ) -> &'a DIArray;
2357
2358 pub(crate) fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>(
2359 Builder: &DIBuilder<'a>,
2360 Val: &'a Value,
2361 VarInfo: &'a DIVariable,
2362 AddrOps: *const u64,
2363 AddrOpsCount: c_uint,
2364 DL: &'a DILocation,
2365 InsertAtEnd: &'a BasicBlock,
2366 );
2367
2368 pub(crate) fn LLVMRustDIBuilderCreateEnumerator<'a>(
2369 Builder: &DIBuilder<'a>,
2370 Name: *const c_char,
2371 NameLen: size_t,
2372 Value: *const u64,
2373 SizeInBits: c_uint,
2374 IsUnsigned: bool,
2375 ) -> &'a DIEnumerator;
2376
2377 pub(crate) fn LLVMRustDIBuilderCreateEnumerationType<'a>(
2378 Builder: &DIBuilder<'a>,
2379 Scope: &'a DIScope,
2380 Name: *const c_char,
2381 NameLen: size_t,
2382 File: &'a DIFile,
2383 LineNumber: c_uint,
2384 SizeInBits: u64,
2385 AlignInBits: u32,
2386 Elements: &'a DIArray,
2387 ClassType: &'a DIType,
2388 IsScoped: bool,
2389 ) -> &'a DIType;
2390
2391 pub(crate) fn LLVMRustDIBuilderCreateUnionType<'a>(
2392 Builder: &DIBuilder<'a>,
2393 Scope: Option<&'a DIScope>,
2394 Name: *const c_char,
2395 NameLen: size_t,
2396 File: &'a DIFile,
2397 LineNumber: c_uint,
2398 SizeInBits: u64,
2399 AlignInBits: u32,
2400 Flags: DIFlags,
2401 Elements: Option<&'a DIArray>,
2402 RunTimeLang: c_uint,
2403 UniqueId: *const c_char,
2404 UniqueIdLen: size_t,
2405 ) -> &'a DIType;
2406
2407 pub(crate) fn LLVMRustDIBuilderCreateVariantPart<'a>(
2408 Builder: &DIBuilder<'a>,
2409 Scope: &'a DIScope,
2410 Name: *const c_char,
2411 NameLen: size_t,
2412 File: &'a DIFile,
2413 LineNo: c_uint,
2414 SizeInBits: u64,
2415 AlignInBits: u32,
2416 Flags: DIFlags,
2417 Discriminator: Option<&'a DIDerivedType>,
2418 Elements: &'a DIArray,
2419 UniqueId: *const c_char,
2420 UniqueIdLen: size_t,
2421 ) -> &'a DIDerivedType;
2422
2423 pub(crate) fn LLVMRustDIBuilderCreateTemplateTypeParameter<'a>(
2424 Builder: &DIBuilder<'a>,
2425 Scope: Option<&'a DIScope>,
2426 Name: *const c_char,
2427 NameLen: size_t,
2428 Ty: &'a DIType,
2429 ) -> &'a DITemplateTypeParameter;
2430
2431 pub(crate) fn LLVMRustDICompositeTypeReplaceArrays<'a>(
2432 Builder: &DIBuilder<'a>,
2433 CompositeType: &'a DIType,
2434 Elements: Option<&'a DIArray>,
2435 Params: Option<&'a DIArray>,
2436 );
2437
2438 pub(crate) fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>(
2439 Location: &'a DILocation,
2440 BD: c_uint,
2441 ) -> Option<&'a DILocation>;
2442
2443 pub(crate) fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2444 pub(crate) fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2445
2446 pub(crate) fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2447
2448 pub(crate) fn LLVMRustPrintTargetCPUs(TM: &TargetMachine, OutStr: &RustString);
2449 pub(crate) fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2450 pub(crate) fn LLVMRustGetTargetFeature(
2451 T: &TargetMachine,
2452 Index: size_t,
2453 Feature: &mut *const c_char,
2454 Desc: &mut *const c_char,
2455 );
2456
2457 pub(crate) fn LLVMRustGetHostCPUName(LenOut: &mut size_t) -> *const u8;
2458
2459 pub(crate) fn LLVMRustCreateTargetMachine(
2462 Triple: *const c_char,
2463 CPU: *const c_char,
2464 Features: *const c_char,
2465 Abi: *const c_char,
2466 Model: CodeModel,
2467 Reloc: RelocModel,
2468 Level: CodeGenOptLevel,
2469 FloatABIType: FloatAbi,
2470 FunctionSections: bool,
2471 DataSections: bool,
2472 UniqueSectionNames: bool,
2473 TrapUnreachable: bool,
2474 Singlethread: bool,
2475 VerboseAsm: bool,
2476 EmitStackSizeSection: bool,
2477 RelaxELFRelocations: bool,
2478 UseInitArray: bool,
2479 SplitDwarfFile: *const c_char,
2480 OutputObjFile: *const c_char,
2481 DebugInfoCompression: *const c_char,
2482 UseEmulatedTls: bool,
2483 ArgsCstrBuff: *const c_uchar, ArgsCstrBuffLen: usize,
2485 UseWasmEH: bool,
2486 ) -> *mut TargetMachine;
2487
2488 pub(crate) fn LLVMRustDisposeTargetMachine(T: *mut TargetMachine);
2489 pub(crate) fn LLVMRustAddLibraryInfo<'a>(
2490 PM: &PassManager<'a>,
2491 M: &'a Module,
2492 DisableSimplifyLibCalls: bool,
2493 );
2494 pub(crate) fn LLVMRustWriteOutputFile<'a>(
2495 T: &'a TargetMachine,
2496 PM: *mut PassManager<'a>,
2497 M: &'a Module,
2498 Output: *const c_char,
2499 DwoOutput: *const c_char,
2500 FileType: FileType,
2501 VerifyIR: bool,
2502 ) -> LLVMRustResult;
2503 pub(crate) fn LLVMRustOptimize<'a>(
2504 M: &'a Module,
2505 TM: &'a TargetMachine,
2506 OptLevel: PassBuilderOptLevel,
2507 OptStage: OptStage,
2508 IsLinkerPluginLTO: bool,
2509 NoPrepopulatePasses: bool,
2510 VerifyIR: bool,
2511 LintIR: bool,
2512 ThinLTOBuffer: Option<&mut *mut ThinLTOBuffer>,
2513 EmitThinLTO: bool,
2514 EmitThinLTOSummary: bool,
2515 MergeFunctions: bool,
2516 UnrollLoops: bool,
2517 SLPVectorize: bool,
2518 LoopVectorize: bool,
2519 DisableSimplifyLibCalls: bool,
2520 EmitLifetimeMarkers: bool,
2521 RunEnzyme: bool,
2522 PrintBeforeEnzyme: bool,
2523 PrintAfterEnzyme: bool,
2524 PrintPasses: bool,
2525 SanitizerOptions: Option<&SanitizerOptions>,
2526 PGOGenPath: *const c_char,
2527 PGOUsePath: *const c_char,
2528 InstrumentCoverage: bool,
2529 InstrProfileOutput: *const c_char,
2530 PGOSampleUsePath: *const c_char,
2531 DebugInfoForProfiling: bool,
2532 llvm_selfprofiler: *mut c_void,
2533 begin_callback: SelfProfileBeforePassCallback,
2534 end_callback: SelfProfileAfterPassCallback,
2535 ExtraPasses: *const c_char,
2536 ExtraPassesLen: size_t,
2537 LLVMPlugins: *const c_char,
2538 LLVMPluginsLen: size_t,
2539 ) -> LLVMRustResult;
2540 pub(crate) fn LLVMRustPrintModule(
2541 M: &Module,
2542 Output: *const c_char,
2543 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2544 ) -> LLVMRustResult;
2545 pub(crate) fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2546 pub(crate) fn LLVMRustPrintPasses();
2547 pub(crate) fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2548 pub(crate) fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2549
2550 pub(crate) fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2551
2552 pub(crate) fn LLVMRustUnpackOptimizationDiagnostic<'a>(
2553 DI: &'a DiagnosticInfo,
2554 pass_name_out: &RustString,
2555 function_out: &mut Option<&'a Value>,
2556 loc_line_out: &mut c_uint,
2557 loc_column_out: &mut c_uint,
2558 loc_filename_out: &RustString,
2559 message_out: &RustString,
2560 );
2561
2562 pub(crate) fn LLVMRustUnpackInlineAsmDiagnostic<'a>(
2563 DI: &'a DiagnosticInfo,
2564 level_out: &mut DiagnosticLevel,
2565 cookie_out: &mut u64,
2566 message_out: &mut Option<&'a Twine>,
2567 );
2568
2569 pub(crate) fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2570 pub(crate) fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2571
2572 pub(crate) fn LLVMRustGetSMDiagnostic<'a>(
2573 DI: &'a DiagnosticInfo,
2574 cookie_out: &mut u64,
2575 ) -> &'a SMDiagnostic;
2576
2577 pub(crate) fn LLVMRustUnpackSMDiagnostic(
2578 d: &SMDiagnostic,
2579 message_out: &RustString,
2580 buffer_out: &RustString,
2581 level_out: &mut DiagnosticLevel,
2582 loc_out: &mut c_uint,
2583 ranges_out: *mut c_uint,
2584 num_ranges: &mut usize,
2585 ) -> bool;
2586
2587 pub(crate) fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
2588
2589 pub(crate) fn LLVMRustPositionBuilderPastAllocas<'a>(B: &Builder<'a>, Fn: &'a Value);
2590 pub(crate) fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
2591
2592 pub(crate) fn LLVMRustSetModulePICLevel(M: &Module);
2593 pub(crate) fn LLVMRustSetModulePIELevel(M: &Module);
2594 pub(crate) fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2595 pub(crate) fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2596 pub(crate) fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2597 pub(crate) fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2598 pub(crate) fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2599 pub(crate) fn LLVMRustModuleCost(M: &Module) -> u64;
2600 pub(crate) fn LLVMRustModuleInstructionStats(M: &Module, Str: &RustString);
2601
2602 pub(crate) fn LLVMRustThinLTOBufferCreate(
2603 M: &Module,
2604 is_thin: bool,
2605 ) -> &'static mut ThinLTOBuffer;
2606 pub(crate) fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2607 pub(crate) fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2608 pub(crate) fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2609 pub(crate) fn LLVMRustThinLTOBufferThinLinkDataPtr(M: &ThinLTOBuffer) -> *const c_char;
2610 pub(crate) fn LLVMRustThinLTOBufferThinLinkDataLen(M: &ThinLTOBuffer) -> size_t;
2611 pub(crate) fn LLVMRustCreateThinLTOData(
2612 Modules: *const ThinLTOModule,
2613 NumModules: size_t,
2614 PreservedSymbols: *const *const c_char,
2615 PreservedSymbolsLen: size_t,
2616 ) -> Option<&'static mut ThinLTOData>;
2617 pub(crate) fn LLVMRustPrepareThinLTORename(
2618 Data: &ThinLTOData,
2619 Module: &Module,
2620 Target: &TargetMachine,
2621 );
2622 pub(crate) fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2623 pub(crate) fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2624 pub(crate) fn LLVMRustPrepareThinLTOImport(
2625 Data: &ThinLTOData,
2626 Module: &Module,
2627 Target: &TargetMachine,
2628 ) -> bool;
2629 pub(crate) fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2630 pub(crate) fn LLVMRustParseBitcodeForLTO(
2631 Context: &Context,
2632 Data: *const u8,
2633 len: usize,
2634 Identifier: *const c_char,
2635 ) -> Option<&Module>;
2636
2637 pub(crate) fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>;
2638 pub(crate) fn LLVMRustLinkerAdd(
2639 linker: &Linker<'_>,
2640 bytecode: *const c_char,
2641 bytecode_len: usize,
2642 ) -> bool;
2643 pub(crate) fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>);
2644 pub(crate) fn LLVMRustComputeLTOCacheKey(
2645 key_out: &RustString,
2646 mod_id: *const c_char,
2647 data: &ThinLTOData,
2648 );
2649
2650 pub(crate) fn LLVMRustContextGetDiagnosticHandler(
2651 Context: &Context,
2652 ) -> Option<&DiagnosticHandler>;
2653 pub(crate) fn LLVMRustContextSetDiagnosticHandler(
2654 context: &Context,
2655 diagnostic_handler: Option<&DiagnosticHandler>,
2656 );
2657 pub(crate) fn LLVMRustContextConfigureDiagnosticHandler(
2658 context: &Context,
2659 diagnostic_handler_callback: DiagnosticHandlerTy,
2660 diagnostic_handler_context: *mut c_void,
2661 remark_all_passes: bool,
2662 remark_passes: *const *const c_char,
2663 remark_passes_len: usize,
2664 remark_file: *const c_char,
2665 pgo_available: bool,
2666 );
2667
2668 pub(crate) fn LLVMRustGetMangledName(V: &Value, out: &RustString);
2669
2670 pub(crate) fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32;
2671
2672 pub(crate) fn LLVMRustLLVMHasZlibCompressionForDebugSymbols() -> bool;
2673
2674 pub(crate) fn LLVMRustLLVMHasZstdCompressionForDebugSymbols() -> bool;
2675
2676 pub(crate) fn LLVMRustGetSymbols(
2677 buf_ptr: *const u8,
2678 buf_len: usize,
2679 state: *mut c_void,
2680 callback: GetSymbolsCallback,
2681 error_callback: GetSymbolsErrorCallback,
2682 ) -> *mut c_void;
2683
2684 pub(crate) fn LLVMRustIs64BitSymbolicFile(buf_ptr: *const u8, buf_len: usize) -> bool;
2685
2686 pub(crate) fn LLVMRustIsECObject(buf_ptr: *const u8, buf_len: usize) -> bool;
2687
2688 pub(crate) fn LLVMRustIsAnyArm64Coff(buf_ptr: *const u8, buf_len: usize) -> bool;
2689
2690 pub(crate) fn LLVMRustSetNoSanitizeAddress(Global: &Value);
2691 pub(crate) fn LLVMRustSetNoSanitizeHWAddress(Global: &Value);
2692}