]> git.proxmox.com Git - rustc.git/blob - src/librustc_llvm/lib.rs
Imported Upstream version 1.8.0+dfsg1
[rustc.git] / src / librustc_llvm / lib.rs
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(non_upper_case_globals)]
12 #![allow(non_camel_case_types)]
13 #![allow(non_snake_case)]
14 #![allow(dead_code)]
15
16 #![crate_name = "rustc_llvm"]
17 #![unstable(feature = "rustc_private", issue = "27812")]
18 #![crate_type = "dylib"]
19 #![crate_type = "rlib"]
20 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
21 html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
22 html_root_url = "https://doc.rust-lang.org/nightly/")]
23 #![cfg_attr(not(stage0), deny(warnings))]
24
25 #![feature(associated_consts)]
26 #![feature(box_syntax)]
27 #![feature(libc)]
28 #![feature(link_args)]
29 #![feature(staged_api)]
30 #![feature(linked_from)]
31 #![feature(concat_idents)]
32
33 extern crate libc;
34 #[macro_use] #[no_link] extern crate rustc_bitflags;
35
36 pub use self::OtherAttribute::*;
37 pub use self::SpecialAttribute::*;
38 pub use self::AttributeSet::*;
39 pub use self::IntPredicate::*;
40 pub use self::RealPredicate::*;
41 pub use self::TypeKind::*;
42 pub use self::AtomicBinOp::*;
43 pub use self::AtomicOrdering::*;
44 pub use self::SynchronizationScope::*;
45 pub use self::FileType::*;
46 pub use self::MetadataType::*;
47 pub use self::AsmDialect::*;
48 pub use self::CodeGenOptLevel::*;
49 pub use self::RelocMode::*;
50 pub use self::CodeGenModel::*;
51 pub use self::DiagnosticKind::*;
52 pub use self::CallConv::*;
53 pub use self::Visibility::*;
54 pub use self::DiagnosticSeverity::*;
55 pub use self::Linkage::*;
56 pub use self::DLLStorageClassTypes::*;
57
58 use std::ffi::{CString, CStr};
59 use std::cell::RefCell;
60 use std::slice;
61 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
62 use libc::{c_longlong, c_ulonglong, c_void};
63 use debuginfo::{DIBuilderRef, DIDescriptor,
64 DIFile, DILexicalBlock, DISubprogram, DIType,
65 DIBasicType, DIDerivedType, DICompositeType, DIScope,
66 DIVariable, DIGlobalVariable, DIArray, DISubrange,
67 DITemplateTypeParameter, DIEnumerator, DINameSpace};
68
69 pub mod archive_ro;
70 pub mod diagnostic;
71
72 pub type Opcode = u32;
73 pub type Bool = c_uint;
74
75 pub const True: Bool = 1 as Bool;
76 pub const False: Bool = 0 as Bool;
77
78 // Consts for the LLVM CallConv type, pre-cast to usize.
79
80 #[derive(Copy, Clone, PartialEq)]
81 pub enum CallConv {
82 CCallConv = 0,
83 FastCallConv = 8,
84 ColdCallConv = 9,
85 X86StdcallCallConv = 64,
86 X86FastcallCallConv = 65,
87 X86_64_Win64 = 79,
88 X86_VectorCall = 80
89 }
90
91 #[derive(Copy, Clone)]
92 pub enum Visibility {
93 LLVMDefaultVisibility = 0,
94 HiddenVisibility = 1,
95 ProtectedVisibility = 2,
96 }
97
98 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
99 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
100 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
101 // they've been removed in upstream LLVM commit r203866.
102 #[derive(Copy, Clone)]
103 pub enum Linkage {
104 ExternalLinkage = 0,
105 AvailableExternallyLinkage = 1,
106 LinkOnceAnyLinkage = 2,
107 LinkOnceODRLinkage = 3,
108 WeakAnyLinkage = 5,
109 WeakODRLinkage = 6,
110 AppendingLinkage = 7,
111 InternalLinkage = 8,
112 PrivateLinkage = 9,
113 ExternalWeakLinkage = 12,
114 CommonLinkage = 14,
115 }
116
117 #[repr(C)]
118 #[derive(Copy, Clone, Debug)]
119 pub enum DiagnosticSeverity {
120 Error,
121 Warning,
122 Remark,
123 Note,
124 }
125
126
127 #[repr(C)]
128 #[derive(Copy, Clone)]
129 pub enum DLLStorageClassTypes {
130 DefaultStorageClass = 0,
131 DLLImportStorageClass = 1,
132 DLLExportStorageClass = 2,
133 }
134
135 bitflags! {
136 flags Attribute : u64 {
137 const ZExt = 1 << 0,
138 const SExt = 1 << 1,
139 const NoReturn = 1 << 2,
140 const InReg = 1 << 3,
141 const StructRet = 1 << 4,
142 const NoUnwind = 1 << 5,
143 const NoAlias = 1 << 6,
144 const ByVal = 1 << 7,
145 const Nest = 1 << 8,
146 const ReadNone = 1 << 9,
147 const ReadOnly = 1 << 10,
148 const NoInline = 1 << 11,
149 const AlwaysInline = 1 << 12,
150 const OptimizeForSize = 1 << 13,
151 const StackProtect = 1 << 14,
152 const StackProtectReq = 1 << 15,
153 const Alignment = 1 << 16,
154 const NoCapture = 1 << 21,
155 const NoRedZone = 1 << 22,
156 const NoImplicitFloat = 1 << 23,
157 const Naked = 1 << 24,
158 const InlineHint = 1 << 25,
159 const Stack = 7 << 26,
160 const ReturnsTwice = 1 << 29,
161 const UWTable = 1 << 30,
162 const NonLazyBind = 1 << 31,
163 const OptimizeNone = 1 << 42,
164 }
165 }
166
167
168 #[repr(u64)]
169 #[derive(Copy, Clone)]
170 pub enum OtherAttribute {
171 // The following are not really exposed in
172 // the LLVM C api so instead to add these
173 // we call a wrapper function in RustWrapper
174 // that uses the C++ api.
175 SanitizeAddressAttribute = 1 << 32,
176 MinSizeAttribute = 1 << 33,
177 NoDuplicateAttribute = 1 << 34,
178 StackProtectStrongAttribute = 1 << 35,
179 SanitizeThreadAttribute = 1 << 36,
180 SanitizeMemoryAttribute = 1 << 37,
181 NoBuiltinAttribute = 1 << 38,
182 ReturnedAttribute = 1 << 39,
183 ColdAttribute = 1 << 40,
184 BuiltinAttribute = 1 << 41,
185 OptimizeNoneAttribute = 1 << 42,
186 InAllocaAttribute = 1 << 43,
187 NonNullAttribute = 1 << 44,
188 }
189
190 #[derive(Copy, Clone)]
191 pub enum SpecialAttribute {
192 DereferenceableAttribute(u64)
193 }
194
195 #[repr(C)]
196 #[derive(Copy, Clone)]
197 pub enum AttributeSet {
198 ReturnIndex = 0,
199 FunctionIndex = !0
200 }
201
202 pub trait AttrHelper {
203 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
204 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
205 }
206
207 impl AttrHelper for Attribute {
208 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
209 unsafe {
210 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
211 }
212 }
213
214 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
215 unsafe {
216 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
217 }
218 }
219 }
220
221 impl AttrHelper for OtherAttribute {
222 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
223 unsafe {
224 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
225 }
226 }
227
228 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
229 unsafe {
230 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
231 }
232 }
233 }
234
235 impl AttrHelper for SpecialAttribute {
236 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
237 match *self {
238 DereferenceableAttribute(bytes) => unsafe {
239 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
240 }
241 }
242 }
243
244 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
245 match *self {
246 DereferenceableAttribute(bytes) => unsafe {
247 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
248 }
249 }
250 }
251 }
252
253 pub struct AttrBuilder {
254 attrs: Vec<(usize, Box<AttrHelper+'static>)>
255 }
256
257 impl AttrBuilder {
258 pub fn new() -> AttrBuilder {
259 AttrBuilder {
260 attrs: Vec::new()
261 }
262 }
263
264 pub fn arg<T: AttrHelper + 'static>(&mut self, idx: usize, a: T) -> &mut AttrBuilder {
265 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
266 self
267 }
268
269 pub fn ret<T: AttrHelper + 'static>(&mut self, a: T) -> &mut AttrBuilder {
270 self.attrs.push((ReturnIndex as usize, box a as Box<AttrHelper+'static>));
271 self
272 }
273
274 pub fn apply_llfn(&self, llfn: ValueRef) {
275 for &(idx, ref attr) in &self.attrs {
276 attr.apply_llfn(idx as c_uint, llfn);
277 }
278 }
279
280 pub fn apply_callsite(&self, callsite: ValueRef) {
281 for &(idx, ref attr) in &self.attrs {
282 attr.apply_callsite(idx as c_uint, callsite);
283 }
284 }
285 }
286
287 // enum for the LLVM IntPredicate type
288 #[derive(Copy, Clone)]
289 pub enum IntPredicate {
290 IntEQ = 32,
291 IntNE = 33,
292 IntUGT = 34,
293 IntUGE = 35,
294 IntULT = 36,
295 IntULE = 37,
296 IntSGT = 38,
297 IntSGE = 39,
298 IntSLT = 40,
299 IntSLE = 41,
300 }
301
302 // enum for the LLVM RealPredicate type
303 #[derive(Copy, Clone)]
304 pub enum RealPredicate {
305 RealPredicateFalse = 0,
306 RealOEQ = 1,
307 RealOGT = 2,
308 RealOGE = 3,
309 RealOLT = 4,
310 RealOLE = 5,
311 RealONE = 6,
312 RealORD = 7,
313 RealUNO = 8,
314 RealUEQ = 9,
315 RealUGT = 10,
316 RealUGE = 11,
317 RealULT = 12,
318 RealULE = 13,
319 RealUNE = 14,
320 RealPredicateTrue = 15,
321 }
322
323 // The LLVM TypeKind type - must stay in sync with the def of
324 // LLVMTypeKind in llvm/include/llvm-c/Core.h
325 #[derive(Copy, Clone, PartialEq, Debug)]
326 #[repr(C)]
327 pub enum TypeKind {
328 Void = 0,
329 Half = 1,
330 Float = 2,
331 Double = 3,
332 X86_FP80 = 4,
333 FP128 = 5,
334 PPC_FP128 = 6,
335 Label = 7,
336 Integer = 8,
337 Function = 9,
338 Struct = 10,
339 Array = 11,
340 Pointer = 12,
341 Vector = 13,
342 Metadata = 14,
343 X86_MMX = 15,
344 }
345
346 #[repr(C)]
347 #[derive(Copy, Clone)]
348 pub enum AtomicBinOp {
349 AtomicXchg = 0,
350 AtomicAdd = 1,
351 AtomicSub = 2,
352 AtomicAnd = 3,
353 AtomicNand = 4,
354 AtomicOr = 5,
355 AtomicXor = 6,
356 AtomicMax = 7,
357 AtomicMin = 8,
358 AtomicUMax = 9,
359 AtomicUMin = 10,
360 }
361
362 #[repr(C)]
363 #[derive(Copy, Clone)]
364 pub enum AtomicOrdering {
365 NotAtomic = 0,
366 Unordered = 1,
367 Monotonic = 2,
368 // Consume = 3, // Not specified yet.
369 Acquire = 4,
370 Release = 5,
371 AcquireRelease = 6,
372 SequentiallyConsistent = 7
373 }
374
375 #[repr(C)]
376 #[derive(Copy, Clone)]
377 pub enum SynchronizationScope {
378 SingleThread = 0,
379 CrossThread = 1
380 }
381
382 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
383 #[repr(C)]
384 #[derive(Copy, Clone)]
385 pub enum FileType {
386 AssemblyFileType = 0,
387 ObjectFileType = 1
388 }
389
390 #[derive(Copy, Clone)]
391 pub enum MetadataType {
392 MD_dbg = 0,
393 MD_tbaa = 1,
394 MD_prof = 2,
395 MD_fpmath = 3,
396 MD_range = 4,
397 MD_tbaa_struct = 5,
398 MD_invariant_load = 6,
399 MD_alias_scope = 7,
400 MD_noalias = 8,
401 MD_nontemporal = 9,
402 MD_mem_parallel_loop_access = 10,
403 MD_nonnull = 11,
404 }
405
406 // Inline Asm Dialect
407 #[derive(Copy, Clone)]
408 pub enum AsmDialect {
409 AD_ATT = 0,
410 AD_Intel = 1
411 }
412
413 #[derive(Copy, Clone, PartialEq)]
414 #[repr(C)]
415 pub enum CodeGenOptLevel {
416 CodeGenLevelNone = 0,
417 CodeGenLevelLess = 1,
418 CodeGenLevelDefault = 2,
419 CodeGenLevelAggressive = 3,
420 }
421
422 #[derive(Copy, Clone, PartialEq)]
423 #[repr(C)]
424 pub enum RelocMode {
425 RelocDefault = 0,
426 RelocStatic = 1,
427 RelocPIC = 2,
428 RelocDynamicNoPic = 3,
429 }
430
431 #[repr(C)]
432 #[derive(Copy, Clone)]
433 pub enum CodeGenModel {
434 CodeModelDefault = 0,
435 CodeModelJITDefault = 1,
436 CodeModelSmall = 2,
437 CodeModelKernel = 3,
438 CodeModelMedium = 4,
439 CodeModelLarge = 5,
440 }
441
442 #[repr(C)]
443 #[derive(Copy, Clone)]
444 pub enum DiagnosticKind {
445 DK_InlineAsm = 0,
446 DK_StackSize,
447 DK_DebugMetadataVersion,
448 DK_SampleProfile,
449 DK_OptimizationRemark,
450 DK_OptimizationRemarkMissed,
451 DK_OptimizationRemarkAnalysis,
452 DK_OptimizationFailure,
453 }
454
455 #[repr(C)]
456 #[derive(Copy, Clone)]
457 pub enum ArchiveKind {
458 K_GNU,
459 K_MIPS64,
460 K_BSD,
461 K_COFF,
462 }
463
464 /// Represents the different LLVM passes Rust supports
465 #[derive(Copy, Clone, PartialEq, Debug)]
466 #[repr(C)]
467 pub enum SupportedPassKind {
468 Function,
469 Module,
470 Unsupported,
471 }
472
473 // Opaque pointer types
474 #[allow(missing_copy_implementations)]
475 pub enum Module_opaque {}
476 pub type ModuleRef = *mut Module_opaque;
477 #[allow(missing_copy_implementations)]
478 pub enum Context_opaque {}
479 pub type ContextRef = *mut Context_opaque;
480 #[allow(missing_copy_implementations)]
481 pub enum Type_opaque {}
482 pub type TypeRef = *mut Type_opaque;
483 #[allow(missing_copy_implementations)]
484 pub enum Value_opaque {}
485 pub type ValueRef = *mut Value_opaque;
486 #[allow(missing_copy_implementations)]
487 pub enum Metadata_opaque {}
488 pub type MetadataRef = *mut Metadata_opaque;
489 #[allow(missing_copy_implementations)]
490 pub enum BasicBlock_opaque {}
491 pub type BasicBlockRef = *mut BasicBlock_opaque;
492 #[allow(missing_copy_implementations)]
493 pub enum Builder_opaque {}
494 pub type BuilderRef = *mut Builder_opaque;
495 #[allow(missing_copy_implementations)]
496 pub enum ExecutionEngine_opaque {}
497 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
498 #[allow(missing_copy_implementations)]
499 pub enum MemoryBuffer_opaque {}
500 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
501 #[allow(missing_copy_implementations)]
502 pub enum PassManager_opaque {}
503 pub type PassManagerRef = *mut PassManager_opaque;
504 #[allow(missing_copy_implementations)]
505 pub enum PassManagerBuilder_opaque {}
506 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
507 #[allow(missing_copy_implementations)]
508 pub enum Use_opaque {}
509 pub type UseRef = *mut Use_opaque;
510 #[allow(missing_copy_implementations)]
511 pub enum TargetData_opaque {}
512 pub type TargetDataRef = *mut TargetData_opaque;
513 #[allow(missing_copy_implementations)]
514 pub enum ObjectFile_opaque {}
515 pub type ObjectFileRef = *mut ObjectFile_opaque;
516 #[allow(missing_copy_implementations)]
517 pub enum SectionIterator_opaque {}
518 pub type SectionIteratorRef = *mut SectionIterator_opaque;
519 #[allow(missing_copy_implementations)]
520 pub enum Pass_opaque {}
521 pub type PassRef = *mut Pass_opaque;
522 #[allow(missing_copy_implementations)]
523 pub enum TargetMachine_opaque {}
524 pub type TargetMachineRef = *mut TargetMachine_opaque;
525 pub enum Archive_opaque {}
526 pub type ArchiveRef = *mut Archive_opaque;
527 pub enum ArchiveIterator_opaque {}
528 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
529 pub enum ArchiveChild_opaque {}
530 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
531 #[allow(missing_copy_implementations)]
532 pub enum Twine_opaque {}
533 pub type TwineRef = *mut Twine_opaque;
534 #[allow(missing_copy_implementations)]
535 pub enum DiagnosticInfo_opaque {}
536 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
537 #[allow(missing_copy_implementations)]
538 pub enum DebugLoc_opaque {}
539 pub type DebugLocRef = *mut DebugLoc_opaque;
540 #[allow(missing_copy_implementations)]
541 pub enum SMDiagnostic_opaque {}
542 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
543 #[allow(missing_copy_implementations)]
544 pub enum RustArchiveMember_opaque {}
545 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
546 #[allow(missing_copy_implementations)]
547 pub enum OperandBundleDef_opaque {}
548 pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
549
550 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
551 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
552
553 pub mod debuginfo {
554 pub use self::DIDescriptorFlags::*;
555 use super::{MetadataRef};
556
557 #[allow(missing_copy_implementations)]
558 pub enum DIBuilder_opaque {}
559 pub type DIBuilderRef = *mut DIBuilder_opaque;
560
561 pub type DIDescriptor = MetadataRef;
562 pub type DIScope = DIDescriptor;
563 pub type DILocation = DIDescriptor;
564 pub type DIFile = DIScope;
565 pub type DILexicalBlock = DIScope;
566 pub type DISubprogram = DIScope;
567 pub type DINameSpace = DIScope;
568 pub type DIType = DIDescriptor;
569 pub type DIBasicType = DIType;
570 pub type DIDerivedType = DIType;
571 pub type DICompositeType = DIDerivedType;
572 pub type DIVariable = DIDescriptor;
573 pub type DIGlobalVariable = DIDescriptor;
574 pub type DIArray = DIDescriptor;
575 pub type DISubrange = DIDescriptor;
576 pub type DIEnumerator = DIDescriptor;
577 pub type DITemplateTypeParameter = DIDescriptor;
578
579 #[derive(Copy, Clone)]
580 pub enum DIDescriptorFlags {
581 FlagPrivate = 1 << 0,
582 FlagProtected = 1 << 1,
583 FlagFwdDecl = 1 << 2,
584 FlagAppleBlock = 1 << 3,
585 FlagBlockByrefStruct = 1 << 4,
586 FlagVirtual = 1 << 5,
587 FlagArtificial = 1 << 6,
588 FlagExplicit = 1 << 7,
589 FlagPrototyped = 1 << 8,
590 FlagObjcClassComplete = 1 << 9,
591 FlagObjectPointer = 1 << 10,
592 FlagVector = 1 << 11,
593 FlagStaticMember = 1 << 12,
594 FlagIndirectVariable = 1 << 13,
595 FlagLValueReference = 1 << 14,
596 FlagRValueReference = 1 << 15
597 }
598 }
599
600
601 // Link to our native llvm bindings (things that we need to use the C++ api
602 // for) and because llvm is written in C++ we need to link against libstdc++
603 //
604 // You'll probably notice that there is an omission of all LLVM libraries
605 // from this location. This is because the set of LLVM libraries that we
606 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
607 // figure out the exact set of libraries. To do this, the build system
608 // generates an llvmdeps.rs file next to this one which will be
609 // automatically updated whenever LLVM is updated to include an up-to-date
610 // set of the libraries we need to link to LLVM for.
611 #[link(name = "rustllvm", kind = "static")]
612 #[cfg(not(cargobuild))]
613 extern {}
614
615 #[linked_from = "rustllvm"] // not quite true but good enough
616 extern {
617 /* Create and destroy contexts. */
618 pub fn LLVMContextCreate() -> ContextRef;
619 pub fn LLVMContextDispose(C: ContextRef);
620 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
621 Name: *const c_char,
622 SLen: c_uint)
623 -> c_uint;
624
625 /* Create and destroy modules. */
626 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
627 C: ContextRef)
628 -> ModuleRef;
629 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
630 pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
631 pub fn LLVMDisposeModule(M: ModuleRef);
632
633 /// Data layout. See Module::getDataLayout.
634 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
635 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
636
637 /// Target triple. See Module::getTargetTriple.
638 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
639 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
640
641 /// See Module::dump.
642 pub fn LLVMDumpModule(M: ModuleRef);
643
644 /// See Module::setModuleInlineAsm.
645 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
646
647 /// See llvm::LLVMTypeKind::getTypeID.
648 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
649
650 /// See llvm::LLVMType::getContext.
651 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
652
653 /* Operations on integer types */
654 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
655 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
656 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
657 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
658 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
659 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
660 -> TypeRef;
661
662 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
663
664 /* Operations on real types */
665 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
666 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
667 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
668 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
669 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
670
671 /* Operations on function types */
672 pub fn LLVMFunctionType(ReturnType: TypeRef,
673 ParamTypes: *const TypeRef,
674 ParamCount: c_uint,
675 IsVarArg: Bool)
676 -> TypeRef;
677 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
678 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
679 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
680 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
681
682 /* Operations on struct types */
683 pub fn LLVMStructTypeInContext(C: ContextRef,
684 ElementTypes: *const TypeRef,
685 ElementCount: c_uint,
686 Packed: Bool)
687 -> TypeRef;
688 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
689 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
690 Dest: *mut TypeRef);
691 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
692
693 /* Operations on array, pointer, and vector types (sequence types) */
694 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
695 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
696 -> TypeRef;
697 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
698 -> TypeRef;
699
700 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
701 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
702 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
703 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
704 -> *const c_void;
705 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
706
707 /* Operations on other types */
708 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
709 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
710 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
711
712 /* Operations on all values */
713 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
714 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
715 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
716 pub fn LLVMDumpValue(Val: ValueRef);
717 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
718 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
719 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
720 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
721
722 /* Operations on Uses */
723 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
724 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
725 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
726 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
727
728 /* Operations on Users */
729 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
730 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
731 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
732
733 /* Operations on constants of any type */
734 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
735 /* all zeroes */
736 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
737 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
738 -> ValueRef;
739 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
740 -> ValueRef;
741 /* only for isize/vector */
742 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
743 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
744 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
745 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
746 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
747
748 /* Operations on metadata */
749 pub fn LLVMMDStringInContext(C: ContextRef,
750 Str: *const c_char,
751 SLen: c_uint)
752 -> ValueRef;
753 pub fn LLVMMDNodeInContext(C: ContextRef,
754 Vals: *const ValueRef,
755 Count: c_uint)
756 -> ValueRef;
757 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
758 Str: *const c_char,
759 Val: ValueRef);
760
761 /* Operations on scalar constants */
762 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
763 -> ValueRef;
764 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
765 -> ValueRef;
766 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
767 Text: *const c_char,
768 SLen: c_uint,
769 Radix: u8)
770 -> ValueRef;
771 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
772 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
773 -> ValueRef;
774 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
775 Text: *const c_char,
776 SLen: c_uint)
777 -> ValueRef;
778 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
779 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
780
781
782 /* Operations on composite constants */
783 pub fn LLVMConstStringInContext(C: ContextRef,
784 Str: *const c_char,
785 Length: c_uint,
786 DontNullTerminate: Bool)
787 -> ValueRef;
788 pub fn LLVMConstStructInContext(C: ContextRef,
789 ConstantVals: *const ValueRef,
790 Count: c_uint,
791 Packed: Bool)
792 -> ValueRef;
793
794 pub fn LLVMConstArray(ElementTy: TypeRef,
795 ConstantVals: *const ValueRef,
796 Length: c_uint)
797 -> ValueRef;
798 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
799 -> ValueRef;
800
801 /* Constant expressions */
802 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
803 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
804 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
805 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
806 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
807 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
808 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
809 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
810 -> ValueRef;
811 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
812 -> ValueRef;
813 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
814 -> ValueRef;
815 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
816 -> ValueRef;
817 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
818 -> ValueRef;
819 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
820 -> ValueRef;
821 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
822 -> ValueRef;
823 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
824 -> ValueRef;
825 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
826 -> ValueRef;
827 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
828 -> ValueRef;
829 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
830 -> ValueRef;
831 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
832 -> ValueRef;
833 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
834 -> ValueRef;
835 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
836 -> ValueRef;
837 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
838 RHSConstant: ValueRef)
839 -> ValueRef;
840 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
841 -> ValueRef;
842 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
843 -> ValueRef;
844 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
845 -> ValueRef;
846 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
847 -> ValueRef;
848 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
849 -> ValueRef;
850 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
851 -> ValueRef;
852 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
853 -> ValueRef;
854 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
855 -> ValueRef;
856 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
857 -> ValueRef;
858 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
859 -> ValueRef;
860 pub fn LLVMConstGEP(ConstantVal: ValueRef,
861 ConstantIndices: *const ValueRef,
862 NumIndices: c_uint)
863 -> ValueRef;
864 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
865 ConstantIndices: *const ValueRef,
866 NumIndices: c_uint)
867 -> ValueRef;
868 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
869 -> ValueRef;
870 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
871 -> ValueRef;
872 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
873 -> ValueRef;
874 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
875 -> ValueRef;
876 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
877 -> ValueRef;
878 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
879 -> ValueRef;
880 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
881 -> ValueRef;
882 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
883 -> ValueRef;
884 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
885 -> ValueRef;
886 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
887 -> ValueRef;
888 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
889 -> ValueRef;
890 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
891 -> ValueRef;
892 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
893 -> ValueRef;
894 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
895 -> ValueRef;
896 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
897 -> ValueRef;
898 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
899 -> ValueRef;
900 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
901 ToType: TypeRef,
902 isSigned: Bool)
903 -> ValueRef;
904 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
905 -> ValueRef;
906 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
907 ConstantIfTrue: ValueRef,
908 ConstantIfFalse: ValueRef)
909 -> ValueRef;
910 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
911 IndexConstant: ValueRef)
912 -> ValueRef;
913 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
914 ElementValueConstant: ValueRef,
915 IndexConstant: ValueRef)
916 -> ValueRef;
917 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
918 VectorBConstant: ValueRef,
919 MaskConstant: ValueRef)
920 -> ValueRef;
921 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
922 IdxList: *const c_uint,
923 NumIdx: c_uint)
924 -> ValueRef;
925 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
926 ElementValueConstant: ValueRef,
927 IdxList: *const c_uint,
928 NumIdx: c_uint)
929 -> ValueRef;
930 pub fn LLVMConstInlineAsm(Ty: TypeRef,
931 AsmString: *const c_char,
932 Constraints: *const c_char,
933 HasSideEffects: Bool,
934 IsAlignStack: Bool)
935 -> ValueRef;
936 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
937
938
939
940 /* Operations on global variables, functions, and aliases (globals) */
941 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
942 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
943 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
944 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
945 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
946 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
947 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
948 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
949 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
950 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
951
952
953 /* Operations on global variables */
954 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
955 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
956 -> ValueRef;
957 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
958 Ty: TypeRef,
959 Name: *const c_char,
960 AddressSpace: c_uint)
961 -> ValueRef;
962 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
963 pub fn LLVMGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
964 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
965 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
966 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
967 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
968 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
969 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
970 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
971 ConstantVal: ValueRef);
972 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
973 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
974 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
975 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
976 pub fn LLVMGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
977
978 /* Operations on aliases */
979 pub fn LLVMAddAlias(M: ModuleRef,
980 Ty: TypeRef,
981 Aliasee: ValueRef,
982 Name: *const c_char)
983 -> ValueRef;
984
985 /* Operations on functions */
986 pub fn LLVMAddFunction(M: ModuleRef,
987 Name: *const c_char,
988 FunctionTy: TypeRef)
989 -> ValueRef;
990 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
991 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
992 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
993 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
994 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
995 pub fn LLVMDeleteFunction(Fn: ValueRef);
996 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
997 Name: *const c_char,
998 FunctionTy: TypeRef)
999 -> ValueRef;
1000 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
1001 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
1002 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
1003 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
1004 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
1005 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
1006 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
1007 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
1008 pub fn LLVMAddFunctionAttrStringValue(Fn: ValueRef, index: c_uint,
1009 Name: *const c_char,
1010 Value: *const c_char);
1011 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
1012 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
1013 pub fn LLVMRemoveFunctionAttr(Fn: ValueRef, val: c_ulonglong);
1014
1015 /* Operations on parameters */
1016 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
1017 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
1018 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
1019 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
1020 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
1021 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
1022 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
1023 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
1024 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
1025 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
1026 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
1027 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
1028
1029 /* Operations on basic blocks */
1030 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
1031 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
1032 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
1033 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
1034 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
1035 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
1036 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1037 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1038 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
1039 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
1040 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
1041
1042 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
1043 Fn: ValueRef,
1044 Name: *const c_char)
1045 -> BasicBlockRef;
1046 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
1047 BB: BasicBlockRef,
1048 Name: *const c_char)
1049 -> BasicBlockRef;
1050 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
1051
1052 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
1053 MoveAfter: BasicBlockRef);
1054
1055 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
1056 MoveBefore: BasicBlockRef);
1057
1058 /* Operations on instructions */
1059 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
1060 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
1061 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
1062 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
1063 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
1064 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
1065
1066 /* Operations on call sites */
1067 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
1068 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
1069 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
1070 index: c_uint,
1071 IA: c_uint);
1072 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1073 index: c_uint,
1074 IA: c_uint);
1075 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1076 index: c_uint,
1077 align: c_uint);
1078 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1079 index: c_uint,
1080 Val: uint64_t);
1081 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1082 index: c_uint,
1083 bytes: uint64_t);
1084
1085 /* Operations on call instructions (only) */
1086 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1087 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1088
1089 /* Operations on load/store instructions (only) */
1090 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1091 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1092
1093 /* Operations on phi nodes */
1094 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1095 IncomingValues: *const ValueRef,
1096 IncomingBlocks: *const BasicBlockRef,
1097 Count: c_uint);
1098 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1099 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1100 -> ValueRef;
1101 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1102 -> BasicBlockRef;
1103
1104 /* Instruction builders */
1105 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1106 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1107 Block: BasicBlockRef,
1108 Instr: ValueRef);
1109 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1110 Instr: ValueRef);
1111 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1112 Block: BasicBlockRef);
1113 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1114 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1115 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1116 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1117 Instr: ValueRef,
1118 Name: *const c_char);
1119 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1120
1121 /* Execution engine */
1122 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef) -> ExecutionEngineRef;
1123 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1124 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1125 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1126 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1127 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1128 -> Bool;
1129
1130 /* Metadata */
1131 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1132 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1133 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1134
1135 /* Terminators */
1136 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1137 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1138 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1139 RetVals: *const ValueRef,
1140 N: c_uint)
1141 -> ValueRef;
1142 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1143 pub fn LLVMBuildCondBr(B: BuilderRef,
1144 If: ValueRef,
1145 Then: BasicBlockRef,
1146 Else: BasicBlockRef)
1147 -> ValueRef;
1148 pub fn LLVMBuildSwitch(B: BuilderRef,
1149 V: ValueRef,
1150 Else: BasicBlockRef,
1151 NumCases: c_uint)
1152 -> ValueRef;
1153 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1154 Addr: ValueRef,
1155 NumDests: c_uint)
1156 -> ValueRef;
1157 pub fn LLVMRustBuildInvoke(B: BuilderRef,
1158 Fn: ValueRef,
1159 Args: *const ValueRef,
1160 NumArgs: c_uint,
1161 Then: BasicBlockRef,
1162 Catch: BasicBlockRef,
1163 Bundle: OperandBundleDefRef,
1164 Name: *const c_char)
1165 -> ValueRef;
1166 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
1167 Ty: TypeRef,
1168 PersFn: ValueRef,
1169 NumClauses: c_uint,
1170 Name: *const c_char,
1171 F: ValueRef)
1172 -> ValueRef;
1173 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1174 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1175
1176 pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
1177 ParentPad: ValueRef,
1178 ArgCnt: c_uint,
1179 Args: *const ValueRef,
1180 Name: *const c_char) -> ValueRef;
1181 pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
1182 CleanupPad: ValueRef,
1183 UnwindBB: BasicBlockRef) -> ValueRef;
1184 pub fn LLVMRustBuildCatchPad(B: BuilderRef,
1185 ParentPad: ValueRef,
1186 ArgCnt: c_uint,
1187 Args: *const ValueRef,
1188 Name: *const c_char) -> ValueRef;
1189 pub fn LLVMRustBuildCatchRet(B: BuilderRef,
1190 Pad: ValueRef,
1191 BB: BasicBlockRef) -> ValueRef;
1192 pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
1193 ParentPad: ValueRef,
1194 BB: BasicBlockRef,
1195 NumHandlers: c_uint,
1196 Name: *const c_char) -> ValueRef;
1197 pub fn LLVMRustAddHandler(CatchSwitch: ValueRef,
1198 Handler: BasicBlockRef);
1199 pub fn LLVMRustSetPersonalityFn(B: BuilderRef, Pers: ValueRef);
1200
1201 /* Add a case to the switch instruction */
1202 pub fn LLVMAddCase(Switch: ValueRef,
1203 OnVal: ValueRef,
1204 Dest: BasicBlockRef);
1205
1206 /* Add a destination to the indirectbr instruction */
1207 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1208
1209 /* Add a clause to the landing pad instruction */
1210 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1211
1212 /* Set the cleanup on a landing pad instruction */
1213 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1214
1215 /* Arithmetic */
1216 pub fn LLVMBuildAdd(B: BuilderRef,
1217 LHS: ValueRef,
1218 RHS: ValueRef,
1219 Name: *const c_char)
1220 -> ValueRef;
1221 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1222 LHS: ValueRef,
1223 RHS: ValueRef,
1224 Name: *const c_char)
1225 -> ValueRef;
1226 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1227 LHS: ValueRef,
1228 RHS: ValueRef,
1229 Name: *const c_char)
1230 -> ValueRef;
1231 pub fn LLVMBuildFAdd(B: BuilderRef,
1232 LHS: ValueRef,
1233 RHS: ValueRef,
1234 Name: *const c_char)
1235 -> ValueRef;
1236 pub fn LLVMBuildSub(B: BuilderRef,
1237 LHS: ValueRef,
1238 RHS: ValueRef,
1239 Name: *const c_char)
1240 -> ValueRef;
1241 pub fn LLVMBuildNSWSub(B: BuilderRef,
1242 LHS: ValueRef,
1243 RHS: ValueRef,
1244 Name: *const c_char)
1245 -> ValueRef;
1246 pub fn LLVMBuildNUWSub(B: BuilderRef,
1247 LHS: ValueRef,
1248 RHS: ValueRef,
1249 Name: *const c_char)
1250 -> ValueRef;
1251 pub fn LLVMBuildFSub(B: BuilderRef,
1252 LHS: ValueRef,
1253 RHS: ValueRef,
1254 Name: *const c_char)
1255 -> ValueRef;
1256 pub fn LLVMBuildMul(B: BuilderRef,
1257 LHS: ValueRef,
1258 RHS: ValueRef,
1259 Name: *const c_char)
1260 -> ValueRef;
1261 pub fn LLVMBuildNSWMul(B: BuilderRef,
1262 LHS: ValueRef,
1263 RHS: ValueRef,
1264 Name: *const c_char)
1265 -> ValueRef;
1266 pub fn LLVMBuildNUWMul(B: BuilderRef,
1267 LHS: ValueRef,
1268 RHS: ValueRef,
1269 Name: *const c_char)
1270 -> ValueRef;
1271 pub fn LLVMBuildFMul(B: BuilderRef,
1272 LHS: ValueRef,
1273 RHS: ValueRef,
1274 Name: *const c_char)
1275 -> ValueRef;
1276 pub fn LLVMBuildUDiv(B: BuilderRef,
1277 LHS: ValueRef,
1278 RHS: ValueRef,
1279 Name: *const c_char)
1280 -> ValueRef;
1281 pub fn LLVMBuildSDiv(B: BuilderRef,
1282 LHS: ValueRef,
1283 RHS: ValueRef,
1284 Name: *const c_char)
1285 -> ValueRef;
1286 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1287 LHS: ValueRef,
1288 RHS: ValueRef,
1289 Name: *const c_char)
1290 -> ValueRef;
1291 pub fn LLVMBuildFDiv(B: BuilderRef,
1292 LHS: ValueRef,
1293 RHS: ValueRef,
1294 Name: *const c_char)
1295 -> ValueRef;
1296 pub fn LLVMBuildURem(B: BuilderRef,
1297 LHS: ValueRef,
1298 RHS: ValueRef,
1299 Name: *const c_char)
1300 -> ValueRef;
1301 pub fn LLVMBuildSRem(B: BuilderRef,
1302 LHS: ValueRef,
1303 RHS: ValueRef,
1304 Name: *const c_char)
1305 -> ValueRef;
1306 pub fn LLVMBuildFRem(B: BuilderRef,
1307 LHS: ValueRef,
1308 RHS: ValueRef,
1309 Name: *const c_char)
1310 -> ValueRef;
1311 pub fn LLVMBuildShl(B: BuilderRef,
1312 LHS: ValueRef,
1313 RHS: ValueRef,
1314 Name: *const c_char)
1315 -> ValueRef;
1316 pub fn LLVMBuildLShr(B: BuilderRef,
1317 LHS: ValueRef,
1318 RHS: ValueRef,
1319 Name: *const c_char)
1320 -> ValueRef;
1321 pub fn LLVMBuildAShr(B: BuilderRef,
1322 LHS: ValueRef,
1323 RHS: ValueRef,
1324 Name: *const c_char)
1325 -> ValueRef;
1326 pub fn LLVMBuildAnd(B: BuilderRef,
1327 LHS: ValueRef,
1328 RHS: ValueRef,
1329 Name: *const c_char)
1330 -> ValueRef;
1331 pub fn LLVMBuildOr(B: BuilderRef,
1332 LHS: ValueRef,
1333 RHS: ValueRef,
1334 Name: *const c_char)
1335 -> ValueRef;
1336 pub fn LLVMBuildXor(B: BuilderRef,
1337 LHS: ValueRef,
1338 RHS: ValueRef,
1339 Name: *const c_char)
1340 -> ValueRef;
1341 pub fn LLVMBuildBinOp(B: BuilderRef,
1342 Op: Opcode,
1343 LHS: ValueRef,
1344 RHS: ValueRef,
1345 Name: *const c_char)
1346 -> ValueRef;
1347 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1348 -> ValueRef;
1349 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1350 -> ValueRef;
1351 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1352 -> ValueRef;
1353 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1354 -> ValueRef;
1355 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1356 -> ValueRef;
1357
1358 /* Memory */
1359 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1360 -> ValueRef;
1361 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1362 pub fn LLVMBuildLoad(B: BuilderRef,
1363 PointerVal: ValueRef,
1364 Name: *const c_char)
1365 -> ValueRef;
1366
1367 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1368 -> ValueRef;
1369
1370 pub fn LLVMBuildGEP(B: BuilderRef,
1371 Pointer: ValueRef,
1372 Indices: *const ValueRef,
1373 NumIndices: c_uint,
1374 Name: *const c_char)
1375 -> ValueRef;
1376 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1377 Pointer: ValueRef,
1378 Indices: *const ValueRef,
1379 NumIndices: c_uint,
1380 Name: *const c_char)
1381 -> ValueRef;
1382 pub fn LLVMBuildStructGEP(B: BuilderRef,
1383 Pointer: ValueRef,
1384 Idx: c_uint,
1385 Name: *const c_char)
1386 -> ValueRef;
1387 pub fn LLVMBuildGlobalString(B: BuilderRef,
1388 Str: *const c_char,
1389 Name: *const c_char)
1390 -> ValueRef;
1391 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1392 Str: *const c_char,
1393 Name: *const c_char)
1394 -> ValueRef;
1395
1396 /* Casts */
1397 pub fn LLVMBuildTrunc(B: BuilderRef,
1398 Val: ValueRef,
1399 DestTy: TypeRef,
1400 Name: *const c_char)
1401 -> ValueRef;
1402 pub fn LLVMBuildZExt(B: BuilderRef,
1403 Val: ValueRef,
1404 DestTy: TypeRef,
1405 Name: *const c_char)
1406 -> ValueRef;
1407 pub fn LLVMBuildSExt(B: BuilderRef,
1408 Val: ValueRef,
1409 DestTy: TypeRef,
1410 Name: *const c_char)
1411 -> ValueRef;
1412 pub fn LLVMBuildFPToUI(B: BuilderRef,
1413 Val: ValueRef,
1414 DestTy: TypeRef,
1415 Name: *const c_char)
1416 -> ValueRef;
1417 pub fn LLVMBuildFPToSI(B: BuilderRef,
1418 Val: ValueRef,
1419 DestTy: TypeRef,
1420 Name: *const c_char)
1421 -> ValueRef;
1422 pub fn LLVMBuildUIToFP(B: BuilderRef,
1423 Val: ValueRef,
1424 DestTy: TypeRef,
1425 Name: *const c_char)
1426 -> ValueRef;
1427 pub fn LLVMBuildSIToFP(B: BuilderRef,
1428 Val: ValueRef,
1429 DestTy: TypeRef,
1430 Name: *const c_char)
1431 -> ValueRef;
1432 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1433 Val: ValueRef,
1434 DestTy: TypeRef,
1435 Name: *const c_char)
1436 -> ValueRef;
1437 pub fn LLVMBuildFPExt(B: BuilderRef,
1438 Val: ValueRef,
1439 DestTy: TypeRef,
1440 Name: *const c_char)
1441 -> ValueRef;
1442 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1443 Val: ValueRef,
1444 DestTy: TypeRef,
1445 Name: *const c_char)
1446 -> ValueRef;
1447 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1448 Val: ValueRef,
1449 DestTy: TypeRef,
1450 Name: *const c_char)
1451 -> ValueRef;
1452 pub fn LLVMBuildBitCast(B: BuilderRef,
1453 Val: ValueRef,
1454 DestTy: TypeRef,
1455 Name: *const c_char)
1456 -> ValueRef;
1457 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1458 Val: ValueRef,
1459 DestTy: TypeRef,
1460 Name: *const c_char)
1461 -> ValueRef;
1462 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1463 Val: ValueRef,
1464 DestTy: TypeRef,
1465 Name: *const c_char)
1466 -> ValueRef;
1467 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1468 Val: ValueRef,
1469 DestTy: TypeRef,
1470 Name: *const c_char)
1471 -> ValueRef;
1472 pub fn LLVMBuildCast(B: BuilderRef,
1473 Op: Opcode,
1474 Val: ValueRef,
1475 DestTy: TypeRef,
1476 Name: *const c_char) -> ValueRef;
1477 pub fn LLVMBuildPointerCast(B: BuilderRef,
1478 Val: ValueRef,
1479 DestTy: TypeRef,
1480 Name: *const c_char)
1481 -> ValueRef;
1482 pub fn LLVMBuildIntCast(B: BuilderRef,
1483 Val: ValueRef,
1484 DestTy: TypeRef,
1485 Name: *const c_char)
1486 -> ValueRef;
1487 pub fn LLVMBuildFPCast(B: BuilderRef,
1488 Val: ValueRef,
1489 DestTy: TypeRef,
1490 Name: *const c_char)
1491 -> ValueRef;
1492
1493 /* Comparisons */
1494 pub fn LLVMBuildICmp(B: BuilderRef,
1495 Op: c_uint,
1496 LHS: ValueRef,
1497 RHS: ValueRef,
1498 Name: *const c_char)
1499 -> ValueRef;
1500 pub fn LLVMBuildFCmp(B: BuilderRef,
1501 Op: c_uint,
1502 LHS: ValueRef,
1503 RHS: ValueRef,
1504 Name: *const c_char)
1505 -> ValueRef;
1506
1507 /* Miscellaneous instructions */
1508 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1509 -> ValueRef;
1510 pub fn LLVMRustBuildCall(B: BuilderRef,
1511 Fn: ValueRef,
1512 Args: *const ValueRef,
1513 NumArgs: c_uint,
1514 Bundle: OperandBundleDefRef,
1515 Name: *const c_char)
1516 -> ValueRef;
1517 pub fn LLVMBuildSelect(B: BuilderRef,
1518 If: ValueRef,
1519 Then: ValueRef,
1520 Else: ValueRef,
1521 Name: *const c_char)
1522 -> ValueRef;
1523 pub fn LLVMBuildVAArg(B: BuilderRef,
1524 list: ValueRef,
1525 Ty: TypeRef,
1526 Name: *const c_char)
1527 -> ValueRef;
1528 pub fn LLVMBuildExtractElement(B: BuilderRef,
1529 VecVal: ValueRef,
1530 Index: ValueRef,
1531 Name: *const c_char)
1532 -> ValueRef;
1533 pub fn LLVMBuildInsertElement(B: BuilderRef,
1534 VecVal: ValueRef,
1535 EltVal: ValueRef,
1536 Index: ValueRef,
1537 Name: *const c_char)
1538 -> ValueRef;
1539 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1540 V1: ValueRef,
1541 V2: ValueRef,
1542 Mask: ValueRef,
1543 Name: *const c_char)
1544 -> ValueRef;
1545 pub fn LLVMBuildExtractValue(B: BuilderRef,
1546 AggVal: ValueRef,
1547 Index: c_uint,
1548 Name: *const c_char)
1549 -> ValueRef;
1550 pub fn LLVMBuildInsertValue(B: BuilderRef,
1551 AggVal: ValueRef,
1552 EltVal: ValueRef,
1553 Index: c_uint,
1554 Name: *const c_char)
1555 -> ValueRef;
1556
1557 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1558 -> ValueRef;
1559 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1560 -> ValueRef;
1561 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1562 LHS: ValueRef,
1563 RHS: ValueRef,
1564 Name: *const c_char)
1565 -> ValueRef;
1566
1567 /* Atomic Operations */
1568 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1569 PointerVal: ValueRef,
1570 Name: *const c_char,
1571 Order: AtomicOrdering,
1572 Alignment: c_uint)
1573 -> ValueRef;
1574
1575 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1576 Val: ValueRef,
1577 Ptr: ValueRef,
1578 Order: AtomicOrdering,
1579 Alignment: c_uint)
1580 -> ValueRef;
1581
1582 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1583 LHS: ValueRef,
1584 CMP: ValueRef,
1585 RHS: ValueRef,
1586 Order: AtomicOrdering,
1587 FailureOrder: AtomicOrdering,
1588 Weak: Bool)
1589 -> ValueRef;
1590 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1591 Op: AtomicBinOp,
1592 LHS: ValueRef,
1593 RHS: ValueRef,
1594 Order: AtomicOrdering,
1595 SingleThreaded: Bool)
1596 -> ValueRef;
1597
1598 pub fn LLVMBuildAtomicFence(B: BuilderRef,
1599 Order: AtomicOrdering,
1600 Scope: SynchronizationScope);
1601
1602
1603 /* Selected entries from the downcasts. */
1604 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1605 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1606
1607 /// Writes a module to the specified path. Returns 0 on success.
1608 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1609
1610 /// Creates target data from a target layout string.
1611 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1612 /// Adds the target data to the given pass manager. The pass manager
1613 /// references the target data only weakly.
1614 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1615 /// Number of bytes clobbered when doing a Store to *T.
1616 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1617 -> c_ulonglong;
1618
1619 /// Number of bytes clobbered when doing a Store to *T.
1620 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1621 -> c_ulonglong;
1622
1623 /// Distance between successive elements in an array of T. Includes ABI padding.
1624 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1625
1626 /// Returns the preferred alignment of a type.
1627 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1628 -> c_uint;
1629 /// Returns the minimum alignment of a type.
1630 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1631 -> c_uint;
1632
1633 /// Computes the byte offset of the indexed struct element for a
1634 /// target.
1635 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1636 StructTy: TypeRef,
1637 Element: c_uint)
1638 -> c_ulonglong;
1639
1640 /// Returns the minimum alignment of a type when part of a call frame.
1641 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1642 -> c_uint;
1643
1644 /// Disposes target data.
1645 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1646
1647 /// Creates a pass manager.
1648 pub fn LLVMCreatePassManager() -> PassManagerRef;
1649
1650 /// Creates a function-by-function pass manager
1651 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1652 -> PassManagerRef;
1653
1654 /// Disposes a pass manager.
1655 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1656
1657 /// Runs a pass manager on a module.
1658 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1659
1660 /// Runs the function passes on the provided function.
1661 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1662 -> Bool;
1663
1664 /// Initializes all the function passes scheduled in the manager
1665 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1666
1667 /// Finalizes all the function passes scheduled in the manager
1668 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1669
1670 pub fn LLVMInitializePasses();
1671
1672 /// Adds a verification pass.
1673 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1674
1675 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1676 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1677 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1678 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1679 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1680 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1681 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1682 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1683 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1684 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1685 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1686 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1687 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1688 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1689 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1690 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1691 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1692 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1693 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1694 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1695 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1696 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1697 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1698 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1699 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1700 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1701 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1702 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1703 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1704 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1705 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1706 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1707 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1708 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1709 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1710
1711 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1712 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1713 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1714 OptimizationLevel: c_uint);
1715 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1716 Value: Bool);
1717 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1718 PMB: PassManagerBuilderRef,
1719 Value: Bool);
1720 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1721 PMB: PassManagerBuilderRef,
1722 Value: Bool);
1723 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1724 PMB: PassManagerBuilderRef,
1725 Value: Bool);
1726 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1727 PMB: PassManagerBuilderRef,
1728 threshold: c_uint);
1729 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1730 PMB: PassManagerBuilderRef,
1731 PM: PassManagerRef);
1732
1733 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1734 PMB: PassManagerBuilderRef,
1735 PM: PassManagerRef);
1736 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1737 PMB: PassManagerBuilderRef,
1738 PM: PassManagerRef,
1739 Internalize: Bool,
1740 RunInliner: Bool);
1741
1742 /// Destroys a memory buffer.
1743 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1744
1745
1746 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1747
1748 /// Opens an object file.
1749 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1750 /// Closes an object file.
1751 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1752
1753 /// Enumerates the sections in an object file.
1754 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1755 /// Destroys a section iterator.
1756 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1757 /// Returns true if the section iterator is at the end of the section
1758 /// list:
1759 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1760 SI: SectionIteratorRef)
1761 -> Bool;
1762 /// Moves the section iterator to point to the next section.
1763 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1764 /// Returns the current section size.
1765 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1766 /// Returns the current section contents as a string buffer.
1767 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1768
1769 /// Reads the given file and returns it as a memory buffer. Use
1770 /// LLVMDisposeMemoryBuffer() to get rid of it.
1771 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1772 -> MemoryBufferRef;
1773 /// Borrows the contents of the memory buffer (doesn't copy it)
1774 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1775 InputDataLength: size_t,
1776 BufferName: *const c_char,
1777 RequiresNull: Bool)
1778 -> MemoryBufferRef;
1779 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1780 InputDataLength: size_t,
1781 BufferName: *const c_char)
1782 -> MemoryBufferRef;
1783
1784 pub fn LLVMIsMultithreaded() -> Bool;
1785 pub fn LLVMStartMultithreaded() -> Bool;
1786
1787 /// Returns a string describing the last error caused by an LLVMRust* call.
1788 pub fn LLVMRustGetLastError() -> *const c_char;
1789
1790 /// Print the pass timings since static dtors aren't picking them up.
1791 pub fn LLVMRustPrintPassTimings();
1792
1793 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1794
1795 pub fn LLVMStructSetBody(StructTy: TypeRef,
1796 ElementTypes: *const TypeRef,
1797 ElementCount: c_uint,
1798 Packed: Bool);
1799
1800 pub fn LLVMConstNamedStruct(S: TypeRef,
1801 ConstantVals: *const ValueRef,
1802 Count: c_uint)
1803 -> ValueRef;
1804
1805 /// Enables LLVM debug output.
1806 pub fn LLVMSetDebug(Enabled: c_int);
1807
1808 /// Prepares inline assembly.
1809 pub fn LLVMInlineAsm(Ty: TypeRef,
1810 AsmString: *const c_char,
1811 Constraints: *const c_char,
1812 SideEffects: Bool,
1813 AlignStack: Bool,
1814 Dialect: c_uint)
1815 -> ValueRef;
1816
1817 pub fn LLVMRustDebugMetadataVersion() -> u32;
1818 pub fn LLVMVersionMajor() -> u32;
1819 pub fn LLVMVersionMinor() -> u32;
1820
1821 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1822 name: *const c_char,
1823 value: u32);
1824
1825 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1826
1827 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1828
1829 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1830
1831 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1832 Lang: c_uint,
1833 File: *const c_char,
1834 Dir: *const c_char,
1835 Producer: *const c_char,
1836 isOptimized: bool,
1837 Flags: *const c_char,
1838 RuntimeVer: c_uint,
1839 SplitName: *const c_char)
1840 -> DIDescriptor;
1841
1842 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1843 Filename: *const c_char,
1844 Directory: *const c_char)
1845 -> DIFile;
1846
1847 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1848 File: DIFile,
1849 ParameterTypes: DIArray)
1850 -> DICompositeType;
1851
1852 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1853 Scope: DIDescriptor,
1854 Name: *const c_char,
1855 LinkageName: *const c_char,
1856 File: DIFile,
1857 LineNo: c_uint,
1858 Ty: DIType,
1859 isLocalToUnit: bool,
1860 isDefinition: bool,
1861 ScopeLine: c_uint,
1862 Flags: c_uint,
1863 isOptimized: bool,
1864 Fn: ValueRef,
1865 TParam: DIArray,
1866 Decl: DIDescriptor)
1867 -> DISubprogram;
1868
1869 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1870 Name: *const c_char,
1871 SizeInBits: c_ulonglong,
1872 AlignInBits: c_ulonglong,
1873 Encoding: c_uint)
1874 -> DIBasicType;
1875
1876 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1877 PointeeTy: DIType,
1878 SizeInBits: c_ulonglong,
1879 AlignInBits: c_ulonglong,
1880 Name: *const c_char)
1881 -> DIDerivedType;
1882
1883 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1884 Scope: DIDescriptor,
1885 Name: *const c_char,
1886 File: DIFile,
1887 LineNumber: c_uint,
1888 SizeInBits: c_ulonglong,
1889 AlignInBits: c_ulonglong,
1890 Flags: c_uint,
1891 DerivedFrom: DIType,
1892 Elements: DIArray,
1893 RunTimeLang: c_uint,
1894 VTableHolder: DIType,
1895 UniqueId: *const c_char)
1896 -> DICompositeType;
1897
1898 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1899 Scope: DIDescriptor,
1900 Name: *const c_char,
1901 File: DIFile,
1902 LineNo: c_uint,
1903 SizeInBits: c_ulonglong,
1904 AlignInBits: c_ulonglong,
1905 OffsetInBits: c_ulonglong,
1906 Flags: c_uint,
1907 Ty: DIType)
1908 -> DIDerivedType;
1909
1910 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1911 Scope: DIScope,
1912 File: DIFile,
1913 Line: c_uint,
1914 Col: c_uint)
1915 -> DILexicalBlock;
1916
1917 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1918 Context: DIScope,
1919 Name: *const c_char,
1920 LinkageName: *const c_char,
1921 File: DIFile,
1922 LineNo: c_uint,
1923 Ty: DIType,
1924 isLocalToUnit: bool,
1925 Val: ValueRef,
1926 Decl: DIDescriptor)
1927 -> DIGlobalVariable;
1928
1929 pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef,
1930 Tag: c_uint,
1931 Scope: DIDescriptor,
1932 Name: *const c_char,
1933 File: DIFile,
1934 LineNo: c_uint,
1935 Ty: DIType,
1936 AlwaysPreserve: bool,
1937 Flags: c_uint,
1938 AddrOps: *const i64,
1939 AddrOpsCount: c_uint,
1940 ArgNo: c_uint)
1941 -> DIVariable;
1942
1943 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1944 Size: c_ulonglong,
1945 AlignInBits: c_ulonglong,
1946 Ty: DIType,
1947 Subscripts: DIArray)
1948 -> DIType;
1949
1950 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1951 Size: c_ulonglong,
1952 AlignInBits: c_ulonglong,
1953 Ty: DIType,
1954 Subscripts: DIArray)
1955 -> DIType;
1956
1957 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1958 Lo: c_longlong,
1959 Count: c_longlong)
1960 -> DISubrange;
1961
1962 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1963 Ptr: *const DIDescriptor,
1964 Count: c_uint)
1965 -> DIArray;
1966
1967 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1968 Val: ValueRef,
1969 VarInfo: DIVariable,
1970 AddrOps: *const i64,
1971 AddrOpsCount: c_uint,
1972 DL: ValueRef,
1973 InsertAtEnd: BasicBlockRef)
1974 -> ValueRef;
1975
1976 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1977 Val: ValueRef,
1978 VarInfo: DIVariable,
1979 AddrOps: *const i64,
1980 AddrOpsCount: c_uint,
1981 DL: ValueRef,
1982 InsertBefore: ValueRef)
1983 -> ValueRef;
1984
1985 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1986 Name: *const c_char,
1987 Val: c_ulonglong)
1988 -> DIEnumerator;
1989
1990 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1991 Scope: DIScope,
1992 Name: *const c_char,
1993 File: DIFile,
1994 LineNumber: c_uint,
1995 SizeInBits: c_ulonglong,
1996 AlignInBits: c_ulonglong,
1997 Elements: DIArray,
1998 ClassType: DIType)
1999 -> DIType;
2000
2001 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
2002 Scope: DIScope,
2003 Name: *const c_char,
2004 File: DIFile,
2005 LineNumber: c_uint,
2006 SizeInBits: c_ulonglong,
2007 AlignInBits: c_ulonglong,
2008 Flags: c_uint,
2009 Elements: DIArray,
2010 RunTimeLang: c_uint,
2011 UniqueId: *const c_char)
2012 -> DIType;
2013
2014 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
2015
2016 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
2017 Scope: DIScope,
2018 Name: *const c_char,
2019 Ty: DIType,
2020 File: DIFile,
2021 LineNo: c_uint,
2022 ColumnNo: c_uint)
2023 -> DITemplateTypeParameter;
2024
2025 pub fn LLVMDIBuilderCreateOpDeref() -> i64;
2026
2027 pub fn LLVMDIBuilderCreateOpPlus() -> i64;
2028
2029 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
2030 Scope: DIScope,
2031 Name: *const c_char,
2032 File: DIFile,
2033 LineNo: c_uint)
2034 -> DINameSpace;
2035
2036 pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef,
2037 Line: c_uint,
2038 Column: c_uint,
2039 Scope: DIScope,
2040 InlinedAt: MetadataRef)
2041 -> ValueRef;
2042
2043 pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
2044 CompositeType: DIType,
2045 TypeArray: DIArray);
2046 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
2047 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
2048
2049 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
2050
2051 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
2052 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
2053
2054 pub fn LLVMRustPassKind(Pass: PassRef) -> SupportedPassKind;
2055 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
2056 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
2057
2058 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
2059 CPU: *const c_char,
2060 Features: *const c_char,
2061 Model: CodeGenModel,
2062 Reloc: RelocMode,
2063 Level: CodeGenOptLevel,
2064 UseSoftFP: bool,
2065 PositionIndependentExecutable: bool,
2066 FunctionSections: bool,
2067 DataSections: bool) -> TargetMachineRef;
2068 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
2069 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
2070 PM: PassManagerRef,
2071 M: ModuleRef);
2072 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
2073 M: ModuleRef,
2074 DisableSimplifyLibCalls: bool);
2075 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
2076 OptLevel: CodeGenOptLevel,
2077 MergeFunctions: bool,
2078 SLPVectorize: bool,
2079 LoopVectorize: bool);
2080 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
2081 DisableSimplifyLibCalls: bool);
2082 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
2083 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2084 PM: PassManagerRef,
2085 M: ModuleRef,
2086 Output: *const c_char,
2087 FileType: FileType) -> bool;
2088 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2089 M: ModuleRef,
2090 Output: *const c_char);
2091 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2092 pub fn LLVMRustPrintPasses();
2093 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2094 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2095 AddLifetimes: bool);
2096 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2097 bc: *const c_char,
2098 len: size_t) -> bool;
2099 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2100 syms: *const *const c_char,
2101 len: size_t);
2102 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2103
2104 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2105 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
2106 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
2107 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef,
2108 size: *mut size_t) -> *const c_char;
2109 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef,
2110 size: *mut size_t) -> *const c_char;
2111 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
2112 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
2113 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2114
2115 pub fn LLVMRustSetDLLStorageClass(V: ValueRef,
2116 C: DLLStorageClassTypes);
2117
2118 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2119 data: *mut *const c_char) -> c_int;
2120
2121 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2122
2123 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2124 Handler: DiagnosticHandler,
2125 DiagnosticContext: *mut c_void);
2126
2127 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2128 pass_name_out: *mut *const c_char,
2129 function_out: *mut ValueRef,
2130 debugloc_out: *mut DebugLocRef,
2131 message_out: *mut TwineRef);
2132 pub fn LLVMUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
2133 cookie_out: *mut c_uint,
2134 message_out: *mut TwineRef,
2135 instruction_out: *mut ValueRef);
2136
2137 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2138 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2139 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2140
2141 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2142
2143 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2144 H: InlineAsmDiagHandler,
2145 CX: *mut c_void);
2146
2147 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2148
2149 pub fn LLVMRustWriteArchive(Dst: *const c_char,
2150 NumMembers: size_t,
2151 Members: *const RustArchiveMemberRef,
2152 WriteSymbtab: bool,
2153 Kind: ArchiveKind) -> c_int;
2154 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
2155 Name: *const c_char,
2156 Child: ArchiveChildRef) -> RustArchiveMemberRef;
2157 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
2158
2159 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef,
2160 TM: TargetMachineRef);
2161 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
2162
2163 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
2164 Inputs: *const ValueRef,
2165 NumInputs: c_uint)
2166 -> OperandBundleDefRef;
2167 pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
2168 }
2169
2170 // LLVM requires symbols from this library, but apparently they're not printed
2171 // during llvm-config?
2172 #[cfg(windows)]
2173 #[link(name = "ole32")]
2174 extern {}
2175
2176 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2177 unsafe {
2178 LLVMSetInstructionCallConv(instr, cc as c_uint);
2179 }
2180 }
2181 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2182 unsafe {
2183 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2184 }
2185 }
2186 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2187 unsafe {
2188 LLVMSetLinkage(global, link as c_uint);
2189 }
2190 }
2191
2192 pub fn SetDLLStorageClass(global: ValueRef, class: DLLStorageClassTypes) {
2193 unsafe {
2194 LLVMRustSetDLLStorageClass(global, class);
2195 }
2196 }
2197
2198 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2199 unsafe {
2200 LLVMSetUnnamedAddr(global, unnamed as Bool);
2201 }
2202 }
2203
2204 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2205 unsafe {
2206 LLVMSetThreadLocal(global, is_thread_local as Bool);
2207 }
2208 }
2209
2210 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2211 unsafe {
2212 LLVMConstICmp(pred as c_ushort, v1, v2)
2213 }
2214 }
2215 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2216 unsafe {
2217 LLVMConstFCmp(pred as c_ushort, v1, v2)
2218 }
2219 }
2220
2221 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2222 unsafe {
2223 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint,
2224 attr.bits() as uint64_t)
2225 }
2226 }
2227
2228 /* Memory-managed interface to target data. */
2229
2230 pub struct TargetData {
2231 pub lltd: TargetDataRef
2232 }
2233
2234 impl Drop for TargetData {
2235 fn drop(&mut self) {
2236 unsafe {
2237 LLVMDisposeTargetData(self.lltd);
2238 }
2239 }
2240 }
2241
2242 pub fn mk_target_data(string_rep: &str) -> TargetData {
2243 let string_rep = CString::new(string_rep).unwrap();
2244 TargetData {
2245 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2246 }
2247 }
2248
2249 /* Memory-managed interface to object files. */
2250
2251 pub struct ObjectFile {
2252 pub llof: ObjectFileRef,
2253 }
2254
2255 impl ObjectFile {
2256 // This will take ownership of llmb
2257 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2258 unsafe {
2259 let llof = LLVMCreateObjectFile(llmb);
2260 if llof as isize == 0 {
2261 // LLVMCreateObjectFile took ownership of llmb
2262 return None
2263 }
2264
2265 Some(ObjectFile {
2266 llof: llof,
2267 })
2268 }
2269 }
2270 }
2271
2272 impl Drop for ObjectFile {
2273 fn drop(&mut self) {
2274 unsafe {
2275 LLVMDisposeObjectFile(self.llof);
2276 }
2277 }
2278 }
2279
2280 /* Memory-managed interface to section iterators. */
2281
2282 pub struct SectionIter {
2283 pub llsi: SectionIteratorRef
2284 }
2285
2286 impl Drop for SectionIter {
2287 fn drop(&mut self) {
2288 unsafe {
2289 LLVMDisposeSectionIterator(self.llsi);
2290 }
2291 }
2292 }
2293
2294 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2295 unsafe {
2296 SectionIter {
2297 llsi: LLVMGetSections(llof)
2298 }
2299 }
2300 }
2301
2302 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2303 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2304 unsafe {
2305 assert!(index < LLVMCountParams(llfn));
2306 LLVMGetParam(llfn, index)
2307 }
2308 }
2309
2310 pub fn get_params(llfn: ValueRef) -> Vec<ValueRef> {
2311 unsafe {
2312 let num_params = LLVMCountParams(llfn);
2313 let mut params = Vec::with_capacity(num_params as usize);
2314 for idx in 0..num_params {
2315 params.push(LLVMGetParam(llfn, idx));
2316 }
2317
2318 params
2319 }
2320 }
2321
2322 #[allow(missing_copy_implementations)]
2323 pub enum RustString_opaque {}
2324 pub type RustStringRef = *mut RustString_opaque;
2325 type RustStringRepr = *mut RefCell<Vec<u8>>;
2326
2327 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2328 #[no_mangle]
2329 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2330 ptr: *const c_char,
2331 size: size_t) {
2332 let slice = slice::from_raw_parts(ptr as *const u8, size as usize);
2333
2334 let sr = sr as RustStringRepr;
2335 (*sr).borrow_mut().extend_from_slice(slice);
2336 }
2337
2338 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2339 let mut buf = RefCell::new(Vec::new());
2340 f(&mut buf as RustStringRepr as RustStringRef);
2341 String::from_utf8(buf.into_inner()).ok()
2342 }
2343
2344 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2345 build_string(|s| LLVMWriteTwineToString(tr, s))
2346 .expect("got a non-UTF8 Twine from LLVM")
2347 }
2348
2349 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2350 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2351 .expect("got a non-UTF8 DebugLoc from LLVM")
2352 }
2353
2354 pub fn initialize_available_targets() {
2355 macro_rules! init_target(
2356 ($cfg:meta, $($method:ident),*) => { {
2357 #[cfg($cfg)]
2358 fn init() {
2359 extern {
2360 $(fn $method();)*
2361 }
2362 unsafe {
2363 $($method();)*
2364 }
2365 }
2366 #[cfg(not($cfg))]
2367 fn init() { }
2368 init();
2369 } }
2370 );
2371 init_target!(llvm_component = "x86",
2372 LLVMInitializeX86TargetInfo,
2373 LLVMInitializeX86Target,
2374 LLVMInitializeX86TargetMC,
2375 LLVMInitializeX86AsmPrinter,
2376 LLVMInitializeX86AsmParser);
2377 init_target!(llvm_component = "arm",
2378 LLVMInitializeARMTargetInfo,
2379 LLVMInitializeARMTarget,
2380 LLVMInitializeARMTargetMC,
2381 LLVMInitializeARMAsmPrinter,
2382 LLVMInitializeARMAsmParser);
2383 init_target!(llvm_component = "aarch64",
2384 LLVMInitializeAArch64TargetInfo,
2385 LLVMInitializeAArch64Target,
2386 LLVMInitializeAArch64TargetMC,
2387 LLVMInitializeAArch64AsmPrinter,
2388 LLVMInitializeAArch64AsmParser);
2389 init_target!(llvm_component = "mips",
2390 LLVMInitializeMipsTargetInfo,
2391 LLVMInitializeMipsTarget,
2392 LLVMInitializeMipsTargetMC,
2393 LLVMInitializeMipsAsmPrinter,
2394 LLVMInitializeMipsAsmParser);
2395 init_target!(llvm_component = "powerpc",
2396 LLVMInitializePowerPCTargetInfo,
2397 LLVMInitializePowerPCTarget,
2398 LLVMInitializePowerPCTargetMC,
2399 LLVMInitializePowerPCAsmPrinter,
2400 LLVMInitializePowerPCAsmParser);
2401 init_target!(llvm_component = "pnacl",
2402 LLVMInitializePNaClTargetInfo,
2403 LLVMInitializePNaClTarget,
2404 LLVMInitializePNaClTargetMC);
2405 }
2406
2407 pub fn last_error() -> Option<String> {
2408 unsafe {
2409 let cstr = LLVMRustGetLastError();
2410 if cstr.is_null() {
2411 None
2412 } else {
2413 let err = CStr::from_ptr(cstr).to_bytes();
2414 let err = String::from_utf8_lossy(err).to_string();
2415 libc::free(cstr as *mut _);
2416 Some(err)
2417 }
2418 }
2419 }
2420
2421 pub struct OperandBundleDef {
2422 inner: OperandBundleDefRef,
2423 }
2424
2425 impl OperandBundleDef {
2426 pub fn new(name: &str, vals: &[ValueRef]) -> OperandBundleDef {
2427 let name = CString::new(name).unwrap();
2428 let def = unsafe {
2429 LLVMRustBuildOperandBundleDef(name.as_ptr(),
2430 vals.as_ptr(),
2431 vals.len() as c_uint)
2432 };
2433 OperandBundleDef { inner: def }
2434 }
2435
2436 pub fn raw(&self) -> OperandBundleDefRef {
2437 self.inner
2438 }
2439 }
2440
2441 impl Drop for OperandBundleDef {
2442 fn drop(&mut self) {
2443 unsafe {
2444 LLVMRustFreeOperandBundleDef(self.inner);
2445 }
2446 }
2447 }
2448
2449 // The module containing the native LLVM dependencies, generated by the build system
2450 // Note that this must come after the rustllvm extern declaration so that
2451 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2452 // Works to the above fix for #15460 to ensure LLVM dependencies that
2453 // are only used by rustllvm don't get stripped by the linker.
2454 #[cfg(not(cargobuild))]
2455 mod llvmdeps {
2456 include! { env!("CFG_LLVM_LINKAGE_FILE") }
2457 }