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