blob: 3139f93bfefaee9c0daf0c01734d5442983f8b9d [file] [log] [blame]
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001#![allow(non_camel_case_types)]
2#![allow(non_upper_case_globals)]
3
4use rustc_codegen_ssa::coverageinfo::map as coverage_map;
5
6use super::debuginfo::{
7 DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +01008 DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace,
9 DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable,
10 DebugEmissionKind,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +010011};
12
13use libc::{c_char, c_int, c_uint, size_t};
14use libc::{c_ulonglong, c_void};
15
16use std::marker::PhantomData;
17
18use super::RustString;
19
20pub type Bool = c_uint;
21
22pub const True: Bool = 1 as Bool;
23pub const False: Bool = 0 as Bool;
24
25#[derive(Copy, Clone, PartialEq)]
26#[repr(C)]
27#[allow(dead_code)] // Variants constructed by C++.
28pub enum LLVMRustResult {
29 Success,
30 Failure,
31}
Chris Wailes2f3fdfe2021-07-29 10:56:18 -070032
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,
Chris Wailesa1538422021-12-02 10:37:12 -080037 pub ordinal_present: bool,
38 // value of `ordinal` only important when `ordinal_present` is true
39 pub ordinal: u16,
Chris Wailes2f3fdfe2021-07-29 10:56:18 -070040}
41
42impl LLVMRustCOFFShortExport {
Chris Wailesa1538422021-12-02 10:37:12 -080043 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 }
Chris Wailes2f3fdfe2021-07-29 10:56:18 -070049 }
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
Chris Wailes2805eef2022-04-07 11:22:56 -070064/// 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
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +010084// 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,
103 AvrNonBlockingInterrupt = 84,
104 AvrInterrupt = 85,
105 AmdGpuKernel = 91,
106}
107
108/// LLVMRustLinkage
Chris Wailes2f3fdfe2021-07-29 10:56:18 -0700109#[derive(Copy, Clone, PartialEq)]
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100110#[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
126#[repr(C)]
Chris Wailes2f3fdfe2021-07-29 10:56:18 -0700127#[derive(Copy, Clone, PartialEq)]
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100128pub enum Visibility {
129 Default = 0,
130 Hidden = 1,
131 Protected = 2,
132}
133
134/// LLVMUnnamedAddr
135#[repr(C)]
136pub enum UnnamedAddr {
137 No,
138 Local,
139 Global,
140}
141
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
153/// Matches LLVMRustAttribute in LLVMWrapper.h
154/// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
155/// though it is not ABI compatible (since it's a C++ enum)
156#[repr(C)]
157#[derive(Copy, Clone, Debug)]
Charisee341341c2022-05-20 05:14:50 +0000158pub enum AttributeKind {
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100159 AlwaysInline = 0,
160 ByVal = 1,
161 Cold = 2,
162 InlineHint = 3,
163 MinSize = 4,
164 Naked = 5,
165 NoAlias = 6,
166 NoCapture = 7,
167 NoInline = 8,
168 NonNull = 9,
169 NoRedZone = 10,
170 NoReturn = 11,
171 NoUnwind = 12,
172 OptimizeForSize = 13,
173 ReadOnly = 14,
174 SExt = 15,
175 StructRet = 16,
176 UWTable = 17,
177 ZExt = 18,
178 InReg = 19,
179 SanitizeThread = 20,
180 SanitizeAddress = 21,
181 SanitizeMemory = 22,
182 NonLazyBind = 23,
183 OptimizeNone = 24,
184 ReturnsTwice = 25,
185 ReadNone = 26,
186 InaccessibleMemOnly = 27,
Chris Wailese3116c42021-07-13 14:40:48 -0700187 SanitizeHWAddress = 28,
188 WillReturn = 29,
Chris Wailes356b57e2022-01-13 10:08:24 -0800189 StackProtectReq = 30,
190 StackProtectStrong = 31,
191 StackProtect = 32,
Chris Wailes2805eef2022-04-07 11:22:56 -0700192 NoUndef = 33,
193 SanitizeMemTag = 34,
Chariseeb1d32802022-09-22 15:38:41 +0000194 NoCfCheck = 35,
195 ShadowCallStack = 36,
196 AllocSize = 37,
197 AllocatedPointer = 38,
198 AllocAlign = 39,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100199}
200
201/// LLVMIntPredicate
202#[derive(Copy, Clone)]
203#[repr(C)]
204pub enum IntPredicate {
205 IntEQ = 32,
206 IntNE = 33,
207 IntUGT = 34,
208 IntUGE = 35,
209 IntULT = 36,
210 IntULE = 37,
211 IntSGT = 38,
212 IntSGE = 39,
213 IntSLT = 40,
214 IntSLE = 41,
215}
216
217impl IntPredicate {
218 pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
219 match intpre {
220 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
221 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
222 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
223 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
224 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
225 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
226 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
227 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
228 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
229 rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
230 }
231 }
232}
233
234/// LLVMRealPredicate
235#[derive(Copy, Clone)]
236#[repr(C)]
237pub enum RealPredicate {
238 RealPredicateFalse = 0,
239 RealOEQ = 1,
240 RealOGT = 2,
241 RealOGE = 3,
242 RealOLT = 4,
243 RealOLE = 5,
244 RealONE = 6,
245 RealORD = 7,
246 RealUNO = 8,
247 RealUEQ = 9,
248 RealUGT = 10,
249 RealUGE = 11,
250 RealULT = 12,
251 RealULE = 13,
252 RealUNE = 14,
253 RealPredicateTrue = 15,
254}
255
Chris Wailesa1538422021-12-02 10:37:12 -0800256impl 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
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100283/// LLVMTypeKind
284#[derive(Copy, Clone, PartialEq, Debug)]
285#[repr(C)]
286pub enum TypeKind {
287 Void = 0,
288 Half = 1,
289 Float = 2,
290 Double = 3,
291 X86_FP80 = 4,
292 FP128 = 5,
293 PPC_FP128 = 6,
294 Label = 7,
295 Integer = 8,
296 Function = 9,
297 Struct = 10,
298 Array = 11,
299 Pointer = 12,
300 Vector = 13,
301 Metadata = 14,
302 X86_MMX = 15,
303 Token = 16,
304 ScalableVector = 17,
305 BFloat = 18,
Chris Wailese3116c42021-07-13 14:40:48 -0700306 X86_AMX = 19,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100307}
308
309impl TypeKind {
310 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
311 match self {
312 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
313 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
314 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
315 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
316 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
317 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
318 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
319 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
320 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
321 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
322 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
323 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
324 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
325 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
326 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
327 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
328 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
329 TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
330 TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
Chris Wailese3116c42021-07-13 14:40:48 -0700331 TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100332 }
333 }
334}
335
336/// LLVMAtomicRmwBinOp
337#[derive(Copy, Clone)]
338#[repr(C)]
339pub enum AtomicRmwBinOp {
340 AtomicXchg = 0,
341 AtomicAdd = 1,
342 AtomicSub = 2,
343 AtomicAnd = 3,
344 AtomicNand = 4,
345 AtomicOr = 5,
346 AtomicXor = 6,
347 AtomicMax = 7,
348 AtomicMin = 8,
349 AtomicUMax = 9,
350 AtomicUMin = 10,
351}
352
353impl AtomicRmwBinOp {
354 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
355 match op {
356 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
357 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
358 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
359 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
360 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
361 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
362 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
363 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
364 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
365 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
366 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
367 }
368 }
369}
370
371/// LLVMAtomicOrdering
372#[derive(Copy, Clone)]
373#[repr(C)]
374pub enum AtomicOrdering {
375 #[allow(dead_code)]
376 NotAtomic = 0,
377 Unordered = 1,
378 Monotonic = 2,
379 // Consume = 3, // Not specified yet.
380 Acquire = 4,
381 Release = 5,
382 AcquireRelease = 6,
383 SequentiallyConsistent = 7,
384}
385
386impl AtomicOrdering {
387 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
388 match ao {
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100389 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
Chris Wailes65720582022-08-11 09:53:28 -0700390 rustc_codegen_ssa::common::AtomicOrdering::Relaxed => AtomicOrdering::Monotonic,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100391 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
392 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
393 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
394 AtomicOrdering::AcquireRelease
395 }
396 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
397 AtomicOrdering::SequentiallyConsistent
398 }
399 }
400 }
401}
402
403/// LLVMRustSynchronizationScope
404#[derive(Copy, Clone)]
405#[repr(C)]
406pub enum SynchronizationScope {
407 SingleThread,
408 CrossThread,
409}
410
411impl SynchronizationScope {
412 pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
413 match sc {
414 rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
415 SynchronizationScope::SingleThread
416 }
417 rustc_codegen_ssa::common::SynchronizationScope::CrossThread => {
418 SynchronizationScope::CrossThread
419 }
420 }
421 }
422}
423
424/// LLVMRustFileType
425#[derive(Copy, Clone)]
426#[repr(C)]
427pub enum FileType {
428 AssemblyFile,
429 ObjectFile,
430}
431
432/// LLVMMetadataType
433#[derive(Copy, Clone)]
434#[repr(C)]
435pub enum MetadataType {
436 MD_dbg = 0,
437 MD_tbaa = 1,
438 MD_prof = 2,
439 MD_fpmath = 3,
440 MD_range = 4,
441 MD_tbaa_struct = 5,
442 MD_invariant_load = 6,
443 MD_alias_scope = 7,
444 MD_noalias = 8,
445 MD_nontemporal = 9,
446 MD_mem_parallel_loop_access = 10,
447 MD_nonnull = 11,
Charisee341341c2022-05-20 05:14:50 +0000448 MD_align = 17,
Chris Wailes356b57e2022-01-13 10:08:24 -0800449 MD_type = 19,
Chris Wailes65720582022-08-11 09:53:28 -0700450 MD_vcall_visibility = 28,
Charisee341341c2022-05-20 05:14:50 +0000451 MD_noundef = 29,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100452}
453
454/// LLVMRustAsmDialect
Chris Wailes2805eef2022-04-07 11:22:56 -0700455#[derive(Copy, Clone, PartialEq)]
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100456#[repr(C)]
457pub enum AsmDialect {
458 Att,
459 Intel,
460}
461
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100462/// LLVMRustCodeGenOptLevel
463#[derive(Copy, Clone, PartialEq)]
464#[repr(C)]
465pub enum CodeGenOptLevel {
466 None,
467 Less,
468 Default,
469 Aggressive,
470}
471
472/// LLVMRustPassBuilderOptLevel
473#[repr(C)]
474pub enum PassBuilderOptLevel {
475 O0,
476 O1,
477 O2,
478 O3,
479 Os,
480 Oz,
481}
482
483/// LLVMRustOptStage
484#[derive(PartialEq)]
485#[repr(C)]
486pub enum OptStage {
487 PreLinkNoLTO,
488 PreLinkThinLTO,
489 PreLinkFatLTO,
490 ThinLTO,
491 FatLTO,
492}
493
494/// LLVMRustSanitizerOptions
495#[repr(C)]
496pub struct SanitizerOptions {
497 pub sanitize_address: bool,
498 pub sanitize_address_recover: bool,
499 pub sanitize_memory: bool,
500 pub sanitize_memory_recover: bool,
501 pub sanitize_memory_track_origins: c_int,
502 pub sanitize_thread: bool,
Chris Wailese3116c42021-07-13 14:40:48 -0700503 pub sanitize_hwaddress: bool,
504 pub sanitize_hwaddress_recover: bool,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100505}
506
507/// LLVMRelocMode
508#[derive(Copy, Clone, PartialEq)]
509#[repr(C)]
510pub enum RelocModel {
511 Static,
512 PIC,
513 DynamicNoPic,
514 ROPI,
515 RWPI,
516 ROPI_RWPI,
517}
518
519/// LLVMRustCodeModel
520#[derive(Copy, Clone)]
521#[repr(C)]
522pub enum CodeModel {
523 Tiny,
524 Small,
525 Kernel,
526 Medium,
527 Large,
528 None,
529}
530
531/// LLVMRustDiagnosticKind
532#[derive(Copy, Clone)]
533#[repr(C)]
534#[allow(dead_code)] // Variants constructed by C++.
535pub enum DiagnosticKind {
536 Other,
537 InlineAsm,
538 StackSize,
539 DebugMetadataVersion,
540 SampleProfile,
541 OptimizationRemark,
542 OptimizationRemarkMissed,
543 OptimizationRemarkAnalysis,
544 OptimizationRemarkAnalysisFPCommute,
545 OptimizationRemarkAnalysisAliasing,
546 OptimizationRemarkOther,
547 OptimizationFailure,
548 PGOProfile,
549 Linker,
550 Unsupported,
Chris Wailesbcf972c2021-10-21 11:03:28 -0700551 SrcMgr,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100552}
553
554/// LLVMRustDiagnosticLevel
555#[derive(Copy, Clone)]
556#[repr(C)]
557#[allow(dead_code)] // Variants constructed by C++.
558pub enum DiagnosticLevel {
559 Error,
560 Warning,
561 Note,
562 Remark,
563}
564
565/// LLVMRustArchiveKind
566#[derive(Copy, Clone)]
567#[repr(C)]
568pub enum ArchiveKind {
569 K_GNU,
570 K_BSD,
571 K_DARWIN,
572 K_COFF,
573}
574
Charisee341341c2022-05-20 05:14:50 +0000575// LLVMRustThinLTOData
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100576extern "C" {
577 pub type ThinLTOData;
578}
579
Charisee341341c2022-05-20 05:14:50 +0000580// LLVMRustThinLTOBuffer
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100581extern "C" {
582 pub type ThinLTOBuffer;
583}
584
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100585/// LLVMRustThinLTOModule
586#[repr(C)]
587pub struct ThinLTOModule {
588 pub identifier: *const c_char,
589 pub data: *const u8,
590 pub len: usize,
591}
592
593/// LLVMThreadLocalMode
594#[derive(Copy, Clone)]
595#[repr(C)]
596pub enum ThreadLocalMode {
597 NotThreadLocal,
598 GeneralDynamic,
599 LocalDynamic,
600 InitialExec,
601 LocalExec,
602}
603
604/// LLVMRustChecksumKind
605#[derive(Copy, Clone)]
606#[repr(C)]
607pub enum ChecksumKind {
608 None,
609 MD5,
610 SHA1,
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +0100611 SHA256,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100612}
613
614extern "C" {
615 type Opaque;
616}
617#[repr(C)]
618struct InvariantOpaque<'a> {
619 _marker: PhantomData<&'a mut &'a ()>,
620 _opaque: Opaque,
621}
622
623// Opaque pointer types
624extern "C" {
625 pub type Module;
626}
627extern "C" {
628 pub type Context;
629}
630extern "C" {
631 pub type Type;
632}
633extern "C" {
634 pub type Value;
635}
636extern "C" {
637 pub type ConstantInt;
638}
639extern "C" {
Charisee341341c2022-05-20 05:14:50 +0000640 pub type Attribute;
641}
642extern "C" {
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100643 pub type Metadata;
644}
645extern "C" {
646 pub type BasicBlock;
647}
648#[repr(C)]
649pub struct Builder<'a>(InvariantOpaque<'a>);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100650#[repr(C)]
651pub struct PassManager<'a>(InvariantOpaque<'a>);
652extern "C" {
653 pub type PassManagerBuilder;
654}
655extern "C" {
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100656 pub type Pass;
657}
658extern "C" {
659 pub type TargetMachine;
660}
661extern "C" {
662 pub type Archive;
663}
664#[repr(C)]
665pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
666#[repr(C)]
667pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
668extern "C" {
669 pub type Twine;
670}
671extern "C" {
672 pub type DiagnosticInfo;
673}
674extern "C" {
675 pub type SMDiagnostic;
676}
677#[repr(C)]
678pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
679#[repr(C)]
680pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
681#[repr(C)]
682pub struct Linker<'a>(InvariantOpaque<'a>);
683
Charisee7878d542022-02-24 18:21:36 +0000684extern "C" {
685 pub type DiagnosticHandler;
686}
687
688pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
689pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100690
691pub mod coverageinfo {
692 use super::coverage_map;
693
Charisee7878d542022-02-24 18:21:36 +0000694 /// 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)
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100695 #[derive(Copy, Clone, Debug)]
696 #[repr(C)]
697 pub enum RegionKind {
698 /// A CodeRegion associates some code with a counter
699 CodeRegion = 0,
700
701 /// An ExpansionRegion represents a file expansion region that associates
702 /// a source range with the expansion of a virtual source file, such as
703 /// for a macro instantiation or #include file.
704 ExpansionRegion = 1,
705
706 /// A SkippedRegion represents a source range with code that was skipped
707 /// by a preprocessor or similar means.
708 SkippedRegion = 2,
709
710 /// A GapRegion is like a CodeRegion, but its count is only set as the
711 /// line execution count when its the only region in the line.
712 GapRegion = 3,
Charisee7878d542022-02-24 18:21:36 +0000713
714 /// A BranchRegion represents leaf-level boolean expressions and is
715 /// associated with two counters, each representing the number of times the
716 /// expression evaluates to true or false.
717 BranchRegion = 4,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100718 }
719
720 /// This struct provides LLVM's representation of a "CoverageMappingRegion", encoded into the
721 /// coverage map, in accordance with the
Charisee7878d542022-02-24 18:21:36 +0000722 /// [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).
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100723 /// The struct composes fields representing the `Counter` type and value(s) (injected counter
724 /// ID, or expression type and operands), the source file (an indirect index into a "filenames
725 /// array", encoded separately), and source location (start and end positions of the represented
726 /// code region).
727 ///
Chris Wailese3116c42021-07-13 14:40:48 -0700728 /// Matches LLVMRustCounterMappingRegion.
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100729 #[derive(Copy, Clone, Debug)]
730 #[repr(C)]
731 pub struct CounterMappingRegion {
732 /// The counter type and type-dependent counter data, if any.
733 counter: coverage_map::Counter,
734
Charisee7878d542022-02-24 18:21:36 +0000735 /// If the `RegionKind` is a `BranchRegion`, this represents the counter
736 /// for the false branch of the region.
737 false_counter: coverage_map::Counter,
738
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100739 /// An indirect reference to the source filename. In the LLVM Coverage Mapping Format, the
740 /// file_id is an index into a function-specific `virtual_file_mapping` array of indexes
741 /// that, in turn, are used to look up the filename for this region.
742 file_id: u32,
743
744 /// If the `RegionKind` is an `ExpansionRegion`, the `expanded_file_id` can be used to find
745 /// the mapping regions created as a result of macro expansion, by checking if their file id
746 /// matches the expanded file id.
747 expanded_file_id: u32,
748
749 /// 1-based starting line of the mapping region.
750 start_line: u32,
751
752 /// 1-based starting column of the mapping region.
753 start_col: u32,
754
755 /// 1-based ending line of the mapping region.
756 end_line: u32,
757
758 /// 1-based ending column of the mapping region. If the high bit is set, the current
759 /// mapping region is a gap area.
760 end_col: u32,
761
762 kind: RegionKind,
763 }
764
765 impl CounterMappingRegion {
Chris Wailes65720582022-08-11 09:53:28 -0700766 pub(crate) fn code_region(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100767 counter: coverage_map::Counter,
768 file_id: u32,
769 start_line: u32,
770 start_col: u32,
771 end_line: u32,
772 end_col: u32,
773 ) -> Self {
774 Self {
775 counter,
Charisee7878d542022-02-24 18:21:36 +0000776 false_counter: coverage_map::Counter::zero(),
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100777 file_id,
778 expanded_file_id: 0,
779 start_line,
780 start_col,
781 end_line,
782 end_col,
783 kind: RegionKind::CodeRegion,
784 }
785 }
786
Chris Wailes32f78352021-07-20 14:04:55 -0700787 // This function might be used in the future; the LLVM API is still evolving, as is coverage
788 // support.
789 #[allow(dead_code)]
Chris Wailes65720582022-08-11 09:53:28 -0700790 pub(crate) fn branch_region(
Charisee7878d542022-02-24 18:21:36 +0000791 counter: coverage_map::Counter,
792 false_counter: coverage_map::Counter,
793 file_id: u32,
794 start_line: u32,
795 start_col: u32,
796 end_line: u32,
797 end_col: u32,
798 ) -> Self {
799 Self {
800 counter,
801 false_counter,
802 file_id,
803 expanded_file_id: 0,
804 start_line,
805 start_col,
806 end_line,
807 end_col,
808 kind: RegionKind::BranchRegion,
809 }
810 }
811
812 // This function might be used in the future; the LLVM API is still evolving, as is coverage
813 // support.
814 #[allow(dead_code)]
Chris Wailes65720582022-08-11 09:53:28 -0700815 pub(crate) fn expansion_region(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100816 file_id: u32,
817 expanded_file_id: u32,
818 start_line: u32,
819 start_col: u32,
820 end_line: u32,
821 end_col: u32,
822 ) -> Self {
823 Self {
824 counter: coverage_map::Counter::zero(),
Charisee7878d542022-02-24 18:21:36 +0000825 false_counter: coverage_map::Counter::zero(),
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100826 file_id,
827 expanded_file_id,
828 start_line,
829 start_col,
830 end_line,
831 end_col,
832 kind: RegionKind::ExpansionRegion,
833 }
834 }
835
Chris Wailes32f78352021-07-20 14:04:55 -0700836 // This function might be used in the future; the LLVM API is still evolving, as is coverage
837 // support.
838 #[allow(dead_code)]
Chris Wailes65720582022-08-11 09:53:28 -0700839 pub(crate) fn skipped_region(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100840 file_id: u32,
841 start_line: u32,
842 start_col: u32,
843 end_line: u32,
844 end_col: u32,
845 ) -> Self {
846 Self {
847 counter: coverage_map::Counter::zero(),
Charisee7878d542022-02-24 18:21:36 +0000848 false_counter: coverage_map::Counter::zero(),
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100849 file_id,
850 expanded_file_id: 0,
851 start_line,
852 start_col,
853 end_line,
854 end_col,
855 kind: RegionKind::SkippedRegion,
856 }
857 }
858
Chris Wailes32f78352021-07-20 14:04:55 -0700859 // This function might be used in the future; the LLVM API is still evolving, as is coverage
860 // support.
861 #[allow(dead_code)]
Chris Wailes65720582022-08-11 09:53:28 -0700862 pub(crate) fn gap_region(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100863 counter: coverage_map::Counter,
864 file_id: u32,
865 start_line: u32,
866 start_col: u32,
867 end_line: u32,
868 end_col: u32,
869 ) -> Self {
870 Self {
871 counter,
Charisee7878d542022-02-24 18:21:36 +0000872 false_counter: coverage_map::Counter::zero(),
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100873 file_id,
874 expanded_file_id: 0,
875 start_line,
876 start_col,
877 end_line,
Chris Wailesa1538422021-12-02 10:37:12 -0800878 end_col: (1_u32 << 31) | end_col,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100879 kind: RegionKind::GapRegion,
880 }
881 }
882 }
883}
884
885pub mod debuginfo {
886 use super::{InvariantOpaque, Metadata};
887 use bitflags::bitflags;
888
889 #[repr(C)]
890 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
891
892 pub type DIDescriptor = Metadata;
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +0100893 pub type DILocation = Metadata;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100894 pub type DIScope = DIDescriptor;
895 pub type DIFile = DIScope;
896 pub type DILexicalBlock = DIScope;
897 pub type DISubprogram = DIScope;
898 pub type DINameSpace = DIScope;
899 pub type DIType = DIDescriptor;
900 pub type DIBasicType = DIType;
901 pub type DIDerivedType = DIType;
902 pub type DICompositeType = DIDerivedType;
903 pub type DIVariable = DIDescriptor;
904 pub type DIGlobalVariableExpression = DIDescriptor;
905 pub type DIArray = DIDescriptor;
906 pub type DISubrange = DIDescriptor;
907 pub type DIEnumerator = DIDescriptor;
908 pub type DITemplateTypeParameter = DIDescriptor;
909
910 // These values **must** match with LLVMRustDIFlags!!
911 bitflags! {
912 #[repr(transparent)]
913 #[derive(Default)]
914 pub struct DIFlags: u32 {
915 const FlagZero = 0;
916 const FlagPrivate = 1;
917 const FlagProtected = 2;
918 const FlagPublic = 3;
919 const FlagFwdDecl = (1 << 2);
920 const FlagAppleBlock = (1 << 3);
921 const FlagBlockByrefStruct = (1 << 4);
922 const FlagVirtual = (1 << 5);
923 const FlagArtificial = (1 << 6);
924 const FlagExplicit = (1 << 7);
925 const FlagPrototyped = (1 << 8);
926 const FlagObjcClassComplete = (1 << 9);
927 const FlagObjectPointer = (1 << 10);
928 const FlagVector = (1 << 11);
929 const FlagStaticMember = (1 << 12);
930 const FlagLValueReference = (1 << 13);
931 const FlagRValueReference = (1 << 14);
932 const FlagExternalTypeRef = (1 << 15);
933 const FlagIntroducedVirtual = (1 << 18);
934 const FlagBitField = (1 << 19);
935 const FlagNoReturn = (1 << 20);
936 }
937 }
938
939 // These values **must** match with LLVMRustDISPFlags!!
940 bitflags! {
941 #[repr(transparent)]
942 #[derive(Default)]
943 pub struct DISPFlags: u32 {
944 const SPFlagZero = 0;
945 const SPFlagVirtual = 1;
946 const SPFlagPureVirtual = 2;
947 const SPFlagLocalToUnit = (1 << 2);
948 const SPFlagDefinition = (1 << 3);
949 const SPFlagOptimized = (1 << 4);
950 const SPFlagMainSubprogram = (1 << 5);
951 }
952 }
953
954 /// LLVMRustDebugEmissionKind
955 #[derive(Copy, Clone)]
956 #[repr(C)]
957 pub enum DebugEmissionKind {
958 NoDebug,
959 FullDebug,
960 LineTablesOnly,
961 }
962
963 impl DebugEmissionKind {
964 pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
965 use rustc_session::config::DebugInfo;
966 match kind {
967 DebugInfo::None => DebugEmissionKind::NoDebug,
968 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
969 DebugInfo::Full => DebugEmissionKind::FullDebug,
970 }
971 }
972 }
973}
974
Chariseeb1d32802022-09-22 15:38:41 +0000975use bitflags::bitflags;
976// These values **must** match with LLVMRustAllocKindFlags
977bitflags! {
978 #[repr(transparent)]
979 #[derive(Default)]
980 pub struct AllocKindFlags : u64 {
981 const Unknown = 0;
982 const Alloc = 1;
983 const Realloc = 1 << 1;
984 const Free = 1 << 2;
985 const Uninitialized = 1 << 3;
986 const Zeroed = 1 << 4;
987 const Aligned = 1 << 5;
988 }
989}
990
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +0100991extern "C" {
992 pub type ModuleBuffer;
993}
994
995pub type SelfProfileBeforePassCallback =
996 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
997pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
998
999extern "C" {
1000 pub fn LLVMRustInstallFatalErrorHandler();
Chris Wailes2805eef2022-04-07 11:22:56 -07001001 pub fn LLVMRustDisableSystemDialogsOnCrash();
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001002
1003 // Create and destroy contexts.
1004 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
1005 pub fn LLVMContextDispose(C: &'static mut Context);
1006 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
1007
1008 // Create modules.
1009 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
1010 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
1011 pub fn LLVMCloneModule(M: &Module) -> &Module;
1012
1013 /// Data layout. See Module::getDataLayout.
1014 pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
1015 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
1016
1017 /// See Module::setModuleInlineAsm.
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001018 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
1019
1020 /// See llvm::LLVMTypeKind::getTypeID.
1021 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
1022
1023 // Operations on integer types
1024 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
1025 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
1026 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
1027 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
1028 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
1029 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
1030
1031 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
1032
1033 // Operations on real types
1034 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
1035 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
1036
1037 // Operations on function types
Charisee7878d542022-02-24 18:21:36 +00001038 pub fn LLVMFunctionType<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001039 ReturnType: &'a Type,
1040 ParamTypes: *const &'a Type,
1041 ParamCount: c_uint,
1042 IsVarArg: Bool,
1043 ) -> &'a Type;
1044 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
Charisee7878d542022-02-24 18:21:36 +00001045 pub fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001046
1047 // Operations on struct types
Charisee7878d542022-02-24 18:21:36 +00001048 pub fn LLVMStructTypeInContext<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001049 C: &'a Context,
1050 ElementTypes: *const &'a Type,
1051 ElementCount: c_uint,
1052 Packed: Bool,
1053 ) -> &'a Type;
1054
1055 // Operations on array, pointer, and vector types (sequence types)
1056 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
1057 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
1058 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
1059
1060 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
1061 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
1062
1063 // Operations on other types
1064 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
1065 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
1066
1067 // Operations on all values
1068 pub fn LLVMTypeOf(Val: &Value) -> &Type;
1069 pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
1070 pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
Charisee7878d542022-02-24 18:21:36 +00001071 pub fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value);
1072 pub fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Node: &'a Value);
1073 pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
Chris Wailes65720582022-08-11 09:53:28 -07001074 pub fn LLVMRustGlobalAddMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
Charisee7878d542022-02-24 18:21:36 +00001075 pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001076
1077 // Operations on constants of any type
1078 pub fn LLVMConstNull(Ty: &Type) -> &Value;
1079 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
1080
1081 // Operations on metadata
1082 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
Charisee7878d542022-02-24 18:21:36 +00001083 pub fn LLVMMDNodeInContext<'a>(
1084 C: &'a Context,
1085 Vals: *const &'a Value,
1086 Count: c_uint,
1087 ) -> &'a Value;
Chris Wailes65720582022-08-11 09:53:28 -07001088 pub fn LLVMMDNodeInContext2<'a>(
1089 C: &'a Context,
1090 Vals: *const &'a Metadata,
1091 Count: size_t,
1092 ) -> &'a Metadata;
Charisee7878d542022-02-24 18:21:36 +00001093 pub fn LLVMAddNamedMetadataOperand<'a>(M: &'a Module, Name: *const c_char, Val: &'a Value);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001094
1095 // Operations on scalar constants
1096 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
1097 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
1098 pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
1099 pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
1100 pub fn LLVMRustConstInt128Get(
1101 ConstantVal: &ConstantInt,
1102 SExt: bool,
1103 high: &mut u64,
1104 low: &mut u64,
1105 ) -> bool;
1106
1107 // Operations on composite constants
1108 pub fn LLVMConstStringInContext(
1109 C: &Context,
1110 Str: *const c_char,
1111 Length: c_uint,
1112 DontNullTerminate: Bool,
1113 ) -> &Value;
Charisee7878d542022-02-24 18:21:36 +00001114 pub fn LLVMConstStructInContext<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001115 C: &'a Context,
1116 ConstantVals: *const &'a Value,
1117 Count: c_uint,
1118 Packed: Bool,
1119 ) -> &'a Value;
1120
Charisee7878d542022-02-24 18:21:36 +00001121 pub fn LLVMConstArray<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001122 ElementTy: &'a Type,
1123 ConstantVals: *const &'a Value,
1124 Length: c_uint,
1125 ) -> &'a Value;
1126 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
1127
1128 // Constant expressions
Charisee7878d542022-02-24 18:21:36 +00001129 pub fn LLVMRustConstInBoundsGEP2<'a>(
Chris Wailesbcf972c2021-10-21 11:03:28 -07001130 ty: &'a Type,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001131 ConstantVal: &'a Value,
1132 ConstantIndices: *const &'a Value,
1133 NumIndices: c_uint,
1134 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001135 pub fn LLVMConstZExt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1136 pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1137 pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1138 pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1139 pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
Chariseeb1d32802022-09-22 15:38:41 +00001140 pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001141
1142 // Operations on global variables, functions, and aliases (globals)
1143 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
1144 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
1145 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
1146 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
1147 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
1148 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
Chris Wailes32f78352021-07-20 14:04:55 -07001149 pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001150 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
1151 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1152 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1153
1154 // Operations on global variables
1155 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
Charisee7878d542022-02-24 18:21:36 +00001156 pub fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001157 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
Charisee7878d542022-02-24 18:21:36 +00001158 pub fn LLVMRustGetOrInsertGlobal<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001159 M: &'a Module,
1160 Name: *const c_char,
1161 NameLen: size_t,
1162 T: &'a Type,
1163 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001164 pub fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001165 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1166 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1167 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
1168 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
Charisee7878d542022-02-24 18:21:36 +00001169 pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
Chris Wailes2f3fdfe2021-07-29 10:56:18 -07001170 pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001171 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1172 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1173 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1174 pub fn LLVMRustGetNamedValue(
1175 M: &Module,
1176 Name: *const c_char,
1177 NameLen: size_t,
1178 ) -> Option<&Value>;
1179 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1180
Charisee341341c2022-05-20 05:14:50 +00001181 // Operations on attributes
1182 pub fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute;
1183 pub fn LLVMCreateStringAttribute(
1184 C: &Context,
1185 Name: *const c_char,
1186 NameLen: c_uint,
1187 Value: *const c_char,
1188 ValueLen: c_uint,
1189 ) -> &Attribute;
1190 pub fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute;
1191 pub fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute;
1192 pub fn LLVMRustCreateDereferenceableOrNullAttr(C: &Context, bytes: u64) -> &Attribute;
1193 pub fn LLVMRustCreateByValAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
1194 pub fn LLVMRustCreateStructRetAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
Chariseeb1d32802022-09-22 15:38:41 +00001195 pub fn LLVMRustCreateElementTypeAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
Charisee341341c2022-05-20 05:14:50 +00001196 pub fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute;
Chariseeb1d32802022-09-22 15:38:41 +00001197 pub fn LLVMRustCreateAllocSizeAttr(C: &Context, size_arg: u32) -> &Attribute;
1198 pub fn LLVMRustCreateAllocKindAttr(C: &Context, size_arg: u64) -> &Attribute;
Charisee341341c2022-05-20 05:14:50 +00001199
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001200 // Operations on functions
Charisee7878d542022-02-24 18:21:36 +00001201 pub fn LLVMRustGetOrInsertFunction<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001202 M: &'a Module,
1203 Name: *const c_char,
1204 NameLen: size_t,
1205 FunctionTy: &'a Type,
1206 ) -> &'a Value;
1207 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
Charisee341341c2022-05-20 05:14:50 +00001208 pub fn LLVMRustAddFunctionAttributes<'a>(
1209 Fn: &'a Value,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001210 index: c_uint,
Charisee341341c2022-05-20 05:14:50 +00001211 Attrs: *const &'a Attribute,
1212 AttrsLen: size_t,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001213 );
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001214
1215 // Operations on parameters
1216 pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1217 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
1218 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1219
1220 // Operations on basic blocks
1221 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
Charisee7878d542022-02-24 18:21:36 +00001222 pub fn LLVMAppendBasicBlockInContext<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001223 C: &'a Context,
1224 Fn: &'a Value,
1225 Name: *const c_char,
1226 ) -> &'a BasicBlock;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001227
1228 // Operations on instructions
1229 pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1230 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1231
1232 // Operations on call sites
1233 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
Charisee341341c2022-05-20 05:14:50 +00001234 pub fn LLVMRustAddCallSiteAttributes<'a>(
1235 Instr: &'a Value,
1236 index: c_uint,
1237 Attrs: *const &'a Attribute,
1238 AttrsLen: size_t,
1239 );
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001240
1241 // Operations on load/store instructions (only)
1242 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1243
1244 // Operations on phi nodes
Charisee7878d542022-02-24 18:21:36 +00001245 pub fn LLVMAddIncoming<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001246 PhiNode: &'a Value,
1247 IncomingValues: *const &'a Value,
1248 IncomingBlocks: *const &'a BasicBlock,
1249 Count: c_uint,
1250 );
1251
1252 // Instruction builders
Charisee7878d542022-02-24 18:21:36 +00001253 pub fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>;
1254 pub fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock);
1255 pub fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock;
1256 pub fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001257
1258 // Metadata
Charisee7878d542022-02-24 18:21:36 +00001259 pub fn LLVMSetCurrentDebugLocation<'a>(Builder: &Builder<'a>, L: &'a Value);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001260
1261 // Terminators
Charisee7878d542022-02-24 18:21:36 +00001262 pub fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;
1263 pub fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1264 pub fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1265 pub fn LLVMBuildCondBr<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001266 B: &Builder<'a>,
1267 If: &'a Value,
1268 Then: &'a BasicBlock,
1269 Else: &'a BasicBlock,
1270 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001271 pub fn LLVMBuildSwitch<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001272 B: &Builder<'a>,
1273 V: &'a Value,
1274 Else: &'a BasicBlock,
1275 NumCases: c_uint,
1276 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001277 pub fn LLVMRustBuildInvoke<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001278 B: &Builder<'a>,
Chris Wailesbcf972c2021-10-21 11:03:28 -07001279 Ty: &'a Type,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001280 Fn: &'a Value,
1281 Args: *const &'a Value,
1282 NumArgs: c_uint,
1283 Then: &'a BasicBlock,
1284 Catch: &'a BasicBlock,
1285 Bundle: Option<&OperandBundleDef<'a>>,
1286 Name: *const c_char,
1287 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001288 pub fn LLVMBuildLandingPad<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001289 B: &Builder<'a>,
1290 Ty: &'a Type,
Chris Wailes54272ac2021-09-09 16:08:13 -07001291 PersFn: Option<&'a Value>,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001292 NumClauses: c_uint,
1293 Name: *const c_char,
1294 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001295 pub fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1296 pub fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001297
Charisee7878d542022-02-24 18:21:36 +00001298 pub fn LLVMRustBuildCleanupPad<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001299 B: &Builder<'a>,
1300 ParentPad: Option<&'a Value>,
1301 ArgCnt: c_uint,
1302 Args: *const &'a Value,
1303 Name: *const c_char,
1304 ) -> Option<&'a Value>;
Charisee7878d542022-02-24 18:21:36 +00001305 pub fn LLVMRustBuildCleanupRet<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001306 B: &Builder<'a>,
1307 CleanupPad: &'a Value,
1308 UnwindBB: Option<&'a BasicBlock>,
1309 ) -> Option<&'a Value>;
Charisee7878d542022-02-24 18:21:36 +00001310 pub fn LLVMRustBuildCatchPad<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001311 B: &Builder<'a>,
1312 ParentPad: &'a Value,
1313 ArgCnt: c_uint,
1314 Args: *const &'a Value,
1315 Name: *const c_char,
1316 ) -> Option<&'a Value>;
Charisee7878d542022-02-24 18:21:36 +00001317 pub fn LLVMRustBuildCatchRet<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001318 B: &Builder<'a>,
1319 Pad: &'a Value,
1320 BB: &'a BasicBlock,
1321 ) -> Option<&'a Value>;
Charisee7878d542022-02-24 18:21:36 +00001322 pub fn LLVMRustBuildCatchSwitch<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001323 Builder: &Builder<'a>,
1324 ParentPad: Option<&'a Value>,
1325 BB: Option<&'a BasicBlock>,
1326 NumHandlers: c_uint,
1327 Name: *const c_char,
1328 ) -> Option<&'a Value>;
Charisee7878d542022-02-24 18:21:36 +00001329 pub fn LLVMRustAddHandler<'a>(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1330 pub fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001331
1332 // Add a case to the switch instruction
Charisee7878d542022-02-24 18:21:36 +00001333 pub fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001334
1335 // Add a clause to the landing pad instruction
Charisee7878d542022-02-24 18:21:36 +00001336 pub fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001337
1338 // Set the cleanup on a landing pad instruction
1339 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1340
1341 // Arithmetic
Charisee7878d542022-02-24 18:21:36 +00001342 pub fn LLVMBuildAdd<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001343 B: &Builder<'a>,
1344 LHS: &'a Value,
1345 RHS: &'a Value,
1346 Name: *const c_char,
1347 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001348 pub fn LLVMBuildFAdd<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001349 B: &Builder<'a>,
1350 LHS: &'a Value,
1351 RHS: &'a Value,
1352 Name: *const c_char,
1353 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001354 pub fn LLVMBuildSub<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001355 B: &Builder<'a>,
1356 LHS: &'a Value,
1357 RHS: &'a Value,
1358 Name: *const c_char,
1359 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001360 pub fn LLVMBuildFSub<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001361 B: &Builder<'a>,
1362 LHS: &'a Value,
1363 RHS: &'a Value,
1364 Name: *const c_char,
1365 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001366 pub fn LLVMBuildMul<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001367 B: &Builder<'a>,
1368 LHS: &'a Value,
1369 RHS: &'a Value,
1370 Name: *const c_char,
1371 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001372 pub fn LLVMBuildFMul<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001373 B: &Builder<'a>,
1374 LHS: &'a Value,
1375 RHS: &'a Value,
1376 Name: *const c_char,
1377 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001378 pub fn LLVMBuildUDiv<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001379 B: &Builder<'a>,
1380 LHS: &'a Value,
1381 RHS: &'a Value,
1382 Name: *const c_char,
1383 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001384 pub fn LLVMBuildExactUDiv<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001385 B: &Builder<'a>,
1386 LHS: &'a Value,
1387 RHS: &'a Value,
1388 Name: *const c_char,
1389 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001390 pub fn LLVMBuildSDiv<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001391 B: &Builder<'a>,
1392 LHS: &'a Value,
1393 RHS: &'a Value,
1394 Name: *const c_char,
1395 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001396 pub fn LLVMBuildExactSDiv<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001397 B: &Builder<'a>,
1398 LHS: &'a Value,
1399 RHS: &'a Value,
1400 Name: *const c_char,
1401 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001402 pub fn LLVMBuildFDiv<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001403 B: &Builder<'a>,
1404 LHS: &'a Value,
1405 RHS: &'a Value,
1406 Name: *const c_char,
1407 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001408 pub fn LLVMBuildURem<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001409 B: &Builder<'a>,
1410 LHS: &'a Value,
1411 RHS: &'a Value,
1412 Name: *const c_char,
1413 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001414 pub fn LLVMBuildSRem<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001415 B: &Builder<'a>,
1416 LHS: &'a Value,
1417 RHS: &'a Value,
1418 Name: *const c_char,
1419 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001420 pub fn LLVMBuildFRem<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001421 B: &Builder<'a>,
1422 LHS: &'a Value,
1423 RHS: &'a Value,
1424 Name: *const c_char,
1425 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001426 pub fn LLVMBuildShl<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001427 B: &Builder<'a>,
1428 LHS: &'a Value,
1429 RHS: &'a Value,
1430 Name: *const c_char,
1431 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001432 pub fn LLVMBuildLShr<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001433 B: &Builder<'a>,
1434 LHS: &'a Value,
1435 RHS: &'a Value,
1436 Name: *const c_char,
1437 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001438 pub fn LLVMBuildAShr<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001439 B: &Builder<'a>,
1440 LHS: &'a Value,
1441 RHS: &'a Value,
1442 Name: *const c_char,
1443 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001444 pub fn LLVMBuildNSWAdd<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001445 B: &Builder<'a>,
1446 LHS: &'a Value,
1447 RHS: &'a Value,
1448 Name: *const c_char,
1449 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001450 pub fn LLVMBuildNUWAdd<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001451 B: &Builder<'a>,
1452 LHS: &'a Value,
1453 RHS: &'a Value,
1454 Name: *const c_char,
1455 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001456 pub fn LLVMBuildNSWSub<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001457 B: &Builder<'a>,
1458 LHS: &'a Value,
1459 RHS: &'a Value,
1460 Name: *const c_char,
1461 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001462 pub fn LLVMBuildNUWSub<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001463 B: &Builder<'a>,
1464 LHS: &'a Value,
1465 RHS: &'a Value,
1466 Name: *const c_char,
1467 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001468 pub fn LLVMBuildNSWMul<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001469 B: &Builder<'a>,
1470 LHS: &'a Value,
1471 RHS: &'a Value,
1472 Name: *const c_char,
1473 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001474 pub fn LLVMBuildNUWMul<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001475 B: &Builder<'a>,
1476 LHS: &'a Value,
1477 RHS: &'a Value,
1478 Name: *const c_char,
1479 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001480 pub fn LLVMBuildAnd<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001481 B: &Builder<'a>,
1482 LHS: &'a Value,
1483 RHS: &'a Value,
1484 Name: *const c_char,
1485 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001486 pub fn LLVMBuildOr<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001487 B: &Builder<'a>,
1488 LHS: &'a Value,
1489 RHS: &'a Value,
1490 Name: *const c_char,
1491 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001492 pub fn LLVMBuildXor<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001493 B: &Builder<'a>,
1494 LHS: &'a Value,
1495 RHS: &'a Value,
1496 Name: *const c_char,
1497 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001498 pub fn LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1499 pub fn LLVMBuildFNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1500 pub fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
Chris Wailes32f78352021-07-20 14:04:55 -07001501 pub fn LLVMRustSetFastMath(Instr: &Value);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001502
1503 // Memory
Charisee7878d542022-02-24 18:21:36 +00001504 pub fn LLVMBuildAlloca<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1505 pub fn LLVMBuildArrayAlloca<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001506 B: &Builder<'a>,
1507 Ty: &'a Type,
1508 Val: &'a Value,
1509 Name: *const c_char,
1510 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001511 pub fn LLVMBuildLoad2<'a>(
Chris Wailes54272ac2021-09-09 16:08:13 -07001512 B: &Builder<'a>,
1513 Ty: &'a Type,
1514 PointerVal: &'a Value,
1515 Name: *const c_char,
1516 ) -> &'a Value;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001517
Charisee7878d542022-02-24 18:21:36 +00001518 pub fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001519
Charisee7878d542022-02-24 18:21:36 +00001520 pub fn LLVMBuildGEP2<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001521 B: &Builder<'a>,
Chris Wailesbcf972c2021-10-21 11:03:28 -07001522 Ty: &'a Type,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001523 Pointer: &'a Value,
1524 Indices: *const &'a Value,
1525 NumIndices: c_uint,
1526 Name: *const c_char,
1527 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001528 pub fn LLVMBuildInBoundsGEP2<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001529 B: &Builder<'a>,
Chris Wailesbcf972c2021-10-21 11:03:28 -07001530 Ty: &'a Type,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001531 Pointer: &'a Value,
1532 Indices: *const &'a Value,
1533 NumIndices: c_uint,
1534 Name: *const c_char,
1535 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001536 pub fn LLVMBuildStructGEP2<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001537 B: &Builder<'a>,
Chris Wailesbcf972c2021-10-21 11:03:28 -07001538 Ty: &'a Type,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001539 Pointer: &'a Value,
1540 Idx: c_uint,
1541 Name: *const c_char,
1542 ) -> &'a Value;
1543
1544 // Casts
Charisee7878d542022-02-24 18:21:36 +00001545 pub fn LLVMBuildTrunc<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001546 B: &Builder<'a>,
1547 Val: &'a Value,
1548 DestTy: &'a Type,
1549 Name: *const c_char,
1550 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001551 pub fn LLVMBuildZExt<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001552 B: &Builder<'a>,
1553 Val: &'a Value,
1554 DestTy: &'a Type,
1555 Name: *const c_char,
1556 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001557 pub fn LLVMBuildSExt<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001558 B: &Builder<'a>,
1559 Val: &'a Value,
1560 DestTy: &'a Type,
1561 Name: *const c_char,
1562 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001563 pub fn LLVMBuildFPToUI<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001564 B: &Builder<'a>,
1565 Val: &'a Value,
1566 DestTy: &'a Type,
1567 Name: *const c_char,
1568 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001569 pub fn LLVMBuildFPToSI<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001570 B: &Builder<'a>,
1571 Val: &'a Value,
1572 DestTy: &'a Type,
1573 Name: *const c_char,
1574 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001575 pub fn LLVMBuildUIToFP<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001576 B: &Builder<'a>,
1577 Val: &'a Value,
1578 DestTy: &'a Type,
1579 Name: *const c_char,
1580 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001581 pub fn LLVMBuildSIToFP<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001582 B: &Builder<'a>,
1583 Val: &'a Value,
1584 DestTy: &'a Type,
1585 Name: *const c_char,
1586 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001587 pub fn LLVMBuildFPTrunc<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001588 B: &Builder<'a>,
1589 Val: &'a Value,
1590 DestTy: &'a Type,
1591 Name: *const c_char,
1592 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001593 pub fn LLVMBuildFPExt<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001594 B: &Builder<'a>,
1595 Val: &'a Value,
1596 DestTy: &'a Type,
1597 Name: *const c_char,
1598 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001599 pub fn LLVMBuildPtrToInt<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001600 B: &Builder<'a>,
1601 Val: &'a Value,
1602 DestTy: &'a Type,
1603 Name: *const c_char,
1604 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001605 pub fn LLVMBuildIntToPtr<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001606 B: &Builder<'a>,
1607 Val: &'a Value,
1608 DestTy: &'a Type,
1609 Name: *const c_char,
1610 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001611 pub fn LLVMBuildBitCast<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001612 B: &Builder<'a>,
1613 Val: &'a Value,
1614 DestTy: &'a Type,
1615 Name: *const c_char,
1616 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001617 pub fn LLVMBuildPointerCast<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001618 B: &Builder<'a>,
1619 Val: &'a Value,
1620 DestTy: &'a Type,
1621 Name: *const c_char,
1622 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001623 pub fn LLVMRustBuildIntCast<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001624 B: &Builder<'a>,
1625 Val: &'a Value,
1626 DestTy: &'a Type,
Chariseeb1d32802022-09-22 15:38:41 +00001627 IsSigned: bool,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001628 ) -> &'a Value;
1629
1630 // Comparisons
Charisee7878d542022-02-24 18:21:36 +00001631 pub fn LLVMBuildICmp<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001632 B: &Builder<'a>,
1633 Op: c_uint,
1634 LHS: &'a Value,
1635 RHS: &'a Value,
1636 Name: *const c_char,
1637 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001638 pub fn LLVMBuildFCmp<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001639 B: &Builder<'a>,
1640 Op: c_uint,
1641 LHS: &'a Value,
1642 RHS: &'a Value,
1643 Name: *const c_char,
1644 ) -> &'a Value;
1645
1646 // Miscellaneous instructions
Charisee7878d542022-02-24 18:21:36 +00001647 pub fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1648 pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &Value;
1649 pub fn LLVMRustBuildCall<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001650 B: &Builder<'a>,
Chris Wailesbcf972c2021-10-21 11:03:28 -07001651 Ty: &'a Type,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001652 Fn: &'a Value,
1653 Args: *const &'a Value,
1654 NumArgs: c_uint,
1655 Bundle: Option<&OperandBundleDef<'a>>,
1656 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001657 pub fn LLVMRustBuildMemCpy<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001658 B: &Builder<'a>,
1659 Dst: &'a Value,
1660 DstAlign: c_uint,
1661 Src: &'a Value,
1662 SrcAlign: c_uint,
1663 Size: &'a Value,
1664 IsVolatile: bool,
1665 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001666 pub fn LLVMRustBuildMemMove<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001667 B: &Builder<'a>,
1668 Dst: &'a Value,
1669 DstAlign: c_uint,
1670 Src: &'a Value,
1671 SrcAlign: c_uint,
1672 Size: &'a Value,
1673 IsVolatile: bool,
1674 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001675 pub fn LLVMRustBuildMemSet<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001676 B: &Builder<'a>,
1677 Dst: &'a Value,
1678 DstAlign: c_uint,
1679 Val: &'a Value,
1680 Size: &'a Value,
1681 IsVolatile: bool,
1682 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001683 pub fn LLVMBuildSelect<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001684 B: &Builder<'a>,
1685 If: &'a Value,
1686 Then: &'a Value,
1687 Else: &'a Value,
1688 Name: *const c_char,
1689 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001690 pub fn LLVMBuildVAArg<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001691 B: &Builder<'a>,
1692 list: &'a Value,
1693 Ty: &'a Type,
1694 Name: *const c_char,
1695 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001696 pub fn LLVMBuildExtractElement<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001697 B: &Builder<'a>,
1698 VecVal: &'a Value,
1699 Index: &'a Value,
1700 Name: *const c_char,
1701 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001702 pub fn LLVMBuildInsertElement<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001703 B: &Builder<'a>,
1704 VecVal: &'a Value,
1705 EltVal: &'a Value,
1706 Index: &'a Value,
1707 Name: *const c_char,
1708 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001709 pub fn LLVMBuildShuffleVector<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001710 B: &Builder<'a>,
1711 V1: &'a Value,
1712 V2: &'a Value,
1713 Mask: &'a Value,
1714 Name: *const c_char,
1715 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001716 pub fn LLVMBuildExtractValue<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001717 B: &Builder<'a>,
1718 AggVal: &'a Value,
1719 Index: c_uint,
1720 Name: *const c_char,
1721 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001722 pub fn LLVMBuildInsertValue<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001723 B: &Builder<'a>,
1724 AggVal: &'a Value,
1725 EltVal: &'a Value,
1726 Index: c_uint,
1727 Name: *const c_char,
1728 ) -> &'a Value;
1729
Charisee7878d542022-02-24 18:21:36 +00001730 pub fn LLVMRustBuildVectorReduceFAdd<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001731 B: &Builder<'a>,
1732 Acc: &'a Value,
1733 Src: &'a Value,
1734 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001735 pub fn LLVMRustBuildVectorReduceFMul<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001736 B: &Builder<'a>,
1737 Acc: &'a Value,
1738 Src: &'a Value,
1739 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001740 pub fn LLVMRustBuildVectorReduceAdd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1741 pub fn LLVMRustBuildVectorReduceMul<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1742 pub fn LLVMRustBuildVectorReduceAnd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1743 pub fn LLVMRustBuildVectorReduceOr<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1744 pub fn LLVMRustBuildVectorReduceXor<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1745 pub fn LLVMRustBuildVectorReduceMin<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001746 B: &Builder<'a>,
1747 Src: &'a Value,
1748 IsSigned: bool,
1749 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001750 pub fn LLVMRustBuildVectorReduceMax<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001751 B: &Builder<'a>,
1752 Src: &'a Value,
1753 IsSigned: bool,
1754 ) -> &'a Value;
Charisee7878d542022-02-24 18:21:36 +00001755 pub fn LLVMRustBuildVectorReduceFMin<'a>(
1756 B: &Builder<'a>,
1757 Src: &'a Value,
1758 IsNaN: bool,
1759 ) -> &'a Value;
1760 pub fn LLVMRustBuildVectorReduceFMax<'a>(
1761 B: &Builder<'a>,
1762 Src: &'a Value,
1763 IsNaN: bool,
1764 ) -> &'a Value;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001765
Charisee7878d542022-02-24 18:21:36 +00001766 pub fn LLVMRustBuildMinNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1767 pub fn LLVMRustBuildMaxNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001768
1769 // Atomic Operations
Charisee7878d542022-02-24 18:21:36 +00001770 pub fn LLVMRustBuildAtomicLoad<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001771 B: &Builder<'a>,
Chris Wailes54272ac2021-09-09 16:08:13 -07001772 ElementType: &'a Type,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001773 PointerVal: &'a Value,
1774 Name: *const c_char,
1775 Order: AtomicOrdering,
1776 ) -> &'a Value;
1777
Charisee7878d542022-02-24 18:21:36 +00001778 pub fn LLVMRustBuildAtomicStore<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001779 B: &Builder<'a>,
1780 Val: &'a Value,
1781 Ptr: &'a Value,
1782 Order: AtomicOrdering,
1783 ) -> &'a Value;
1784
Charisee7878d542022-02-24 18:21:36 +00001785 pub fn LLVMRustBuildAtomicCmpXchg<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001786 B: &Builder<'a>,
1787 LHS: &'a Value,
1788 CMP: &'a Value,
1789 RHS: &'a Value,
1790 Order: AtomicOrdering,
1791 FailureOrder: AtomicOrdering,
1792 Weak: Bool,
1793 ) -> &'a Value;
1794
Charisee7878d542022-02-24 18:21:36 +00001795 pub fn LLVMBuildAtomicRMW<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001796 B: &Builder<'a>,
1797 Op: AtomicRmwBinOp,
1798 LHS: &'a Value,
1799 RHS: &'a Value,
1800 Order: AtomicOrdering,
1801 SingleThreaded: Bool,
1802 ) -> &'a Value;
1803
1804 pub fn LLVMRustBuildAtomicFence(
1805 B: &Builder<'_>,
1806 Order: AtomicOrdering,
1807 Scope: SynchronizationScope,
1808 );
1809
1810 /// Writes a module to the specified path. Returns 0 on success.
1811 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1812
1813 /// Creates a pass manager.
Charisee7878d542022-02-24 18:21:36 +00001814 pub fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001815
1816 /// Creates a function-by-function pass manager
Charisee7878d542022-02-24 18:21:36 +00001817 pub fn LLVMCreateFunctionPassManagerForModule(M: &Module) -> &mut PassManager<'_>;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001818
1819 /// Disposes a pass manager.
Charisee7878d542022-02-24 18:21:36 +00001820 pub fn LLVMDisposePassManager<'a>(PM: &'a mut PassManager<'a>);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001821
1822 /// Runs a pass manager on a module.
Charisee7878d542022-02-24 18:21:36 +00001823 pub fn LLVMRunPassManager<'a>(PM: &PassManager<'a>, M: &'a Module) -> Bool;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001824
1825 pub fn LLVMInitializePasses();
1826
1827 pub fn LLVMTimeTraceProfilerInitialize();
1828
Chris Wailes356b57e2022-01-13 10:08:24 -08001829 pub fn LLVMTimeTraceProfilerFinishThread();
1830
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001831 pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1832
Charisee7878d542022-02-24 18:21:36 +00001833 pub fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001834
Charisee9cf67802022-06-30 20:04:09 +00001835 pub fn LLVMRustPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1836 pub fn LLVMRustPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1837 pub fn LLVMRustPassManagerBuilderUseInlinerWithThreshold(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001838 PMB: &PassManagerBuilder,
1839 threshold: c_uint,
1840 );
Charisee9cf67802022-06-30 20:04:09 +00001841 pub fn LLVMRustPassManagerBuilderPopulateModulePassManager(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001842 PMB: &PassManagerBuilder,
1843 PM: &PassManager<'_>,
1844 );
1845
Charisee9cf67802022-06-30 20:04:09 +00001846 pub fn LLVMRustPassManagerBuilderPopulateFunctionPassManager(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001847 PMB: &PassManagerBuilder,
1848 PM: &PassManager<'_>,
1849 );
Charisee9cf67802022-06-30 20:04:09 +00001850 pub fn LLVMRustPassManagerBuilderPopulateLTOPassManager(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001851 PMB: &PassManagerBuilder,
1852 PM: &PassManager<'_>,
1853 Internalize: Bool,
1854 RunInliner: Bool,
1855 );
1856 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1857 PMB: &PassManagerBuilder,
1858 PM: &PassManager<'_>,
1859 );
1860
Jeff Vander Stoep59fbe182021-03-29 10:17:52 +02001861 pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
1862
1863 pub fn LLVMDisposeMessage(message: *mut c_char);
1864
Chris Wailes356b57e2022-01-13 10:08:24 -08001865 pub fn LLVMIsMultithreaded() -> Bool;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001866
1867 /// Returns a string describing the last error caused by an LLVMRust* call.
1868 pub fn LLVMRustGetLastError() -> *const c_char;
1869
1870 /// Print the pass timings since static dtors aren't picking them up.
1871 pub fn LLVMRustPrintPassTimings();
1872
1873 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1874
Charisee7878d542022-02-24 18:21:36 +00001875 pub fn LLVMStructSetBody<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001876 StructTy: &'a Type,
1877 ElementTypes: *const &'a Type,
1878 ElementCount: c_uint,
1879 Packed: Bool,
1880 );
1881
1882 /// Prepares inline assembly.
1883 pub fn LLVMRustInlineAsm(
1884 Ty: &Type,
1885 AsmString: *const c_char,
1886 AsmStringLen: size_t,
1887 Constraints: *const c_char,
1888 ConstraintsLen: size_t,
1889 SideEffects: Bool,
1890 AlignStack: Bool,
1891 Dialect: AsmDialect,
Charisee7878d542022-02-24 18:21:36 +00001892 CanThrow: Bool,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001893 ) -> &Value;
1894 pub fn LLVMRustInlineAsmVerify(
1895 Ty: &Type,
1896 Constraints: *const c_char,
1897 ConstraintsLen: size_t,
1898 ) -> bool;
1899
1900 #[allow(improper_ctypes)]
1901 pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1902 Filenames: *const *const c_char,
1903 FilenamesLen: size_t,
1904 BufferOut: &RustString,
1905 );
1906
1907 #[allow(improper_ctypes)]
1908 pub fn LLVMRustCoverageWriteMappingToBuffer(
1909 VirtualFileMappingIDs: *const c_uint,
1910 NumVirtualFileMappingIDs: c_uint,
1911 Expressions: *const coverage_map::CounterExpression,
1912 NumExpressions: c_uint,
Chris Wailese3116c42021-07-13 14:40:48 -07001913 MappingRegions: *const coverageinfo::CounterMappingRegion,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001914 NumMappingRegions: c_uint,
1915 BufferOut: &RustString,
1916 );
1917
Charisee7878d542022-02-24 18:21:36 +00001918 pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &Value, FuncName: *const c_char) -> &Value;
Jeff Vander Stoepd59a2872021-02-15 10:22:21 +01001919 pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64;
1920 pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001921
1922 #[allow(improper_ctypes)]
Jeff Vander Stoepd59a2872021-02-15 10:22:21 +01001923 pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
1924
1925 #[allow(improper_ctypes)]
1926 pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001927
1928 #[allow(improper_ctypes)]
1929 pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1930
1931 pub fn LLVMRustCoverageMappingVersion() -> u32;
1932 pub fn LLVMRustDebugMetadataVersion() -> u32;
1933 pub fn LLVMRustVersionMajor() -> u32;
1934 pub fn LLVMRustVersionMinor() -> u32;
Jeff Vander Stoep59fbe182021-03-29 10:17:52 +02001935 pub fn LLVMRustVersionPatch() -> u32;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001936
Chris Wailes2805eef2022-04-07 11:22:56 -07001937 /// Add LLVM module flags.
1938 ///
1939 /// In order for Rust-C LTO to work, module flags must be compatible with Clang. What
1940 /// "compatible" means depends on the merge behaviors involved.
1941 pub fn LLVMRustAddModuleFlag(
1942 M: &Module,
1943 merge_behavior: LLVMModFlagBehavior,
1944 name: *const c_char,
1945 value: u32,
1946 );
Chris Wailes65720582022-08-11 09:53:28 -07001947 pub fn LLVMRustHasModuleFlag(M: &Module, name: *const c_char, len: size_t) -> bool;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001948
Charisee7878d542022-02-24 18:21:36 +00001949 pub fn LLVMRustMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001950
Charisee7878d542022-02-24 18:21:36 +00001951 pub fn LLVMRustDIBuilderCreate(M: &Module) -> &mut DIBuilder<'_>;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001952
Charisee7878d542022-02-24 18:21:36 +00001953 pub fn LLVMRustDIBuilderDispose<'a>(Builder: &'a mut DIBuilder<'a>);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001954
1955 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1956
Charisee7878d542022-02-24 18:21:36 +00001957 pub fn LLVMRustDIBuilderCreateCompileUnit<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001958 Builder: &DIBuilder<'a>,
1959 Lang: c_uint,
1960 File: &'a DIFile,
1961 Producer: *const c_char,
1962 ProducerLen: size_t,
1963 isOptimized: bool,
1964 Flags: *const c_char,
1965 RuntimeVer: c_uint,
1966 SplitName: *const c_char,
1967 SplitNameLen: size_t,
1968 kind: DebugEmissionKind,
Jeff Vander Stoepd59a2872021-02-15 10:22:21 +01001969 DWOId: u64,
1970 SplitDebugInlining: bool,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001971 ) -> &'a DIDescriptor;
1972
Charisee7878d542022-02-24 18:21:36 +00001973 pub fn LLVMRustDIBuilderCreateFile<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001974 Builder: &DIBuilder<'a>,
1975 Filename: *const c_char,
1976 FilenameLen: size_t,
1977 Directory: *const c_char,
1978 DirectoryLen: size_t,
1979 CSKind: ChecksumKind,
1980 Checksum: *const c_char,
1981 ChecksumLen: size_t,
1982 ) -> &'a DIFile;
1983
Charisee7878d542022-02-24 18:21:36 +00001984 pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001985 Builder: &DIBuilder<'a>,
1986 ParameterTypes: &'a DIArray,
1987 ) -> &'a DICompositeType;
1988
Charisee7878d542022-02-24 18:21:36 +00001989 pub fn LLVMRustDIBuilderCreateFunction<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01001990 Builder: &DIBuilder<'a>,
1991 Scope: &'a DIDescriptor,
1992 Name: *const c_char,
1993 NameLen: size_t,
1994 LinkageName: *const c_char,
1995 LinkageNameLen: size_t,
1996 File: &'a DIFile,
1997 LineNo: c_uint,
1998 Ty: &'a DIType,
1999 ScopeLine: c_uint,
2000 Flags: DIFlags,
2001 SPFlags: DISPFlags,
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +01002002 MaybeFn: Option<&'a Value>,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002003 TParam: &'a DIArray,
2004 Decl: Option<&'a DIDescriptor>,
2005 ) -> &'a DISubprogram;
2006
Charisee7878d542022-02-24 18:21:36 +00002007 pub fn LLVMRustDIBuilderCreateBasicType<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002008 Builder: &DIBuilder<'a>,
2009 Name: *const c_char,
2010 NameLen: size_t,
2011 SizeInBits: u64,
2012 Encoding: c_uint,
2013 ) -> &'a DIBasicType;
2014
Charisee7878d542022-02-24 18:21:36 +00002015 pub fn LLVMRustDIBuilderCreateTypedef<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002016 Builder: &DIBuilder<'a>,
2017 Type: &'a DIBasicType,
2018 Name: *const c_char,
2019 NameLen: size_t,
2020 File: &'a DIFile,
2021 LineNo: c_uint,
2022 Scope: Option<&'a DIScope>,
2023 ) -> &'a DIDerivedType;
2024
Charisee7878d542022-02-24 18:21:36 +00002025 pub fn LLVMRustDIBuilderCreatePointerType<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002026 Builder: &DIBuilder<'a>,
2027 PointeeTy: &'a DIType,
2028 SizeInBits: u64,
2029 AlignInBits: u32,
2030 AddressSpace: c_uint,
2031 Name: *const c_char,
2032 NameLen: size_t,
2033 ) -> &'a DIDerivedType;
2034
Charisee7878d542022-02-24 18:21:36 +00002035 pub fn LLVMRustDIBuilderCreateStructType<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002036 Builder: &DIBuilder<'a>,
2037 Scope: Option<&'a DIDescriptor>,
2038 Name: *const c_char,
2039 NameLen: size_t,
2040 File: &'a DIFile,
2041 LineNumber: c_uint,
2042 SizeInBits: u64,
2043 AlignInBits: u32,
2044 Flags: DIFlags,
2045 DerivedFrom: Option<&'a DIType>,
2046 Elements: &'a DIArray,
2047 RunTimeLang: c_uint,
2048 VTableHolder: Option<&'a DIType>,
2049 UniqueId: *const c_char,
2050 UniqueIdLen: size_t,
2051 ) -> &'a DICompositeType;
2052
Charisee7878d542022-02-24 18:21:36 +00002053 pub fn LLVMRustDIBuilderCreateMemberType<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002054 Builder: &DIBuilder<'a>,
2055 Scope: &'a DIDescriptor,
2056 Name: *const c_char,
2057 NameLen: size_t,
2058 File: &'a DIFile,
2059 LineNo: c_uint,
2060 SizeInBits: u64,
2061 AlignInBits: u32,
2062 OffsetInBits: u64,
2063 Flags: DIFlags,
2064 Ty: &'a DIType,
2065 ) -> &'a DIDerivedType;
2066
Charisee7878d542022-02-24 18:21:36 +00002067 pub fn LLVMRustDIBuilderCreateVariantMemberType<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002068 Builder: &DIBuilder<'a>,
2069 Scope: &'a DIScope,
2070 Name: *const c_char,
2071 NameLen: size_t,
2072 File: &'a DIFile,
2073 LineNumber: c_uint,
2074 SizeInBits: u64,
2075 AlignInBits: u32,
2076 OffsetInBits: u64,
2077 Discriminant: Option<&'a Value>,
2078 Flags: DIFlags,
2079 Ty: &'a DIType,
2080 ) -> &'a DIType;
2081
Charisee7878d542022-02-24 18:21:36 +00002082 pub fn LLVMRustDIBuilderCreateLexicalBlock<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002083 Builder: &DIBuilder<'a>,
2084 Scope: &'a DIScope,
2085 File: &'a DIFile,
2086 Line: c_uint,
2087 Col: c_uint,
2088 ) -> &'a DILexicalBlock;
2089
Charisee7878d542022-02-24 18:21:36 +00002090 pub fn LLVMRustDIBuilderCreateLexicalBlockFile<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002091 Builder: &DIBuilder<'a>,
2092 Scope: &'a DIScope,
2093 File: &'a DIFile,
2094 ) -> &'a DILexicalBlock;
2095
Charisee7878d542022-02-24 18:21:36 +00002096 pub fn LLVMRustDIBuilderCreateStaticVariable<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002097 Builder: &DIBuilder<'a>,
2098 Context: Option<&'a DIScope>,
2099 Name: *const c_char,
2100 NameLen: size_t,
2101 LinkageName: *const c_char,
2102 LinkageNameLen: size_t,
2103 File: &'a DIFile,
2104 LineNo: c_uint,
2105 Ty: &'a DIType,
2106 isLocalToUnit: bool,
2107 Val: &'a Value,
2108 Decl: Option<&'a DIDescriptor>,
2109 AlignInBits: u32,
2110 ) -> &'a DIGlobalVariableExpression;
2111
Charisee7878d542022-02-24 18:21:36 +00002112 pub fn LLVMRustDIBuilderCreateVariable<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002113 Builder: &DIBuilder<'a>,
2114 Tag: c_uint,
2115 Scope: &'a DIDescriptor,
2116 Name: *const c_char,
2117 NameLen: size_t,
2118 File: &'a DIFile,
2119 LineNo: c_uint,
2120 Ty: &'a DIType,
2121 AlwaysPreserve: bool,
2122 Flags: DIFlags,
2123 ArgNo: c_uint,
2124 AlignInBits: u32,
2125 ) -> &'a DIVariable;
2126
Charisee7878d542022-02-24 18:21:36 +00002127 pub fn LLVMRustDIBuilderCreateArrayType<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002128 Builder: &DIBuilder<'a>,
2129 Size: u64,
2130 AlignInBits: u32,
2131 Ty: &'a DIType,
2132 Subscripts: &'a DIArray,
2133 ) -> &'a DIType;
2134
Charisee7878d542022-02-24 18:21:36 +00002135 pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002136 Builder: &DIBuilder<'a>,
2137 Lo: i64,
2138 Count: i64,
2139 ) -> &'a DISubrange;
2140
Charisee7878d542022-02-24 18:21:36 +00002141 pub fn LLVMRustDIBuilderGetOrCreateArray<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002142 Builder: &DIBuilder<'a>,
2143 Ptr: *const Option<&'a DIDescriptor>,
2144 Count: c_uint,
2145 ) -> &'a DIArray;
2146
Charisee7878d542022-02-24 18:21:36 +00002147 pub fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002148 Builder: &DIBuilder<'a>,
2149 Val: &'a Value,
2150 VarInfo: &'a DIVariable,
Charisee7878d542022-02-24 18:21:36 +00002151 AddrOps: *const u64,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002152 AddrOpsCount: c_uint,
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +01002153 DL: &'a DILocation,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002154 InsertAtEnd: &'a BasicBlock,
2155 ) -> &'a Value;
2156
Charisee7878d542022-02-24 18:21:36 +00002157 pub fn LLVMRustDIBuilderCreateEnumerator<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002158 Builder: &DIBuilder<'a>,
2159 Name: *const c_char,
2160 NameLen: size_t,
2161 Value: i64,
2162 IsUnsigned: bool,
2163 ) -> &'a DIEnumerator;
2164
Charisee7878d542022-02-24 18:21:36 +00002165 pub fn LLVMRustDIBuilderCreateEnumerationType<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002166 Builder: &DIBuilder<'a>,
2167 Scope: &'a DIScope,
2168 Name: *const c_char,
2169 NameLen: size_t,
2170 File: &'a DIFile,
2171 LineNumber: c_uint,
2172 SizeInBits: u64,
2173 AlignInBits: u32,
2174 Elements: &'a DIArray,
2175 ClassType: &'a DIType,
2176 IsScoped: bool,
2177 ) -> &'a DIType;
2178
Charisee7878d542022-02-24 18:21:36 +00002179 pub fn LLVMRustDIBuilderCreateUnionType<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002180 Builder: &DIBuilder<'a>,
Chris Wailes2f3fdfe2021-07-29 10:56:18 -07002181 Scope: Option<&'a DIScope>,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002182 Name: *const c_char,
2183 NameLen: size_t,
2184 File: &'a DIFile,
2185 LineNumber: c_uint,
2186 SizeInBits: u64,
2187 AlignInBits: u32,
2188 Flags: DIFlags,
2189 Elements: Option<&'a DIArray>,
2190 RunTimeLang: c_uint,
2191 UniqueId: *const c_char,
2192 UniqueIdLen: size_t,
2193 ) -> &'a DIType;
2194
Charisee7878d542022-02-24 18:21:36 +00002195 pub fn LLVMRustDIBuilderCreateVariantPart<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002196 Builder: &DIBuilder<'a>,
2197 Scope: &'a DIScope,
2198 Name: *const c_char,
2199 NameLen: size_t,
2200 File: &'a DIFile,
2201 LineNo: c_uint,
2202 SizeInBits: u64,
2203 AlignInBits: u32,
2204 Flags: DIFlags,
2205 Discriminator: Option<&'a DIDerivedType>,
2206 Elements: &'a DIArray,
2207 UniqueId: *const c_char,
2208 UniqueIdLen: size_t,
2209 ) -> &'a DIDerivedType;
2210
2211 pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
2212
Charisee7878d542022-02-24 18:21:36 +00002213 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002214 Builder: &DIBuilder<'a>,
2215 Scope: Option<&'a DIScope>,
2216 Name: *const c_char,
2217 NameLen: size_t,
2218 Ty: &'a DIType,
2219 ) -> &'a DITemplateTypeParameter;
2220
Charisee7878d542022-02-24 18:21:36 +00002221 pub fn LLVMRustDIBuilderCreateNameSpace<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002222 Builder: &DIBuilder<'a>,
2223 Scope: Option<&'a DIScope>,
2224 Name: *const c_char,
2225 NameLen: size_t,
2226 ExportSymbols: bool,
2227 ) -> &'a DINameSpace;
2228
Charisee7878d542022-02-24 18:21:36 +00002229 pub fn LLVMRustDICompositeTypeReplaceArrays<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002230 Builder: &DIBuilder<'a>,
2231 CompositeType: &'a DIType,
2232 Elements: Option<&'a DIArray>,
2233 Params: Option<&'a DIArray>,
2234 );
2235
Charisee7878d542022-02-24 18:21:36 +00002236 pub fn LLVMRustDIBuilderCreateDebugLocation<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002237 Line: c_uint,
2238 Column: c_uint,
2239 Scope: &'a DIScope,
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +01002240 InlinedAt: Option<&'a DILocation>,
2241 ) -> &'a DILocation;
Charisee7878d542022-02-24 18:21:36 +00002242 pub fn LLVMRustDIBuilderCreateOpDeref() -> u64;
2243 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002244
2245 #[allow(improper_ctypes)]
2246 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2247 #[allow(improper_ctypes)]
2248 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2249
2250 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2251
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002252 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
2253 pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
2254 pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2255 pub fn LLVMRustCreateMemorySanitizerPass(
2256 TrackOrigins: c_int,
2257 Recover: bool,
2258 ) -> &'static mut Pass;
2259 pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
Chris Wailese3116c42021-07-13 14:40:48 -07002260 pub fn LLVMRustCreateHWAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002261 pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
2262 pub fn LLVMRustAddLastExtensionPasses(
2263 PMB: &PassManagerBuilder,
2264 Passes: *const &'static mut Pass,
2265 NumPasses: size_t,
2266 );
2267
2268 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2269
2270 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
Chris Wailes32f78352021-07-20 14:04:55 -07002271 pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2272 pub fn LLVMRustGetTargetFeature(
2273 T: &TargetMachine,
2274 Index: size_t,
2275 Feature: &mut *const c_char,
2276 Desc: &mut *const c_char,
2277 );
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002278
2279 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2280 pub fn LLVMRustCreateTargetMachine(
2281 Triple: *const c_char,
2282 CPU: *const c_char,
2283 Features: *const c_char,
2284 Abi: *const c_char,
2285 Model: CodeModel,
2286 Reloc: RelocModel,
2287 Level: CodeGenOptLevel,
2288 UseSoftFP: bool,
2289 FunctionSections: bool,
2290 DataSections: bool,
Chris Wailes356b57e2022-01-13 10:08:24 -08002291 UniqueSectionNames: bool,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002292 TrapUnreachable: bool,
2293 Singlethread: bool,
2294 AsmComments: bool,
2295 EmitStackSizeSection: bool,
2296 RelaxELFRelocations: bool,
2297 UseInitArray: bool,
Jeff Vander Stoepd59a2872021-02-15 10:22:21 +01002298 SplitDwarfFile: *const c_char,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002299 ) -> Option<&'static mut TargetMachine>;
2300 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
Charisee7878d542022-02-24 18:21:36 +00002301 pub fn LLVMRustAddBuilderLibraryInfo<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002302 PMB: &'a PassManagerBuilder,
2303 M: &'a Module,
2304 DisableSimplifyLibCalls: bool,
2305 );
2306 pub fn LLVMRustConfigurePassManagerBuilder(
2307 PMB: &PassManagerBuilder,
2308 OptLevel: CodeGenOptLevel,
2309 MergeFunctions: bool,
2310 SLPVectorize: bool,
2311 LoopVectorize: bool,
2312 PrepareForThinLTO: bool,
2313 PGOGenPath: *const c_char,
2314 PGOUsePath: *const c_char,
Chris Wailesa1538422021-12-02 10:37:12 -08002315 PGOSampleUsePath: *const c_char,
Charisee9cf67802022-06-30 20:04:09 +00002316 SizeLevel: c_int,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002317 );
Charisee7878d542022-02-24 18:21:36 +00002318 pub fn LLVMRustAddLibraryInfo<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002319 PM: &PassManager<'a>,
2320 M: &'a Module,
2321 DisableSimplifyLibCalls: bool,
2322 );
Charisee7878d542022-02-24 18:21:36 +00002323 pub fn LLVMRustRunFunctionPassManager<'a>(PM: &PassManager<'a>, M: &'a Module);
2324 pub fn LLVMRustWriteOutputFile<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002325 T: &'a TargetMachine,
2326 PM: &PassManager<'a>,
2327 M: &'a Module,
2328 Output: *const c_char,
Jeff Vander Stoepd59a2872021-02-15 10:22:21 +01002329 DwoOutput: *const c_char,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002330 FileType: FileType,
2331 ) -> LLVMRustResult;
Charisee7878d542022-02-24 18:21:36 +00002332 pub fn LLVMRustOptimizeWithNewPassManager<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002333 M: &'a Module,
2334 TM: &'a TargetMachine,
2335 OptLevel: PassBuilderOptLevel,
2336 OptStage: OptStage,
2337 NoPrepopulatePasses: bool,
2338 VerifyIR: bool,
2339 UseThinLTOBuffers: bool,
2340 MergeFunctions: bool,
2341 UnrollLoops: bool,
2342 SLPVectorize: bool,
2343 LoopVectorize: bool,
2344 DisableSimplifyLibCalls: bool,
2345 EmitLifetimeMarkers: bool,
2346 SanitizerOptions: Option<&SanitizerOptions>,
2347 PGOGenPath: *const c_char,
2348 PGOUsePath: *const c_char,
Chris Wailes2f3fdfe2021-07-29 10:56:18 -07002349 InstrumentCoverage: bool,
2350 InstrumentGCOV: bool,
Chris Wailesa1538422021-12-02 10:37:12 -08002351 PGOSampleUsePath: *const c_char,
2352 DebugInfoForProfiling: bool,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002353 llvm_selfprofiler: *mut c_void,
2354 begin_callback: SelfProfileBeforePassCallback,
2355 end_callback: SelfProfileAfterPassCallback,
Chris Wailes2f3fdfe2021-07-29 10:56:18 -07002356 ExtraPasses: *const c_char,
2357 ExtraPassesLen: size_t,
Charisee7878d542022-02-24 18:21:36 +00002358 LLVMPlugins: *const c_char,
2359 LLVMPluginsLen: size_t,
Chris Wailes2f3fdfe2021-07-29 10:56:18 -07002360 ) -> LLVMRustResult;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002361 pub fn LLVMRustPrintModule(
Charisee7878d542022-02-24 18:21:36 +00002362 M: &Module,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002363 Output: *const c_char,
2364 Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2365 ) -> LLVMRustResult;
2366 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2367 pub fn LLVMRustPrintPasses();
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002368 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2369 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
2370 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002371
2372 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
Charisee7878d542022-02-24 18:21:36 +00002373 pub fn LLVMRustArchiveIteratorNew(AR: &Archive) -> &mut ArchiveIterator<'_>;
2374 pub fn LLVMRustArchiveIteratorNext<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002375 AIR: &ArchiveIterator<'a>,
2376 ) -> Option<&'a mut ArchiveChild<'a>>;
2377 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2378 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
Charisee7878d542022-02-24 18:21:36 +00002379 pub fn LLVMRustArchiveChildFree<'a>(ACR: &'a mut ArchiveChild<'a>);
2380 pub fn LLVMRustArchiveIteratorFree<'a>(AIR: &'a mut ArchiveIterator<'a>);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002381 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2382
2383 #[allow(improper_ctypes)]
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002384 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2385
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002386 #[allow(improper_ctypes)]
Charisee7878d542022-02-24 18:21:36 +00002387 pub fn LLVMRustUnpackOptimizationDiagnostic<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002388 DI: &'a DiagnosticInfo,
2389 pass_name_out: &RustString,
2390 function_out: &mut Option<&'a Value>,
2391 loc_line_out: &mut c_uint,
2392 loc_column_out: &mut c_uint,
2393 loc_filename_out: &RustString,
2394 message_out: &RustString,
2395 );
2396
Charisee7878d542022-02-24 18:21:36 +00002397 pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002398 DI: &'a DiagnosticInfo,
2399 level_out: &mut DiagnosticLevel,
2400 cookie_out: &mut c_uint,
2401 message_out: &mut Option<&'a Twine>,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002402 );
2403
2404 #[allow(improper_ctypes)]
2405 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2406 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2407
Charisee7878d542022-02-24 18:21:36 +00002408 pub fn LLVMRustGetSMDiagnostic<'a>(
Chris Wailesbcf972c2021-10-21 11:03:28 -07002409 DI: &'a DiagnosticInfo,
2410 cookie_out: &mut c_uint,
2411 ) -> &'a SMDiagnostic;
2412
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002413 pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2414 C: &Context,
Charisee7878d542022-02-24 18:21:36 +00002415 H: InlineAsmDiagHandlerTy,
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002416 CX: *mut c_void,
2417 );
2418
2419 #[allow(improper_ctypes)]
2420 pub fn LLVMRustUnpackSMDiagnostic(
2421 d: &SMDiagnostic,
2422 message_out: &RustString,
2423 buffer_out: &RustString,
2424 level_out: &mut DiagnosticLevel,
2425 loc_out: &mut c_uint,
2426 ranges_out: *mut c_uint,
2427 num_ranges: &mut usize,
2428 ) -> bool;
2429
2430 pub fn LLVMRustWriteArchive(
2431 Dst: *const c_char,
2432 NumMembers: size_t,
2433 Members: *const &RustArchiveMember<'_>,
2434 WriteSymbtab: bool,
2435 Kind: ArchiveKind,
2436 ) -> LLVMRustResult;
Charisee7878d542022-02-24 18:21:36 +00002437 pub fn LLVMRustArchiveMemberNew<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002438 Filename: *const c_char,
2439 Name: *const c_char,
2440 Child: Option<&ArchiveChild<'a>>,
2441 ) -> &'a mut RustArchiveMember<'a>;
Charisee7878d542022-02-24 18:21:36 +00002442 pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002443
Chris Wailes2f3fdfe2021-07-29 10:56:18 -07002444 pub fn LLVMRustWriteImportLibrary(
2445 ImportName: *const c_char,
2446 Path: *const c_char,
2447 Exports: *const LLVMRustCOFFShortExport,
2448 NumExports: usize,
2449 Machine: u16,
2450 MinGW: bool,
2451 ) -> LLVMRustResult;
2452
Charisee7878d542022-02-24 18:21:36 +00002453 pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002454
Charisee7878d542022-02-24 18:21:36 +00002455 pub fn LLVMRustBuildOperandBundleDef<'a>(
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002456 Name: *const c_char,
2457 Inputs: *const &'a Value,
2458 NumInputs: c_uint,
2459 ) -> &'a mut OperandBundleDef<'a>;
Charisee7878d542022-02-24 18:21:36 +00002460 pub fn LLVMRustFreeOperandBundleDef<'a>(Bundle: &'a mut OperandBundleDef<'a>);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002461
Charisee7878d542022-02-24 18:21:36 +00002462 pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002463
Charisee7878d542022-02-24 18:21:36 +00002464 pub fn LLVMRustSetComdat<'a>(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002465 pub fn LLVMRustSetModulePICLevel(M: &Module);
2466 pub fn LLVMRustSetModulePIELevel(M: &Module);
Chris Wailese3116c42021-07-13 14:40:48 -07002467 pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002468 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2469 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2470 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2471 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2472 pub fn LLVMRustModuleCost(M: &Module) -> u64;
2473
Chariseeb1d32802022-09-22 15:38:41 +00002474 pub fn LLVMRustThinLTOBufferCreate(M: &Module, is_thin: bool) -> &'static mut ThinLTOBuffer;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002475 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2476 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2477 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2478 pub fn LLVMRustCreateThinLTOData(
2479 Modules: *const ThinLTOModule,
2480 NumModules: c_uint,
2481 PreservedSymbols: *const *const c_char,
2482 PreservedSymbolsLen: c_uint,
2483 ) -> Option<&'static mut ThinLTOData>;
2484 pub fn LLVMRustPrepareThinLTORename(
2485 Data: &ThinLTOData,
2486 Module: &Module,
2487 Target: &TargetMachine,
2488 ) -> bool;
2489 pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2490 pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2491 pub fn LLVMRustPrepareThinLTOImport(
2492 Data: &ThinLTOData,
2493 Module: &Module,
2494 Target: &TargetMachine,
2495 ) -> bool;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002496 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2497 pub fn LLVMRustParseBitcodeForLTO(
2498 Context: &Context,
2499 Data: *const u8,
2500 len: usize,
2501 Identifier: *const c_char,
2502 ) -> Option<&Module>;
2503 pub fn LLVMRustGetBitcodeSliceFromObjectData(
2504 Data: *const u8,
2505 len: usize,
2506 out_len: &mut usize,
2507 ) -> *const u8;
Chariseeb1d32802022-09-22 15:38:41 +00002508 pub fn LLVMRustThinLTOGetDICompileUnit(
2509 M: &Module,
2510 CU1: &mut *mut c_void,
2511 CU2: &mut *mut c_void,
2512 );
2513 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002514
Charisee7878d542022-02-24 18:21:36 +00002515 pub fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002516 pub fn LLVMRustLinkerAdd(
2517 linker: &Linker<'_>,
2518 bytecode: *const c_char,
2519 bytecode_len: usize,
2520 ) -> bool;
Charisee7878d542022-02-24 18:21:36 +00002521 pub fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>);
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +01002522 #[allow(improper_ctypes)]
2523 pub fn LLVMRustComputeLTOCacheKey(
2524 key_out: &RustString,
2525 mod_id: *const c_char,
2526 data: &ThinLTOData,
2527 );
Charisee7878d542022-02-24 18:21:36 +00002528
2529 pub fn LLVMRustContextGetDiagnosticHandler(Context: &Context) -> Option<&DiagnosticHandler>;
2530 pub fn LLVMRustContextSetDiagnosticHandler(
2531 context: &Context,
2532 diagnostic_handler: Option<&DiagnosticHandler>,
2533 );
2534 pub fn LLVMRustContextConfigureDiagnosticHandler(
2535 context: &Context,
2536 diagnostic_handler_callback: DiagnosticHandlerTy,
2537 diagnostic_handler_context: *mut c_void,
2538 remark_all_passes: bool,
2539 remark_passes: *const *const c_char,
2540 remark_passes_len: usize,
2541 );
2542
Charisee9cf67802022-06-30 20:04:09 +00002543 #[allow(improper_ctypes)]
2544 pub fn LLVMRustGetMangledName(V: &Value, out: &RustString);
Chariseeb1d32802022-09-22 15:38:41 +00002545
2546 pub fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32;
Thiébaud Weksteen3b664ca2020-11-26 14:41:59 +01002547}