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
366#[derive(Copy, Clone)]
368#[repr(C)]
369pub(crate) enum AtomicRmwBinOp {
370 AtomicXchg = 0,
371 AtomicAdd = 1,
372 AtomicSub = 2,
373 AtomicAnd = 3,
374 AtomicNand = 4,
375 AtomicOr = 5,
376 AtomicXor = 6,
377 AtomicMax = 7,
378 AtomicMin = 8,
379 AtomicUMax = 9,
380 AtomicUMin = 10,
381}
382
383#[derive(Copy, Clone)]
385#[repr(C)]
386pub(crate) enum AtomicOrdering {
387 #[allow(dead_code)]
388 NotAtomic = 0,
389 #[allow(dead_code)]
390 Unordered = 1,
391 Monotonic = 2,
392 Acquire = 4,
394 Release = 5,
395 AcquireRelease = 6,
396 SequentiallyConsistent = 7,
397}
398
399#[derive(Copy, Clone)]
401#[repr(C)]
402pub(crate) enum FileType {
403 AssemblyFile,
404 ObjectFile,
405}
406
407#[derive(Copy, Clone, PartialEq)]
409#[repr(C)]
410pub(crate) enum AsmDialect {
411 Att,
412 Intel,
413}
414
415#[derive(Copy, Clone, PartialEq)]
417#[repr(C)]
418pub(crate) enum CodeGenOptLevel {
419 None,
420 Less,
421 Default,
422 Aggressive,
423}
424
425#[repr(C)]
427pub(crate) enum PassBuilderOptLevel {
428 O0,
429 O1,
430 O2,
431 O3,
432 Os,
433 Oz,
434}
435
436#[derive(PartialEq)]
438#[repr(C)]
439pub(crate) enum OptStage {
440 PreLinkNoLTO,
441 PreLinkThinLTO,
442 PreLinkFatLTO,
443 ThinLTO,
444 FatLTO,
445}
446
447#[repr(C)]
449pub(crate) struct SanitizerOptions {
450 pub sanitize_address: bool,
451 pub sanitize_address_recover: bool,
452 pub sanitize_cfi: bool,
453 pub sanitize_dataflow: bool,
454 pub sanitize_dataflow_abilist: *const *const c_char,
455 pub sanitize_dataflow_abilist_len: size_t,
456 pub sanitize_kcfi: bool,
457 pub sanitize_memory: bool,
458 pub sanitize_memory_recover: bool,
459 pub sanitize_memory_track_origins: c_int,
460 pub sanitize_realtime: bool,
461 pub sanitize_thread: bool,
462 pub sanitize_hwaddress: bool,
463 pub sanitize_hwaddress_recover: bool,
464 pub sanitize_kernel_address: bool,
465 pub sanitize_kernel_address_recover: bool,
466}
467
468#[derive(Copy, Clone, PartialEq)]
470#[repr(C)]
471pub(crate) enum RelocModel {
472 Static,
473 PIC,
474 DynamicNoPic,
475 ROPI,
476 RWPI,
477 ROPI_RWPI,
478}
479
480#[derive(Copy, Clone, PartialEq)]
482#[repr(C)]
483pub(crate) enum FloatAbi {
484 Default,
485 Soft,
486 Hard,
487}
488
489#[derive(Copy, Clone)]
491#[repr(C)]
492pub(crate) enum CodeModel {
493 Tiny,
494 Small,
495 Kernel,
496 Medium,
497 Large,
498 None,
499}
500
501#[derive(Copy, Clone)]
503#[repr(C)]
504#[allow(dead_code)] pub(crate) enum DiagnosticKind {
506 Other,
507 InlineAsm,
508 StackSize,
509 DebugMetadataVersion,
510 SampleProfile,
511 OptimizationRemark,
512 OptimizationRemarkMissed,
513 OptimizationRemarkAnalysis,
514 OptimizationRemarkAnalysisFPCommute,
515 OptimizationRemarkAnalysisAliasing,
516 OptimizationRemarkOther,
517 OptimizationFailure,
518 PGOProfile,
519 Linker,
520 Unsupported,
521 SrcMgr,
522}
523
524#[derive(Copy, Clone)]
526#[repr(C)]
527#[allow(dead_code)] pub(crate) enum DiagnosticLevel {
529 Error,
530 Warning,
531 Note,
532 Remark,
533}
534
535unsafe extern "C" {
536 pub(crate) type ThinLTOData;
538
539 pub(crate) type ThinLTOBuffer;
541}
542
543#[repr(C)]
545pub(crate) struct ThinLTOModule {
546 pub identifier: *const c_char,
547 pub data: *const u8,
548 pub len: usize,
549}
550
551#[derive(Copy, Clone)]
553#[repr(C)]
554pub(crate) enum ThreadLocalMode {
555 #[expect(dead_code)]
556 NotThreadLocal,
557 GeneralDynamic,
558 LocalDynamic,
559 InitialExec,
560 LocalExec,
561}
562
563#[derive(Copy, Clone)]
565#[repr(C)]
566pub(crate) enum ChecksumKind {
567 None,
568 MD5,
569 SHA1,
570 SHA256,
571}
572
573#[derive(Copy, Clone)]
575#[repr(C)]
576pub(crate) enum MemoryEffects {
577 None,
578 ReadOnly,
579 InaccessibleMemOnly,
580 ReadOnlyNotPure,
581}
582
583#[derive(Copy, Clone, PartialEq, Eq)]
585#[repr(C)]
586#[expect(dead_code, reason = "Some variants are unused, but are kept to match LLVM-C")]
587pub(crate) enum Opcode {
588 Ret = 1,
589 Br = 2,
590 Switch = 3,
591 IndirectBr = 4,
592 Invoke = 5,
593 Unreachable = 7,
594 CallBr = 67,
595 FNeg = 66,
596 Add = 8,
597 FAdd = 9,
598 Sub = 10,
599 FSub = 11,
600 Mul = 12,
601 FMul = 13,
602 UDiv = 14,
603 SDiv = 15,
604 FDiv = 16,
605 URem = 17,
606 SRem = 18,
607 FRem = 19,
608 Shl = 20,
609 LShr = 21,
610 AShr = 22,
611 And = 23,
612 Or = 24,
613 Xor = 25,
614 Alloca = 26,
615 Load = 27,
616 Store = 28,
617 GetElementPtr = 29,
618 Trunc = 30,
619 ZExt = 31,
620 SExt = 32,
621 FPToUI = 33,
622 FPToSI = 34,
623 UIToFP = 35,
624 SIToFP = 36,
625 FPTrunc = 37,
626 FPExt = 38,
627 PtrToInt = 39,
628 IntToPtr = 40,
629 BitCast = 41,
630 AddrSpaceCast = 60,
631 ICmp = 42,
632 FCmp = 43,
633 PHI = 44,
634 Call = 45,
635 Select = 46,
636 UserOp1 = 47,
637 UserOp2 = 48,
638 VAArg = 49,
639 ExtractElement = 50,
640 InsertElement = 51,
641 ShuffleVector = 52,
642 ExtractValue = 53,
643 InsertValue = 54,
644 Freeze = 68,
645 Fence = 55,
646 AtomicCmpXchg = 56,
647 AtomicRMW = 57,
648 Resume = 58,
649 LandingPad = 59,
650 CleanupRet = 61,
651 CatchRet = 62,
652 CatchPad = 63,
653 CleanupPad = 64,
654 CatchSwitch = 65,
655}
656
657#[derive(Copy, Clone)]
659#[repr(C)]
660pub(crate) enum CompressionKind {
661 None = 0,
662 Zlib = 1,
663 Zstd = 2,
664}
665
666unsafe extern "C" {
667 type Opaque;
668}
669#[repr(C)]
670struct InvariantOpaque<'a> {
671 _marker: PhantomData<&'a mut &'a ()>,
672 _opaque: Opaque,
673}
674
675unsafe extern "C" {
677 pub(crate) type Module;
678 pub(crate) type Context;
679 pub(crate) type Type;
680 pub(crate) type Value;
681 pub(crate) type ConstantInt;
682 pub(crate) type Attribute;
683 pub(crate) type Metadata;
684 pub(crate) type BasicBlock;
685 pub(crate) type Comdat;
686 pub(crate) type DbgRecord;
688}
689#[repr(C)]
690pub(crate) struct Builder<'a>(InvariantOpaque<'a>);
691#[repr(C)]
692pub(crate) struct PassManager<'a>(InvariantOpaque<'a>);
693unsafe extern "C" {
694 pub type TargetMachine;
695}
696unsafe extern "C" {
697 pub(crate) type Twine;
698 pub(crate) type DiagnosticInfo;
699 pub(crate) type SMDiagnostic;
700}
701#[repr(C)]
703pub(crate) struct OperandBundle<'a>(InvariantOpaque<'a>);
704#[repr(C)]
705pub(crate) struct Linker<'a>(InvariantOpaque<'a>);
706
707unsafe extern "C" {
708 pub(crate) type DiagnosticHandler;
709}
710
711pub(crate) type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
712
713pub(crate) mod debuginfo {
714 use bitflags::bitflags;
715
716 use super::{InvariantOpaque, Metadata};
717
718 #[repr(C)]
727 pub(crate) struct DIBuilder<'ll>(InvariantOpaque<'ll>);
728
729 pub(crate) type DIDescriptor = Metadata;
730 pub(crate) type DILocation = Metadata;
731 pub(crate) type DIScope = DIDescriptor;
732 pub(crate) type DIFile = DIScope;
733 pub(crate) type DILexicalBlock = DIScope;
734 pub(crate) type DISubprogram = DIScope;
735 pub(crate) type DIType = DIDescriptor;
736 pub(crate) type DIBasicType = DIType;
737 pub(crate) type DIDerivedType = DIType;
738 pub(crate) type DICompositeType = DIDerivedType;
739 pub(crate) type DIVariable = DIDescriptor;
740 pub(crate) type DIArray = DIDescriptor;
741 pub(crate) type DIEnumerator = DIDescriptor;
742 pub(crate) type DITemplateTypeParameter = DIDescriptor;
743
744 bitflags! {
745 #[repr(transparent)]
750 #[derive(Clone, Copy, Default)]
751 pub(crate) struct DIFlags: u32 {
752 const FlagZero = 0;
753 const FlagPrivate = 1;
754 const FlagProtected = 2;
755 const FlagPublic = 3;
756 const FlagFwdDecl = (1 << 2);
757 const FlagAppleBlock = (1 << 3);
758 const FlagReservedBit4 = (1 << 4);
759 const FlagVirtual = (1 << 5);
760 const FlagArtificial = (1 << 6);
761 const FlagExplicit = (1 << 7);
762 const FlagPrototyped = (1 << 8);
763 const FlagObjcClassComplete = (1 << 9);
764 const FlagObjectPointer = (1 << 10);
765 const FlagVector = (1 << 11);
766 const FlagStaticMember = (1 << 12);
767 const FlagLValueReference = (1 << 13);
768 const FlagRValueReference = (1 << 14);
769 const FlagReserved = (1 << 15);
770 const FlagSingleInheritance = (1 << 16);
771 const FlagMultipleInheritance = (2 << 16);
772 const FlagVirtualInheritance = (3 << 16);
773 const FlagIntroducedVirtual = (1 << 18);
774 const FlagBitField = (1 << 19);
775 const FlagNoReturn = (1 << 20);
776 const FlagTypePassByValue = (1 << 22);
778 const FlagTypePassByReference = (1 << 23);
779 const FlagEnumClass = (1 << 24);
780 const FlagThunk = (1 << 25);
781 const FlagNonTrivial = (1 << 26);
782 const FlagBigEndian = (1 << 27);
783 const FlagLittleEndian = (1 << 28);
784 }
785 }
786
787 bitflags! {
789 #[repr(transparent)]
790 #[derive(Clone, Copy, Default)]
791 pub(crate) struct DISPFlags: u32 {
792 const SPFlagZero = 0;
793 const SPFlagVirtual = 1;
794 const SPFlagPureVirtual = 2;
795 const SPFlagLocalToUnit = (1 << 2);
796 const SPFlagDefinition = (1 << 3);
797 const SPFlagOptimized = (1 << 4);
798 const SPFlagMainSubprogram = (1 << 5);
799 }
800 }
801
802 #[derive(Copy, Clone)]
804 #[repr(C)]
805 pub(crate) enum DebugEmissionKind {
806 NoDebug,
807 FullDebug,
808 LineTablesOnly,
809 DebugDirectivesOnly,
810 }
811
812 #[derive(Clone, Copy)]
814 #[repr(C)]
815 pub(crate) enum DebugNameTableKind {
816 Default,
817 #[expect(dead_code)]
818 Gnu,
819 None,
820 }
821}
822
823bitflags! {
825 #[repr(transparent)]
826 #[derive(Default)]
827 pub(crate) struct AllocKindFlags : u64 {
828 const Unknown = 0;
829 const Alloc = 1;
830 const Realloc = 1 << 1;
831 const Free = 1 << 2;
832 const Uninitialized = 1 << 3;
833 const Zeroed = 1 << 4;
834 const Aligned = 1 << 5;
835 }
836}
837
838bitflags! {
840 #[repr(transparent)]
841 #[derive(Default)]
842 pub struct GEPNoWrapFlags : c_uint {
843 const InBounds = 1 << 0;
844 const NUSW = 1 << 1;
845 const NUW = 1 << 2;
846 }
847}
848
849unsafe extern "C" {
850 pub(crate) type ModuleBuffer;
851}
852
853pub(crate) type SelfProfileBeforePassCallback =
854 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
855pub(crate) type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
856
857pub(crate) type GetSymbolsCallback =
858 unsafe extern "C" fn(*mut c_void, *const c_char) -> *mut c_void;
859pub(crate) type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) -> *mut c_void;
860
861unsafe extern "C" {
862 pub(crate) fn LLVMContextCreate() -> &'static mut Context;
864 pub(crate) fn LLVMContextDispose(C: &'static mut Context);
865 pub(crate) fn LLVMContextSetDiscardValueNames(C: &Context, Discard: Bool);
866 pub(crate) fn LLVMGetMDKindIDInContext(
867 C: &Context,
868 Name: *const c_char,
869 SLen: c_uint,
870 ) -> MetadataKindId;
871
872 pub(crate) fn LLVMDisposeTargetMachine(T: ptr::NonNull<TargetMachine>);
873
874 pub(crate) fn LLVMModuleCreateWithNameInContext(
876 ModuleID: *const c_char,
877 C: &Context,
878 ) -> &Module;
879 pub(crate) safe fn LLVMCloneModule(M: &Module) -> &Module;
880
881 pub(crate) fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
883 pub(crate) fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
884
885 pub(crate) fn LLVMAppendModuleInlineAsm(
887 M: &Module,
888 Asm: *const c_uchar, Len: size_t,
890 );
891
892 pub(crate) fn LLVMGetInlineAsm<'ll>(
894 Ty: &'ll Type,
895 AsmString: *const c_uchar, AsmStringSize: size_t,
897 Constraints: *const c_uchar, ConstraintsSize: size_t,
899 HasSideEffects: llvm::Bool,
900 IsAlignStack: llvm::Bool,
901 Dialect: AsmDialect,
902 CanThrow: llvm::Bool,
903 ) -> &'ll Value;
904
905 pub(crate) safe fn LLVMGetTypeKind(Ty: &Type) -> RawEnum<TypeKind>;
906
907 pub(crate) fn LLVMInt1TypeInContext(C: &Context) -> &Type;
909 pub(crate) fn LLVMInt8TypeInContext(C: &Context) -> &Type;
910 pub(crate) fn LLVMInt16TypeInContext(C: &Context) -> &Type;
911 pub(crate) fn LLVMInt32TypeInContext(C: &Context) -> &Type;
912 pub(crate) fn LLVMInt64TypeInContext(C: &Context) -> &Type;
913 pub(crate) safe fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
914
915 pub(crate) fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
916
917 pub(crate) fn LLVMHalfTypeInContext(C: &Context) -> &Type;
919 pub(crate) fn LLVMFloatTypeInContext(C: &Context) -> &Type;
920 pub(crate) fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
921 pub(crate) fn LLVMFP128TypeInContext(C: &Context) -> &Type;
922
923 pub(crate) fn LLVMFunctionType<'a>(
925 ReturnType: &'a Type,
926 ParamTypes: *const &'a Type,
927 ParamCount: c_uint,
928 IsVarArg: Bool,
929 ) -> &'a Type;
930 pub(crate) fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
931 pub(crate) fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type);
932
933 pub(crate) fn LLVMStructTypeInContext<'a>(
935 C: &'a Context,
936 ElementTypes: *const &'a Type,
937 ElementCount: c_uint,
938 Packed: Bool,
939 ) -> &'a Type;
940
941 pub(crate) safe fn LLVMPointerTypeInContext(C: &Context, AddressSpace: c_uint) -> &Type;
943 pub(crate) fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
944 pub(crate) fn LLVMScalableVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
945
946 pub(crate) fn LLVMGetElementType(Ty: &Type) -> &Type;
947 pub(crate) fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
948
949 pub(crate) fn LLVMVoidTypeInContext(C: &Context) -> &Type;
951
952 pub(crate) fn LLVMTypeOf(Val: &Value) -> &Type;
954 pub(crate) fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
955 pub(crate) fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
956 pub(crate) fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value);
957 pub(crate) safe fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: MetadataKindId, Node: &'a Value);
958 pub(crate) fn LLVMGlobalSetMetadata<'a>(
959 Val: &'a Value,
960 KindID: MetadataKindId,
961 Metadata: &'a Metadata,
962 );
963 pub(crate) safe fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
964
965 pub(crate) fn LLVMConstNull(Ty: &Type) -> &Value;
967 pub(crate) fn LLVMGetUndef(Ty: &Type) -> &Value;
968 pub(crate) fn LLVMGetPoison(Ty: &Type) -> &Value;
969
970 pub(crate) fn LLVMMDStringInContext2(
972 C: &Context,
973 Str: *const c_char,
974 SLen: size_t,
975 ) -> &Metadata;
976 pub(crate) fn LLVMMDNodeInContext2<'a>(
977 C: &'a Context,
978 Vals: *const &'a Metadata,
979 Count: size_t,
980 ) -> &'a Metadata;
981 pub(crate) fn LLVMAddNamedMetadataOperand<'a>(
982 M: &'a Module,
983 Name: *const c_char,
984 Val: &'a Value,
985 );
986
987 pub(crate) fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
989 pub(crate) fn LLVMConstIntOfArbitraryPrecision(
990 IntTy: &Type,
991 Wn: c_uint,
992 Ws: *const u64,
993 ) -> &Value;
994 pub(crate) fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
995
996 pub(crate) fn LLVMConstArray2<'a>(
998 ElementTy: &'a Type,
999 ConstantVals: *const &'a Value,
1000 Length: u64,
1001 ) -> &'a Value;
1002 pub(crate) fn LLVMArrayType2(ElementType: &Type, ElementCount: u64) -> &Type;
1003 pub(crate) fn LLVMConstStringInContext2(
1004 C: &Context,
1005 Str: *const c_char,
1006 Length: size_t,
1007 DontNullTerminate: Bool,
1008 ) -> &Value;
1009 pub(crate) fn LLVMConstStructInContext<'a>(
1010 C: &'a Context,
1011 ConstantVals: *const &'a Value,
1012 Count: c_uint,
1013 Packed: Bool,
1014 ) -> &'a Value;
1015 pub(crate) fn LLVMConstNamedStruct<'a>(
1016 StructTy: &'a Type,
1017 ConstantVals: *const &'a Value,
1018 Count: c_uint,
1019 ) -> &'a Value;
1020 pub(crate) fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
1021
1022 pub(crate) fn LLVMConstInBoundsGEP2<'a>(
1024 ty: &'a Type,
1025 ConstantVal: &'a Value,
1026 ConstantIndices: *const &'a Value,
1027 NumIndices: c_uint,
1028 ) -> &'a Value;
1029 pub(crate) fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1030 pub(crate) fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1031 pub(crate) fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1032 pub(crate) fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1033 pub(crate) fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
1034 pub(crate) fn LLVMGetConstOpcode(ConstantVal: &Value) -> Opcode;
1035 pub(crate) fn LLVMIsAConstantExpr(Val: &Value) -> Option<&Value>;
1036
1037 pub(crate) fn LLVMIsDeclaration(Global: &Value) -> Bool;
1039 pub(crate) fn LLVMGetLinkage(Global: &Value) -> RawEnum<Linkage>;
1040 pub(crate) fn LLVMSetLinkage(Global: &Value, RustLinkage: Linkage);
1041 pub(crate) fn LLVMSetSection(Global: &Value, Section: *const c_char);
1042 pub(crate) fn LLVMGetVisibility(Global: &Value) -> RawEnum<Visibility>;
1043 pub(crate) fn LLVMSetVisibility(Global: &Value, Viz: Visibility);
1044 pub(crate) fn LLVMGetAlignment(Global: &Value) -> c_uint;
1045 pub(crate) fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1046 pub(crate) fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1047 pub(crate) fn LLVMGlobalGetValueType(Global: &Value) -> &Type;
1048
1049 pub(crate) safe fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
1051 pub(crate) fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1052 pub(crate) fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
1053 pub(crate) fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1054 pub(crate) fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1055 pub(crate) fn LLVMDeleteGlobal(GlobalVar: &Value);
1056 pub(crate) safe fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1057 pub(crate) fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
1058 pub(crate) safe fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
1059 pub(crate) fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1060 pub(crate) safe fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1061 pub(crate) safe fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1062 pub(crate) safe fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1063 pub(crate) safe fn LLVMSetTailCallKind(CallInst: &Value, kind: TailCallKind);
1064 pub(crate) safe fn LLVMSetExternallyInitialized(GlobalVar: &Value, IsExtInit: Bool);
1065
1066 pub(crate) fn LLVMCreateStringAttribute(
1068 C: &Context,
1069 Name: *const c_char,
1070 NameLen: c_uint,
1071 Value: *const c_char,
1072 ValueLen: c_uint,
1073 ) -> &Attribute;
1074
1075 pub(crate) fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1077 pub(crate) fn LLVMAddFunction<'a>(
1078 Mod: &'a Module,
1079 Name: *const c_char,
1080 FunctionTy: &'a Type,
1081 ) -> &'a Value;
1082 pub(crate) fn LLVMDeleteFunction(Fn: &Value);
1083
1084 pub(crate) fn LLVMLookupIntrinsicID(Name: *const c_char, NameLen: size_t) -> c_uint;
1086 pub(crate) fn LLVMGetIntrinsicDeclaration<'a>(
1087 Mod: &'a Module,
1088 ID: NonZero<c_uint>,
1089 ParamTypes: *const &'a Type,
1090 ParamCount: size_t,
1091 ) -> &'a Value;
1092
1093 pub(crate) fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1095 pub(crate) safe fn LLVMCountParams(Fn: &Value) -> c_uint;
1096 pub(crate) fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1097
1098 pub(crate) fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1100 pub(crate) fn LLVMAppendBasicBlockInContext<'a>(
1101 C: &'a Context,
1102 Fn: &'a Value,
1103 Name: *const c_char,
1104 ) -> &'a BasicBlock;
1105
1106 pub(crate) fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1108 pub(crate) fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1109 pub(crate) fn LLVMGetOperand(Val: &Value, Index: c_uint) -> Option<&Value>;
1110
1111 pub(crate) fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1113
1114 pub(crate) fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1116 pub(crate) fn LLVMSetOrdering(MemoryAccessInst: &Value, Ordering: AtomicOrdering);
1117
1118 pub(crate) fn LLVMAddIncoming<'a>(
1120 PhiNode: &'a Value,
1121 IncomingValues: *const &'a Value,
1122 IncomingBlocks: *const &'a BasicBlock,
1123 Count: c_uint,
1124 );
1125
1126 pub(crate) fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>;
1128 pub(crate) fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock);
1129 pub(crate) fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock;
1130 pub(crate) fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);
1131
1132 pub(crate) fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: *const Metadata);
1134 pub(crate) fn LLVMGetCurrentDebugLocation2<'a>(Builder: &Builder<'a>) -> Option<&'a Metadata>;
1135
1136 pub(crate) safe fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;
1138 pub(crate) fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1139 pub(crate) fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1140 pub(crate) fn LLVMBuildCondBr<'a>(
1141 B: &Builder<'a>,
1142 If: &'a Value,
1143 Then: &'a BasicBlock,
1144 Else: &'a BasicBlock,
1145 ) -> &'a Value;
1146 pub(crate) fn LLVMBuildSwitch<'a>(
1147 B: &Builder<'a>,
1148 V: &'a Value,
1149 Else: &'a BasicBlock,
1150 NumCases: c_uint,
1151 ) -> &'a Value;
1152 pub(crate) fn LLVMBuildLandingPad<'a>(
1153 B: &Builder<'a>,
1154 Ty: &'a Type,
1155 PersFn: Option<&'a Value>,
1156 NumClauses: c_uint,
1157 Name: *const c_char,
1158 ) -> &'a Value;
1159 pub(crate) fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1160 pub(crate) fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value;
1161
1162 pub(crate) fn LLVMBuildCleanupPad<'a>(
1163 B: &Builder<'a>,
1164 ParentPad: Option<&'a Value>,
1165 Args: *const &'a Value,
1166 NumArgs: c_uint,
1167 Name: *const c_char,
1168 ) -> Option<&'a Value>;
1169 pub(crate) fn LLVMBuildCleanupRet<'a>(
1170 B: &Builder<'a>,
1171 CleanupPad: &'a Value,
1172 BB: Option<&'a BasicBlock>,
1173 ) -> Option<&'a Value>;
1174 pub(crate) fn LLVMBuildCatchPad<'a>(
1175 B: &Builder<'a>,
1176 ParentPad: &'a Value,
1177 Args: *const &'a Value,
1178 NumArgs: c_uint,
1179 Name: *const c_char,
1180 ) -> Option<&'a Value>;
1181 pub(crate) fn LLVMBuildCatchRet<'a>(
1182 B: &Builder<'a>,
1183 CatchPad: &'a Value,
1184 BB: &'a BasicBlock,
1185 ) -> Option<&'a Value>;
1186 pub(crate) fn LLVMBuildCatchSwitch<'a>(
1187 Builder: &Builder<'a>,
1188 ParentPad: Option<&'a Value>,
1189 UnwindBB: Option<&'a BasicBlock>,
1190 NumHandlers: c_uint,
1191 Name: *const c_char,
1192 ) -> Option<&'a Value>;
1193 pub(crate) fn LLVMAddHandler<'a>(CatchSwitch: &'a Value, Dest: &'a BasicBlock);
1194 pub(crate) fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value);
1195
1196 pub(crate) fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1198
1199 pub(crate) fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value);
1201
1202 pub(crate) fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1204
1205 pub(crate) fn LLVMBuildAdd<'a>(
1207 B: &Builder<'a>,
1208 LHS: &'a Value,
1209 RHS: &'a Value,
1210 Name: *const c_char,
1211 ) -> &'a Value;
1212 pub(crate) fn LLVMBuildFAdd<'a>(
1213 B: &Builder<'a>,
1214 LHS: &'a Value,
1215 RHS: &'a Value,
1216 Name: *const c_char,
1217 ) -> &'a Value;
1218 pub(crate) fn LLVMBuildSub<'a>(
1219 B: &Builder<'a>,
1220 LHS: &'a Value,
1221 RHS: &'a Value,
1222 Name: *const c_char,
1223 ) -> &'a Value;
1224 pub(crate) fn LLVMBuildFSub<'a>(
1225 B: &Builder<'a>,
1226 LHS: &'a Value,
1227 RHS: &'a Value,
1228 Name: *const c_char,
1229 ) -> &'a Value;
1230 pub(crate) fn LLVMBuildMul<'a>(
1231 B: &Builder<'a>,
1232 LHS: &'a Value,
1233 RHS: &'a Value,
1234 Name: *const c_char,
1235 ) -> &'a Value;
1236 pub(crate) fn LLVMBuildFMul<'a>(
1237 B: &Builder<'a>,
1238 LHS: &'a Value,
1239 RHS: &'a Value,
1240 Name: *const c_char,
1241 ) -> &'a Value;
1242 pub(crate) fn LLVMBuildUDiv<'a>(
1243 B: &Builder<'a>,
1244 LHS: &'a Value,
1245 RHS: &'a Value,
1246 Name: *const c_char,
1247 ) -> &'a Value;
1248 pub(crate) fn LLVMBuildExactUDiv<'a>(
1249 B: &Builder<'a>,
1250 LHS: &'a Value,
1251 RHS: &'a Value,
1252 Name: *const c_char,
1253 ) -> &'a Value;
1254 pub(crate) fn LLVMBuildSDiv<'a>(
1255 B: &Builder<'a>,
1256 LHS: &'a Value,
1257 RHS: &'a Value,
1258 Name: *const c_char,
1259 ) -> &'a Value;
1260 pub(crate) fn LLVMBuildExactSDiv<'a>(
1261 B: &Builder<'a>,
1262 LHS: &'a Value,
1263 RHS: &'a Value,
1264 Name: *const c_char,
1265 ) -> &'a Value;
1266 pub(crate) fn LLVMBuildFDiv<'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 LLVMBuildURem<'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 LLVMBuildSRem<'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 LLVMBuildFRem<'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 LLVMBuildShl<'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 LLVMBuildLShr<'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 LLVMBuildAShr<'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 LLVMBuildNSWAdd<'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 LLVMBuildNUWAdd<'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 LLVMBuildNSWSub<'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 LLVMBuildNUWSub<'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 LLVMBuildNSWMul<'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 LLVMBuildNUWMul<'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 LLVMBuildAnd<'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 LLVMBuildOr<'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 LLVMBuildXor<'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 LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char)
1363 -> &'a Value;
1364 pub(crate) fn LLVMBuildFNeg<'a>(
1365 B: &Builder<'a>,
1366 V: &'a Value,
1367 Name: *const c_char,
1368 ) -> &'a Value;
1369 pub(crate) fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char)
1370 -> &'a Value;
1371
1372 pub(crate) fn LLVMSetIsDisjoint(Instr: &Value, IsDisjoint: Bool);
1374 pub(crate) fn LLVMSetNUW(ArithInst: &Value, HasNUW: Bool);
1375 pub(crate) fn LLVMSetNSW(ArithInst: &Value, HasNSW: Bool);
1376
1377 pub(crate) fn LLVMBuildAlloca<'a>(
1379 B: &Builder<'a>,
1380 Ty: &'a Type,
1381 Name: *const c_char,
1382 ) -> &'a Value;
1383 pub(crate) fn LLVMBuildLoad2<'a>(
1384 B: &Builder<'a>,
1385 Ty: &'a Type,
1386 PointerVal: &'a Value,
1387 Name: *const c_char,
1388 ) -> &'a Value;
1389
1390 pub(crate) fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1391
1392 pub(crate) fn LLVMBuildGEPWithNoWrapFlags<'a>(
1393 B: &Builder<'a>,
1394 Ty: &'a Type,
1395 Pointer: &'a Value,
1396 Indices: *const &'a Value,
1397 NumIndices: c_uint,
1398 Name: *const c_char,
1399 Flags: GEPNoWrapFlags,
1400 ) -> &'a Value;
1401
1402 pub(crate) fn LLVMBuildTrunc<'a>(
1404 B: &Builder<'a>,
1405 Val: &'a Value,
1406 DestTy: &'a Type,
1407 Name: *const c_char,
1408 ) -> &'a Value;
1409 pub(crate) fn LLVMBuildZExt<'a>(
1410 B: &Builder<'a>,
1411 Val: &'a Value,
1412 DestTy: &'a Type,
1413 Name: *const c_char,
1414 ) -> &'a Value;
1415 pub(crate) fn LLVMBuildSExt<'a>(
1416 B: &Builder<'a>,
1417 Val: &'a Value,
1418 DestTy: &'a Type,
1419 Name: *const c_char,
1420 ) -> &'a Value;
1421 pub(crate) fn LLVMBuildFPToUI<'a>(
1422 B: &Builder<'a>,
1423 Val: &'a Value,
1424 DestTy: &'a Type,
1425 Name: *const c_char,
1426 ) -> &'a Value;
1427 pub(crate) fn LLVMBuildFPToSI<'a>(
1428 B: &Builder<'a>,
1429 Val: &'a Value,
1430 DestTy: &'a Type,
1431 Name: *const c_char,
1432 ) -> &'a Value;
1433 pub(crate) fn LLVMBuildUIToFP<'a>(
1434 B: &Builder<'a>,
1435 Val: &'a Value,
1436 DestTy: &'a Type,
1437 Name: *const c_char,
1438 ) -> &'a Value;
1439 pub(crate) fn LLVMBuildSIToFP<'a>(
1440 B: &Builder<'a>,
1441 Val: &'a Value,
1442 DestTy: &'a Type,
1443 Name: *const c_char,
1444 ) -> &'a Value;
1445 pub(crate) fn LLVMBuildFPTrunc<'a>(
1446 B: &Builder<'a>,
1447 Val: &'a Value,
1448 DestTy: &'a Type,
1449 Name: *const c_char,
1450 ) -> &'a Value;
1451 pub(crate) fn LLVMBuildFPExt<'a>(
1452 B: &Builder<'a>,
1453 Val: &'a Value,
1454 DestTy: &'a Type,
1455 Name: *const c_char,
1456 ) -> &'a Value;
1457 pub(crate) fn LLVMBuildPtrToInt<'a>(
1458 B: &Builder<'a>,
1459 Val: &'a Value,
1460 DestTy: &'a Type,
1461 Name: *const c_char,
1462 ) -> &'a Value;
1463 pub(crate) fn LLVMBuildIntToPtr<'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 LLVMBuildBitCast<'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 LLVMBuildPointerCast<'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 LLVMBuildIntCast2<'a>(
1482 B: &Builder<'a>,
1483 Val: &'a Value,
1484 DestTy: &'a Type,
1485 IsSigned: Bool,
1486 Name: *const c_char,
1487 ) -> &'a Value;
1488
1489 pub(crate) fn LLVMBuildICmp<'a>(
1491 B: &Builder<'a>,
1492 Op: c_uint,
1493 LHS: &'a Value,
1494 RHS: &'a Value,
1495 Name: *const c_char,
1496 ) -> &'a Value;
1497 pub(crate) fn LLVMBuildFCmp<'a>(
1498 B: &Builder<'a>,
1499 Op: c_uint,
1500 LHS: &'a Value,
1501 RHS: &'a Value,
1502 Name: *const c_char,
1503 ) -> &'a Value;
1504
1505 pub(crate) fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char)
1507 -> &'a Value;
1508 pub(crate) fn LLVMBuildSelect<'a>(
1509 B: &Builder<'a>,
1510 If: &'a Value,
1511 Then: &'a Value,
1512 Else: &'a Value,
1513 Name: *const c_char,
1514 ) -> &'a Value;
1515 pub(crate) fn LLVMBuildVAArg<'a>(
1516 B: &Builder<'a>,
1517 list: &'a Value,
1518 Ty: &'a Type,
1519 Name: *const c_char,
1520 ) -> &'a Value;
1521 pub(crate) fn LLVMBuildExtractElement<'a>(
1522 B: &Builder<'a>,
1523 VecVal: &'a Value,
1524 Index: &'a Value,
1525 Name: *const c_char,
1526 ) -> &'a Value;
1527 pub(crate) fn LLVMBuildInsertElement<'a>(
1528 B: &Builder<'a>,
1529 VecVal: &'a Value,
1530 EltVal: &'a Value,
1531 Index: &'a Value,
1532 Name: *const c_char,
1533 ) -> &'a Value;
1534 pub(crate) fn LLVMBuildShuffleVector<'a>(
1535 B: &Builder<'a>,
1536 V1: &'a Value,
1537 V2: &'a Value,
1538 Mask: &'a Value,
1539 Name: *const c_char,
1540 ) -> &'a Value;
1541 pub(crate) fn LLVMBuildExtractValue<'a>(
1542 B: &Builder<'a>,
1543 AggVal: &'a Value,
1544 Index: c_uint,
1545 Name: *const c_char,
1546 ) -> &'a Value;
1547 pub(crate) fn LLVMBuildInsertValue<'a>(
1548 B: &Builder<'a>,
1549 AggVal: &'a Value,
1550 EltVal: &'a Value,
1551 Index: c_uint,
1552 Name: *const c_char,
1553 ) -> &'a Value;
1554
1555 pub(crate) fn LLVMBuildAtomicCmpXchg<'a>(
1557 B: &Builder<'a>,
1558 LHS: &'a Value,
1559 CMP: &'a Value,
1560 RHS: &'a Value,
1561 Order: AtomicOrdering,
1562 FailureOrder: AtomicOrdering,
1563 SingleThreaded: Bool,
1564 ) -> &'a Value;
1565
1566 pub(crate) fn LLVMSetWeak(CmpXchgInst: &Value, IsWeak: Bool);
1567
1568 pub(crate) fn LLVMBuildAtomicRMW<'a>(
1569 B: &Builder<'a>,
1570 Op: AtomicRmwBinOp,
1571 LHS: &'a Value,
1572 RHS: &'a Value,
1573 Order: AtomicOrdering,
1574 SingleThreaded: Bool,
1575 ) -> &'a Value;
1576
1577 pub(crate) fn LLVMBuildFence<'a>(
1578 B: &Builder<'a>,
1579 Order: AtomicOrdering,
1580 SingleThreaded: Bool,
1581 Name: *const c_char,
1582 ) -> &'a Value;
1583
1584 pub(crate) fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1586
1587 pub(crate) fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>;
1589
1590 pub(crate) fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>);
1591
1592 pub(crate) fn LLVMGetHostCPUFeatures() -> *mut c_char;
1593
1594 pub(crate) fn LLVMDisposeMessage(message: *mut c_char);
1595
1596 pub(crate) fn LLVMIsMultithreaded() -> Bool;
1597
1598 pub(crate) fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1599
1600 pub(crate) fn LLVMStructSetBody<'a>(
1601 StructTy: &'a Type,
1602 ElementTypes: *const &'a Type,
1603 ElementCount: c_uint,
1604 Packed: Bool,
1605 );
1606
1607 pub(crate) safe fn LLVMMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1608
1609 pub(crate) safe fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
1610
1611 pub(crate) fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
1612
1613 pub(crate) fn LLVMGetOrInsertComdat(M: &Module, Name: *const c_char) -> &Comdat;
1614 pub(crate) fn LLVMSetComdat(V: &Value, C: &Comdat);
1615
1616 pub(crate) fn LLVMCreateOperandBundle(
1617 Tag: *const c_char,
1618 TagLen: size_t,
1619 Args: *const &'_ Value,
1620 NumArgs: c_uint,
1621 ) -> *mut OperandBundle<'_>;
1622 pub(crate) fn LLVMDisposeOperandBundle(Bundle: ptr::NonNull<OperandBundle<'_>>);
1623
1624 pub(crate) fn LLVMBuildCallWithOperandBundles<'a>(
1625 B: &Builder<'a>,
1626 Ty: &'a Type,
1627 Fn: &'a Value,
1628 Args: *const &'a Value,
1629 NumArgs: c_uint,
1630 Bundles: *const &OperandBundle<'a>,
1631 NumBundles: c_uint,
1632 Name: *const c_char,
1633 ) -> &'a Value;
1634 pub(crate) fn LLVMBuildInvokeWithOperandBundles<'a>(
1635 B: &Builder<'a>,
1636 Ty: &'a Type,
1637 Fn: &'a Value,
1638 Args: *const &'a Value,
1639 NumArgs: c_uint,
1640 Then: &'a BasicBlock,
1641 Catch: &'a BasicBlock,
1642 Bundles: *const &OperandBundle<'a>,
1643 NumBundles: c_uint,
1644 Name: *const c_char,
1645 ) -> &'a Value;
1646 pub(crate) fn LLVMBuildCallBr<'a>(
1647 B: &Builder<'a>,
1648 Ty: &'a Type,
1649 Fn: &'a Value,
1650 DefaultDest: &'a BasicBlock,
1651 IndirectDests: *const &'a BasicBlock,
1652 NumIndirectDests: c_uint,
1653 Args: *const &'a Value,
1654 NumArgs: c_uint,
1655 Bundles: *const &OperandBundle<'a>,
1656 NumBundles: c_uint,
1657 Name: *const c_char,
1658 ) -> &'a Value;
1659}
1660
1661#[cfg(feature = "llvm_offload")]
1662pub(crate) use self::Offload::*;
1663
1664#[cfg(feature = "llvm_offload")]
1665mod Offload {
1666 use super::*;
1667 unsafe extern "C" {
1668 pub(crate) fn LLVMRustBundleImages<'a>(
1670 M: &'a Module,
1671 TM: &'a TargetMachine,
1672 host_out: *const c_char,
1673 ) -> bool;
1674 pub(crate) unsafe fn LLVMRustOffloadEmbedBufferInModule<'a>(
1675 _M: &'a Module,
1676 _host_out: *const c_char,
1677 ) -> bool;
1678 pub(crate) fn LLVMRustOffloadMapper<'a>(OldFn: &'a Value, NewFn: &'a Value);
1679 }
1680}
1681
1682#[cfg(not(feature = "llvm_offload"))]
1683pub(crate) use self::Offload_fallback::*;
1684
1685#[cfg(not(feature = "llvm_offload"))]
1686mod Offload_fallback {
1687 use super::*;
1688 #[allow(unused_unsafe)]
1691 pub(crate) unsafe fn LLVMRustBundleImages<'a>(
1692 _M: &'a Module,
1693 _TM: &'a TargetMachine,
1694 _host_out: *const c_char,
1695 ) -> bool {
1696 unimplemented!("This rustc version was not built with LLVM Offload support!");
1697 }
1698 pub(crate) unsafe fn LLVMRustOffloadEmbedBufferInModule<'a>(
1699 _M: &'a Module,
1700 _host_out: *const c_char,
1701 ) -> bool {
1702 unimplemented!("This rustc version was not built with LLVM Offload support!");
1703 }
1704 #[allow(unused_unsafe)]
1705 pub(crate) unsafe fn LLVMRustOffloadMapper<'a>(_OldFn: &'a Value, _NewFn: &'a Value) {
1706 unimplemented!("This rustc version was not built with LLVM Offload support!");
1707 }
1708}
1709
1710unsafe extern "C" {
1717 pub(crate) fn LLVMCreateDIBuilder<'ll>(M: &'ll Module) -> *mut DIBuilder<'ll>;
1718 pub(crate) fn LLVMDisposeDIBuilder<'ll>(Builder: ptr::NonNull<DIBuilder<'ll>>);
1719
1720 pub(crate) fn LLVMDIBuilderFinalize<'ll>(Builder: &DIBuilder<'ll>);
1721
1722 pub(crate) fn LLVMDIBuilderCreateNameSpace<'ll>(
1723 Builder: &DIBuilder<'ll>,
1724 ParentScope: Option<&'ll Metadata>,
1725 Name: *const c_uchar, NameLen: size_t,
1727 ExportSymbols: llvm::Bool,
1728 ) -> &'ll Metadata;
1729
1730 pub(crate) fn LLVMDIBuilderCreateLexicalBlock<'ll>(
1731 Builder: &DIBuilder<'ll>,
1732 Scope: &'ll Metadata,
1733 File: &'ll Metadata,
1734 Line: c_uint,
1735 Column: c_uint,
1736 ) -> &'ll Metadata;
1737
1738 pub(crate) fn LLVMDIBuilderCreateLexicalBlockFile<'ll>(
1739 Builder: &DIBuilder<'ll>,
1740 Scope: &'ll Metadata,
1741 File: &'ll Metadata,
1742 Discriminator: c_uint, ) -> &'ll Metadata;
1744
1745 pub(crate) fn LLVMDIBuilderCreateDebugLocation<'ll>(
1746 Ctx: &'ll Context,
1747 Line: c_uint,
1748 Column: c_uint,
1749 Scope: &'ll Metadata,
1750 InlinedAt: Option<&'ll Metadata>,
1751 ) -> &'ll Metadata;
1752
1753 pub(crate) fn LLVMDIBuilderCreateSubroutineType<'ll>(
1754 Builder: &DIBuilder<'ll>,
1755 File: Option<&'ll Metadata>, ParameterTypes: *const Option<&'ll Metadata>,
1757 NumParameterTypes: c_uint,
1758 Flags: DIFlags, ) -> &'ll Metadata;
1760
1761 pub(crate) fn LLVMDIBuilderCreateUnionType<'ll>(
1762 Builder: &DIBuilder<'ll>,
1763 Scope: Option<&'ll Metadata>,
1764 Name: *const c_uchar, NameLen: size_t,
1766 File: &'ll Metadata,
1767 LineNumber: c_uint,
1768 SizeInBits: u64,
1769 AlignInBits: u32,
1770 Flags: DIFlags,
1771 Elements: *const Option<&'ll Metadata>,
1772 NumElements: c_uint,
1773 RunTimeLang: c_uint, UniqueId: *const c_uchar, UniqueIdLen: size_t,
1776 ) -> &'ll Metadata;
1777
1778 pub(crate) fn LLVMDIBuilderCreateArrayType<'ll>(
1779 Builder: &DIBuilder<'ll>,
1780 Size: u64,
1781 Align: u32,
1782 Ty: &'ll Metadata,
1783 Subscripts: *const &'ll Metadata,
1784 NumSubscripts: c_uint,
1785 ) -> &'ll Metadata;
1786
1787 pub(crate) fn LLVMDIBuilderCreateBasicType<'ll>(
1788 Builder: &DIBuilder<'ll>,
1789 Name: *const c_uchar, NameLen: size_t,
1791 SizeInBits: u64,
1792 Encoding: c_uint, Flags: DIFlags, ) -> &'ll Metadata;
1795
1796 pub(crate) fn LLVMDIBuilderCreatePointerType<'ll>(
1797 Builder: &DIBuilder<'ll>,
1798 PointeeTy: &'ll Metadata,
1799 SizeInBits: u64,
1800 AlignInBits: u32,
1801 AddressSpace: c_uint, Name: *const c_uchar, NameLen: size_t,
1804 ) -> &'ll Metadata;
1805
1806 pub(crate) fn LLVMDIBuilderCreateStructType<'ll>(
1807 Builder: &DIBuilder<'ll>,
1808 Scope: Option<&'ll Metadata>,
1809 Name: *const c_uchar, NameLen: size_t,
1811 File: &'ll Metadata,
1812 LineNumber: c_uint,
1813 SizeInBits: u64,
1814 AlignInBits: u32,
1815 Flags: DIFlags,
1816 DerivedFrom: Option<&'ll Metadata>,
1817 Elements: *const Option<&'ll Metadata>,
1818 NumElements: c_uint,
1819 RunTimeLang: c_uint, VTableHolder: Option<&'ll Metadata>,
1821 UniqueId: *const c_uchar, UniqueIdLen: size_t,
1823 ) -> &'ll Metadata;
1824
1825 pub(crate) fn LLVMDIBuilderCreateMemberType<'ll>(
1826 Builder: &DIBuilder<'ll>,
1827 Scope: &'ll Metadata,
1828 Name: *const c_uchar, NameLen: size_t,
1830 File: &'ll Metadata,
1831 LineNo: c_uint,
1832 SizeInBits: u64,
1833 AlignInBits: u32,
1834 OffsetInBits: u64,
1835 Flags: DIFlags,
1836 Ty: &'ll Metadata,
1837 ) -> &'ll Metadata;
1838
1839 pub(crate) fn LLVMDIBuilderCreateStaticMemberType<'ll>(
1840 Builder: &DIBuilder<'ll>,
1841 Scope: &'ll Metadata,
1842 Name: *const c_uchar, NameLen: size_t,
1844 File: &'ll Metadata,
1845 LineNumber: c_uint,
1846 Type: &'ll Metadata,
1847 Flags: DIFlags,
1848 ConstantVal: Option<&'ll Value>,
1849 AlignInBits: u32,
1850 ) -> &'ll Metadata;
1851
1852 pub(crate) fn LLVMDIBuilderCreateQualifiedType<'ll>(
1855 Builder: &DIBuilder<'ll>,
1856 Tag: c_uint, Type: &'ll Metadata,
1858 ) -> &'ll Metadata;
1859
1860 pub(crate) fn LLVMDIBuilderCreateTypedef<'ll>(
1861 Builder: &DIBuilder<'ll>,
1862 Type: &'ll Metadata,
1863 Name: *const c_uchar, NameLen: size_t,
1865 File: &'ll Metadata,
1866 LineNo: c_uint,
1867 Scope: Option<&'ll Metadata>,
1868 AlignInBits: u32, ) -> &'ll Metadata;
1870
1871 pub(crate) fn LLVMDIBuilderGetOrCreateSubrange<'ll>(
1872 Builder: &DIBuilder<'ll>,
1873 LowerBound: i64,
1874 Count: i64,
1875 ) -> &'ll Metadata;
1876
1877 pub(crate) fn LLVMDIBuilderGetOrCreateArray<'ll>(
1878 Builder: &DIBuilder<'ll>,
1879 Data: *const Option<&'ll Metadata>,
1880 NumElements: size_t,
1881 ) -> &'ll Metadata;
1882
1883 pub(crate) fn LLVMDIBuilderCreateExpression<'ll>(
1884 Builder: &DIBuilder<'ll>,
1885 Addr: *const u64,
1886 Length: size_t,
1887 ) -> &'ll Metadata;
1888
1889 pub(crate) fn LLVMDIBuilderCreateGlobalVariableExpression<'ll>(
1890 Builder: &DIBuilder<'ll>,
1891 Scope: Option<&'ll Metadata>,
1892 Name: *const c_uchar, NameLen: size_t,
1894 Linkage: *const c_uchar, LinkLen: size_t,
1896 File: &'ll Metadata,
1897 LineNo: c_uint,
1898 Ty: &'ll Metadata,
1899 LocalToUnit: llvm::Bool,
1900 Expr: &'ll Metadata,
1901 Decl: Option<&'ll Metadata>,
1902 AlignInBits: u32,
1903 ) -> &'ll Metadata;
1904
1905 pub(crate) fn LLVMDIBuilderInsertDeclareRecordAtEnd<'ll>(
1906 Builder: &DIBuilder<'ll>,
1907 Storage: &'ll Value,
1908 VarInfo: &'ll Metadata,
1909 Expr: &'ll Metadata,
1910 DebugLoc: &'ll Metadata,
1911 Block: &'ll BasicBlock,
1912 ) -> &'ll DbgRecord;
1913
1914 pub(crate) fn LLVMDIBuilderInsertDbgValueRecordAtEnd<'ll>(
1915 Builder: &DIBuilder<'ll>,
1916 Val: &'ll Value,
1917 VarInfo: &'ll Metadata,
1918 Expr: &'ll Metadata,
1919 DebugLoc: &'ll Metadata,
1920 Block: &'ll BasicBlock,
1921 ) -> &'ll DbgRecord;
1922
1923 pub(crate) fn LLVMDIBuilderCreateAutoVariable<'ll>(
1924 Builder: &DIBuilder<'ll>,
1925 Scope: &'ll Metadata,
1926 Name: *const c_uchar, NameLen: size_t,
1928 File: &'ll Metadata,
1929 LineNo: c_uint,
1930 Ty: &'ll Metadata,
1931 AlwaysPreserve: llvm::Bool, Flags: DIFlags,
1933 AlignInBits: u32,
1934 ) -> &'ll Metadata;
1935
1936 pub(crate) fn LLVMDIBuilderCreateParameterVariable<'ll>(
1937 Builder: &DIBuilder<'ll>,
1938 Scope: &'ll Metadata,
1939 Name: *const c_uchar, NameLen: size_t,
1941 ArgNo: c_uint,
1942 File: &'ll Metadata,
1943 LineNo: c_uint,
1944 Ty: &'ll Metadata,
1945 AlwaysPreserve: llvm::Bool, Flags: DIFlags,
1947 ) -> &'ll Metadata;
1948}
1949
1950#[link(name = "llvm-wrapper", kind = "static")]
1951unsafe extern "C" {
1952 pub(crate) fn LLVMRustInstallErrorHandlers();
1953 pub(crate) fn LLVMRustDisableSystemDialogsOnCrash();
1954
1955 pub(crate) fn LLVMRustGlobalAddMetadata<'a>(
1957 Val: &'a Value,
1958 KindID: MetadataKindId,
1959 Metadata: &'a Metadata,
1960 );
1961 pub(crate) fn LLVMRustIsNonGVFunctionPointerTy(Val: &Value) -> bool;
1962
1963 pub(crate) fn LLVMRustConstIntGetZExtValue(ConstantVal: &ConstantInt, Value: &mut u64) -> bool;
1965 pub(crate) fn LLVMRustConstInt128Get(
1966 ConstantVal: &ConstantInt,
1967 SExt: bool,
1968 high: &mut u64,
1969 low: &mut u64,
1970 ) -> bool;
1971
1972 pub(crate) fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
1974
1975 pub(crate) fn LLVMRustGetOrInsertGlobal<'a>(
1977 M: &'a Module,
1978 Name: *const c_char,
1979 NameLen: size_t,
1980 T: &'a Type,
1981 ) -> &'a Value;
1982 pub(crate) fn LLVMRustGetNamedValue(
1983 M: &Module,
1984 Name: *const c_char,
1985 NameLen: size_t,
1986 ) -> Option<&Value>;
1987
1988 pub(crate) fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute;
1990 pub(crate) fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute;
1991 pub(crate) fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute;
1992 pub(crate) fn LLVMRustCreateDereferenceableOrNullAttr(C: &Context, bytes: u64) -> &Attribute;
1993 pub(crate) fn LLVMRustCreateByValAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1994 pub(crate) fn LLVMRustCreateStructRetAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1995 pub(crate) fn LLVMRustCreateElementTypeAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1996 pub(crate) fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute;
1997 pub(crate) fn LLVMRustCreateAllocSizeAttr(C: &Context, size_arg: u32) -> &Attribute;
1998 pub(crate) fn LLVMRustCreateAllocKindAttr(C: &Context, size_arg: u64) -> &Attribute;
1999 pub(crate) fn LLVMRustCreateMemoryEffectsAttr(
2000 C: &Context,
2001 effects: MemoryEffects,
2002 ) -> &Attribute;
2003 pub(crate) fn LLVMRustCreateRangeAttribute(
2010 C: &Context,
2011 NumBits: c_uint,
2012 LowerWords: *const u64,
2013 UpperWords: *const u64,
2014 ) -> &Attribute;
2015
2016 pub(crate) fn LLVMRustGetOrInsertFunction<'a>(
2018 M: &'a Module,
2019 Name: *const c_char,
2020 NameLen: size_t,
2021 FunctionTy: &'a Type,
2022 ) -> &'a Value;
2023 pub(crate) fn LLVMRustAddFunctionAttributes<'a>(
2024 Fn: &'a Value,
2025 index: c_uint,
2026 Attrs: *const &'a Attribute,
2027 AttrsLen: size_t,
2028 );
2029
2030 pub(crate) fn LLVMRustAddCallSiteAttributes<'a>(
2032 Instr: &'a Value,
2033 index: c_uint,
2034 Attrs: *const &'a Attribute,
2035 AttrsLen: size_t,
2036 );
2037
2038 pub(crate) fn LLVMRustSetFastMath(Instr: &Value);
2039 pub(crate) fn LLVMRustSetAlgebraicMath(Instr: &Value);
2040 pub(crate) fn LLVMRustSetAllowReassoc(Instr: &Value);
2041
2042 pub(crate) fn LLVMRustBuildMemCpy<'a>(
2044 B: &Builder<'a>,
2045 Dst: &'a Value,
2046 DstAlign: c_uint,
2047 Src: &'a Value,
2048 SrcAlign: c_uint,
2049 Size: &'a Value,
2050 IsVolatile: bool,
2051 ) -> &'a Value;
2052 pub(crate) fn LLVMRustBuildMemMove<'a>(
2053 B: &Builder<'a>,
2054 Dst: &'a Value,
2055 DstAlign: c_uint,
2056 Src: &'a Value,
2057 SrcAlign: c_uint,
2058 Size: &'a Value,
2059 IsVolatile: bool,
2060 ) -> &'a Value;
2061 pub(crate) fn LLVMRustBuildMemSet<'a>(
2062 B: &Builder<'a>,
2063 Dst: &'a Value,
2064 DstAlign: c_uint,
2065 Val: &'a Value,
2066 Size: &'a Value,
2067 IsVolatile: bool,
2068 ) -> &'a Value;
2069
2070 pub(crate) fn LLVMRustTimeTraceProfilerInitialize();
2071
2072 pub(crate) fn LLVMRustTimeTraceProfilerFinishThread();
2073
2074 pub(crate) fn LLVMRustTimeTraceProfilerFinish(FileName: *const c_char);
2075
2076 pub(crate) fn LLVMRustGetLastError() -> *const c_char;
2078
2079 pub(crate) fn LLVMRustPrintPassTimings(OutStr: &RustString);
2081
2082 pub(crate) fn LLVMRustPrintStatistics(OutStr: &RustString);
2084
2085 pub(crate) fn LLVMRustInlineAsmVerify(
2086 Ty: &Type,
2087 Constraints: *const c_uchar, ConstraintsLen: size_t,
2089 ) -> bool;
2090
2091 pub(crate) fn LLVMRustCoverageWriteFilenamesToBuffer(
2095 Filenames: *const *const c_uchar, FilenamesLen: size_t,
2097 Lengths: *const size_t,
2098 LengthsLen: size_t,
2099 BufferOut: &RustString,
2100 );
2101
2102 pub(crate) fn LLVMRustCoverageWriteFunctionMappingsToBuffer(
2103 VirtualFileMappingIDs: *const c_uint,
2104 NumVirtualFileMappingIDs: size_t,
2105 Expressions: *const crate::coverageinfo::ffi::CounterExpression,
2106 NumExpressions: size_t,
2107 CodeRegions: *const crate::coverageinfo::ffi::CodeRegion,
2108 NumCodeRegions: size_t,
2109 ExpansionRegions: *const crate::coverageinfo::ffi::ExpansionRegion,
2110 NumExpansionRegions: size_t,
2111 BranchRegions: *const crate::coverageinfo::ffi::BranchRegion,
2112 NumBranchRegions: size_t,
2113 BufferOut: &RustString,
2114 );
2115
2116 pub(crate) fn LLVMRustCoverageCreatePGOFuncNameVar(
2117 F: &Value,
2118 FuncName: *const c_uchar, FuncNameLen: size_t,
2120 ) -> &Value;
2121 pub(crate) fn LLVMRustCoverageHashBytes(
2122 Bytes: *const c_uchar, NumBytes: size_t,
2124 ) -> u64;
2125
2126 pub(crate) safe fn LLVMRustCoverageWriteCovmapSectionNameToString(
2127 M: &Module,
2128 OutStr: &RustString,
2129 );
2130 pub(crate) safe fn LLVMRustCoverageWriteCovfunSectionNameToString(
2131 M: &Module,
2132 OutStr: &RustString,
2133 );
2134 pub(crate) safe fn LLVMRustCoverageWriteCovmapVarNameToString(OutStr: &RustString);
2135
2136 pub(crate) safe fn LLVMRustCoverageMappingVersion() -> u32;
2137 pub(crate) fn LLVMRustDebugMetadataVersion() -> u32;
2138 pub(crate) fn LLVMRustVersionMajor() -> u32;
2139 pub(crate) fn LLVMRustVersionMinor() -> u32;
2140 pub(crate) fn LLVMRustVersionPatch() -> u32;
2141
2142 pub(crate) fn LLVMRustAddModuleFlagU32(
2147 M: &Module,
2148 MergeBehavior: ModuleFlagMergeBehavior,
2149 Name: *const c_char,
2150 NameLen: size_t,
2151 Value: u32,
2152 );
2153
2154 pub(crate) fn LLVMRustAddModuleFlagString(
2155 M: &Module,
2156 MergeBehavior: ModuleFlagMergeBehavior,
2157 Name: *const c_char,
2158 NameLen: size_t,
2159 Value: *const c_char,
2160 ValueLen: size_t,
2161 );
2162
2163 pub(crate) fn LLVMRustDIBuilderCreateCompileUnit<'a>(
2164 Builder: &DIBuilder<'a>,
2165 Lang: c_uint,
2166 File: &'a DIFile,
2167 Producer: *const c_char,
2168 ProducerLen: size_t,
2169 isOptimized: bool,
2170 Flags: *const c_char,
2171 RuntimeVer: c_uint,
2172 SplitName: *const c_char,
2173 SplitNameLen: size_t,
2174 kind: DebugEmissionKind,
2175 DWOId: u64,
2176 SplitDebugInlining: bool,
2177 DebugNameTableKind: DebugNameTableKind,
2178 ) -> &'a DIDescriptor;
2179
2180 pub(crate) fn LLVMRustDIBuilderCreateFile<'a>(
2181 Builder: &DIBuilder<'a>,
2182 Filename: *const c_char,
2183 FilenameLen: size_t,
2184 Directory: *const c_char,
2185 DirectoryLen: size_t,
2186 CSKind: ChecksumKind,
2187 Checksum: *const c_char,
2188 ChecksumLen: size_t,
2189 Source: *const c_char,
2190 SourceLen: size_t,
2191 ) -> &'a DIFile;
2192
2193 pub(crate) fn LLVMRustDIBuilderCreateFunction<'a>(
2194 Builder: &DIBuilder<'a>,
2195 Scope: &'a DIDescriptor,
2196 Name: *const c_char,
2197 NameLen: size_t,
2198 LinkageName: *const c_char,
2199 LinkageNameLen: size_t,
2200 File: &'a DIFile,
2201 LineNo: c_uint,
2202 Ty: &'a DIType,
2203 ScopeLine: c_uint,
2204 Flags: DIFlags,
2205 SPFlags: DISPFlags,
2206 MaybeFn: Option<&'a Value>,
2207 TParam: &'a DIArray,
2208 Decl: Option<&'a DIDescriptor>,
2209 ) -> &'a DISubprogram;
2210
2211 pub(crate) fn LLVMRustDIBuilderCreateMethod<'a>(
2212 Builder: &DIBuilder<'a>,
2213 Scope: &'a DIDescriptor,
2214 Name: *const c_char,
2215 NameLen: size_t,
2216 LinkageName: *const c_char,
2217 LinkageNameLen: size_t,
2218 File: &'a DIFile,
2219 LineNo: c_uint,
2220 Ty: &'a DIType,
2221 Flags: DIFlags,
2222 SPFlags: DISPFlags,
2223 TParam: &'a DIArray,
2224 ) -> &'a DISubprogram;
2225
2226 pub(crate) fn LLVMRustDIBuilderCreateVariantMemberType<'a>(
2227 Builder: &DIBuilder<'a>,
2228 Scope: &'a DIScope,
2229 Name: *const c_char,
2230 NameLen: size_t,
2231 File: &'a DIFile,
2232 LineNumber: c_uint,
2233 SizeInBits: u64,
2234 AlignInBits: u32,
2235 OffsetInBits: u64,
2236 Discriminant: Option<&'a Value>,
2237 Flags: DIFlags,
2238 Ty: &'a DIType,
2239 ) -> &'a DIType;
2240
2241 pub(crate) fn LLVMRustDIBuilderCreateEnumerator<'a>(
2242 Builder: &DIBuilder<'a>,
2243 Name: *const c_char,
2244 NameLen: size_t,
2245 Value: *const u64,
2246 SizeInBits: c_uint,
2247 IsUnsigned: bool,
2248 ) -> &'a DIEnumerator;
2249
2250 pub(crate) fn LLVMRustDIBuilderCreateEnumerationType<'a>(
2251 Builder: &DIBuilder<'a>,
2252 Scope: &'a DIScope,
2253 Name: *const c_char,
2254 NameLen: size_t,
2255 File: &'a DIFile,
2256 LineNumber: c_uint,
2257 SizeInBits: u64,
2258 AlignInBits: u32,
2259 Elements: &'a DIArray,
2260 ClassType: &'a DIType,
2261 IsScoped: bool,
2262 ) -> &'a DIType;
2263
2264 pub(crate) fn LLVMRustDIBuilderCreateVariantPart<'a>(
2265 Builder: &DIBuilder<'a>,
2266 Scope: &'a DIScope,
2267 Name: *const c_char,
2268 NameLen: size_t,
2269 File: &'a DIFile,
2270 LineNo: c_uint,
2271 SizeInBits: u64,
2272 AlignInBits: u32,
2273 Flags: DIFlags,
2274 Discriminator: Option<&'a DIDerivedType>,
2275 Elements: &'a DIArray,
2276 UniqueId: *const c_char,
2277 UniqueIdLen: size_t,
2278 ) -> &'a DIDerivedType;
2279
2280 pub(crate) fn LLVMRustDIBuilderCreateTemplateTypeParameter<'a>(
2281 Builder: &DIBuilder<'a>,
2282 Scope: Option<&'a DIScope>,
2283 Name: *const c_char,
2284 NameLen: size_t,
2285 Ty: &'a DIType,
2286 ) -> &'a DITemplateTypeParameter;
2287
2288 pub(crate) fn LLVMRustDICompositeTypeReplaceArrays<'a>(
2289 Builder: &DIBuilder<'a>,
2290 CompositeType: &'a DIType,
2291 Elements: Option<&'a DIArray>,
2292 Params: Option<&'a DIArray>,
2293 );
2294
2295 pub(crate) fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>(
2296 Location: &'a DILocation,
2297 BD: c_uint,
2298 ) -> Option<&'a DILocation>;
2299
2300 pub(crate) fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2301 pub(crate) fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2302
2303 pub(crate) fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2304
2305 pub(crate) fn LLVMRustPrintTargetCPUs(TM: &TargetMachine, OutStr: &RustString);
2306 pub(crate) fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2307 pub(crate) fn LLVMRustGetTargetFeature(
2308 T: &TargetMachine,
2309 Index: size_t,
2310 Feature: &mut *const c_char,
2311 Desc: &mut *const c_char,
2312 );
2313
2314 pub(crate) fn LLVMRustGetHostCPUName(LenOut: &mut size_t) -> *const u8;
2315
2316 pub(crate) fn LLVMRustCreateTargetMachine(
2319 Triple: *const c_char,
2320 CPU: *const c_char,
2321 Features: *const c_char,
2322 Abi: *const c_char,
2323 Model: CodeModel,
2324 Reloc: RelocModel,
2325 Level: CodeGenOptLevel,
2326 FloatABIType: FloatAbi,
2327 FunctionSections: bool,
2328 DataSections: bool,
2329 UniqueSectionNames: bool,
2330 TrapUnreachable: bool,
2331 Singlethread: bool,
2332 VerboseAsm: bool,
2333 EmitStackSizeSection: bool,
2334 RelaxELFRelocations: bool,
2335 UseInitArray: bool,
2336 SplitDwarfFile: *const c_char,
2337 OutputObjFile: *const c_char,
2338 DebugInfoCompression: CompressionKind,
2339 UseEmulatedTls: bool,
2340 UseWasmEH: bool,
2341 ) -> *mut TargetMachine;
2342
2343 pub(crate) fn LLVMRustAddLibraryInfo<'a>(
2344 T: &TargetMachine,
2345 PM: &PassManager<'a>,
2346 M: &'a Module,
2347 DisableSimplifyLibCalls: bool,
2348 );
2349 pub(crate) fn LLVMRustWriteOutputFile<'a>(
2350 T: &'a TargetMachine,
2351 PM: *mut PassManager<'a>,
2352 M: &'a Module,
2353 Output: *const c_char,
2354 DwoOutput: *const c_char,
2355 FileType: FileType,
2356 VerifyIR: bool,
2357 ) -> LLVMRustResult;
2358 pub(crate) fn LLVMRustOptimize<'a>(
2359 M: &'a Module,
2360 TM: &'a TargetMachine,
2361 OptLevel: PassBuilderOptLevel,
2362 OptStage: OptStage,
2363 IsLinkerPluginLTO: bool,
2364 NoPrepopulatePasses: bool,
2365 VerifyIR: bool,
2366 LintIR: bool,
2367 ThinLTOBuffer: Option<&mut *mut ThinLTOBuffer>,
2368 EmitThinLTO: bool,
2369 EmitThinLTOSummary: bool,
2370 MergeFunctions: bool,
2371 UnrollLoops: bool,
2372 SLPVectorize: bool,
2373 LoopVectorize: bool,
2374 DisableSimplifyLibCalls: bool,
2375 EmitLifetimeMarkers: bool,
2376 RunEnzyme: *const c_void,
2377 PrintBeforeEnzyme: bool,
2378 PrintAfterEnzyme: bool,
2379 PrintPasses: bool,
2380 SanitizerOptions: Option<&SanitizerOptions>,
2381 PGOGenPath: *const c_char,
2382 PGOUsePath: *const c_char,
2383 InstrumentCoverage: bool,
2384 InstrProfileOutput: *const c_char,
2385 PGOSampleUsePath: *const c_char,
2386 DebugInfoForProfiling: bool,
2387 llvm_selfprofiler: *mut c_void,
2388 begin_callback: SelfProfileBeforePassCallback,
2389 end_callback: SelfProfileAfterPassCallback,
2390 ExtraPasses: *const c_char,
2391 ExtraPassesLen: size_t,
2392 LLVMPlugins: *const c_char,
2393 LLVMPluginsLen: size_t,
2394 ) -> LLVMRustResult;
2395 pub(crate) fn LLVMRustPrintModule(
2396 M: &Module,
2397 Output: *const c_char,
2398 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2399 ) -> LLVMRustResult;
2400 pub(crate) fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2401 pub(crate) fn LLVMRustPrintPasses();
2402 pub(crate) fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2403 pub(crate) fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2404
2405 pub(crate) fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2406
2407 pub(crate) fn LLVMRustUnpackOptimizationDiagnostic<'a>(
2408 DI: &'a DiagnosticInfo,
2409 pass_name_out: &RustString,
2410 function_out: &mut Option<&'a Value>,
2411 loc_line_out: &mut c_uint,
2412 loc_column_out: &mut c_uint,
2413 loc_filename_out: &RustString,
2414 message_out: &RustString,
2415 );
2416
2417 pub(crate) fn LLVMRustUnpackInlineAsmDiagnostic<'a>(
2418 DI: &'a DiagnosticInfo,
2419 level_out: &mut DiagnosticLevel,
2420 cookie_out: &mut u64,
2421 message_out: &mut Option<&'a Twine>,
2422 );
2423
2424 pub(crate) fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2425 pub(crate) fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2426
2427 pub(crate) fn LLVMRustGetSMDiagnostic<'a>(
2428 DI: &'a DiagnosticInfo,
2429 cookie_out: &mut u64,
2430 ) -> &'a SMDiagnostic;
2431
2432 pub(crate) fn LLVMRustUnpackSMDiagnostic(
2433 d: &SMDiagnostic,
2434 message_out: &RustString,
2435 buffer_out: &RustString,
2436 level_out: &mut DiagnosticLevel,
2437 loc_out: &mut c_uint,
2438 ranges_out: *mut c_uint,
2439 num_ranges: &mut usize,
2440 ) -> bool;
2441
2442 pub(crate) fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
2443
2444 pub(crate) fn LLVMRustPositionBuilderPastAllocas<'a>(B: &Builder<'a>, Fn: &'a Value);
2445 pub(crate) fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
2446 pub(crate) fn LLVMRustGetInsertPoint<'a>(B: &Builder<'a>) -> &'a Value;
2447 pub(crate) fn LLVMRustRestoreInsertPoint<'a>(B: &Builder<'a>, IP: &'a Value);
2448
2449 pub(crate) fn LLVMRustSetModulePICLevel(M: &Module);
2450 pub(crate) fn LLVMRustSetModulePIELevel(M: &Module);
2451 pub(crate) fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2452 pub(crate) fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2453 pub(crate) fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2454 pub(crate) fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2455 pub(crate) fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2456 pub(crate) fn LLVMRustModuleCost(M: &Module) -> u64;
2457 pub(crate) fn LLVMRustModuleInstructionStats(M: &Module, Str: &RustString);
2458
2459 pub(crate) fn LLVMRustThinLTOBufferCreate(
2460 M: &Module,
2461 is_thin: bool,
2462 ) -> &'static mut ThinLTOBuffer;
2463 pub(crate) fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2464 pub(crate) fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2465 pub(crate) fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2466 pub(crate) fn LLVMRustThinLTOBufferThinLinkDataPtr(M: &ThinLTOBuffer) -> *const c_char;
2467 pub(crate) fn LLVMRustThinLTOBufferThinLinkDataLen(M: &ThinLTOBuffer) -> size_t;
2468 pub(crate) fn LLVMRustCreateThinLTOData(
2469 Modules: *const ThinLTOModule,
2470 NumModules: size_t,
2471 PreservedSymbols: *const *const c_char,
2472 PreservedSymbolsLen: size_t,
2473 ) -> Option<&'static mut ThinLTOData>;
2474 pub(crate) fn LLVMRustPrepareThinLTORename(
2475 Data: &ThinLTOData,
2476 Module: &Module,
2477 Target: &TargetMachine,
2478 );
2479 pub(crate) fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2480 pub(crate) fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2481 pub(crate) fn LLVMRustPrepareThinLTOImport(
2482 Data: &ThinLTOData,
2483 Module: &Module,
2484 Target: &TargetMachine,
2485 ) -> bool;
2486 pub(crate) fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2487 pub(crate) fn LLVMRustParseBitcodeForLTO(
2488 Context: &Context,
2489 Data: *const u8,
2490 len: usize,
2491 Identifier: *const c_char,
2492 ) -> Option<&Module>;
2493
2494 pub(crate) fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>;
2495 pub(crate) fn LLVMRustLinkerAdd(
2496 linker: &Linker<'_>,
2497 bytecode: *const c_char,
2498 bytecode_len: usize,
2499 ) -> bool;
2500 pub(crate) fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>);
2501 pub(crate) fn LLVMRustComputeLTOCacheKey(
2502 key_out: &RustString,
2503 mod_id: *const c_char,
2504 data: &ThinLTOData,
2505 );
2506
2507 pub(crate) fn LLVMRustContextGetDiagnosticHandler(
2508 Context: &Context,
2509 ) -> Option<&DiagnosticHandler>;
2510 pub(crate) fn LLVMRustContextSetDiagnosticHandler(
2511 context: &Context,
2512 diagnostic_handler: Option<&DiagnosticHandler>,
2513 );
2514 pub(crate) fn LLVMRustContextConfigureDiagnosticHandler(
2515 context: &Context,
2516 diagnostic_handler_callback: DiagnosticHandlerTy,
2517 diagnostic_handler_context: *mut c_void,
2518 remark_all_passes: bool,
2519 remark_passes: *const *const c_char,
2520 remark_passes_len: usize,
2521 remark_file: *const c_char,
2522 pgo_available: bool,
2523 );
2524
2525 pub(crate) fn LLVMRustGetMangledName(V: &Value, out: &RustString);
2526
2527 pub(crate) fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32;
2528
2529 pub(crate) safe fn LLVMRustLLVMHasZlibCompression() -> bool;
2530 pub(crate) safe fn LLVMRustLLVMHasZstdCompression() -> bool;
2531
2532 pub(crate) fn LLVMRustGetSymbols(
2533 buf_ptr: *const u8,
2534 buf_len: usize,
2535 state: *mut c_void,
2536 callback: GetSymbolsCallback,
2537 error_callback: GetSymbolsErrorCallback,
2538 ) -> *mut c_void;
2539
2540 pub(crate) fn LLVMRustIs64BitSymbolicFile(buf_ptr: *const u8, buf_len: usize) -> bool;
2541
2542 pub(crate) fn LLVMRustIsECObject(buf_ptr: *const u8, buf_len: usize) -> bool;
2543
2544 pub(crate) fn LLVMRustIsAnyArm64Coff(buf_ptr: *const u8, buf_len: usize) -> bool;
2545
2546 pub(crate) fn LLVMRustSetNoSanitizeAddress(Global: &Value);
2547 pub(crate) fn LLVMRustSetNoSanitizeHWAddress(Global: &Value);
2548
2549 pub(crate) fn LLVMAddAlias2<'ll>(
2550 M: &'ll Module,
2551 ValueTy: &Type,
2552 AddressSpace: c_uint,
2553 Aliasee: &Value,
2554 Name: *const c_char,
2555 ) -> &'ll Value;
2556}