]> git.proxmox.com Git - rustc.git/blame_incremental - compiler/rustc_codegen_llvm/src/llvm/ffi.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / compiler / rustc_codegen_llvm / src / llvm / ffi.rs
... / ...
CommitLineData
1#![allow(non_camel_case_types)]
2#![allow(non_upper_case_globals)]
3
4use super::debuginfo::{
5 DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
6 DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace,
7 DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable,
8 DebugEmissionKind,
9};
10
11use libc::{c_char, c_int, c_uint, size_t};
12use libc::{c_ulonglong, c_void};
13
14use std::marker::PhantomData;
15
16use super::RustString;
17
18pub type Bool = c_uint;
19
20pub const True: Bool = 1 as Bool;
21pub const False: Bool = 0 as Bool;
22
23#[derive(Copy, Clone, PartialEq)]
24#[repr(C)]
25#[allow(dead_code)] // Variants constructed by C++.
26pub enum LLVMRustResult {
27 Success,
28 Failure,
29}
30
31// Rust version of the C struct with the same name in rustc_llvm/llvm-wrapper/RustWrapper.cpp.
32#[repr(C)]
33pub struct LLVMRustCOFFShortExport {
34 pub name: *const c_char,
35 pub ordinal_present: bool,
36 /// value of `ordinal` only important when `ordinal_present` is true
37 pub ordinal: u16,
38}
39
40impl LLVMRustCOFFShortExport {
41 pub fn new(name: *const c_char, ordinal: Option<u16>) -> LLVMRustCOFFShortExport {
42 LLVMRustCOFFShortExport {
43 name,
44 ordinal_present: ordinal.is_some(),
45 ordinal: ordinal.unwrap_or(0),
46 }
47 }
48}
49
50/// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h.
51///
52/// We include only architectures supported on Windows.
53#[derive(Copy, Clone, PartialEq)]
54#[repr(C)]
55pub enum LLVMMachineType {
56 AMD64 = 0x8664,
57 I386 = 0x14c,
58 ARM64 = 0xaa64,
59 ARM = 0x01c0,
60}
61
62/// LLVM's Module::ModFlagBehavior, defined in llvm/include/llvm/IR/Module.h.
63///
64/// When merging modules (e.g. during LTO), their metadata flags are combined. Conflicts are
65/// resolved according to the merge behaviors specified here. Flags differing only in merge
66/// behavior are still considered to be in conflict.
67///
68/// In order for Rust-C LTO to work, we must specify behaviors compatible with Clang. Notably,
69/// 'Error' and 'Warning' cannot be mixed for a given flag.
70#[derive(Copy, Clone, PartialEq)]
71#[repr(C)]
72pub enum LLVMModFlagBehavior {
73 Error = 1,
74 Warning = 2,
75 Require = 3,
76 Override = 4,
77 Append = 5,
78 AppendUnique = 6,
79 Max = 7,
80 Min = 8,
81}
82
83// Consts for the LLVM CallConv type, pre-cast to usize.
84
85/// LLVM CallingConv::ID. Should we wrap this?
86///
87/// See <https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/CallingConv.h>
88#[derive(Copy, Clone, PartialEq, Debug)]
89#[repr(C)]
90pub enum CallConv {
91 CCallConv = 0,
92 FastCallConv = 8,
93 ColdCallConv = 9,
94 PreserveMost = 14,
95 PreserveAll = 15,
96 Tail = 18,
97 X86StdcallCallConv = 64,
98 X86FastcallCallConv = 65,
99 ArmAapcsCallConv = 67,
100 Msp430Intr = 69,
101 X86_ThisCall = 70,
102 PtxKernel = 71,
103 X86_64_SysV = 78,
104 X86_64_Win64 = 79,
105 X86_VectorCall = 80,
106 X86_Intr = 83,
107 AvrNonBlockingInterrupt = 84,
108 AvrInterrupt = 85,
109 AmdGpuKernel = 91,
110}
111
112/// LLVMRustLinkage
113#[derive(Copy, Clone, PartialEq)]
114#[repr(C)]
115pub enum Linkage {
116 ExternalLinkage = 0,
117 AvailableExternallyLinkage = 1,
118 LinkOnceAnyLinkage = 2,
119 LinkOnceODRLinkage = 3,
120 WeakAnyLinkage = 4,
121 WeakODRLinkage = 5,
122 AppendingLinkage = 6,
123 InternalLinkage = 7,
124 PrivateLinkage = 8,
125 ExternalWeakLinkage = 9,
126 CommonLinkage = 10,
127}
128
129// LLVMRustVisibility
130#[repr(C)]
131#[derive(Copy, Clone, PartialEq)]
132pub enum Visibility {
133 Default = 0,
134 Hidden = 1,
135 Protected = 2,
136}
137
138/// LLVMUnnamedAddr
139#[repr(C)]
140pub enum UnnamedAddr {
141 No,
142 Local,
143 Global,
144}
145
146/// LLVMDLLStorageClass
147#[derive(Copy, Clone)]
148#[repr(C)]
149pub enum DLLStorageClass {
150 #[allow(dead_code)]
151 Default = 0,
152 DllImport = 1, // Function to be imported from DLL.
153 #[allow(dead_code)]
154 DllExport = 2, // Function to be accessible from DLL.
155}
156
157/// Matches LLVMRustAttribute in LLVMWrapper.h
158/// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
159/// though it is not ABI compatible (since it's a C++ enum)
160#[repr(C)]
161#[derive(Copy, Clone, Debug)]
162pub enum AttributeKind {
163 AlwaysInline = 0,
164 ByVal = 1,
165 Cold = 2,
166 InlineHint = 3,
167 MinSize = 4,
168 Naked = 5,
169 NoAlias = 6,
170 NoCapture = 7,
171 NoInline = 8,
172 NonNull = 9,
173 NoRedZone = 10,
174 NoReturn = 11,
175 NoUnwind = 12,
176 OptimizeForSize = 13,
177 ReadOnly = 14,
178 SExt = 15,
179 StructRet = 16,
180 UWTable = 17,
181 ZExt = 18,
182 InReg = 19,
183 SanitizeThread = 20,
184 SanitizeAddress = 21,
185 SanitizeMemory = 22,
186 NonLazyBind = 23,
187 OptimizeNone = 24,
188 ReturnsTwice = 25,
189 ReadNone = 26,
190 SanitizeHWAddress = 28,
191 WillReturn = 29,
192 StackProtectReq = 30,
193 StackProtectStrong = 31,
194 StackProtect = 32,
195 NoUndef = 33,
196 SanitizeMemTag = 34,
197 NoCfCheck = 35,
198 ShadowCallStack = 36,
199 AllocSize = 37,
200 AllocatedPointer = 38,
201 AllocAlign = 39,
202 SanitizeSafeStack = 40,
203}
204
205/// LLVMIntPredicate
206#[derive(Copy, Clone)]
207#[repr(C)]
208pub enum IntPredicate {
209 IntEQ = 32,
210 IntNE = 33,
211 IntUGT = 34,
212 IntUGE = 35,
213 IntULT = 36,
214 IntULE = 37,
215 IntSGT = 38,
216 IntSGE = 39,
217 IntSLT = 40,
218 IntSLE = 41,
219}
220
221impl IntPredicate {
222 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
223 match intpre {
224 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
225 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
226 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
227 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
228 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
229 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
230 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
231 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
232 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
233 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
234 }
235 }
236}
237
238/// LLVMRealPredicate
239#[derive(Copy, Clone)]
240#[repr(C)]
241pub enum RealPredicate {
242 RealPredicateFalse = 0,
243 RealOEQ = 1,
244 RealOGT = 2,
245 RealOGE = 3,
246 RealOLT = 4,
247 RealOLE = 5,
248 RealONE = 6,
249 RealORD = 7,
250 RealUNO = 8,
251 RealUEQ = 9,
252 RealUGT = 10,
253 RealUGE = 11,
254 RealULT = 12,
255 RealULE = 13,
256 RealUNE = 14,
257 RealPredicateTrue = 15,
258}
259
260impl RealPredicate {
261 pub fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self {
262 match realp {
263 rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
264 RealPredicate::RealPredicateFalse
265 }
266 rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
267 rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
268 rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
269 rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
270 rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
271 rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
272 rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
273 rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
274 rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
275 rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
276 rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
277 rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
278 rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
279 rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
280 rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
281 RealPredicate::RealPredicateTrue
282 }
283 }
284 }
285}
286
287/// LLVMTypeKind
288#[derive(Copy, Clone, PartialEq, Debug)]
289#[repr(C)]
290pub enum TypeKind {
291 Void = 0,
292 Half = 1,
293 Float = 2,
294 Double = 3,
295 X86_FP80 = 4,
296 FP128 = 5,
297 PPC_FP128 = 6,
298 Label = 7,
299 Integer = 8,
300 Function = 9,
301 Struct = 10,
302 Array = 11,
303 Pointer = 12,
304 Vector = 13,
305 Metadata = 14,
306 X86_MMX = 15,
307 Token = 16,
308 ScalableVector = 17,
309 BFloat = 18,
310 X86_AMX = 19,
311}
312
313impl TypeKind {
314 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
315 match self {
316 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
317 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
318 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
319 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
320 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
321 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
322 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
323 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
324 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
325 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
326 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
327 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
328 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
329 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
330 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
331 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
332 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
333 TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
334 TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
335 TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX,
336 }
337 }
338}
339
340/// LLVMAtomicRmwBinOp
341#[derive(Copy, Clone)]
342#[repr(C)]
343pub enum AtomicRmwBinOp {
344 AtomicXchg = 0,
345 AtomicAdd = 1,
346 AtomicSub = 2,
347 AtomicAnd = 3,
348 AtomicNand = 4,
349 AtomicOr = 5,
350 AtomicXor = 6,
351 AtomicMax = 7,
352 AtomicMin = 8,
353 AtomicUMax = 9,
354 AtomicUMin = 10,
355}
356
357impl AtomicRmwBinOp {
358 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
359 match op {
360 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
361 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
362 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
363 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
364 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
365 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
366 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
367 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
368 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
369 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
370 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
371 }
372 }
373}
374
375/// LLVMAtomicOrdering
376#[derive(Copy, Clone)]
377#[repr(C)]
378pub enum AtomicOrdering {
379 #[allow(dead_code)]
380 NotAtomic = 0,
381 Unordered = 1,
382 Monotonic = 2,
383 // Consume = 3, // Not specified yet.
384 Acquire = 4,
385 Release = 5,
386 AcquireRelease = 6,
387 SequentiallyConsistent = 7,
388}
389
390impl AtomicOrdering {
391 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
392 match ao {
393 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
394 rustc_codegen_ssa::common::AtomicOrdering::Relaxed => AtomicOrdering::Monotonic,
395 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
396 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
397 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
398 AtomicOrdering::AcquireRelease
399 }
400 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
401 AtomicOrdering::SequentiallyConsistent
402 }
403 }
404 }
405}
406
407/// LLVMRustFileType
408#[derive(Copy, Clone)]
409#[repr(C)]
410pub enum FileType {
411 AssemblyFile,
412 ObjectFile,
413}
414
415/// LLVMMetadataType
416#[derive(Copy, Clone)]
417#[repr(C)]
418pub enum MetadataType {
419 MD_dbg = 0,
420 MD_tbaa = 1,
421 MD_prof = 2,
422 MD_fpmath = 3,
423 MD_range = 4,
424 MD_tbaa_struct = 5,
425 MD_invariant_load = 6,
426 MD_alias_scope = 7,
427 MD_noalias = 8,
428 MD_nontemporal = 9,
429 MD_mem_parallel_loop_access = 10,
430 MD_nonnull = 11,
431 MD_align = 17,
432 MD_type = 19,
433 MD_vcall_visibility = 28,
434 MD_noundef = 29,
435 MD_kcfi_type = 36,
436}
437
438/// LLVMRustAsmDialect
439#[derive(Copy, Clone, PartialEq)]
440#[repr(C)]
441pub enum AsmDialect {
442 Att,
443 Intel,
444}
445
446/// LLVMRustCodeGenOptLevel
447#[derive(Copy, Clone, PartialEq)]
448#[repr(C)]
449pub enum CodeGenOptLevel {
450 None,
451 Less,
452 Default,
453 Aggressive,
454}
455
456/// LLVMRustPassBuilderOptLevel
457#[repr(C)]
458pub enum PassBuilderOptLevel {
459 O0,
460 O1,
461 O2,
462 O3,
463 Os,
464 Oz,
465}
466
467/// LLVMRustOptStage
468#[derive(PartialEq)]
469#[repr(C)]
470pub enum OptStage {
471 PreLinkNoLTO,
472 PreLinkThinLTO,
473 PreLinkFatLTO,
474 ThinLTO,
475 FatLTO,
476}
477
478/// LLVMRustSanitizerOptions
479#[repr(C)]
480pub struct SanitizerOptions {
481 pub sanitize_address: bool,
482 pub sanitize_address_recover: bool,
483 pub sanitize_cfi: bool,
484 pub sanitize_kcfi: bool,
485 pub sanitize_memory: bool,
486 pub sanitize_memory_recover: bool,
487 pub sanitize_memory_track_origins: c_int,
488 pub sanitize_thread: bool,
489 pub sanitize_hwaddress: bool,
490 pub sanitize_hwaddress_recover: bool,
491 pub sanitize_kernel_address: bool,
492 pub sanitize_kernel_address_recover: bool,
493}
494
495/// LLVMRelocMode
496#[derive(Copy, Clone, PartialEq)]
497#[repr(C)]
498pub enum RelocModel {
499 Static,
500 PIC,
501 DynamicNoPic,
502 ROPI,
503 RWPI,
504 ROPI_RWPI,
505}
506
507/// LLVMRustCodeModel
508#[derive(Copy, Clone)]
509#[repr(C)]
510pub enum CodeModel {
511 Tiny,
512 Small,
513 Kernel,
514 Medium,
515 Large,
516 None,
517}
518
519/// LLVMRustDiagnosticKind
520#[derive(Copy, Clone)]
521#[repr(C)]
522#[allow(dead_code)] // Variants constructed by C++.
523pub enum DiagnosticKind {
524 Other,
525 InlineAsm,
526 StackSize,
527 DebugMetadataVersion,
528 SampleProfile,
529 OptimizationRemark,
530 OptimizationRemarkMissed,
531 OptimizationRemarkAnalysis,
532 OptimizationRemarkAnalysisFPCommute,
533 OptimizationRemarkAnalysisAliasing,
534 OptimizationRemarkOther,
535 OptimizationFailure,
536 PGOProfile,
537 Linker,
538 Unsupported,
539 SrcMgr,
540}
541
542/// LLVMRustDiagnosticLevel
543#[derive(Copy, Clone)]
544#[repr(C)]
545#[allow(dead_code)] // Variants constructed by C++.
546pub enum DiagnosticLevel {
547 Error,
548 Warning,
549 Note,
550 Remark,
551}
552
553/// LLVMRustArchiveKind
554#[derive(Copy, Clone)]
555#[repr(C)]
556pub enum ArchiveKind {
557 K_GNU,
558 K_BSD,
559 K_DARWIN,
560 K_COFF,
561 K_AIXBIG,
562}
563
564// LLVMRustThinLTOData
565extern "C" {
566 pub type ThinLTOData;
567}
568
569// LLVMRustThinLTOBuffer
570extern "C" {
571 pub type ThinLTOBuffer;
572}
573
574/// LLVMRustThinLTOModule
575#[repr(C)]
576pub struct ThinLTOModule {
577 pub identifier: *const c_char,
578 pub data: *const u8,
579 pub len: usize,
580}
581
582/// LLVMThreadLocalMode
583#[derive(Copy, Clone)]
584#[repr(C)]
585pub enum ThreadLocalMode {
586 NotThreadLocal,
587 GeneralDynamic,
588 LocalDynamic,
589 InitialExec,
590 LocalExec,
591}
592
593/// LLVMRustTailCallKind
594#[derive(Copy, Clone)]
595#[repr(C)]
596pub enum TailCallKind {
597 None,
598 Tail,
599 MustTail,
600 NoTail,
601}
602
603/// LLVMRustChecksumKind
604#[derive(Copy, Clone)]
605#[repr(C)]
606pub enum ChecksumKind {
607 None,
608 MD5,
609 SHA1,
610 SHA256,
611}
612
613/// LLVMRustMemoryEffects
614#[derive(Copy, Clone)]
615#[repr(C)]
616pub enum MemoryEffects {
617 None,
618 ReadOnly,
619 InaccessibleMemOnly,
620}
621
622extern "C" {
623 type Opaque;
624}
625#[repr(C)]
626struct InvariantOpaque<'a> {
627 _marker: PhantomData<&'a mut &'a ()>,
628 _opaque: Opaque,
629}
630
631// Opaque pointer types
632extern "C" {
633 pub type Module;
634}
635extern "C" {
636 pub type Context;
637}
638extern "C" {
639 pub type Type;
640}
641extern "C" {
642 pub type Value;
643}
644extern "C" {
645 pub type ConstantInt;
646}
647extern "C" {
648 pub type Attribute;
649}
650extern "C" {
651 pub type Metadata;
652}
653extern "C" {
654 pub type BasicBlock;
655}
656#[repr(C)]
657pub struct Builder<'a>(InvariantOpaque<'a>);
658#[repr(C)]
659pub struct PassManager<'a>(InvariantOpaque<'a>);
660extern "C" {
661 pub type Pass;
662}
663extern "C" {
664 pub type TargetMachine;
665}
666extern "C" {
667 pub type Archive;
668}
669#[repr(C)]
670pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
671#[repr(C)]
672pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
673extern "C" {
674 pub type Twine;
675}
676extern "C" {
677 pub type DiagnosticInfo;
678}
679extern "C" {
680 pub type SMDiagnostic;
681}
682#[repr(C)]
683pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
684#[repr(C)]
685pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
686#[repr(C)]
687pub struct Linker<'a>(InvariantOpaque<'a>);
688
689extern "C" {
690 pub type DiagnosticHandler;
691}
692
693pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
694pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
695
696pub mod debuginfo {
697 use super::{InvariantOpaque, Metadata};
698 use bitflags::bitflags;
699
700 #[repr(C)]
701 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
702
703 pub type DIDescriptor = Metadata;
704 pub type DILocation = Metadata;
705 pub type DIScope = DIDescriptor;
706 pub type DIFile = DIScope;
707 pub type DILexicalBlock = DIScope;
708 pub type DISubprogram = DIScope;
709 pub type DINameSpace = DIScope;
710 pub type DIType = DIDescriptor;
711 pub type DIBasicType = DIType;
712 pub type DIDerivedType = DIType;
713 pub type DICompositeType = DIDerivedType;
714 pub type DIVariable = DIDescriptor;
715 pub type DIGlobalVariableExpression = DIDescriptor;
716 pub type DIArray = DIDescriptor;
717 pub type DISubrange = DIDescriptor;
718 pub type DIEnumerator = DIDescriptor;
719 pub type DITemplateTypeParameter = DIDescriptor;
720
721 // These values **must** match with LLVMRustDIFlags!!
722 bitflags! {
723 #[repr(transparent)]
724 #[derive(Default)]
725 pub struct DIFlags: u32 {
726 const FlagZero = 0;
727 const FlagPrivate = 1;
728 const FlagProtected = 2;
729 const FlagPublic = 3;
730 const FlagFwdDecl = (1 << 2);
731 const FlagAppleBlock = (1 << 3);
732 const FlagBlockByrefStruct = (1 << 4);
733 const FlagVirtual = (1 << 5);
734 const FlagArtificial = (1 << 6);
735 const FlagExplicit = (1 << 7);
736 const FlagPrototyped = (1 << 8);
737 const FlagObjcClassComplete = (1 << 9);
738 const FlagObjectPointer = (1 << 10);
739 const FlagVector = (1 << 11);
740 const FlagStaticMember = (1 << 12);
741 const FlagLValueReference = (1 << 13);
742 const FlagRValueReference = (1 << 14);
743 const FlagExternalTypeRef = (1 << 15);
744 const FlagIntroducedVirtual = (1 << 18);
745 const FlagBitField = (1 << 19);
746 const FlagNoReturn = (1 << 20);
747 }
748 }
749
750 // These values **must** match with LLVMRustDISPFlags!!
751 bitflags! {
752 #[repr(transparent)]
753 #[derive(Default)]
754 pub struct DISPFlags: u32 {
755 const SPFlagZero = 0;
756 const SPFlagVirtual = 1;
757 const SPFlagPureVirtual = 2;
758 const SPFlagLocalToUnit = (1 << 2);
759 const SPFlagDefinition = (1 << 3);
760 const SPFlagOptimized = (1 << 4);
761 const SPFlagMainSubprogram = (1 << 5);
762 }
763 }
764
765 /// LLVMRustDebugEmissionKind
766 #[derive(Copy, Clone)]
767 #[repr(C)]
768 pub enum DebugEmissionKind {
769 NoDebug,
770 FullDebug,
771 LineTablesOnly,
772 DebugDirectivesOnly,
773 }
774
775 impl DebugEmissionKind {
776 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
777 // We should be setting LLVM's emission kind to `LineTablesOnly` if
778 // we are compiling with "limited" debuginfo. However, some of the
779 // existing tools relied on slightly more debuginfo being generated than
780 // would be the case with `LineTablesOnly`, and we did not want to break
781 // these tools in a "drive-by fix", without a good idea or plan about
782 // what limited debuginfo should exactly look like. So for now we are
783 // instead adding a new debuginfo option "line-tables-only" so as to
784 // not break anything and to allow users to have 'limited' debug info.
785 //
786 // See https://github.com/rust-lang/rust/issues/60020 for details.
787 use rustc_session::config::DebugInfo;
788 match kind {
789 DebugInfo::None => DebugEmissionKind::NoDebug,
790 DebugInfo::LineDirectivesOnly => DebugEmissionKind::DebugDirectivesOnly,
791 DebugInfo::LineTablesOnly => DebugEmissionKind::LineTablesOnly,
792 DebugInfo::Limited | DebugInfo::Full => DebugEmissionKind::FullDebug,
793 }
794 }
795 }
796}
797
798use bitflags::bitflags;
799// These values **must** match with LLVMRustAllocKindFlags
800bitflags! {
801 #[repr(transparent)]
802 #[derive(Default)]
803 pub struct AllocKindFlags : u64 {
804 const Unknown = 0;
805 const Alloc = 1;
806 const Realloc = 1 << 1;
807 const Free = 1 << 2;
808 const Uninitialized = 1 << 3;
809 const Zeroed = 1 << 4;
810 const Aligned = 1 << 5;
811 }
812}
813
814extern "C" {
815 pub type ModuleBuffer;
816}
817
818pub type SelfProfileBeforePassCallback =
819 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
820pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
821
822pub type GetSymbolsCallback = unsafe extern "C" fn(*mut c_void, *const c_char) -> *mut c_void;
823pub type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) -> *mut c_void;
824
825extern "C" {
826 pub fn LLVMRustInstallFatalErrorHandler();
827 pub fn LLVMRustDisableSystemDialogsOnCrash();
828
829 // Create and destroy contexts.
830 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
831 pub fn LLVMContextDispose(C: &'static mut Context);
832 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
833
834 // Create modules.
835 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
836 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
837 pub fn LLVMCloneModule(M: &Module) -> &Module;
838
839 /// Data layout. See Module::getDataLayout.
840 pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
841 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
842
843 /// See Module::setModuleInlineAsm.
844 pub fn LLVMAppendModuleInlineAsm(M: &Module, Asm: *const c_char, Len: size_t);
845
846 /// See llvm::LLVMTypeKind::getTypeID.
847 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
848
849 // Operations on integer types
850 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
851 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
852 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
853 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
854 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
855 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
856
857 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
858
859 // Operations on real types
860 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
861 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
862
863 // Operations on function types
864 pub fn LLVMFunctionType<'a>(
865 ReturnType: &'a Type,
866 ParamTypes: *const &'a Type,
867 ParamCount: c_uint,
868 IsVarArg: Bool,
869 ) -> &'a Type;
870 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
871 pub fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type);
872
873 // Operations on struct types
874 pub fn LLVMStructTypeInContext<'a>(
875 C: &'a Context,
876 ElementTypes: *const &'a Type,
877 ElementCount: c_uint,
878 Packed: Bool,
879 ) -> &'a Type;
880
881 // Operations on array, pointer, and vector types (sequence types)
882 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
883 pub fn LLVMPointerTypeInContext(C: &Context, AddressSpace: c_uint) -> &Type;
884 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
885
886 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
887 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
888
889 // Operations on other types
890 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
891 pub fn LLVMTokenTypeInContext(C: &Context) -> &Type;
892 pub fn LLVMMetadataTypeInContext(C: &Context) -> &Type;
893
894 // Operations on all values
895 pub fn LLVMTypeOf(Val: &Value) -> &Type;
896 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
897 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
898 pub fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value);
899 pub fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Node: &'a Value);
900 pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
901 pub fn LLVMRustGlobalAddMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
902 pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
903 pub fn LLVMIsAFunction(Val: &Value) -> Option<&Value>;
904 pub fn LLVMRustIsNonGVFunctionPointerTy(Val: &Value) -> bool;
905
906 // Operations on constants of any type
907 pub fn LLVMConstNull(Ty: &Type) -> &Value;
908 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
909 pub fn LLVMGetPoison(Ty: &Type) -> &Value;
910
911 // Operations on metadata
912 // FIXME: deprecated, replace with LLVMMDStringInContext2
913 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
914
915 pub fn LLVMMDStringInContext2(C: &Context, Str: *const c_char, SLen: size_t) -> &Metadata;
916
917 // FIXME: deprecated, replace with LLVMMDNodeInContext2
918 pub fn LLVMMDNodeInContext<'a>(
919 C: &'a Context,
920 Vals: *const &'a Value,
921 Count: c_uint,
922 ) -> &'a Value;
923 pub fn LLVMMDNodeInContext2<'a>(
924 C: &'a Context,
925 Vals: *const &'a Metadata,
926 Count: size_t,
927 ) -> &'a Metadata;
928 pub fn LLVMAddNamedMetadataOperand<'a>(M: &'a Module, Name: *const c_char, Val: &'a Value);
929
930 // Operations on scalar constants
931 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
932 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
933 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
934 pub fn LLVMRustConstIntGetZExtValue(ConstantVal: &ConstantInt, Value: &mut u64) -> bool;
935 pub fn LLVMRustConstInt128Get(
936 ConstantVal: &ConstantInt,
937 SExt: bool,
938 high: &mut u64,
939 low: &mut u64,
940 ) -> bool;
941
942 // Operations on composite constants
943 pub fn LLVMConstStringInContext(
944 C: &Context,
945 Str: *const c_char,
946 Length: c_uint,
947 DontNullTerminate: Bool,
948 ) -> &Value;
949 pub fn LLVMConstStructInContext<'a>(
950 C: &'a Context,
951 ConstantVals: *const &'a Value,
952 Count: c_uint,
953 Packed: Bool,
954 ) -> &'a Value;
955
956 // FIXME: replace with LLVMConstArray2 when bumped minimal version to llvm-17
957 // https://github.com/llvm/llvm-project/commit/35276f16e5a2cae0dfb49c0fbf874d4d2f177acc
958 pub fn LLVMConstArray<'a>(
959 ElementTy: &'a Type,
960 ConstantVals: *const &'a Value,
961 Length: c_uint,
962 ) -> &'a Value;
963 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
964
965 // Constant expressions
966 pub fn LLVMConstInBoundsGEP2<'a>(
967 ty: &'a Type,
968 ConstantVal: &'a Value,
969 ConstantIndices: *const &'a Value,
970 NumIndices: c_uint,
971 ) -> &'a Value;
972 pub fn LLVMConstZExt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
973 pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
974 pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
975 pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
976 pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
977 pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
978
979 // Operations on global variables, functions, and aliases (globals)
980 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
981 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
982 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
983 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
984 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
985 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
986 pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
987 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
988 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
989 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
990
991 // Operations on global variables
992 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
993 pub fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
994 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
995 pub fn LLVMRustGetOrInsertGlobal<'a>(
996 M: &'a Module,
997 Name: *const c_char,
998 NameLen: size_t,
999 T: &'a Type,
1000 ) -> &'a Value;
1001 pub fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value;
1002 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1003 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1004 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
1005 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1006 pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
1007 pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
1008 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1009 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1010 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1011 pub fn LLVMRustGetNamedValue(
1012 M: &Module,
1013 Name: *const c_char,
1014 NameLen: size_t,
1015 ) -> Option<&Value>;
1016 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1017 pub fn LLVMRustSetTailCallKind(CallInst: &Value, TKC: TailCallKind);
1018
1019 // Operations on attributes
1020 pub fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute;
1021 pub fn LLVMCreateStringAttribute(
1022 C: &Context,
1023 Name: *const c_char,
1024 NameLen: c_uint,
1025 Value: *const c_char,
1026 ValueLen: c_uint,
1027 ) -> &Attribute;
1028 pub fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute;
1029 pub fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute;
1030 pub fn LLVMRustCreateDereferenceableOrNullAttr(C: &Context, bytes: u64) -> &Attribute;
1031 pub fn LLVMRustCreateByValAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1032 pub fn LLVMRustCreateStructRetAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1033 pub fn LLVMRustCreateElementTypeAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1034 pub fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute;
1035 pub fn LLVMRustCreateAllocSizeAttr(C: &Context, size_arg: u32) -> &Attribute;
1036 pub fn LLVMRustCreateAllocKindAttr(C: &Context, size_arg: u64) -> &Attribute;
1037 pub fn LLVMRustCreateMemoryEffectsAttr(C: &Context, effects: MemoryEffects) -> &Attribute;
1038
1039 // Operations on functions
1040 pub fn LLVMRustGetOrInsertFunction<'a>(
1041 M: &'a Module,
1042 Name: *const c_char,
1043 NameLen: size_t,
1044 FunctionTy: &'a Type,
1045 ) -> &'a Value;
1046 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1047 pub fn LLVMRustAddFunctionAttributes<'a>(
1048 Fn: &'a Value,
1049 index: c_uint,
1050 Attrs: *const &'a Attribute,
1051 AttrsLen: size_t,
1052 );
1053
1054 // Operations on parameters
1055 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1056 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
1057 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1058
1059 // Operations on basic blocks
1060 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1061 pub fn LLVMAppendBasicBlockInContext<'a>(
1062 C: &'a Context,
1063 Fn: &'a Value,
1064 Name: *const c_char,
1065 ) -> &'a BasicBlock;
1066
1067 // Operations on instructions
1068 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1069 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1070
1071 // Operations on call sites
1072 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1073 pub fn LLVMRustAddCallSiteAttributes<'a>(
1074 Instr: &'a Value,
1075 index: c_uint,
1076 Attrs: *const &'a Attribute,
1077 AttrsLen: size_t,
1078 );
1079
1080 // Operations on load/store instructions (only)
1081 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1082
1083 // Operations on phi nodes
1084 pub fn LLVMAddIncoming<'a>(
1085 PhiNode: &'a Value,
1086 IncomingValues: *const &'a Value,
1087 IncomingBlocks: *const &'a BasicBlock,
1088 Count: c_uint,
1089 );
1090
1091 // Instruction builders
1092 pub fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>;
1093 pub fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock);
1094 pub fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock;
1095 pub fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);
1096
1097 // Metadata
1098 pub fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: &'a Metadata);
1099
1100 // Terminators
1101 pub fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;
1102 pub fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1103 pub fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1104 pub fn LLVMBuildCondBr<'a>(
1105 B: &Builder<'a>,
1106 If: &'a Value,
1107 Then: &'a BasicBlock,
1108 Else: &'a BasicBlock,
1109 ) -> &'a Value;
1110 pub fn LLVMBuildSwitch<'a>(
1111 B: &Builder<'a>,
1112 V: &'a Value,
1113 Else: &'a BasicBlock,
1114 NumCases: c_uint,
1115 ) -> &'a Value;
1116 pub fn LLVMRustBuildInvoke<'a>(
1117 B: &Builder<'a>,
1118 Ty: &'a Type,
1119 Fn: &'a Value,
1120 Args: *const &'a Value,
1121 NumArgs: c_uint,
1122 Then: &'a BasicBlock,
1123 Catch: &'a BasicBlock,
1124 OpBundles: *const &OperandBundleDef<'a>,
1125 NumOpBundles: c_uint,
1126 Name: *const c_char,
1127 ) -> &'a Value;
1128 pub fn LLVMBuildLandingPad<'a>(
1129 B: &Builder<'a>,
1130 Ty: &'a Type,
1131 PersFn: Option<&'a Value>,
1132 NumClauses: c_uint,
1133 Name: *const c_char,
1134 ) -> &'a Value;
1135 pub fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1136 pub fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value;
1137
1138 pub fn LLVMBuildCleanupPad<'a>(
1139 B: &Builder<'a>,
1140 ParentPad: Option<&'a Value>,
1141 Args: *const &'a Value,
1142 NumArgs: c_uint,
1143 Name: *const c_char,
1144 ) -> Option<&'a Value>;
1145 pub fn LLVMBuildCleanupRet<'a>(
1146 B: &Builder<'a>,
1147 CleanupPad: &'a Value,
1148 BB: Option<&'a BasicBlock>,
1149 ) -> Option<&'a Value>;
1150 pub fn LLVMBuildCatchPad<'a>(
1151 B: &Builder<'a>,
1152 ParentPad: &'a Value,
1153 Args: *const &'a Value,
1154 NumArgs: c_uint,
1155 Name: *const c_char,
1156 ) -> Option<&'a Value>;
1157 pub fn LLVMBuildCatchRet<'a>(
1158 B: &Builder<'a>,
1159 CatchPad: &'a Value,
1160 BB: &'a BasicBlock,
1161 ) -> Option<&'a Value>;
1162 pub fn LLVMBuildCatchSwitch<'a>(
1163 Builder: &Builder<'a>,
1164 ParentPad: Option<&'a Value>,
1165 UnwindBB: Option<&'a BasicBlock>,
1166 NumHandlers: c_uint,
1167 Name: *const c_char,
1168 ) -> Option<&'a Value>;
1169 pub fn LLVMAddHandler<'a>(CatchSwitch: &'a Value, Dest: &'a BasicBlock);
1170 pub fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value);
1171
1172 // Add a case to the switch instruction
1173 pub fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1174
1175 // Add a clause to the landing pad instruction
1176 pub fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value);
1177
1178 // Set the cleanup on a landing pad instruction
1179 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1180
1181 // Arithmetic
1182 pub fn LLVMBuildAdd<'a>(
1183 B: &Builder<'a>,
1184 LHS: &'a Value,
1185 RHS: &'a Value,
1186 Name: *const c_char,
1187 ) -> &'a Value;
1188 pub fn LLVMBuildFAdd<'a>(
1189 B: &Builder<'a>,
1190 LHS: &'a Value,
1191 RHS: &'a Value,
1192 Name: *const c_char,
1193 ) -> &'a Value;
1194 pub fn LLVMBuildSub<'a>(
1195 B: &Builder<'a>,
1196 LHS: &'a Value,
1197 RHS: &'a Value,
1198 Name: *const c_char,
1199 ) -> &'a Value;
1200 pub fn LLVMBuildFSub<'a>(
1201 B: &Builder<'a>,
1202 LHS: &'a Value,
1203 RHS: &'a Value,
1204 Name: *const c_char,
1205 ) -> &'a Value;
1206 pub fn LLVMBuildMul<'a>(
1207 B: &Builder<'a>,
1208 LHS: &'a Value,
1209 RHS: &'a Value,
1210 Name: *const c_char,
1211 ) -> &'a Value;
1212 pub fn LLVMBuildFMul<'a>(
1213 B: &Builder<'a>,
1214 LHS: &'a Value,
1215 RHS: &'a Value,
1216 Name: *const c_char,
1217 ) -> &'a Value;
1218 pub fn LLVMBuildUDiv<'a>(
1219 B: &Builder<'a>,
1220 LHS: &'a Value,
1221 RHS: &'a Value,
1222 Name: *const c_char,
1223 ) -> &'a Value;
1224 pub fn LLVMBuildExactUDiv<'a>(
1225 B: &Builder<'a>,
1226 LHS: &'a Value,
1227 RHS: &'a Value,
1228 Name: *const c_char,
1229 ) -> &'a Value;
1230 pub fn LLVMBuildSDiv<'a>(
1231 B: &Builder<'a>,
1232 LHS: &'a Value,
1233 RHS: &'a Value,
1234 Name: *const c_char,
1235 ) -> &'a Value;
1236 pub fn LLVMBuildExactSDiv<'a>(
1237 B: &Builder<'a>,
1238 LHS: &'a Value,
1239 RHS: &'a Value,
1240 Name: *const c_char,
1241 ) -> &'a Value;
1242 pub fn LLVMBuildFDiv<'a>(
1243 B: &Builder<'a>,
1244 LHS: &'a Value,
1245 RHS: &'a Value,
1246 Name: *const c_char,
1247 ) -> &'a Value;
1248 pub fn LLVMBuildURem<'a>(
1249 B: &Builder<'a>,
1250 LHS: &'a Value,
1251 RHS: &'a Value,
1252 Name: *const c_char,
1253 ) -> &'a Value;
1254 pub fn LLVMBuildSRem<'a>(
1255 B: &Builder<'a>,
1256 LHS: &'a Value,
1257 RHS: &'a Value,
1258 Name: *const c_char,
1259 ) -> &'a Value;
1260 pub fn LLVMBuildFRem<'a>(
1261 B: &Builder<'a>,
1262 LHS: &'a Value,
1263 RHS: &'a Value,
1264 Name: *const c_char,
1265 ) -> &'a Value;
1266 pub fn LLVMBuildShl<'a>(
1267 B: &Builder<'a>,
1268 LHS: &'a Value,
1269 RHS: &'a Value,
1270 Name: *const c_char,
1271 ) -> &'a Value;
1272 pub fn LLVMBuildLShr<'a>(
1273 B: &Builder<'a>,
1274 LHS: &'a Value,
1275 RHS: &'a Value,
1276 Name: *const c_char,
1277 ) -> &'a Value;
1278 pub fn LLVMBuildAShr<'a>(
1279 B: &Builder<'a>,
1280 LHS: &'a Value,
1281 RHS: &'a Value,
1282 Name: *const c_char,
1283 ) -> &'a Value;
1284 pub fn LLVMBuildNSWAdd<'a>(
1285 B: &Builder<'a>,
1286 LHS: &'a Value,
1287 RHS: &'a Value,
1288 Name: *const c_char,
1289 ) -> &'a Value;
1290 pub fn LLVMBuildNUWAdd<'a>(
1291 B: &Builder<'a>,
1292 LHS: &'a Value,
1293 RHS: &'a Value,
1294 Name: *const c_char,
1295 ) -> &'a Value;
1296 pub fn LLVMBuildNSWSub<'a>(
1297 B: &Builder<'a>,
1298 LHS: &'a Value,
1299 RHS: &'a Value,
1300 Name: *const c_char,
1301 ) -> &'a Value;
1302 pub fn LLVMBuildNUWSub<'a>(
1303 B: &Builder<'a>,
1304 LHS: &'a Value,
1305 RHS: &'a Value,
1306 Name: *const c_char,
1307 ) -> &'a Value;
1308 pub fn LLVMBuildNSWMul<'a>(
1309 B: &Builder<'a>,
1310 LHS: &'a Value,
1311 RHS: &'a Value,
1312 Name: *const c_char,
1313 ) -> &'a Value;
1314 pub fn LLVMBuildNUWMul<'a>(
1315 B: &Builder<'a>,
1316 LHS: &'a Value,
1317 RHS: &'a Value,
1318 Name: *const c_char,
1319 ) -> &'a Value;
1320 pub fn LLVMBuildAnd<'a>(
1321 B: &Builder<'a>,
1322 LHS: &'a Value,
1323 RHS: &'a Value,
1324 Name: *const c_char,
1325 ) -> &'a Value;
1326 pub fn LLVMBuildOr<'a>(
1327 B: &Builder<'a>,
1328 LHS: &'a Value,
1329 RHS: &'a Value,
1330 Name: *const c_char,
1331 ) -> &'a Value;
1332 pub fn LLVMBuildXor<'a>(
1333 B: &Builder<'a>,
1334 LHS: &'a Value,
1335 RHS: &'a Value,
1336 Name: *const c_char,
1337 ) -> &'a Value;
1338 pub fn LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1339 pub fn LLVMBuildFNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1340 pub fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1341 pub fn LLVMRustSetFastMath(Instr: &Value);
1342
1343 // Memory
1344 pub fn LLVMBuildAlloca<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1345 pub fn LLVMBuildArrayAlloca<'a>(
1346 B: &Builder<'a>,
1347 Ty: &'a Type,
1348 Val: &'a Value,
1349 Name: *const c_char,
1350 ) -> &'a Value;
1351 pub fn LLVMBuildLoad2<'a>(
1352 B: &Builder<'a>,
1353 Ty: &'a Type,
1354 PointerVal: &'a Value,
1355 Name: *const c_char,
1356 ) -> &'a Value;
1357
1358 pub fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1359
1360 pub fn LLVMBuildGEP2<'a>(
1361 B: &Builder<'a>,
1362 Ty: &'a Type,
1363 Pointer: &'a Value,
1364 Indices: *const &'a Value,
1365 NumIndices: c_uint,
1366 Name: *const c_char,
1367 ) -> &'a Value;
1368 pub fn LLVMBuildInBoundsGEP2<'a>(
1369 B: &Builder<'a>,
1370 Ty: &'a Type,
1371 Pointer: &'a Value,
1372 Indices: *const &'a Value,
1373 NumIndices: c_uint,
1374 Name: *const c_char,
1375 ) -> &'a Value;
1376 pub fn LLVMBuildStructGEP2<'a>(
1377 B: &Builder<'a>,
1378 Ty: &'a Type,
1379 Pointer: &'a Value,
1380 Idx: c_uint,
1381 Name: *const c_char,
1382 ) -> &'a Value;
1383
1384 // Casts
1385 pub fn LLVMBuildTrunc<'a>(
1386 B: &Builder<'a>,
1387 Val: &'a Value,
1388 DestTy: &'a Type,
1389 Name: *const c_char,
1390 ) -> &'a Value;
1391 pub fn LLVMBuildZExt<'a>(
1392 B: &Builder<'a>,
1393 Val: &'a Value,
1394 DestTy: &'a Type,
1395 Name: *const c_char,
1396 ) -> &'a Value;
1397 pub fn LLVMBuildSExt<'a>(
1398 B: &Builder<'a>,
1399 Val: &'a Value,
1400 DestTy: &'a Type,
1401 Name: *const c_char,
1402 ) -> &'a Value;
1403 pub fn LLVMBuildFPToUI<'a>(
1404 B: &Builder<'a>,
1405 Val: &'a Value,
1406 DestTy: &'a Type,
1407 Name: *const c_char,
1408 ) -> &'a Value;
1409 pub fn LLVMBuildFPToSI<'a>(
1410 B: &Builder<'a>,
1411 Val: &'a Value,
1412 DestTy: &'a Type,
1413 Name: *const c_char,
1414 ) -> &'a Value;
1415 pub fn LLVMBuildUIToFP<'a>(
1416 B: &Builder<'a>,
1417 Val: &'a Value,
1418 DestTy: &'a Type,
1419 Name: *const c_char,
1420 ) -> &'a Value;
1421 pub fn LLVMBuildSIToFP<'a>(
1422 B: &Builder<'a>,
1423 Val: &'a Value,
1424 DestTy: &'a Type,
1425 Name: *const c_char,
1426 ) -> &'a Value;
1427 pub fn LLVMBuildFPTrunc<'a>(
1428 B: &Builder<'a>,
1429 Val: &'a Value,
1430 DestTy: &'a Type,
1431 Name: *const c_char,
1432 ) -> &'a Value;
1433 pub fn LLVMBuildFPExt<'a>(
1434 B: &Builder<'a>,
1435 Val: &'a Value,
1436 DestTy: &'a Type,
1437 Name: *const c_char,
1438 ) -> &'a Value;
1439 pub fn LLVMBuildPtrToInt<'a>(
1440 B: &Builder<'a>,
1441 Val: &'a Value,
1442 DestTy: &'a Type,
1443 Name: *const c_char,
1444 ) -> &'a Value;
1445 pub fn LLVMBuildIntToPtr<'a>(
1446 B: &Builder<'a>,
1447 Val: &'a Value,
1448 DestTy: &'a Type,
1449 Name: *const c_char,
1450 ) -> &'a Value;
1451 pub fn LLVMBuildBitCast<'a>(
1452 B: &Builder<'a>,
1453 Val: &'a Value,
1454 DestTy: &'a Type,
1455 Name: *const c_char,
1456 ) -> &'a Value;
1457 pub fn LLVMBuildPointerCast<'a>(
1458 B: &Builder<'a>,
1459 Val: &'a Value,
1460 DestTy: &'a Type,
1461 Name: *const c_char,
1462 ) -> &'a Value;
1463 pub fn LLVMBuildIntCast2<'a>(
1464 B: &Builder<'a>,
1465 Val: &'a Value,
1466 DestTy: &'a Type,
1467 IsSigned: Bool,
1468 Name: *const c_char,
1469 ) -> &'a Value;
1470
1471 // Comparisons
1472 pub fn LLVMBuildICmp<'a>(
1473 B: &Builder<'a>,
1474 Op: c_uint,
1475 LHS: &'a Value,
1476 RHS: &'a Value,
1477 Name: *const c_char,
1478 ) -> &'a Value;
1479 pub fn LLVMBuildFCmp<'a>(
1480 B: &Builder<'a>,
1481 Op: c_uint,
1482 LHS: &'a Value,
1483 RHS: &'a Value,
1484 Name: *const c_char,
1485 ) -> &'a Value;
1486
1487 // Miscellaneous instructions
1488 pub fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1489 pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &Value;
1490 pub fn LLVMRustBuildCall<'a>(
1491 B: &Builder<'a>,
1492 Ty: &'a Type,
1493 Fn: &'a Value,
1494 Args: *const &'a Value,
1495 NumArgs: c_uint,
1496 OpBundles: *const &OperandBundleDef<'a>,
1497 NumOpBundles: c_uint,
1498 ) -> &'a Value;
1499 pub fn LLVMRustBuildMemCpy<'a>(
1500 B: &Builder<'a>,
1501 Dst: &'a Value,
1502 DstAlign: c_uint,
1503 Src: &'a Value,
1504 SrcAlign: c_uint,
1505 Size: &'a Value,
1506 IsVolatile: bool,
1507 ) -> &'a Value;
1508 pub fn LLVMRustBuildMemMove<'a>(
1509 B: &Builder<'a>,
1510 Dst: &'a Value,
1511 DstAlign: c_uint,
1512 Src: &'a Value,
1513 SrcAlign: c_uint,
1514 Size: &'a Value,
1515 IsVolatile: bool,
1516 ) -> &'a Value;
1517 pub fn LLVMRustBuildMemSet<'a>(
1518 B: &Builder<'a>,
1519 Dst: &'a Value,
1520 DstAlign: c_uint,
1521 Val: &'a Value,
1522 Size: &'a Value,
1523 IsVolatile: bool,
1524 ) -> &'a Value;
1525 pub fn LLVMBuildSelect<'a>(
1526 B: &Builder<'a>,
1527 If: &'a Value,
1528 Then: &'a Value,
1529 Else: &'a Value,
1530 Name: *const c_char,
1531 ) -> &'a Value;
1532 pub fn LLVMBuildVAArg<'a>(
1533 B: &Builder<'a>,
1534 list: &'a Value,
1535 Ty: &'a Type,
1536 Name: *const c_char,
1537 ) -> &'a Value;
1538 pub fn LLVMBuildExtractElement<'a>(
1539 B: &Builder<'a>,
1540 VecVal: &'a Value,
1541 Index: &'a Value,
1542 Name: *const c_char,
1543 ) -> &'a Value;
1544 pub fn LLVMBuildInsertElement<'a>(
1545 B: &Builder<'a>,
1546 VecVal: &'a Value,
1547 EltVal: &'a Value,
1548 Index: &'a Value,
1549 Name: *const c_char,
1550 ) -> &'a Value;
1551 pub fn LLVMBuildShuffleVector<'a>(
1552 B: &Builder<'a>,
1553 V1: &'a Value,
1554 V2: &'a Value,
1555 Mask: &'a Value,
1556 Name: *const c_char,
1557 ) -> &'a Value;
1558 pub fn LLVMBuildExtractValue<'a>(
1559 B: &Builder<'a>,
1560 AggVal: &'a Value,
1561 Index: c_uint,
1562 Name: *const c_char,
1563 ) -> &'a Value;
1564 pub fn LLVMBuildInsertValue<'a>(
1565 B: &Builder<'a>,
1566 AggVal: &'a Value,
1567 EltVal: &'a Value,
1568 Index: c_uint,
1569 Name: *const c_char,
1570 ) -> &'a Value;
1571
1572 pub fn LLVMRustBuildVectorReduceFAdd<'a>(
1573 B: &Builder<'a>,
1574 Acc: &'a Value,
1575 Src: &'a Value,
1576 ) -> &'a Value;
1577 pub fn LLVMRustBuildVectorReduceFMul<'a>(
1578 B: &Builder<'a>,
1579 Acc: &'a Value,
1580 Src: &'a Value,
1581 ) -> &'a Value;
1582 pub fn LLVMRustBuildVectorReduceAdd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1583 pub fn LLVMRustBuildVectorReduceMul<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1584 pub fn LLVMRustBuildVectorReduceAnd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1585 pub fn LLVMRustBuildVectorReduceOr<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1586 pub fn LLVMRustBuildVectorReduceXor<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1587 pub fn LLVMRustBuildVectorReduceMin<'a>(
1588 B: &Builder<'a>,
1589 Src: &'a Value,
1590 IsSigned: bool,
1591 ) -> &'a Value;
1592 pub fn LLVMRustBuildVectorReduceMax<'a>(
1593 B: &Builder<'a>,
1594 Src: &'a Value,
1595 IsSigned: bool,
1596 ) -> &'a Value;
1597 pub fn LLVMRustBuildVectorReduceFMin<'a>(
1598 B: &Builder<'a>,
1599 Src: &'a Value,
1600 IsNaN: bool,
1601 ) -> &'a Value;
1602 pub fn LLVMRustBuildVectorReduceFMax<'a>(
1603 B: &Builder<'a>,
1604 Src: &'a Value,
1605 IsNaN: bool,
1606 ) -> &'a Value;
1607
1608 pub fn LLVMRustBuildMinNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1609 pub fn LLVMRustBuildMaxNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1610
1611 // Atomic Operations
1612 pub fn LLVMRustBuildAtomicLoad<'a>(
1613 B: &Builder<'a>,
1614 ElementType: &'a Type,
1615 PointerVal: &'a Value,
1616 Name: *const c_char,
1617 Order: AtomicOrdering,
1618 ) -> &'a Value;
1619
1620 pub fn LLVMRustBuildAtomicStore<'a>(
1621 B: &Builder<'a>,
1622 Val: &'a Value,
1623 Ptr: &'a Value,
1624 Order: AtomicOrdering,
1625 ) -> &'a Value;
1626
1627 pub fn LLVMBuildAtomicCmpXchg<'a>(
1628 B: &Builder<'a>,
1629 LHS: &'a Value,
1630 CMP: &'a Value,
1631 RHS: &'a Value,
1632 Order: AtomicOrdering,
1633 FailureOrder: AtomicOrdering,
1634 SingleThreaded: Bool,
1635 ) -> &'a Value;
1636
1637 pub fn LLVMSetWeak(CmpXchgInst: &Value, IsWeak: Bool);
1638
1639 pub fn LLVMBuildAtomicRMW<'a>(
1640 B: &Builder<'a>,
1641 Op: AtomicRmwBinOp,
1642 LHS: &'a Value,
1643 RHS: &'a Value,
1644 Order: AtomicOrdering,
1645 SingleThreaded: Bool,
1646 ) -> &'a Value;
1647
1648 pub fn LLVMBuildFence<'a>(
1649 B: &Builder<'a>,
1650 Order: AtomicOrdering,
1651 SingleThreaded: Bool,
1652 Name: *const c_char,
1653 ) -> &'a Value;
1654
1655 /// Writes a module to the specified path. Returns 0 on success.
1656 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1657
1658 /// Creates a legacy pass manager -- only used for final codegen.
1659 pub fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>;
1660
1661 pub fn LLVMTimeTraceProfilerInitialize();
1662
1663 pub fn LLVMTimeTraceProfilerFinishThread();
1664
1665 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1666
1667 pub fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>);
1668
1669 pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
1670
1671 pub fn LLVMDisposeMessage(message: *mut c_char);
1672
1673 pub fn LLVMIsMultithreaded() -> Bool;
1674
1675 /// Returns a string describing the last error caused by an LLVMRust* call.
1676 pub fn LLVMRustGetLastError() -> *const c_char;
1677
1678 /// Print the pass timings since static dtors aren't picking them up.
1679 pub fn LLVMRustPrintPassTimings(size: *const size_t) -> *const c_char;
1680
1681 /// Print the statistics since static dtors aren't picking them up.
1682 pub fn LLVMRustPrintStatistics(size: *const size_t) -> *const c_char;
1683
1684 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1685
1686 pub fn LLVMStructSetBody<'a>(
1687 StructTy: &'a Type,
1688 ElementTypes: *const &'a Type,
1689 ElementCount: c_uint,
1690 Packed: Bool,
1691 );
1692
1693 /// Prepares inline assembly.
1694 pub fn LLVMRustInlineAsm(
1695 Ty: &Type,
1696 AsmString: *const c_char,
1697 AsmStringLen: size_t,
1698 Constraints: *const c_char,
1699 ConstraintsLen: size_t,
1700 SideEffects: Bool,
1701 AlignStack: Bool,
1702 Dialect: AsmDialect,
1703 CanThrow: Bool,
1704 ) -> &Value;
1705 pub fn LLVMRustInlineAsmVerify(
1706 Ty: &Type,
1707 Constraints: *const c_char,
1708 ConstraintsLen: size_t,
1709 ) -> bool;
1710
1711 #[allow(improper_ctypes)]
1712 pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1713 Filenames: *const *const c_char,
1714 FilenamesLen: size_t,
1715 Lengths: *const size_t,
1716 LengthsLen: size_t,
1717 BufferOut: &RustString,
1718 );
1719
1720 #[allow(improper_ctypes)]
1721 pub fn LLVMRustCoverageWriteMappingToBuffer(
1722 VirtualFileMappingIDs: *const c_uint,
1723 NumVirtualFileMappingIDs: c_uint,
1724 Expressions: *const crate::coverageinfo::ffi::CounterExpression,
1725 NumExpressions: c_uint,
1726 MappingRegions: *const crate::coverageinfo::ffi::CounterMappingRegion,
1727 NumMappingRegions: c_uint,
1728 BufferOut: &RustString,
1729 );
1730
1731 pub fn LLVMRustCoverageCreatePGOFuncNameVar(
1732 F: &Value,
1733 FuncName: *const c_char,
1734 FuncNameLen: size_t,
1735 ) -> &Value;
1736 pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
1737
1738 #[allow(improper_ctypes)]
1739 pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
1740
1741 #[allow(improper_ctypes)]
1742 pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
1743
1744 #[allow(improper_ctypes)]
1745 pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1746
1747 pub fn LLVMRustCoverageMappingVersion() -> u32;
1748 pub fn LLVMRustDebugMetadataVersion() -> u32;
1749 pub fn LLVMRustVersionMajor() -> u32;
1750 pub fn LLVMRustVersionMinor() -> u32;
1751 pub fn LLVMRustVersionPatch() -> u32;
1752
1753 /// Add LLVM module flags.
1754 ///
1755 /// In order for Rust-C LTO to work, module flags must be compatible with Clang. What
1756 /// "compatible" means depends on the merge behaviors involved.
1757 pub fn LLVMRustAddModuleFlag(
1758 M: &Module,
1759 merge_behavior: LLVMModFlagBehavior,
1760 name: *const c_char,
1761 value: u32,
1762 );
1763 pub fn LLVMRustHasModuleFlag(M: &Module, name: *const c_char, len: size_t) -> bool;
1764
1765 pub fn LLVMMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1766
1767 pub fn LLVMRustDIBuilderCreate(M: &Module) -> &mut DIBuilder<'_>;
1768
1769 pub fn LLVMRustDIBuilderDispose<'a>(Builder: &'a mut DIBuilder<'a>);
1770
1771 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1772
1773 pub fn LLVMRustDIBuilderCreateCompileUnit<'a>(
1774 Builder: &DIBuilder<'a>,
1775 Lang: c_uint,
1776 File: &'a DIFile,
1777 Producer: *const c_char,
1778 ProducerLen: size_t,
1779 isOptimized: bool,
1780 Flags: *const c_char,
1781 RuntimeVer: c_uint,
1782 SplitName: *const c_char,
1783 SplitNameLen: size_t,
1784 kind: DebugEmissionKind,
1785 DWOId: u64,
1786 SplitDebugInlining: bool,
1787 ) -> &'a DIDescriptor;
1788
1789 pub fn LLVMRustDIBuilderCreateFile<'a>(
1790 Builder: &DIBuilder<'a>,
1791 Filename: *const c_char,
1792 FilenameLen: size_t,
1793 Directory: *const c_char,
1794 DirectoryLen: size_t,
1795 CSKind: ChecksumKind,
1796 Checksum: *const c_char,
1797 ChecksumLen: size_t,
1798 ) -> &'a DIFile;
1799
1800 pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
1801 Builder: &DIBuilder<'a>,
1802 ParameterTypes: &'a DIArray,
1803 ) -> &'a DICompositeType;
1804
1805 pub fn LLVMRustDIBuilderCreateFunction<'a>(
1806 Builder: &DIBuilder<'a>,
1807 Scope: &'a DIDescriptor,
1808 Name: *const c_char,
1809 NameLen: size_t,
1810 LinkageName: *const c_char,
1811 LinkageNameLen: size_t,
1812 File: &'a DIFile,
1813 LineNo: c_uint,
1814 Ty: &'a DIType,
1815 ScopeLine: c_uint,
1816 Flags: DIFlags,
1817 SPFlags: DISPFlags,
1818 MaybeFn: Option<&'a Value>,
1819 TParam: &'a DIArray,
1820 Decl: Option<&'a DIDescriptor>,
1821 ) -> &'a DISubprogram;
1822
1823 pub fn LLVMRustDIBuilderCreateMethod<'a>(
1824 Builder: &DIBuilder<'a>,
1825 Scope: &'a DIDescriptor,
1826 Name: *const c_char,
1827 NameLen: size_t,
1828 LinkageName: *const c_char,
1829 LinkageNameLen: size_t,
1830 File: &'a DIFile,
1831 LineNo: c_uint,
1832 Ty: &'a DIType,
1833 Flags: DIFlags,
1834 SPFlags: DISPFlags,
1835 TParam: &'a DIArray,
1836 ) -> &'a DISubprogram;
1837
1838 pub fn LLVMRustDIBuilderCreateBasicType<'a>(
1839 Builder: &DIBuilder<'a>,
1840 Name: *const c_char,
1841 NameLen: size_t,
1842 SizeInBits: u64,
1843 Encoding: c_uint,
1844 ) -> &'a DIBasicType;
1845
1846 pub fn LLVMRustDIBuilderCreateTypedef<'a>(
1847 Builder: &DIBuilder<'a>,
1848 Type: &'a DIBasicType,
1849 Name: *const c_char,
1850 NameLen: size_t,
1851 File: &'a DIFile,
1852 LineNo: c_uint,
1853 Scope: Option<&'a DIScope>,
1854 ) -> &'a DIDerivedType;
1855
1856 pub fn LLVMRustDIBuilderCreatePointerType<'a>(
1857 Builder: &DIBuilder<'a>,
1858 PointeeTy: &'a DIType,
1859 SizeInBits: u64,
1860 AlignInBits: u32,
1861 AddressSpace: c_uint,
1862 Name: *const c_char,
1863 NameLen: size_t,
1864 ) -> &'a DIDerivedType;
1865
1866 pub fn LLVMRustDIBuilderCreateStructType<'a>(
1867 Builder: &DIBuilder<'a>,
1868 Scope: Option<&'a DIDescriptor>,
1869 Name: *const c_char,
1870 NameLen: size_t,
1871 File: &'a DIFile,
1872 LineNumber: c_uint,
1873 SizeInBits: u64,
1874 AlignInBits: u32,
1875 Flags: DIFlags,
1876 DerivedFrom: Option<&'a DIType>,
1877 Elements: &'a DIArray,
1878 RunTimeLang: c_uint,
1879 VTableHolder: Option<&'a DIType>,
1880 UniqueId: *const c_char,
1881 UniqueIdLen: size_t,
1882 ) -> &'a DICompositeType;
1883
1884 pub fn LLVMRustDIBuilderCreateMemberType<'a>(
1885 Builder: &DIBuilder<'a>,
1886 Scope: &'a DIDescriptor,
1887 Name: *const c_char,
1888 NameLen: size_t,
1889 File: &'a DIFile,
1890 LineNo: c_uint,
1891 SizeInBits: u64,
1892 AlignInBits: u32,
1893 OffsetInBits: u64,
1894 Flags: DIFlags,
1895 Ty: &'a DIType,
1896 ) -> &'a DIDerivedType;
1897
1898 pub fn LLVMRustDIBuilderCreateVariantMemberType<'a>(
1899 Builder: &DIBuilder<'a>,
1900 Scope: &'a DIScope,
1901 Name: *const c_char,
1902 NameLen: size_t,
1903 File: &'a DIFile,
1904 LineNumber: c_uint,
1905 SizeInBits: u64,
1906 AlignInBits: u32,
1907 OffsetInBits: u64,
1908 Discriminant: Option<&'a Value>,
1909 Flags: DIFlags,
1910 Ty: &'a DIType,
1911 ) -> &'a DIType;
1912
1913 pub fn LLVMRustDIBuilderCreateStaticMemberType<'a>(
1914 Builder: &DIBuilder<'a>,
1915 Scope: &'a DIDescriptor,
1916 Name: *const c_char,
1917 NameLen: size_t,
1918 File: &'a DIFile,
1919 LineNo: c_uint,
1920 Ty: &'a DIType,
1921 Flags: DIFlags,
1922 val: Option<&'a Value>,
1923 AlignInBits: u32,
1924 ) -> &'a DIDerivedType;
1925
1926 pub fn LLVMRustDIBuilderCreateLexicalBlock<'a>(
1927 Builder: &DIBuilder<'a>,
1928 Scope: &'a DIScope,
1929 File: &'a DIFile,
1930 Line: c_uint,
1931 Col: c_uint,
1932 ) -> &'a DILexicalBlock;
1933
1934 pub fn LLVMRustDIBuilderCreateLexicalBlockFile<'a>(
1935 Builder: &DIBuilder<'a>,
1936 Scope: &'a DIScope,
1937 File: &'a DIFile,
1938 ) -> &'a DILexicalBlock;
1939
1940 pub fn LLVMRustDIBuilderCreateStaticVariable<'a>(
1941 Builder: &DIBuilder<'a>,
1942 Context: Option<&'a DIScope>,
1943 Name: *const c_char,
1944 NameLen: size_t,
1945 LinkageName: *const c_char,
1946 LinkageNameLen: size_t,
1947 File: &'a DIFile,
1948 LineNo: c_uint,
1949 Ty: &'a DIType,
1950 isLocalToUnit: bool,
1951 Val: &'a Value,
1952 Decl: Option<&'a DIDescriptor>,
1953 AlignInBits: u32,
1954 ) -> &'a DIGlobalVariableExpression;
1955
1956 pub fn LLVMRustDIBuilderCreateVariable<'a>(
1957 Builder: &DIBuilder<'a>,
1958 Tag: c_uint,
1959 Scope: &'a DIDescriptor,
1960 Name: *const c_char,
1961 NameLen: size_t,
1962 File: &'a DIFile,
1963 LineNo: c_uint,
1964 Ty: &'a DIType,
1965 AlwaysPreserve: bool,
1966 Flags: DIFlags,
1967 ArgNo: c_uint,
1968 AlignInBits: u32,
1969 ) -> &'a DIVariable;
1970
1971 pub fn LLVMRustDIBuilderCreateArrayType<'a>(
1972 Builder: &DIBuilder<'a>,
1973 Size: u64,
1974 AlignInBits: u32,
1975 Ty: &'a DIType,
1976 Subscripts: &'a DIArray,
1977 ) -> &'a DIType;
1978
1979 pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
1980 Builder: &DIBuilder<'a>,
1981 Lo: i64,
1982 Count: i64,
1983 ) -> &'a DISubrange;
1984
1985 pub fn LLVMRustDIBuilderGetOrCreateArray<'a>(
1986 Builder: &DIBuilder<'a>,
1987 Ptr: *const Option<&'a DIDescriptor>,
1988 Count: c_uint,
1989 ) -> &'a DIArray;
1990
1991 pub fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>(
1992 Builder: &DIBuilder<'a>,
1993 Val: &'a Value,
1994 VarInfo: &'a DIVariable,
1995 AddrOps: *const u64,
1996 AddrOpsCount: c_uint,
1997 DL: &'a DILocation,
1998 InsertAtEnd: &'a BasicBlock,
1999 ) -> &'a Value;
2000
2001 pub fn LLVMRustDIBuilderCreateEnumerator<'a>(
2002 Builder: &DIBuilder<'a>,
2003 Name: *const c_char,
2004 NameLen: size_t,
2005 Value: *const u64,
2006 SizeInBits: c_uint,
2007 IsUnsigned: bool,
2008 ) -> &'a DIEnumerator;
2009
2010 pub fn LLVMRustDIBuilderCreateEnumerationType<'a>(
2011 Builder: &DIBuilder<'a>,
2012 Scope: &'a DIScope,
2013 Name: *const c_char,
2014 NameLen: size_t,
2015 File: &'a DIFile,
2016 LineNumber: c_uint,
2017 SizeInBits: u64,
2018 AlignInBits: u32,
2019 Elements: &'a DIArray,
2020 ClassType: &'a DIType,
2021 IsScoped: bool,
2022 ) -> &'a DIType;
2023
2024 pub fn LLVMRustDIBuilderCreateUnionType<'a>(
2025 Builder: &DIBuilder<'a>,
2026 Scope: Option<&'a DIScope>,
2027 Name: *const c_char,
2028 NameLen: size_t,
2029 File: &'a DIFile,
2030 LineNumber: c_uint,
2031 SizeInBits: u64,
2032 AlignInBits: u32,
2033 Flags: DIFlags,
2034 Elements: Option<&'a DIArray>,
2035 RunTimeLang: c_uint,
2036 UniqueId: *const c_char,
2037 UniqueIdLen: size_t,
2038 ) -> &'a DIType;
2039
2040 pub fn LLVMRustDIBuilderCreateVariantPart<'a>(
2041 Builder: &DIBuilder<'a>,
2042 Scope: &'a DIScope,
2043 Name: *const c_char,
2044 NameLen: size_t,
2045 File: &'a DIFile,
2046 LineNo: c_uint,
2047 SizeInBits: u64,
2048 AlignInBits: u32,
2049 Flags: DIFlags,
2050 Discriminator: Option<&'a DIDerivedType>,
2051 Elements: &'a DIArray,
2052 UniqueId: *const c_char,
2053 UniqueIdLen: size_t,
2054 ) -> &'a DIDerivedType;
2055
2056 pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
2057
2058 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter<'a>(
2059 Builder: &DIBuilder<'a>,
2060 Scope: Option<&'a DIScope>,
2061 Name: *const c_char,
2062 NameLen: size_t,
2063 Ty: &'a DIType,
2064 ) -> &'a DITemplateTypeParameter;
2065
2066 pub fn LLVMRustDIBuilderCreateNameSpace<'a>(
2067 Builder: &DIBuilder<'a>,
2068 Scope: Option<&'a DIScope>,
2069 Name: *const c_char,
2070 NameLen: size_t,
2071 ExportSymbols: bool,
2072 ) -> &'a DINameSpace;
2073
2074 pub fn LLVMRustDICompositeTypeReplaceArrays<'a>(
2075 Builder: &DIBuilder<'a>,
2076 CompositeType: &'a DIType,
2077 Elements: Option<&'a DIArray>,
2078 Params: Option<&'a DIArray>,
2079 );
2080
2081 pub fn LLVMRustDIBuilderCreateDebugLocation<'a>(
2082 Line: c_uint,
2083 Column: c_uint,
2084 Scope: &'a DIScope,
2085 InlinedAt: Option<&'a DILocation>,
2086 ) -> &'a DILocation;
2087 pub fn LLVMRustDIBuilderCreateOpDeref() -> u64;
2088 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64;
2089 pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64;
2090
2091 #[allow(improper_ctypes)]
2092 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2093 #[allow(improper_ctypes)]
2094 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2095
2096 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2097
2098 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2099
2100 pub fn LLVMRustPrintTargetCPUs(
2101 T: &TargetMachine,
2102 cpu: *const c_char,
2103 print: unsafe extern "C" fn(out: *mut c_void, string: *const c_char, len: usize),
2104 out: *mut c_void,
2105 );
2106 pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2107 pub fn LLVMRustGetTargetFeature(
2108 T: &TargetMachine,
2109 Index: size_t,
2110 Feature: &mut *const c_char,
2111 Desc: &mut *const c_char,
2112 );
2113
2114 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2115
2116 // This function makes copies of pointed to data, so the data's lifetime may end after this function returns
2117 pub fn LLVMRustCreateTargetMachine(
2118 Triple: *const c_char,
2119 CPU: *const c_char,
2120 Features: *const c_char,
2121 Abi: *const c_char,
2122 Model: CodeModel,
2123 Reloc: RelocModel,
2124 Level: CodeGenOptLevel,
2125 UseSoftFP: bool,
2126 FunctionSections: bool,
2127 DataSections: bool,
2128 UniqueSectionNames: bool,
2129 TrapUnreachable: bool,
2130 Singlethread: bool,
2131 AsmComments: bool,
2132 EmitStackSizeSection: bool,
2133 RelaxELFRelocations: bool,
2134 UseInitArray: bool,
2135 SplitDwarfFile: *const c_char,
2136 OutputObjFile: *const c_char,
2137 DebugInfoCompression: *const c_char,
2138 ForceEmulatedTls: bool,
2139 ArgsCstrBuff: *const c_char,
2140 ArgsCstrBuffLen: usize,
2141 ) -> *mut TargetMachine;
2142
2143 pub fn LLVMRustDisposeTargetMachine(T: *mut TargetMachine);
2144 pub fn LLVMRustAddLibraryInfo<'a>(
2145 PM: &PassManager<'a>,
2146 M: &'a Module,
2147 DisableSimplifyLibCalls: bool,
2148 );
2149 pub fn LLVMRustWriteOutputFile<'a>(
2150 T: &'a TargetMachine,
2151 PM: &PassManager<'a>,
2152 M: &'a Module,
2153 Output: *const c_char,
2154 DwoOutput: *const c_char,
2155 FileType: FileType,
2156 ) -> LLVMRustResult;
2157 pub fn LLVMRustOptimize<'a>(
2158 M: &'a Module,
2159 TM: &'a TargetMachine,
2160 OptLevel: PassBuilderOptLevel,
2161 OptStage: OptStage,
2162 IsLinkerPluginLTO: bool,
2163 NoPrepopulatePasses: bool,
2164 VerifyIR: bool,
2165 UseThinLTOBuffers: bool,
2166 MergeFunctions: bool,
2167 UnrollLoops: bool,
2168 SLPVectorize: bool,
2169 LoopVectorize: bool,
2170 DisableSimplifyLibCalls: bool,
2171 EmitLifetimeMarkers: bool,
2172 SanitizerOptions: Option<&SanitizerOptions>,
2173 PGOGenPath: *const c_char,
2174 PGOUsePath: *const c_char,
2175 InstrumentCoverage: bool,
2176 InstrProfileOutput: *const c_char,
2177 InstrumentGCOV: bool,
2178 PGOSampleUsePath: *const c_char,
2179 DebugInfoForProfiling: bool,
2180 llvm_selfprofiler: *mut c_void,
2181 begin_callback: SelfProfileBeforePassCallback,
2182 end_callback: SelfProfileAfterPassCallback,
2183 ExtraPasses: *const c_char,
2184 ExtraPassesLen: size_t,
2185 LLVMPlugins: *const c_char,
2186 LLVMPluginsLen: size_t,
2187 ) -> LLVMRustResult;
2188 pub fn LLVMRustPrintModule(
2189 M: &Module,
2190 Output: *const c_char,
2191 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2192 ) -> LLVMRustResult;
2193 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2194 pub fn LLVMRustPrintPasses();
2195 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2196 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2197
2198 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2199 pub fn LLVMRustArchiveIteratorNew(AR: &Archive) -> &mut ArchiveIterator<'_>;
2200 pub fn LLVMRustArchiveIteratorNext<'a>(
2201 AIR: &ArchiveIterator<'a>,
2202 ) -> Option<&'a mut ArchiveChild<'a>>;
2203 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2204 pub fn LLVMRustArchiveChildFree<'a>(ACR: &'a mut ArchiveChild<'a>);
2205 pub fn LLVMRustArchiveIteratorFree<'a>(AIR: &'a mut ArchiveIterator<'a>);
2206 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2207
2208 #[allow(improper_ctypes)]
2209 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2210
2211 #[allow(improper_ctypes)]
2212 pub fn LLVMRustUnpackOptimizationDiagnostic<'a>(
2213 DI: &'a DiagnosticInfo,
2214 pass_name_out: &RustString,
2215 function_out: &mut Option<&'a Value>,
2216 loc_line_out: &mut c_uint,
2217 loc_column_out: &mut c_uint,
2218 loc_filename_out: &RustString,
2219 message_out: &RustString,
2220 );
2221
2222 pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>(
2223 DI: &'a DiagnosticInfo,
2224 level_out: &mut DiagnosticLevel,
2225 cookie_out: &mut c_uint,
2226 message_out: &mut Option<&'a Twine>,
2227 );
2228
2229 #[allow(improper_ctypes)]
2230 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2231 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2232
2233 pub fn LLVMRustGetSMDiagnostic<'a>(
2234 DI: &'a DiagnosticInfo,
2235 cookie_out: &mut c_uint,
2236 ) -> &'a SMDiagnostic;
2237
2238 #[allow(improper_ctypes)]
2239 pub fn LLVMRustUnpackSMDiagnostic(
2240 d: &SMDiagnostic,
2241 message_out: &RustString,
2242 buffer_out: &RustString,
2243 level_out: &mut DiagnosticLevel,
2244 loc_out: &mut c_uint,
2245 ranges_out: *mut c_uint,
2246 num_ranges: &mut usize,
2247 ) -> bool;
2248
2249 pub fn LLVMRustWriteArchive(
2250 Dst: *const c_char,
2251 NumMembers: size_t,
2252 Members: *const &RustArchiveMember<'_>,
2253 WriteSymbtab: bool,
2254 Kind: ArchiveKind,
2255 ) -> LLVMRustResult;
2256 pub fn LLVMRustArchiveMemberNew<'a>(
2257 Filename: *const c_char,
2258 Name: *const c_char,
2259 Child: Option<&ArchiveChild<'a>>,
2260 ) -> &'a mut RustArchiveMember<'a>;
2261 pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>);
2262
2263 pub fn LLVMRustWriteImportLibrary(
2264 ImportName: *const c_char,
2265 Path: *const c_char,
2266 Exports: *const LLVMRustCOFFShortExport,
2267 NumExports: usize,
2268 Machine: u16,
2269 MinGW: bool,
2270 ) -> LLVMRustResult;
2271
2272 pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
2273
2274 pub fn LLVMRustBuildOperandBundleDef(
2275 Name: *const c_char,
2276 Inputs: *const &'_ Value,
2277 NumInputs: c_uint,
2278 ) -> &mut OperandBundleDef<'_>;
2279 pub fn LLVMRustFreeOperandBundleDef<'a>(Bundle: &'a mut OperandBundleDef<'a>);
2280
2281 pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
2282
2283 pub fn LLVMRustSetComdat<'a>(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2284 pub fn LLVMRustSetModulePICLevel(M: &Module);
2285 pub fn LLVMRustSetModulePIELevel(M: &Module);
2286 pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2287 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2288 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2289 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2290 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2291 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2292 #[allow(improper_ctypes)]
2293 pub fn LLVMRustModuleInstructionStats(M: &Module, Str: &RustString);
2294
2295 pub fn LLVMRustThinLTOBufferCreate(M: &Module, is_thin: bool) -> &'static mut ThinLTOBuffer;
2296 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2297 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2298 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2299 pub fn LLVMRustCreateThinLTOData(
2300 Modules: *const ThinLTOModule,
2301 NumModules: c_uint,
2302 PreservedSymbols: *const *const c_char,
2303 PreservedSymbolsLen: c_uint,
2304 ) -> Option<&'static mut ThinLTOData>;
2305 pub fn LLVMRustPrepareThinLTORename(
2306 Data: &ThinLTOData,
2307 Module: &Module,
2308 Target: &TargetMachine,
2309 ) -> bool;
2310 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2311 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2312 pub fn LLVMRustPrepareThinLTOImport(
2313 Data: &ThinLTOData,
2314 Module: &Module,
2315 Target: &TargetMachine,
2316 ) -> bool;
2317 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2318 pub fn LLVMRustParseBitcodeForLTO(
2319 Context: &Context,
2320 Data: *const u8,
2321 len: usize,
2322 Identifier: *const c_char,
2323 ) -> Option<&Module>;
2324 pub fn LLVMRustGetBitcodeSliceFromObjectData(
2325 Data: *const u8,
2326 len: usize,
2327 out_len: &mut usize,
2328 ) -> *const u8;
2329 pub fn LLVMRustGetSliceFromObjectDataByName(
2330 data: *const u8,
2331 len: usize,
2332 name: *const u8,
2333 out_len: &mut usize,
2334 ) -> *const u8;
2335
2336 pub fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>;
2337 pub fn LLVMRustLinkerAdd(
2338 linker: &Linker<'_>,
2339 bytecode: *const c_char,
2340 bytecode_len: usize,
2341 ) -> bool;
2342 pub fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>);
2343 #[allow(improper_ctypes)]
2344 pub fn LLVMRustComputeLTOCacheKey(
2345 key_out: &RustString,
2346 mod_id: *const c_char,
2347 data: &ThinLTOData,
2348 );
2349
2350 pub fn LLVMRustContextGetDiagnosticHandler(Context: &Context) -> Option<&DiagnosticHandler>;
2351 pub fn LLVMRustContextSetDiagnosticHandler(
2352 context: &Context,
2353 diagnostic_handler: Option<&DiagnosticHandler>,
2354 );
2355 pub fn LLVMRustContextConfigureDiagnosticHandler(
2356 context: &Context,
2357 diagnostic_handler_callback: DiagnosticHandlerTy,
2358 diagnostic_handler_context: *mut c_void,
2359 remark_all_passes: bool,
2360 remark_passes: *const *const c_char,
2361 remark_passes_len: usize,
2362 remark_file: *const c_char,
2363 pgo_available: bool,
2364 );
2365
2366 #[allow(improper_ctypes)]
2367 pub fn LLVMRustGetMangledName(V: &Value, out: &RustString);
2368
2369 pub fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32;
2370
2371 pub fn LLVMRustIsBitcode(ptr: *const u8, len: usize) -> bool;
2372
2373 pub fn LLVMRustLLVMHasZlibCompressionForDebugSymbols() -> bool;
2374
2375 pub fn LLVMRustLLVMHasZstdCompressionForDebugSymbols() -> bool;
2376
2377 pub fn LLVMRustGetSymbols(
2378 buf_ptr: *const u8,
2379 buf_len: usize,
2380 state: *mut c_void,
2381 callback: GetSymbolsCallback,
2382 error_callback: GetSymbolsErrorCallback,
2383 ) -> *mut c_void;
2384}