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