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