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