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