]> git.proxmox.com Git - rustc.git/blob - src/librustc_codegen_llvm/llvm/ffi.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / librustc_codegen_llvm / llvm / ffi.rs
1 #![allow(non_camel_case_types)]
2 #![allow(non_upper_case_globals)]
3
4 use super::debuginfo::{
5 DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
6 DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DINameSpace, DISPFlags, DIScope,
7 DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind,
8 };
9
10 use libc::{c_char, c_int, c_uint, size_t};
11 use libc::{c_ulonglong, c_void};
12
13 use std::marker::PhantomData;
14
15 use super::RustString;
16
17 pub type Bool = c_uint;
18
19 pub const True: Bool = 1 as Bool;
20 pub const False: Bool = 0 as Bool;
21
22 #[derive(Copy, Clone, PartialEq)]
23 #[repr(C)]
24 #[allow(dead_code)] // Variants constructed by C++.
25 pub enum LLVMRustResult {
26 Success,
27 Failure,
28 }
29 // Consts for the LLVM CallConv type, pre-cast to usize.
30
31 /// LLVM CallingConv::ID. Should we wrap this?
32 #[derive(Copy, Clone, PartialEq, Debug)]
33 #[repr(C)]
34 pub enum CallConv {
35 CCallConv = 0,
36 FastCallConv = 8,
37 ColdCallConv = 9,
38 X86StdcallCallConv = 64,
39 X86FastcallCallConv = 65,
40 ArmAapcsCallConv = 67,
41 Msp430Intr = 69,
42 X86_ThisCall = 70,
43 PtxKernel = 71,
44 X86_64_SysV = 78,
45 X86_64_Win64 = 79,
46 X86_VectorCall = 80,
47 X86_Intr = 83,
48 AmdGpuKernel = 91,
49 }
50
51 /// LLVMRustLinkage
52 #[derive(PartialEq)]
53 #[repr(C)]
54 pub enum Linkage {
55 ExternalLinkage = 0,
56 AvailableExternallyLinkage = 1,
57 LinkOnceAnyLinkage = 2,
58 LinkOnceODRLinkage = 3,
59 WeakAnyLinkage = 4,
60 WeakODRLinkage = 5,
61 AppendingLinkage = 6,
62 InternalLinkage = 7,
63 PrivateLinkage = 8,
64 ExternalWeakLinkage = 9,
65 CommonLinkage = 10,
66 }
67
68 // LLVMRustVisibility
69 #[repr(C)]
70 pub enum Visibility {
71 Default = 0,
72 Hidden = 1,
73 Protected = 2,
74 }
75
76 /// LLVMUnnamedAddr
77 #[repr(C)]
78 pub enum UnnamedAddr {
79 No,
80 Local,
81 Global,
82 }
83
84 /// LLVMDLLStorageClass
85 #[derive(Copy, Clone)]
86 #[repr(C)]
87 pub enum DLLStorageClass {
88 #[allow(dead_code)]
89 Default = 0,
90 DllImport = 1, // Function to be imported from DLL.
91 #[allow(dead_code)]
92 DllExport = 2, // Function to be accessible from DLL.
93 }
94
95 /// Matches LLVMRustAttribute in rustllvm.h
96 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
97 /// though it is not ABI compatible (since it's a C++ enum)
98 #[repr(C)]
99 #[derive(Copy, Clone, Debug)]
100 pub enum Attribute {
101 AlwaysInline = 0,
102 ByVal = 1,
103 Cold = 2,
104 InlineHint = 3,
105 MinSize = 4,
106 Naked = 5,
107 NoAlias = 6,
108 NoCapture = 7,
109 NoInline = 8,
110 NonNull = 9,
111 NoRedZone = 10,
112 NoReturn = 11,
113 NoUnwind = 12,
114 OptimizeForSize = 13,
115 ReadOnly = 14,
116 SExt = 15,
117 StructRet = 16,
118 UWTable = 17,
119 ZExt = 18,
120 InReg = 19,
121 SanitizeThread = 20,
122 SanitizeAddress = 21,
123 SanitizeMemory = 22,
124 NonLazyBind = 23,
125 OptimizeNone = 24,
126 ReturnsTwice = 25,
127 }
128
129 /// LLVMIntPredicate
130 #[derive(Copy, Clone)]
131 #[repr(C)]
132 pub enum IntPredicate {
133 IntEQ = 32,
134 IntNE = 33,
135 IntUGT = 34,
136 IntUGE = 35,
137 IntULT = 36,
138 IntULE = 37,
139 IntSGT = 38,
140 IntSGE = 39,
141 IntSLT = 40,
142 IntSLE = 41,
143 }
144
145 impl IntPredicate {
146 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
147 match intpre {
148 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
149 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
150 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
151 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
152 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
153 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
154 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
155 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
156 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
157 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
158 }
159 }
160 }
161
162 /// LLVMRealPredicate
163 #[derive(Copy, Clone)]
164 #[repr(C)]
165 pub enum RealPredicate {
166 RealPredicateFalse = 0,
167 RealOEQ = 1,
168 RealOGT = 2,
169 RealOGE = 3,
170 RealOLT = 4,
171 RealOLE = 5,
172 RealONE = 6,
173 RealORD = 7,
174 RealUNO = 8,
175 RealUEQ = 9,
176 RealUGT = 10,
177 RealUGE = 11,
178 RealULT = 12,
179 RealULE = 13,
180 RealUNE = 14,
181 RealPredicateTrue = 15,
182 }
183
184 impl RealPredicate {
185 pub fn from_generic(realpred: rustc_codegen_ssa::common::RealPredicate) -> Self {
186 match realpred {
187 rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
188 RealPredicate::RealPredicateFalse
189 }
190 rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
191 rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
192 rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
193 rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
194 rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
195 rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
196 rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
197 rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
198 rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
199 rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
200 rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
201 rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
202 rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
203 rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
204 rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
205 RealPredicate::RealPredicateTrue
206 }
207 }
208 }
209 }
210
211 /// LLVMTypeKind
212 #[derive(Copy, Clone, PartialEq, Debug)]
213 #[repr(C)]
214 pub enum TypeKind {
215 Void = 0,
216 Half = 1,
217 Float = 2,
218 Double = 3,
219 X86_FP80 = 4,
220 FP128 = 5,
221 PPC_FP128 = 6,
222 Label = 7,
223 Integer = 8,
224 Function = 9,
225 Struct = 10,
226 Array = 11,
227 Pointer = 12,
228 Vector = 13,
229 Metadata = 14,
230 X86_MMX = 15,
231 Token = 16,
232 }
233
234 impl TypeKind {
235 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
236 match self {
237 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
238 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
239 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
240 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
241 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
242 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
243 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
244 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
245 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
246 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
247 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
248 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
249 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
250 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
251 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
252 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
253 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
254 }
255 }
256 }
257
258 /// LLVMAtomicRmwBinOp
259 #[derive(Copy, Clone)]
260 #[repr(C)]
261 pub enum AtomicRmwBinOp {
262 AtomicXchg = 0,
263 AtomicAdd = 1,
264 AtomicSub = 2,
265 AtomicAnd = 3,
266 AtomicNand = 4,
267 AtomicOr = 5,
268 AtomicXor = 6,
269 AtomicMax = 7,
270 AtomicMin = 8,
271 AtomicUMax = 9,
272 AtomicUMin = 10,
273 }
274
275 impl AtomicRmwBinOp {
276 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
277 match op {
278 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
279 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
280 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
281 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
282 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
283 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
284 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
285 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
286 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
287 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
288 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
289 }
290 }
291 }
292
293 /// LLVMAtomicOrdering
294 #[derive(Copy, Clone)]
295 #[repr(C)]
296 pub enum AtomicOrdering {
297 #[allow(dead_code)]
298 NotAtomic = 0,
299 Unordered = 1,
300 Monotonic = 2,
301 // Consume = 3, // Not specified yet.
302 Acquire = 4,
303 Release = 5,
304 AcquireRelease = 6,
305 SequentiallyConsistent = 7,
306 }
307
308 impl AtomicOrdering {
309 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
310 match ao {
311 rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
312 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
313 rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
314 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
315 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
316 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
317 AtomicOrdering::AcquireRelease
318 }
319 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
320 AtomicOrdering::SequentiallyConsistent
321 }
322 }
323 }
324 }
325
326 /// LLVMRustSynchronizationScope
327 #[derive(Copy, Clone)]
328 #[repr(C)]
329 pub enum SynchronizationScope {
330 // FIXME: figure out if this variant is needed at all.
331 #[allow(dead_code)]
332 Other,
333 SingleThread,
334 CrossThread,
335 }
336
337 impl SynchronizationScope {
338 pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
339 match sc {
340 rustc_codegen_ssa::common::SynchronizationScope::Other => SynchronizationScope::Other,
341 rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
342 SynchronizationScope::SingleThread
343 }
344 rustc_codegen_ssa::common::SynchronizationScope::CrossThread => {
345 SynchronizationScope::CrossThread
346 }
347 }
348 }
349 }
350
351 /// LLVMRustFileType
352 #[derive(Copy, Clone)]
353 #[repr(C)]
354 pub enum FileType {
355 // FIXME: figure out if this variant is needed at all.
356 #[allow(dead_code)]
357 Other,
358 AssemblyFile,
359 ObjectFile,
360 }
361
362 /// LLVMMetadataType
363 #[derive(Copy, Clone)]
364 #[repr(C)]
365 pub enum MetadataType {
366 MD_dbg = 0,
367 MD_tbaa = 1,
368 MD_prof = 2,
369 MD_fpmath = 3,
370 MD_range = 4,
371 MD_tbaa_struct = 5,
372 MD_invariant_load = 6,
373 MD_alias_scope = 7,
374 MD_noalias = 8,
375 MD_nontemporal = 9,
376 MD_mem_parallel_loop_access = 10,
377 MD_nonnull = 11,
378 }
379
380 /// LLVMRustAsmDialect
381 #[derive(Copy, Clone)]
382 #[repr(C)]
383 pub enum AsmDialect {
384 // FIXME: figure out if this variant is needed at all.
385 #[allow(dead_code)]
386 Other,
387 Att,
388 Intel,
389 }
390
391 impl AsmDialect {
392 pub fn from_generic(asm: rustc_ast::ast::LlvmAsmDialect) -> Self {
393 match asm {
394 rustc_ast::ast::LlvmAsmDialect::Att => AsmDialect::Att,
395 rustc_ast::ast::LlvmAsmDialect::Intel => AsmDialect::Intel,
396 }
397 }
398 }
399
400 /// LLVMRustCodeGenOptLevel
401 #[derive(Copy, Clone, PartialEq)]
402 #[repr(C)]
403 pub enum CodeGenOptLevel {
404 // FIXME: figure out if this variant is needed at all.
405 #[allow(dead_code)]
406 Other,
407 None,
408 Less,
409 Default,
410 Aggressive,
411 }
412
413 /// LLVMRustPassBuilderOptLevel
414 #[repr(C)]
415 pub enum PassBuilderOptLevel {
416 O0,
417 O1,
418 O2,
419 O3,
420 Os,
421 Oz,
422 }
423
424 /// LLVMRustOptStage
425 #[derive(PartialEq)]
426 #[repr(C)]
427 pub enum OptStage {
428 PreLinkNoLTO,
429 PreLinkThinLTO,
430 PreLinkFatLTO,
431 ThinLTO,
432 FatLTO,
433 }
434
435 /// LLVMRustSanitizerOptions
436 #[repr(C)]
437 pub struct SanitizerOptions {
438 pub sanitize_memory: bool,
439 pub sanitize_thread: bool,
440 pub sanitize_address: bool,
441 pub sanitize_recover: bool,
442 pub sanitize_memory_track_origins: c_int,
443 }
444
445 /// LLVMRelocMode
446 #[derive(Copy, Clone, PartialEq)]
447 #[repr(C)]
448 pub enum RelocMode {
449 Default,
450 Static,
451 PIC,
452 DynamicNoPic,
453 ROPI,
454 RWPI,
455 ROPI_RWPI,
456 }
457
458 /// LLVMRustCodeModel
459 #[derive(Copy, Clone)]
460 #[repr(C)]
461 pub enum CodeModel {
462 // FIXME: figure out if this variant is needed at all.
463 #[allow(dead_code)]
464 Other,
465 Small,
466 Kernel,
467 Medium,
468 Large,
469 None,
470 }
471
472 /// LLVMRustDiagnosticKind
473 #[derive(Copy, Clone)]
474 #[repr(C)]
475 #[allow(dead_code)] // Variants constructed by C++.
476 pub enum DiagnosticKind {
477 Other,
478 InlineAsm,
479 StackSize,
480 DebugMetadataVersion,
481 SampleProfile,
482 OptimizationRemark,
483 OptimizationRemarkMissed,
484 OptimizationRemarkAnalysis,
485 OptimizationRemarkAnalysisFPCommute,
486 OptimizationRemarkAnalysisAliasing,
487 OptimizationRemarkOther,
488 OptimizationFailure,
489 PGOProfile,
490 Linker,
491 }
492
493 /// LLVMRustArchiveKind
494 #[derive(Copy, Clone)]
495 #[repr(C)]
496 pub enum ArchiveKind {
497 // FIXME: figure out if this variant is needed at all.
498 #[allow(dead_code)]
499 Other,
500 K_GNU,
501 K_BSD,
502 K_DARWIN,
503 K_COFF,
504 }
505
506 /// LLVMRustPassKind
507 #[derive(Copy, Clone, PartialEq, Debug)]
508 #[repr(C)]
509 #[allow(dead_code)] // Variants constructed by C++.
510 pub enum PassKind {
511 Other,
512 Function,
513 Module,
514 }
515
516 /// LLVMRustThinLTOData
517 extern "C" {
518 pub type ThinLTOData;
519 }
520
521 /// LLVMRustThinLTOBuffer
522 extern "C" {
523 pub type ThinLTOBuffer;
524 }
525
526 // LLVMRustModuleNameCallback
527 pub type ThinLTOModuleNameCallback =
528 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
529
530 /// LLVMRustThinLTOModule
531 #[repr(C)]
532 pub struct ThinLTOModule {
533 pub identifier: *const c_char,
534 pub data: *const u8,
535 pub len: usize,
536 }
537
538 /// LLVMThreadLocalMode
539 #[derive(Copy, Clone)]
540 #[repr(C)]
541 pub enum ThreadLocalMode {
542 NotThreadLocal,
543 GeneralDynamic,
544 LocalDynamic,
545 InitialExec,
546 LocalExec,
547 }
548
549 /// LLVMRustChecksumKind
550 #[derive(Copy, Clone)]
551 #[repr(C)]
552 pub enum ChecksumKind {
553 None,
554 MD5,
555 SHA1,
556 }
557
558 extern "C" {
559 type Opaque;
560 }
561 #[repr(C)]
562 struct InvariantOpaque<'a> {
563 _marker: PhantomData<&'a mut &'a ()>,
564 _opaque: Opaque,
565 }
566
567 // Opaque pointer types
568 extern "C" {
569 pub type Module;
570 }
571 extern "C" {
572 pub type Context;
573 }
574 extern "C" {
575 pub type Type;
576 }
577 extern "C" {
578 pub type Value;
579 }
580 extern "C" {
581 pub type ConstantInt;
582 }
583 extern "C" {
584 pub type Metadata;
585 }
586 extern "C" {
587 pub type BasicBlock;
588 }
589 #[repr(C)]
590 pub struct Builder<'a>(InvariantOpaque<'a>);
591 extern "C" {
592 pub type MemoryBuffer;
593 }
594 #[repr(C)]
595 pub struct PassManager<'a>(InvariantOpaque<'a>);
596 extern "C" {
597 pub type PassManagerBuilder;
598 }
599 extern "C" {
600 pub type ObjectFile;
601 }
602 #[repr(C)]
603 pub struct SectionIterator<'a>(InvariantOpaque<'a>);
604 extern "C" {
605 pub type Pass;
606 }
607 extern "C" {
608 pub type TargetMachine;
609 }
610 extern "C" {
611 pub type Archive;
612 }
613 #[repr(C)]
614 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
615 #[repr(C)]
616 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
617 extern "C" {
618 pub type Twine;
619 }
620 extern "C" {
621 pub type DiagnosticInfo;
622 }
623 extern "C" {
624 pub type SMDiagnostic;
625 }
626 #[repr(C)]
627 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
628 #[repr(C)]
629 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
630 #[repr(C)]
631 pub struct Linker<'a>(InvariantOpaque<'a>);
632
633 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
634 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
635
636 pub mod debuginfo {
637 use super::{InvariantOpaque, Metadata};
638 use bitflags::bitflags;
639
640 #[repr(C)]
641 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
642
643 pub type DIDescriptor = Metadata;
644 pub type DIScope = DIDescriptor;
645 pub type DIFile = DIScope;
646 pub type DILexicalBlock = DIScope;
647 pub type DISubprogram = DIScope;
648 pub type DINameSpace = DIScope;
649 pub type DIType = DIDescriptor;
650 pub type DIBasicType = DIType;
651 pub type DIDerivedType = DIType;
652 pub type DICompositeType = DIDerivedType;
653 pub type DIVariable = DIDescriptor;
654 pub type DIGlobalVariableExpression = DIDescriptor;
655 pub type DIArray = DIDescriptor;
656 pub type DISubrange = DIDescriptor;
657 pub type DIEnumerator = DIDescriptor;
658 pub type DITemplateTypeParameter = DIDescriptor;
659
660 // These values **must** match with LLVMRustDIFlags!!
661 bitflags! {
662 #[repr(transparent)]
663 #[derive(Default)]
664 pub struct DIFlags: u32 {
665 const FlagZero = 0;
666 const FlagPrivate = 1;
667 const FlagProtected = 2;
668 const FlagPublic = 3;
669 const FlagFwdDecl = (1 << 2);
670 const FlagAppleBlock = (1 << 3);
671 const FlagBlockByrefStruct = (1 << 4);
672 const FlagVirtual = (1 << 5);
673 const FlagArtificial = (1 << 6);
674 const FlagExplicit = (1 << 7);
675 const FlagPrototyped = (1 << 8);
676 const FlagObjcClassComplete = (1 << 9);
677 const FlagObjectPointer = (1 << 10);
678 const FlagVector = (1 << 11);
679 const FlagStaticMember = (1 << 12);
680 const FlagLValueReference = (1 << 13);
681 const FlagRValueReference = (1 << 14);
682 const FlagExternalTypeRef = (1 << 15);
683 const FlagIntroducedVirtual = (1 << 18);
684 const FlagBitField = (1 << 19);
685 const FlagNoReturn = (1 << 20);
686 }
687 }
688
689 // These values **must** match with LLVMRustDISPFlags!!
690 bitflags! {
691 #[repr(transparent)]
692 #[derive(Default)]
693 pub struct DISPFlags: u32 {
694 const SPFlagZero = 0;
695 const SPFlagVirtual = 1;
696 const SPFlagPureVirtual = 2;
697 const SPFlagLocalToUnit = (1 << 2);
698 const SPFlagDefinition = (1 << 3);
699 const SPFlagOptimized = (1 << 4);
700 const SPFlagMainSubprogram = (1 << 5);
701 }
702 }
703
704 /// LLVMRustDebugEmissionKind
705 #[derive(Copy, Clone)]
706 #[repr(C)]
707 pub enum DebugEmissionKind {
708 NoDebug,
709 FullDebug,
710 LineTablesOnly,
711 }
712
713 impl DebugEmissionKind {
714 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
715 use rustc_session::config::DebugInfo;
716 match kind {
717 DebugInfo::None => DebugEmissionKind::NoDebug,
718 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
719 DebugInfo::Full => DebugEmissionKind::FullDebug,
720 }
721 }
722 }
723 }
724
725 extern "C" {
726 pub type ModuleBuffer;
727 }
728
729 pub type SelfProfileBeforePassCallback =
730 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
731 pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
732
733 extern "C" {
734 pub fn LLVMRustInstallFatalErrorHandler();
735
736 // Create and destroy contexts.
737 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
738 pub fn LLVMContextDispose(C: &'static mut Context);
739 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
740
741 // Create modules.
742 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
743 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
744 pub fn LLVMCloneModule(M: &Module) -> &Module;
745
746 /// Data layout. See Module::getDataLayout.
747 pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
748 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
749
750 /// See Module::setModuleInlineAsm.
751 pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
752 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
753
754 /// See llvm::LLVMTypeKind::getTypeID.
755 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
756
757 // Operations on integer types
758 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
759 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
760 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
761 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
762 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
763 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
764
765 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
766
767 // Operations on real types
768 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
769 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
770
771 // Operations on function types
772 pub fn LLVMFunctionType(
773 ReturnType: &'a Type,
774 ParamTypes: *const &'a Type,
775 ParamCount: c_uint,
776 IsVarArg: Bool,
777 ) -> &'a Type;
778 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
779 pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
780
781 // Operations on struct types
782 pub fn LLVMStructTypeInContext(
783 C: &'a Context,
784 ElementTypes: *const &'a Type,
785 ElementCount: c_uint,
786 Packed: Bool,
787 ) -> &'a Type;
788
789 // Operations on array, pointer, and vector types (sequence types)
790 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
791 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
792 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
793
794 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
795 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
796
797 // Operations on other types
798 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
799 pub fn LLVMX86MMXTypeInContext(C: &Context) -> &Type;
800 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
801
802 // Operations on all values
803 pub fn LLVMTypeOf(Val: &Value) -> &Type;
804 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
805 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
806 pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
807 pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
808
809 // Operations on constants of any type
810 pub fn LLVMConstNull(Ty: &Type) -> &Value;
811 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
812
813 // Operations on metadata
814 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
815 pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
816 pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
817
818 // Operations on scalar constants
819 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
820 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
821 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
822 pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
823 pub fn LLVMRustConstInt128Get(
824 ConstantVal: &ConstantInt,
825 SExt: bool,
826 high: &mut u64,
827 low: &mut u64,
828 ) -> bool;
829
830 // Operations on composite constants
831 pub fn LLVMConstStringInContext(
832 C: &Context,
833 Str: *const c_char,
834 Length: c_uint,
835 DontNullTerminate: Bool,
836 ) -> &Value;
837 pub fn LLVMConstStructInContext(
838 C: &'a Context,
839 ConstantVals: *const &'a Value,
840 Count: c_uint,
841 Packed: Bool,
842 ) -> &'a Value;
843
844 pub fn LLVMConstArray(
845 ElementTy: &'a Type,
846 ConstantVals: *const &'a Value,
847 Length: c_uint,
848 ) -> &'a Value;
849 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
850
851 // Constant expressions
852 pub fn LLVMConstInBoundsGEP(
853 ConstantVal: &'a Value,
854 ConstantIndices: *const &'a Value,
855 NumIndices: c_uint,
856 ) -> &'a Value;
857 pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
858 pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
859 pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
860 pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
861 pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
862 pub fn LLVMConstExtractValue(
863 AggConstant: &Value,
864 IdxList: *const c_uint,
865 NumIdx: c_uint,
866 ) -> &Value;
867
868 // Operations on global variables, functions, and aliases (globals)
869 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
870 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
871 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
872 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
873 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
874 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
875 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
876 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
877 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
878
879 // Operations on global variables
880 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
881 pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
882 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
883 pub fn LLVMRustGetOrInsertGlobal(
884 M: &'a Module,
885 Name: *const c_char,
886 NameLen: size_t,
887 T: &'a Type,
888 ) -> &'a Value;
889 pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
890 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
891 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
892 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
893 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
894 pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
895 pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
896 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
897 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
898 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
899 pub fn LLVMRustGetNamedValue(
900 M: &Module,
901 Name: *const c_char,
902 NameLen: size_t,
903 ) -> Option<&Value>;
904 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
905
906 // Operations on functions
907 pub fn LLVMRustGetOrInsertFunction(
908 M: &'a Module,
909 Name: *const c_char,
910 NameLen: size_t,
911 FunctionTy: &'a Type,
912 ) -> &'a Value;
913 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
914 pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
915 pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
916 pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
917 pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
918 pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
919 pub fn LLVMRustAddFunctionAttrStringValue(
920 Fn: &Value,
921 index: c_uint,
922 Name: *const c_char,
923 Value: *const c_char,
924 );
925 pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
926
927 // Operations on parameters
928 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
929 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
930 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
931
932 // Operations on basic blocks
933 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
934 pub fn LLVMAppendBasicBlockInContext(
935 C: &'a Context,
936 Fn: &'a Value,
937 Name: *const c_char,
938 ) -> &'a BasicBlock;
939 pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
940
941 // Operations on instructions
942 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
943 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
944
945 // Operations on call sites
946 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
947 pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
948 pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
949 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
950 pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
951 pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
952
953 // Operations on load/store instructions (only)
954 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
955
956 // Operations on phi nodes
957 pub fn LLVMAddIncoming(
958 PhiNode: &'a Value,
959 IncomingValues: *const &'a Value,
960 IncomingBlocks: *const &'a BasicBlock,
961 Count: c_uint,
962 );
963
964 // Instruction builders
965 pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
966 pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
967 pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
968 pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
969
970 // Metadata
971 pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
972
973 // Terminators
974 pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
975 pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
976 pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
977 pub fn LLVMBuildCondBr(
978 B: &Builder<'a>,
979 If: &'a Value,
980 Then: &'a BasicBlock,
981 Else: &'a BasicBlock,
982 ) -> &'a Value;
983 pub fn LLVMBuildSwitch(
984 B: &Builder<'a>,
985 V: &'a Value,
986 Else: &'a BasicBlock,
987 NumCases: c_uint,
988 ) -> &'a Value;
989 pub fn LLVMRustBuildInvoke(
990 B: &Builder<'a>,
991 Fn: &'a Value,
992 Args: *const &'a Value,
993 NumArgs: c_uint,
994 Then: &'a BasicBlock,
995 Catch: &'a BasicBlock,
996 Bundle: Option<&OperandBundleDef<'a>>,
997 Name: *const c_char,
998 ) -> &'a Value;
999 pub fn LLVMBuildLandingPad(
1000 B: &Builder<'a>,
1001 Ty: &'a Type,
1002 PersFn: &'a Value,
1003 NumClauses: c_uint,
1004 Name: *const c_char,
1005 ) -> &'a Value;
1006 pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1007 pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
1008
1009 pub fn LLVMRustBuildCleanupPad(
1010 B: &Builder<'a>,
1011 ParentPad: Option<&'a Value>,
1012 ArgCnt: c_uint,
1013 Args: *const &'a Value,
1014 Name: *const c_char,
1015 ) -> Option<&'a Value>;
1016 pub fn LLVMRustBuildCleanupRet(
1017 B: &Builder<'a>,
1018 CleanupPad: &'a Value,
1019 UnwindBB: Option<&'a BasicBlock>,
1020 ) -> Option<&'a Value>;
1021 pub fn LLVMRustBuildCatchPad(
1022 B: &Builder<'a>,
1023 ParentPad: &'a Value,
1024 ArgCnt: c_uint,
1025 Args: *const &'a Value,
1026 Name: *const c_char,
1027 ) -> Option<&'a Value>;
1028 pub fn LLVMRustBuildCatchRet(
1029 B: &Builder<'a>,
1030 Pad: &'a Value,
1031 BB: &'a BasicBlock,
1032 ) -> Option<&'a Value>;
1033 pub fn LLVMRustBuildCatchSwitch(
1034 Builder: &Builder<'a>,
1035 ParentPad: Option<&'a Value>,
1036 BB: Option<&'a BasicBlock>,
1037 NumHandlers: c_uint,
1038 Name: *const c_char,
1039 ) -> Option<&'a Value>;
1040 pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1041 pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
1042
1043 // Add a case to the switch instruction
1044 pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1045
1046 // Add a clause to the landing pad instruction
1047 pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
1048
1049 // Set the cleanup on a landing pad instruction
1050 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1051
1052 // Arithmetic
1053 pub fn LLVMBuildAdd(
1054 B: &Builder<'a>,
1055 LHS: &'a Value,
1056 RHS: &'a Value,
1057 Name: *const c_char,
1058 ) -> &'a Value;
1059 pub fn LLVMBuildFAdd(
1060 B: &Builder<'a>,
1061 LHS: &'a Value,
1062 RHS: &'a Value,
1063 Name: *const c_char,
1064 ) -> &'a Value;
1065 pub fn LLVMBuildSub(
1066 B: &Builder<'a>,
1067 LHS: &'a Value,
1068 RHS: &'a Value,
1069 Name: *const c_char,
1070 ) -> &'a Value;
1071 pub fn LLVMBuildFSub(
1072 B: &Builder<'a>,
1073 LHS: &'a Value,
1074 RHS: &'a Value,
1075 Name: *const c_char,
1076 ) -> &'a Value;
1077 pub fn LLVMBuildMul(
1078 B: &Builder<'a>,
1079 LHS: &'a Value,
1080 RHS: &'a Value,
1081 Name: *const c_char,
1082 ) -> &'a Value;
1083 pub fn LLVMBuildFMul(
1084 B: &Builder<'a>,
1085 LHS: &'a Value,
1086 RHS: &'a Value,
1087 Name: *const c_char,
1088 ) -> &'a Value;
1089 pub fn LLVMBuildUDiv(
1090 B: &Builder<'a>,
1091 LHS: &'a Value,
1092 RHS: &'a Value,
1093 Name: *const c_char,
1094 ) -> &'a Value;
1095 pub fn LLVMBuildExactUDiv(
1096 B: &Builder<'a>,
1097 LHS: &'a Value,
1098 RHS: &'a Value,
1099 Name: *const c_char,
1100 ) -> &'a Value;
1101 pub fn LLVMBuildSDiv(
1102 B: &Builder<'a>,
1103 LHS: &'a Value,
1104 RHS: &'a Value,
1105 Name: *const c_char,
1106 ) -> &'a Value;
1107 pub fn LLVMBuildExactSDiv(
1108 B: &Builder<'a>,
1109 LHS: &'a Value,
1110 RHS: &'a Value,
1111 Name: *const c_char,
1112 ) -> &'a Value;
1113 pub fn LLVMBuildFDiv(
1114 B: &Builder<'a>,
1115 LHS: &'a Value,
1116 RHS: &'a Value,
1117 Name: *const c_char,
1118 ) -> &'a Value;
1119 pub fn LLVMBuildURem(
1120 B: &Builder<'a>,
1121 LHS: &'a Value,
1122 RHS: &'a Value,
1123 Name: *const c_char,
1124 ) -> &'a Value;
1125 pub fn LLVMBuildSRem(
1126 B: &Builder<'a>,
1127 LHS: &'a Value,
1128 RHS: &'a Value,
1129 Name: *const c_char,
1130 ) -> &'a Value;
1131 pub fn LLVMBuildFRem(
1132 B: &Builder<'a>,
1133 LHS: &'a Value,
1134 RHS: &'a Value,
1135 Name: *const c_char,
1136 ) -> &'a Value;
1137 pub fn LLVMBuildShl(
1138 B: &Builder<'a>,
1139 LHS: &'a Value,
1140 RHS: &'a Value,
1141 Name: *const c_char,
1142 ) -> &'a Value;
1143 pub fn LLVMBuildLShr(
1144 B: &Builder<'a>,
1145 LHS: &'a Value,
1146 RHS: &'a Value,
1147 Name: *const c_char,
1148 ) -> &'a Value;
1149 pub fn LLVMBuildAShr(
1150 B: &Builder<'a>,
1151 LHS: &'a Value,
1152 RHS: &'a Value,
1153 Name: *const c_char,
1154 ) -> &'a Value;
1155 pub fn LLVMBuildNSWAdd(
1156 B: &Builder<'a>,
1157 LHS: &'a Value,
1158 RHS: &'a Value,
1159 Name: *const c_char,
1160 ) -> &'a Value;
1161 pub fn LLVMBuildNUWAdd(
1162 B: &Builder<'a>,
1163 LHS: &'a Value,
1164 RHS: &'a Value,
1165 Name: *const c_char,
1166 ) -> &'a Value;
1167 pub fn LLVMBuildNSWSub(
1168 B: &Builder<'a>,
1169 LHS: &'a Value,
1170 RHS: &'a Value,
1171 Name: *const c_char,
1172 ) -> &'a Value;
1173 pub fn LLVMBuildNUWSub(
1174 B: &Builder<'a>,
1175 LHS: &'a Value,
1176 RHS: &'a Value,
1177 Name: *const c_char,
1178 ) -> &'a Value;
1179 pub fn LLVMBuildNSWMul(
1180 B: &Builder<'a>,
1181 LHS: &'a Value,
1182 RHS: &'a Value,
1183 Name: *const c_char,
1184 ) -> &'a Value;
1185 pub fn LLVMBuildNUWMul(
1186 B: &Builder<'a>,
1187 LHS: &'a Value,
1188 RHS: &'a Value,
1189 Name: *const c_char,
1190 ) -> &'a Value;
1191 pub fn LLVMBuildAnd(
1192 B: &Builder<'a>,
1193 LHS: &'a Value,
1194 RHS: &'a Value,
1195 Name: *const c_char,
1196 ) -> &'a Value;
1197 pub fn LLVMBuildOr(
1198 B: &Builder<'a>,
1199 LHS: &'a Value,
1200 RHS: &'a Value,
1201 Name: *const c_char,
1202 ) -> &'a Value;
1203 pub fn LLVMBuildXor(
1204 B: &Builder<'a>,
1205 LHS: &'a Value,
1206 RHS: &'a Value,
1207 Name: *const c_char,
1208 ) -> &'a Value;
1209 pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1210 pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1211 pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1212 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: &Value);
1213
1214 // Memory
1215 pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1216 pub fn LLVMBuildArrayAlloca(
1217 B: &Builder<'a>,
1218 Ty: &'a Type,
1219 Val: &'a Value,
1220 Name: *const c_char,
1221 ) -> &'a Value;
1222 pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
1223
1224 pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1225
1226 pub fn LLVMBuildGEP(
1227 B: &Builder<'a>,
1228 Pointer: &'a Value,
1229 Indices: *const &'a Value,
1230 NumIndices: c_uint,
1231 Name: *const c_char,
1232 ) -> &'a Value;
1233 pub fn LLVMBuildInBoundsGEP(
1234 B: &Builder<'a>,
1235 Pointer: &'a Value,
1236 Indices: *const &'a Value,
1237 NumIndices: c_uint,
1238 Name: *const c_char,
1239 ) -> &'a Value;
1240 pub fn LLVMBuildStructGEP(
1241 B: &Builder<'a>,
1242 Pointer: &'a Value,
1243 Idx: c_uint,
1244 Name: *const c_char,
1245 ) -> &'a Value;
1246
1247 // Casts
1248 pub fn LLVMBuildTrunc(
1249 B: &Builder<'a>,
1250 Val: &'a Value,
1251 DestTy: &'a Type,
1252 Name: *const c_char,
1253 ) -> &'a Value;
1254 pub fn LLVMBuildZExt(
1255 B: &Builder<'a>,
1256 Val: &'a Value,
1257 DestTy: &'a Type,
1258 Name: *const c_char,
1259 ) -> &'a Value;
1260 pub fn LLVMBuildSExt(
1261 B: &Builder<'a>,
1262 Val: &'a Value,
1263 DestTy: &'a Type,
1264 Name: *const c_char,
1265 ) -> &'a Value;
1266 pub fn LLVMBuildFPToUI(
1267 B: &Builder<'a>,
1268 Val: &'a Value,
1269 DestTy: &'a Type,
1270 Name: *const c_char,
1271 ) -> &'a Value;
1272 pub fn LLVMBuildFPToSI(
1273 B: &Builder<'a>,
1274 Val: &'a Value,
1275 DestTy: &'a Type,
1276 Name: *const c_char,
1277 ) -> &'a Value;
1278 pub fn LLVMBuildUIToFP(
1279 B: &Builder<'a>,
1280 Val: &'a Value,
1281 DestTy: &'a Type,
1282 Name: *const c_char,
1283 ) -> &'a Value;
1284 pub fn LLVMBuildSIToFP(
1285 B: &Builder<'a>,
1286 Val: &'a Value,
1287 DestTy: &'a Type,
1288 Name: *const c_char,
1289 ) -> &'a Value;
1290 pub fn LLVMBuildFPTrunc(
1291 B: &Builder<'a>,
1292 Val: &'a Value,
1293 DestTy: &'a Type,
1294 Name: *const c_char,
1295 ) -> &'a Value;
1296 pub fn LLVMBuildFPExt(
1297 B: &Builder<'a>,
1298 Val: &'a Value,
1299 DestTy: &'a Type,
1300 Name: *const c_char,
1301 ) -> &'a Value;
1302 pub fn LLVMBuildPtrToInt(
1303 B: &Builder<'a>,
1304 Val: &'a Value,
1305 DestTy: &'a Type,
1306 Name: *const c_char,
1307 ) -> &'a Value;
1308 pub fn LLVMBuildIntToPtr(
1309 B: &Builder<'a>,
1310 Val: &'a Value,
1311 DestTy: &'a Type,
1312 Name: *const c_char,
1313 ) -> &'a Value;
1314 pub fn LLVMBuildBitCast(
1315 B: &Builder<'a>,
1316 Val: &'a Value,
1317 DestTy: &'a Type,
1318 Name: *const c_char,
1319 ) -> &'a Value;
1320 pub fn LLVMBuildPointerCast(
1321 B: &Builder<'a>,
1322 Val: &'a Value,
1323 DestTy: &'a Type,
1324 Name: *const c_char,
1325 ) -> &'a Value;
1326 pub fn LLVMRustBuildIntCast(
1327 B: &Builder<'a>,
1328 Val: &'a Value,
1329 DestTy: &'a Type,
1330 IsSized: bool,
1331 ) -> &'a Value;
1332
1333 // Comparisons
1334 pub fn LLVMBuildICmp(
1335 B: &Builder<'a>,
1336 Op: c_uint,
1337 LHS: &'a Value,
1338 RHS: &'a Value,
1339 Name: *const c_char,
1340 ) -> &'a Value;
1341 pub fn LLVMBuildFCmp(
1342 B: &Builder<'a>,
1343 Op: c_uint,
1344 LHS: &'a Value,
1345 RHS: &'a Value,
1346 Name: *const c_char,
1347 ) -> &'a Value;
1348
1349 // Miscellaneous instructions
1350 pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1351 pub fn LLVMRustBuildCall(
1352 B: &Builder<'a>,
1353 Fn: &'a Value,
1354 Args: *const &'a Value,
1355 NumArgs: c_uint,
1356 Bundle: Option<&OperandBundleDef<'a>>,
1357 ) -> &'a Value;
1358 pub fn LLVMRustBuildMemCpy(
1359 B: &Builder<'a>,
1360 Dst: &'a Value,
1361 DstAlign: c_uint,
1362 Src: &'a Value,
1363 SrcAlign: c_uint,
1364 Size: &'a Value,
1365 IsVolatile: bool,
1366 ) -> &'a Value;
1367 pub fn LLVMRustBuildMemMove(
1368 B: &Builder<'a>,
1369 Dst: &'a Value,
1370 DstAlign: c_uint,
1371 Src: &'a Value,
1372 SrcAlign: c_uint,
1373 Size: &'a Value,
1374 IsVolatile: bool,
1375 ) -> &'a Value;
1376 pub fn LLVMRustBuildMemSet(
1377 B: &Builder<'a>,
1378 Dst: &'a Value,
1379 DstAlign: c_uint,
1380 Val: &'a Value,
1381 Size: &'a Value,
1382 IsVolatile: bool,
1383 ) -> &'a Value;
1384 pub fn LLVMBuildSelect(
1385 B: &Builder<'a>,
1386 If: &'a Value,
1387 Then: &'a Value,
1388 Else: &'a Value,
1389 Name: *const c_char,
1390 ) -> &'a Value;
1391 pub fn LLVMBuildVAArg(
1392 B: &Builder<'a>,
1393 list: &'a Value,
1394 Ty: &'a Type,
1395 Name: *const c_char,
1396 ) -> &'a Value;
1397 pub fn LLVMBuildExtractElement(
1398 B: &Builder<'a>,
1399 VecVal: &'a Value,
1400 Index: &'a Value,
1401 Name: *const c_char,
1402 ) -> &'a Value;
1403 pub fn LLVMBuildInsertElement(
1404 B: &Builder<'a>,
1405 VecVal: &'a Value,
1406 EltVal: &'a Value,
1407 Index: &'a Value,
1408 Name: *const c_char,
1409 ) -> &'a Value;
1410 pub fn LLVMBuildShuffleVector(
1411 B: &Builder<'a>,
1412 V1: &'a Value,
1413 V2: &'a Value,
1414 Mask: &'a Value,
1415 Name: *const c_char,
1416 ) -> &'a Value;
1417 pub fn LLVMBuildExtractValue(
1418 B: &Builder<'a>,
1419 AggVal: &'a Value,
1420 Index: c_uint,
1421 Name: *const c_char,
1422 ) -> &'a Value;
1423 pub fn LLVMBuildInsertValue(
1424 B: &Builder<'a>,
1425 AggVal: &'a Value,
1426 EltVal: &'a Value,
1427 Index: c_uint,
1428 Name: *const c_char,
1429 ) -> &'a Value;
1430
1431 pub fn LLVMRustBuildVectorReduceFAdd(
1432 B: &Builder<'a>,
1433 Acc: &'a Value,
1434 Src: &'a Value,
1435 ) -> &'a Value;
1436 pub fn LLVMRustBuildVectorReduceFMul(
1437 B: &Builder<'a>,
1438 Acc: &'a Value,
1439 Src: &'a Value,
1440 ) -> &'a Value;
1441 pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1442 pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1443 pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1444 pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1445 pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1446 pub fn LLVMRustBuildVectorReduceMin(
1447 B: &Builder<'a>,
1448 Src: &'a Value,
1449 IsSigned: bool,
1450 ) -> &'a Value;
1451 pub fn LLVMRustBuildVectorReduceMax(
1452 B: &Builder<'a>,
1453 Src: &'a Value,
1454 IsSigned: bool,
1455 ) -> &'a Value;
1456 pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1457 -> &'a Value;
1458 pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1459 -> &'a Value;
1460
1461 pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1462 pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1463
1464 // Atomic Operations
1465 pub fn LLVMRustBuildAtomicLoad(
1466 B: &Builder<'a>,
1467 PointerVal: &'a Value,
1468 Name: *const c_char,
1469 Order: AtomicOrdering,
1470 ) -> &'a Value;
1471
1472 pub fn LLVMRustBuildAtomicStore(
1473 B: &Builder<'a>,
1474 Val: &'a Value,
1475 Ptr: &'a Value,
1476 Order: AtomicOrdering,
1477 ) -> &'a Value;
1478
1479 pub fn LLVMRustBuildAtomicCmpXchg(
1480 B: &Builder<'a>,
1481 LHS: &'a Value,
1482 CMP: &'a Value,
1483 RHS: &'a Value,
1484 Order: AtomicOrdering,
1485 FailureOrder: AtomicOrdering,
1486 Weak: Bool,
1487 ) -> &'a Value;
1488
1489 pub fn LLVMBuildAtomicRMW(
1490 B: &Builder<'a>,
1491 Op: AtomicRmwBinOp,
1492 LHS: &'a Value,
1493 RHS: &'a Value,
1494 Order: AtomicOrdering,
1495 SingleThreaded: Bool,
1496 ) -> &'a Value;
1497
1498 pub fn LLVMRustBuildAtomicFence(
1499 B: &Builder<'_>,
1500 Order: AtomicOrdering,
1501 Scope: SynchronizationScope,
1502 );
1503
1504 /// Writes a module to the specified path. Returns 0 on success.
1505 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1506
1507 /// Creates a pass manager.
1508 pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1509
1510 /// Creates a function-by-function pass manager
1511 pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1512
1513 /// Disposes a pass manager.
1514 pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1515
1516 /// Runs a pass manager on a module.
1517 pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1518
1519 pub fn LLVMInitializePasses();
1520
1521 pub fn LLVMTimeTraceProfilerInitialize();
1522
1523 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1524
1525 pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>);
1526
1527 pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1528 pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1529 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1530 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1531 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1532 PMB: &PassManagerBuilder,
1533 threshold: c_uint,
1534 );
1535 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1536 PMB: &PassManagerBuilder,
1537 PM: &PassManager<'_>,
1538 );
1539
1540 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1541 PMB: &PassManagerBuilder,
1542 PM: &PassManager<'_>,
1543 );
1544 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1545 PMB: &PassManagerBuilder,
1546 PM: &PassManager<'_>,
1547 Internalize: Bool,
1548 RunInliner: Bool,
1549 );
1550 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1551 PMB: &PassManagerBuilder,
1552 PM: &PassManager<'_>,
1553 );
1554
1555 // Stuff that's in rustllvm/ because it's not upstream yet.
1556
1557 /// Opens an object file.
1558 pub fn LLVMCreateObjectFile(
1559 MemBuf: &'static mut MemoryBuffer,
1560 ) -> Option<&'static mut ObjectFile>;
1561 /// Closes an object file.
1562 pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1563
1564 /// Enumerates the sections in an object file.
1565 pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1566 /// Destroys a section iterator.
1567 pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1568 /// Returns `true` if the section iterator is at the end of the section
1569 /// list:
1570 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1571 /// Moves the section iterator to point to the next section.
1572 pub fn LLVMMoveToNextSection(SI: &SectionIterator<'_>);
1573 /// Returns the current section size.
1574 pub fn LLVMGetSectionSize(SI: &SectionIterator<'_>) -> c_ulonglong;
1575 /// Returns the current section contents as a string buffer.
1576 pub fn LLVMGetSectionContents(SI: &SectionIterator<'_>) -> *const c_char;
1577
1578 /// Reads the given file and returns it as a memory buffer. Use
1579 /// LLVMDisposeMemoryBuffer() to get rid of it.
1580 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1581 Path: *const c_char,
1582 ) -> Option<&'static mut MemoryBuffer>;
1583
1584 pub fn LLVMStartMultithreaded() -> Bool;
1585
1586 /// Returns a string describing the last error caused by an LLVMRust* call.
1587 pub fn LLVMRustGetLastError() -> *const c_char;
1588
1589 /// Print the pass timings since static dtors aren't picking them up.
1590 pub fn LLVMRustPrintPassTimings();
1591
1592 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1593
1594 pub fn LLVMStructSetBody(
1595 StructTy: &'a Type,
1596 ElementTypes: *const &'a Type,
1597 ElementCount: c_uint,
1598 Packed: Bool,
1599 );
1600
1601 /// Prepares inline assembly.
1602 pub fn LLVMRustInlineAsm(
1603 Ty: &Type,
1604 AsmString: *const c_char,
1605 AsmStringLen: size_t,
1606 Constraints: *const c_char,
1607 ConstraintsLen: size_t,
1608 SideEffects: Bool,
1609 AlignStack: Bool,
1610 Dialect: AsmDialect,
1611 ) -> &Value;
1612 pub fn LLVMRustInlineAsmVerify(
1613 Ty: &Type,
1614 Constraints: *const c_char,
1615 ConstraintsLen: size_t,
1616 ) -> bool;
1617
1618 pub fn LLVMRustDebugMetadataVersion() -> u32;
1619 pub fn LLVMRustVersionMajor() -> u32;
1620 pub fn LLVMRustVersionMinor() -> u32;
1621
1622 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1623
1624 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1625
1626 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1627
1628 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1629
1630 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1631
1632 pub fn LLVMRustDIBuilderCreateCompileUnit(
1633 Builder: &DIBuilder<'a>,
1634 Lang: c_uint,
1635 File: &'a DIFile,
1636 Producer: *const c_char,
1637 ProducerLen: size_t,
1638 isOptimized: bool,
1639 Flags: *const c_char,
1640 RuntimeVer: c_uint,
1641 SplitName: *const c_char,
1642 SplitNameLen: size_t,
1643 kind: DebugEmissionKind,
1644 ) -> &'a DIDescriptor;
1645
1646 pub fn LLVMRustDIBuilderCreateFile(
1647 Builder: &DIBuilder<'a>,
1648 Filename: *const c_char,
1649 FilenameLen: size_t,
1650 Directory: *const c_char,
1651 DirectoryLen: size_t,
1652 CSKind: ChecksumKind,
1653 Checksum: *const c_char,
1654 ChecksumLen: size_t,
1655 ) -> &'a DIFile;
1656
1657 pub fn LLVMRustDIBuilderCreateSubroutineType(
1658 Builder: &DIBuilder<'a>,
1659 File: &'a DIFile,
1660 ParameterTypes: &'a DIArray,
1661 ) -> &'a DICompositeType;
1662
1663 pub fn LLVMRustDIBuilderCreateFunction(
1664 Builder: &DIBuilder<'a>,
1665 Scope: &'a DIDescriptor,
1666 Name: *const c_char,
1667 NameLen: size_t,
1668 LinkageName: *const c_char,
1669 LinkageNameLen: size_t,
1670 File: &'a DIFile,
1671 LineNo: c_uint,
1672 Ty: &'a DIType,
1673 ScopeLine: c_uint,
1674 Flags: DIFlags,
1675 SPFlags: DISPFlags,
1676 Fn: &'a Value,
1677 TParam: &'a DIArray,
1678 Decl: Option<&'a DIDescriptor>,
1679 ) -> &'a DISubprogram;
1680
1681 pub fn LLVMRustDIBuilderCreateBasicType(
1682 Builder: &DIBuilder<'a>,
1683 Name: *const c_char,
1684 NameLen: size_t,
1685 SizeInBits: u64,
1686 AlignInBits: u32,
1687 Encoding: c_uint,
1688 ) -> &'a DIBasicType;
1689
1690 pub fn LLVMRustDIBuilderCreatePointerType(
1691 Builder: &DIBuilder<'a>,
1692 PointeeTy: &'a DIType,
1693 SizeInBits: u64,
1694 AlignInBits: u32,
1695 AddressSpace: c_uint,
1696 Name: *const c_char,
1697 NameLen: size_t,
1698 ) -> &'a DIDerivedType;
1699
1700 pub fn LLVMRustDIBuilderCreateStructType(
1701 Builder: &DIBuilder<'a>,
1702 Scope: Option<&'a DIDescriptor>,
1703 Name: *const c_char,
1704 NameLen: size_t,
1705 File: &'a DIFile,
1706 LineNumber: c_uint,
1707 SizeInBits: u64,
1708 AlignInBits: u32,
1709 Flags: DIFlags,
1710 DerivedFrom: Option<&'a DIType>,
1711 Elements: &'a DIArray,
1712 RunTimeLang: c_uint,
1713 VTableHolder: Option<&'a DIType>,
1714 UniqueId: *const c_char,
1715 UniqueIdLen: size_t,
1716 ) -> &'a DICompositeType;
1717
1718 pub fn LLVMRustDIBuilderCreateMemberType(
1719 Builder: &DIBuilder<'a>,
1720 Scope: &'a DIDescriptor,
1721 Name: *const c_char,
1722 NameLen: size_t,
1723 File: &'a DIFile,
1724 LineNo: c_uint,
1725 SizeInBits: u64,
1726 AlignInBits: u32,
1727 OffsetInBits: u64,
1728 Flags: DIFlags,
1729 Ty: &'a DIType,
1730 ) -> &'a DIDerivedType;
1731
1732 pub fn LLVMRustDIBuilderCreateVariantMemberType(
1733 Builder: &DIBuilder<'a>,
1734 Scope: &'a DIScope,
1735 Name: *const c_char,
1736 NameLen: size_t,
1737 File: &'a DIFile,
1738 LineNumber: c_uint,
1739 SizeInBits: u64,
1740 AlignInBits: u32,
1741 OffsetInBits: u64,
1742 Discriminant: Option<&'a Value>,
1743 Flags: DIFlags,
1744 Ty: &'a DIType,
1745 ) -> &'a DIType;
1746
1747 pub fn LLVMRustDIBuilderCreateLexicalBlock(
1748 Builder: &DIBuilder<'a>,
1749 Scope: &'a DIScope,
1750 File: &'a DIFile,
1751 Line: c_uint,
1752 Col: c_uint,
1753 ) -> &'a DILexicalBlock;
1754
1755 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(
1756 Builder: &DIBuilder<'a>,
1757 Scope: &'a DIScope,
1758 File: &'a DIFile,
1759 ) -> &'a DILexicalBlock;
1760
1761 pub fn LLVMRustDIBuilderCreateStaticVariable(
1762 Builder: &DIBuilder<'a>,
1763 Context: Option<&'a DIScope>,
1764 Name: *const c_char,
1765 NameLen: size_t,
1766 LinkageName: *const c_char,
1767 LinkageNameLen: size_t,
1768 File: &'a DIFile,
1769 LineNo: c_uint,
1770 Ty: &'a DIType,
1771 isLocalToUnit: bool,
1772 Val: &'a Value,
1773 Decl: Option<&'a DIDescriptor>,
1774 AlignInBits: u32,
1775 ) -> &'a DIGlobalVariableExpression;
1776
1777 pub fn LLVMRustDIBuilderCreateVariable(
1778 Builder: &DIBuilder<'a>,
1779 Tag: c_uint,
1780 Scope: &'a DIDescriptor,
1781 Name: *const c_char,
1782 NameLen: size_t,
1783 File: &'a DIFile,
1784 LineNo: c_uint,
1785 Ty: &'a DIType,
1786 AlwaysPreserve: bool,
1787 Flags: DIFlags,
1788 ArgNo: c_uint,
1789 AlignInBits: u32,
1790 ) -> &'a DIVariable;
1791
1792 pub fn LLVMRustDIBuilderCreateArrayType(
1793 Builder: &DIBuilder<'a>,
1794 Size: u64,
1795 AlignInBits: u32,
1796 Ty: &'a DIType,
1797 Subscripts: &'a DIArray,
1798 ) -> &'a DIType;
1799
1800 pub fn LLVMRustDIBuilderGetOrCreateSubrange(
1801 Builder: &DIBuilder<'a>,
1802 Lo: i64,
1803 Count: i64,
1804 ) -> &'a DISubrange;
1805
1806 pub fn LLVMRustDIBuilderGetOrCreateArray(
1807 Builder: &DIBuilder<'a>,
1808 Ptr: *const Option<&'a DIDescriptor>,
1809 Count: c_uint,
1810 ) -> &'a DIArray;
1811
1812 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(
1813 Builder: &DIBuilder<'a>,
1814 Val: &'a Value,
1815 VarInfo: &'a DIVariable,
1816 AddrOps: *const i64,
1817 AddrOpsCount: c_uint,
1818 DL: &'a Value,
1819 InsertAtEnd: &'a BasicBlock,
1820 ) -> &'a Value;
1821
1822 pub fn LLVMRustDIBuilderCreateEnumerator(
1823 Builder: &DIBuilder<'a>,
1824 Name: *const c_char,
1825 NameLen: size_t,
1826 Value: i64,
1827 IsUnsigned: bool,
1828 ) -> &'a DIEnumerator;
1829
1830 pub fn LLVMRustDIBuilderCreateEnumerationType(
1831 Builder: &DIBuilder<'a>,
1832 Scope: &'a DIScope,
1833 Name: *const c_char,
1834 NameLen: size_t,
1835 File: &'a DIFile,
1836 LineNumber: c_uint,
1837 SizeInBits: u64,
1838 AlignInBits: u32,
1839 Elements: &'a DIArray,
1840 ClassType: &'a DIType,
1841 IsScoped: bool,
1842 ) -> &'a DIType;
1843
1844 pub fn LLVMRustDIBuilderCreateUnionType(
1845 Builder: &DIBuilder<'a>,
1846 Scope: &'a DIScope,
1847 Name: *const c_char,
1848 NameLen: size_t,
1849 File: &'a DIFile,
1850 LineNumber: c_uint,
1851 SizeInBits: u64,
1852 AlignInBits: u32,
1853 Flags: DIFlags,
1854 Elements: Option<&'a DIArray>,
1855 RunTimeLang: c_uint,
1856 UniqueId: *const c_char,
1857 UniqueIdLen: size_t,
1858 ) -> &'a DIType;
1859
1860 pub fn LLVMRustDIBuilderCreateVariantPart(
1861 Builder: &DIBuilder<'a>,
1862 Scope: &'a DIScope,
1863 Name: *const c_char,
1864 NameLen: size_t,
1865 File: &'a DIFile,
1866 LineNo: c_uint,
1867 SizeInBits: u64,
1868 AlignInBits: u32,
1869 Flags: DIFlags,
1870 Discriminator: Option<&'a DIDerivedType>,
1871 Elements: &'a DIArray,
1872 UniqueId: *const c_char,
1873 UniqueIdLen: size_t,
1874 ) -> &'a DIDerivedType;
1875
1876 pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
1877
1878 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
1879 Builder: &DIBuilder<'a>,
1880 Scope: Option<&'a DIScope>,
1881 Name: *const c_char,
1882 NameLen: size_t,
1883 Ty: &'a DIType,
1884 File: &'a DIFile,
1885 LineNo: c_uint,
1886 ColumnNo: c_uint,
1887 ) -> &'a DITemplateTypeParameter;
1888
1889 pub fn LLVMRustDIBuilderCreateNameSpace(
1890 Builder: &DIBuilder<'a>,
1891 Scope: Option<&'a DIScope>,
1892 Name: *const c_char,
1893 NameLen: size_t,
1894 ExportSymbols: bool,
1895 ) -> &'a DINameSpace;
1896
1897 pub fn LLVMRustDICompositeTypeReplaceArrays(
1898 Builder: &DIBuilder<'a>,
1899 CompositeType: &'a DIType,
1900 Elements: Option<&'a DIArray>,
1901 Params: Option<&'a DIArray>,
1902 );
1903
1904 pub fn LLVMRustDIBuilderCreateDebugLocation(
1905 Context: &'a Context,
1906 Line: c_uint,
1907 Column: c_uint,
1908 Scope: &'a DIScope,
1909 InlinedAt: Option<&'a Metadata>,
1910 ) -> &'a Value;
1911 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1912 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
1913
1914 #[allow(improper_ctypes)]
1915 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
1916 #[allow(improper_ctypes)]
1917 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
1918
1919 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
1920
1921 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
1922 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
1923 pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
1924 pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
1925 pub fn LLVMRustCreateMemorySanitizerPass(
1926 TrackOrigins: c_int,
1927 Recover: bool,
1928 ) -> &'static mut Pass;
1929 pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
1930 pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
1931 pub fn LLVMRustAddLastExtensionPasses(
1932 PMB: &PassManagerBuilder,
1933 Passes: *const &'static mut Pass,
1934 NumPasses: size_t,
1935 );
1936
1937 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
1938
1939 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
1940 pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
1941
1942 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
1943 pub fn LLVMRustCreateTargetMachine(
1944 Triple: *const c_char,
1945 CPU: *const c_char,
1946 Features: *const c_char,
1947 Abi: *const c_char,
1948 Model: CodeModel,
1949 Reloc: RelocMode,
1950 Level: CodeGenOptLevel,
1951 UseSoftFP: bool,
1952 PositionIndependentExecutable: bool,
1953 FunctionSections: bool,
1954 DataSections: bool,
1955 TrapUnreachable: bool,
1956 Singlethread: bool,
1957 AsmComments: bool,
1958 EmitStackSizeSection: bool,
1959 RelaxELFRelocations: bool,
1960 ) -> Option<&'static mut TargetMachine>;
1961 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
1962 pub fn LLVMRustAddBuilderLibraryInfo(
1963 PMB: &'a PassManagerBuilder,
1964 M: &'a Module,
1965 DisableSimplifyLibCalls: bool,
1966 );
1967 pub fn LLVMRustConfigurePassManagerBuilder(
1968 PMB: &PassManagerBuilder,
1969 OptLevel: CodeGenOptLevel,
1970 MergeFunctions: bool,
1971 SLPVectorize: bool,
1972 LoopVectorize: bool,
1973 PrepareForThinLTO: bool,
1974 PGOGenPath: *const c_char,
1975 PGOUsePath: *const c_char,
1976 );
1977 pub fn LLVMRustAddLibraryInfo(
1978 PM: &PassManager<'a>,
1979 M: &'a Module,
1980 DisableSimplifyLibCalls: bool,
1981 );
1982 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
1983 pub fn LLVMRustWriteOutputFile(
1984 T: &'a TargetMachine,
1985 PM: &PassManager<'a>,
1986 M: &'a Module,
1987 Output: *const c_char,
1988 FileType: FileType,
1989 ) -> LLVMRustResult;
1990 pub fn LLVMRustOptimizeWithNewPassManager(
1991 M: &'a Module,
1992 TM: &'a TargetMachine,
1993 OptLevel: PassBuilderOptLevel,
1994 OptStage: OptStage,
1995 NoPrepopulatePasses: bool,
1996 VerifyIR: bool,
1997 UseThinLTOBuffers: bool,
1998 MergeFunctions: bool,
1999 UnrollLoops: bool,
2000 SLPVectorize: bool,
2001 LoopVectorize: bool,
2002 DisableSimplifyLibCalls: bool,
2003 SanitizerOptions: Option<&SanitizerOptions>,
2004 PGOGenPath: *const c_char,
2005 PGOUsePath: *const c_char,
2006 llvm_selfprofiler: *mut c_void,
2007 begin_callback: SelfProfileBeforePassCallback,
2008 end_callback: SelfProfileAfterPassCallback,
2009 );
2010 pub fn LLVMRustPrintModule(
2011 M: &'a Module,
2012 Output: *const c_char,
2013 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2014 ) -> LLVMRustResult;
2015 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2016 pub fn LLVMRustPrintPasses();
2017 pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
2018 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2019 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
2020 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2021 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
2022
2023 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2024 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
2025 pub fn LLVMRustArchiveIteratorNext(
2026 AIR: &ArchiveIterator<'a>,
2027 ) -> Option<&'a mut ArchiveChild<'a>>;
2028 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2029 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2030 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
2031 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
2032 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2033
2034 #[allow(improper_ctypes)]
2035 pub fn LLVMRustGetSectionName(
2036 SI: &SectionIterator<'_>,
2037 data: &mut Option<std::ptr::NonNull<c_char>>,
2038 ) -> size_t;
2039
2040 #[allow(improper_ctypes)]
2041 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2042
2043 pub fn LLVMContextSetDiagnosticHandler(
2044 C: &Context,
2045 Handler: DiagnosticHandler,
2046 DiagnosticContext: *mut c_void,
2047 );
2048
2049 #[allow(improper_ctypes)]
2050 pub fn LLVMRustUnpackOptimizationDiagnostic(
2051 DI: &'a DiagnosticInfo,
2052 pass_name_out: &RustString,
2053 function_out: &mut Option<&'a Value>,
2054 loc_line_out: &mut c_uint,
2055 loc_column_out: &mut c_uint,
2056 loc_filename_out: &RustString,
2057 message_out: &RustString,
2058 );
2059
2060 pub fn LLVMRustUnpackInlineAsmDiagnostic(
2061 DI: &'a DiagnosticInfo,
2062 cookie_out: &mut c_uint,
2063 message_out: &mut Option<&'a Twine>,
2064 instruction_out: &mut Option<&'a Value>,
2065 );
2066
2067 #[allow(improper_ctypes)]
2068 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2069 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2070
2071 pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2072 C: &Context,
2073 H: InlineAsmDiagHandler,
2074 CX: *mut c_void,
2075 );
2076
2077 #[allow(improper_ctypes)]
2078 pub fn LLVMRustWriteSMDiagnosticToString(d: &SMDiagnostic, s: &RustString);
2079
2080 pub fn LLVMRustWriteArchive(
2081 Dst: *const c_char,
2082 NumMembers: size_t,
2083 Members: *const &RustArchiveMember<'_>,
2084 WriteSymbtab: bool,
2085 Kind: ArchiveKind,
2086 ) -> LLVMRustResult;
2087 pub fn LLVMRustArchiveMemberNew(
2088 Filename: *const c_char,
2089 Name: *const c_char,
2090 Child: Option<&ArchiveChild<'a>>,
2091 ) -> &'a mut RustArchiveMember<'a>;
2092 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
2093
2094 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
2095
2096 pub fn LLVMRustBuildOperandBundleDef(
2097 Name: *const c_char,
2098 Inputs: *const &'a Value,
2099 NumInputs: c_uint,
2100 ) -> &'a mut OperandBundleDef<'a>;
2101 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
2102
2103 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
2104
2105 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2106 pub fn LLVMRustUnsetComdat(V: &Value);
2107 pub fn LLVMRustSetModulePICLevel(M: &Module);
2108 pub fn LLVMRustSetModulePIELevel(M: &Module);
2109 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2110 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2111 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2112 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2113 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2114
2115 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
2116 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2117 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2118 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2119 pub fn LLVMRustCreateThinLTOData(
2120 Modules: *const ThinLTOModule,
2121 NumModules: c_uint,
2122 PreservedSymbols: *const *const c_char,
2123 PreservedSymbolsLen: c_uint,
2124 ) -> Option<&'static mut ThinLTOData>;
2125 pub fn LLVMRustPrepareThinLTORename(Data: &ThinLTOData, Module: &Module) -> bool;
2126 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2127 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2128 pub fn LLVMRustPrepareThinLTOImport(Data: &ThinLTOData, Module: &Module) -> bool;
2129 pub fn LLVMRustGetThinLTOModuleImports(
2130 Data: *const ThinLTOData,
2131 ModuleNameCallback: ThinLTOModuleNameCallback,
2132 CallbackPayload: *mut c_void,
2133 );
2134 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2135 pub fn LLVMRustParseBitcodeForLTO(
2136 Context: &Context,
2137 Data: *const u8,
2138 len: usize,
2139 Identifier: *const c_char,
2140 ) -> Option<&Module>;
2141 pub fn LLVMRustThinLTOGetDICompileUnit(
2142 M: &Module,
2143 CU1: &mut *mut c_void,
2144 CU2: &mut *mut c_void,
2145 );
2146 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2147
2148 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
2149 pub fn LLVMRustLinkerAdd(
2150 linker: &Linker<'_>,
2151 bytecode: *const c_char,
2152 bytecode_len: usize,
2153 ) -> bool;
2154 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);
2155 }