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