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