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