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.
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.
11 #![allow(non_upper_case_globals)]
12 #![allow(non_camel_case_types)]
13 #![allow(non_snake_case)]
16 #![crate_name = "rustc_llvm"]
19 #![crate_type = "dylib"]
20 #![crate_type = "rlib"]
21 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22 html_favicon_url = "http://www.rust-lang.org/favicon.ico",
23 html_root_url = "http://doc.rust-lang.org/nightly/")]
25 #![allow(unknown_features)]
26 #![feature(link_args)]
27 #![feature(box_syntax)]
28 #![allow(unknown_features)] #![feature(int_uint)]
32 #[macro_use] #[no_link] extern crate rustc_bitflags;
34 pub use self::OtherAttribute::*;
35 pub use self::SpecialAttribute::*;
36 pub use self::AttributeSet::*;
37 pub use self::IntPredicate::*;
38 pub use self::RealPredicate::*;
39 pub use self::TypeKind::*;
40 pub use self::AtomicBinOp::*;
41 pub use self::AtomicOrdering::*;
42 pub use self::FileType::*;
43 pub use self::MetadataType::*;
44 pub use self::AsmDialect::*;
45 pub use self::CodeGenOptLevel::*;
46 pub use self::RelocMode::*;
47 pub use self::CodeGenModel::*;
48 pub use self::DiagnosticKind::*;
49 pub use self::CallConv::*;
50 pub use self::Visibility::*;
51 pub use self::DiagnosticSeverity::*;
52 pub use self::Linkage::*;
54 use std::ffi::CString;
55 use std::cell::RefCell;
57 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
58 use libc::{c_longlong, c_ulonglong, c_void};
59 use debuginfo::{DIBuilderRef, DIDescriptor,
60 DIFile, DILexicalBlock, DISubprogram, DIType,
61 DIBasicType, DIDerivedType, DICompositeType,
62 DIVariable, DIGlobalVariable, DIArray, DISubrange};
67 pub type Opcode = u32;
68 pub type Bool = c_uint;
70 pub const True: Bool = 1 as Bool;
71 pub const False: Bool = 0 as Bool;
73 // Consts for the LLVM CallConv type, pre-cast to uint.
75 #[derive(Copy, PartialEq)]
80 X86StdcallCallConv = 64,
81 X86FastcallCallConv = 65,
87 LLVMDefaultVisibility = 0,
89 ProtectedVisibility = 2,
92 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
93 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
94 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
95 // they've been removed in upstream LLVM commit r203866.
99 AvailableExternallyLinkage = 1,
100 LinkOnceAnyLinkage = 2,
101 LinkOnceODRLinkage = 3,
104 AppendingLinkage = 7,
107 ExternalWeakLinkage = 12,
112 #[derive(Copy, Show)]
113 pub enum DiagnosticSeverity {
121 flags Attribute : u32 {
122 const ZExtAttribute = 1 << 0,
123 const SExtAttribute = 1 << 1,
124 const NoReturnAttribute = 1 << 2,
125 const InRegAttribute = 1 << 3,
126 const StructRetAttribute = 1 << 4,
127 const NoUnwindAttribute = 1 << 5,
128 const NoAliasAttribute = 1 << 6,
129 const ByValAttribute = 1 << 7,
130 const NestAttribute = 1 << 8,
131 const ReadNoneAttribute = 1 << 9,
132 const ReadOnlyAttribute = 1 << 10,
133 const NoInlineAttribute = 1 << 11,
134 const AlwaysInlineAttribute = 1 << 12,
135 const OptimizeForSizeAttribute = 1 << 13,
136 const StackProtectAttribute = 1 << 14,
137 const StackProtectReqAttribute = 1 << 15,
138 const AlignmentAttribute = 31 << 16,
139 const NoCaptureAttribute = 1 << 21,
140 const NoRedZoneAttribute = 1 << 22,
141 const NoImplicitFloatAttribute = 1 << 23,
142 const NakedAttribute = 1 << 24,
143 const InlineHintAttribute = 1 << 25,
144 const StackAttribute = 7 << 26,
145 const ReturnsTwiceAttribute = 1 << 29,
146 const UWTableAttribute = 1 << 30,
147 const NonLazyBindAttribute = 1 << 31,
154 pub enum OtherAttribute {
155 // The following are not really exposed in
156 // the LLVM c api so instead to add these
157 // we call a wrapper function in RustWrapper
158 // that uses the C++ api.
159 SanitizeAddressAttribute = 1 << 32,
160 MinSizeAttribute = 1 << 33,
161 NoDuplicateAttribute = 1 << 34,
162 StackProtectStrongAttribute = 1 << 35,
163 SanitizeThreadAttribute = 1 << 36,
164 SanitizeMemoryAttribute = 1 << 37,
165 NoBuiltinAttribute = 1 << 38,
166 ReturnedAttribute = 1 << 39,
167 ColdAttribute = 1 << 40,
168 BuiltinAttribute = 1 << 41,
169 OptimizeNoneAttribute = 1 << 42,
170 InAllocaAttribute = 1 << 43,
171 NonNullAttribute = 1 << 44,
175 pub enum SpecialAttribute {
176 DereferenceableAttribute(u64)
181 pub enum AttributeSet {
186 pub trait AttrHelper {
187 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
188 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
191 impl AttrHelper for Attribute {
192 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
194 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
198 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
200 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
205 impl AttrHelper for OtherAttribute {
206 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
208 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
212 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
214 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
219 impl AttrHelper for SpecialAttribute {
220 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
222 DereferenceableAttribute(bytes) => unsafe {
223 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
228 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
230 DereferenceableAttribute(bytes) => unsafe {
231 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
237 pub struct AttrBuilder {
238 attrs: Vec<(uint, Box<AttrHelper+'static>)>
242 pub fn new() -> AttrBuilder {
248 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
249 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
253 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
254 self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
258 pub fn apply_llfn(&self, llfn: ValueRef) {
259 for &(idx, ref attr) in self.attrs.iter() {
260 attr.apply_llfn(idx as c_uint, llfn);
264 pub fn apply_callsite(&self, callsite: ValueRef) {
265 for &(idx, ref attr) in self.attrs.iter() {
266 attr.apply_callsite(idx as c_uint, callsite);
271 // enum for the LLVM IntPredicate type
273 pub enum IntPredicate {
286 // enum for the LLVM RealPredicate type
288 pub enum RealPredicate {
289 RealPredicateFalse = 0,
304 RealPredicateTrue = 15,
307 // The LLVM TypeKind type - must stay in sync with the def of
308 // LLVMTypeKind in llvm/include/llvm-c/Core.h
309 #[derive(Copy, PartialEq, Show)]
332 pub enum AtomicBinOp {
348 pub enum AtomicOrdering {
352 // Consume = 3, // Not specified yet.
356 SequentiallyConsistent = 7
359 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
363 AssemblyFileType = 0,
368 pub enum MetadataType {
377 // Inline Asm Dialect
379 pub enum AsmDialect {
384 #[derive(Copy, PartialEq, Clone)]
386 pub enum CodeGenOptLevel {
387 CodeGenLevelNone = 0,
388 CodeGenLevelLess = 1,
389 CodeGenLevelDefault = 2,
390 CodeGenLevelAggressive = 3,
393 #[derive(Copy, PartialEq)]
399 RelocDynamicNoPic = 3,
404 pub enum CodeGenModel {
405 CodeModelDefault = 0,
406 CodeModelJITDefault = 1,
415 pub enum DiagnosticKind {
418 DK_DebugMetadataVersion,
420 DK_OptimizationRemark,
421 DK_OptimizationRemarkMissed,
422 DK_OptimizationRemarkAnalysis,
423 DK_OptimizationFailure,
426 // Opaque pointer types
427 #[allow(missing_copy_implementations)]
428 pub enum Module_opaque {}
429 pub type ModuleRef = *mut Module_opaque;
430 #[allow(missing_copy_implementations)]
431 pub enum Context_opaque {}
432 pub type ContextRef = *mut Context_opaque;
433 #[allow(missing_copy_implementations)]
434 pub enum Type_opaque {}
435 pub type TypeRef = *mut Type_opaque;
436 #[allow(missing_copy_implementations)]
437 pub enum Value_opaque {}
438 pub type ValueRef = *mut Value_opaque;
439 #[allow(missing_copy_implementations)]
440 pub enum BasicBlock_opaque {}
441 pub type BasicBlockRef = *mut BasicBlock_opaque;
442 #[allow(missing_copy_implementations)]
443 pub enum Builder_opaque {}
444 pub type BuilderRef = *mut Builder_opaque;
445 #[allow(missing_copy_implementations)]
446 pub enum ExecutionEngine_opaque {}
447 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
448 #[allow(missing_copy_implementations)]
449 pub enum RustJITMemoryManager_opaque {}
450 pub type RustJITMemoryManagerRef = *mut RustJITMemoryManager_opaque;
451 #[allow(missing_copy_implementations)]
452 pub enum MemoryBuffer_opaque {}
453 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
454 #[allow(missing_copy_implementations)]
455 pub enum PassManager_opaque {}
456 pub type PassManagerRef = *mut PassManager_opaque;
457 #[allow(missing_copy_implementations)]
458 pub enum PassManagerBuilder_opaque {}
459 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
460 #[allow(missing_copy_implementations)]
461 pub enum Use_opaque {}
462 pub type UseRef = *mut Use_opaque;
463 #[allow(missing_copy_implementations)]
464 pub enum TargetData_opaque {}
465 pub type TargetDataRef = *mut TargetData_opaque;
466 #[allow(missing_copy_implementations)]
467 pub enum ObjectFile_opaque {}
468 pub type ObjectFileRef = *mut ObjectFile_opaque;
469 #[allow(missing_copy_implementations)]
470 pub enum SectionIterator_opaque {}
471 pub type SectionIteratorRef = *mut SectionIterator_opaque;
472 #[allow(missing_copy_implementations)]
473 pub enum Pass_opaque {}
474 pub type PassRef = *mut Pass_opaque;
475 #[allow(missing_copy_implementations)]
476 pub enum TargetMachine_opaque {}
477 pub type TargetMachineRef = *mut TargetMachine_opaque;
478 #[allow(missing_copy_implementations)]
479 pub enum Archive_opaque {}
480 pub type ArchiveRef = *mut Archive_opaque;
481 #[allow(missing_copy_implementations)]
482 pub enum Twine_opaque {}
483 pub type TwineRef = *mut Twine_opaque;
484 #[allow(missing_copy_implementations)]
485 pub enum DiagnosticInfo_opaque {}
486 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
487 #[allow(missing_copy_implementations)]
488 pub enum DebugLoc_opaque {}
489 pub type DebugLocRef = *mut DebugLoc_opaque;
490 #[allow(missing_copy_implementations)]
491 pub enum SMDiagnostic_opaque {}
492 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
494 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
495 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
498 pub use self::DIDescriptorFlags::*;
499 use super::{ValueRef};
501 #[allow(missing_copy_implementations)]
502 pub enum DIBuilder_opaque {}
503 pub type DIBuilderRef = *mut DIBuilder_opaque;
505 pub type DIDescriptor = ValueRef;
506 pub type DIScope = DIDescriptor;
507 pub type DILocation = DIDescriptor;
508 pub type DIFile = DIScope;
509 pub type DILexicalBlock = DIScope;
510 pub type DISubprogram = DIScope;
511 pub type DIType = DIDescriptor;
512 pub type DIBasicType = DIType;
513 pub type DIDerivedType = DIType;
514 pub type DICompositeType = DIDerivedType;
515 pub type DIVariable = DIDescriptor;
516 pub type DIGlobalVariable = DIDescriptor;
517 pub type DIArray = DIDescriptor;
518 pub type DISubrange = DIDescriptor;
521 pub enum DIDescriptorFlags {
522 FlagPrivate = 1 << 0,
523 FlagProtected = 1 << 1,
524 FlagFwdDecl = 1 << 2,
525 FlagAppleBlock = 1 << 3,
526 FlagBlockByrefStruct = 1 << 4,
527 FlagVirtual = 1 << 5,
528 FlagArtificial = 1 << 6,
529 FlagExplicit = 1 << 7,
530 FlagPrototyped = 1 << 8,
531 FlagObjcClassComplete = 1 << 9,
532 FlagObjectPointer = 1 << 10,
533 FlagVector = 1 << 11,
534 FlagStaticMember = 1 << 12,
535 FlagIndirectVariable = 1 << 13,
536 FlagLValueReference = 1 << 14,
537 FlagRValueReference = 1 << 15
542 // Link to our native llvm bindings (things that we need to use the C++ api
543 // for) and because llvm is written in C++ we need to link against libstdc++
545 // You'll probably notice that there is an omission of all LLVM libraries
546 // from this location. This is because the set of LLVM libraries that we
547 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
548 // figure out the exact set of libraries. To do this, the build system
549 // generates an llvmdeps.rs file next to this one which will be
550 // automatically updated whenever LLVM is updated to include an up-to-date
551 // set of the libraries we need to link to LLVM for.
552 #[link(name = "rustllvm", kind = "static")]
554 /* Create and destroy contexts. */
555 pub fn LLVMContextCreate() -> ContextRef;
556 pub fn LLVMContextDispose(C: ContextRef);
557 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
562 /* Create and destroy modules. */
563 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
566 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
567 pub fn LLVMDisposeModule(M: ModuleRef);
569 /// Data layout. See Module::getDataLayout.
570 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
571 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
573 /// Target triple. See Module::getTargetTriple.
574 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
575 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
577 /// See Module::dump.
578 pub fn LLVMDumpModule(M: ModuleRef);
580 /// See Module::setModuleInlineAsm.
581 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
583 /// See llvm::LLVMTypeKind::getTypeID.
584 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
586 /// See llvm::LLVMType::getContext.
587 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
589 /* Operations on integer types */
590 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
591 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
592 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
593 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
594 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
595 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
598 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
600 /* Operations on real types */
601 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
602 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
603 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
604 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
605 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
607 /* Operations on function types */
608 pub fn LLVMFunctionType(ReturnType: TypeRef,
609 ParamTypes: *const TypeRef,
613 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
614 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
615 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
616 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
618 /* Operations on struct types */
619 pub fn LLVMStructTypeInContext(C: ContextRef,
620 ElementTypes: *const TypeRef,
621 ElementCount: c_uint,
624 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
625 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
627 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
629 /* Operations on array, pointer, and vector types (sequence types) */
630 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
631 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
633 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
636 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
637 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
638 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
639 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
641 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
643 /* Operations on other types */
644 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
645 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
646 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
648 /* Operations on all values */
649 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
650 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
651 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
652 pub fn LLVMDumpValue(Val: ValueRef);
653 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
654 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
655 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
656 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
658 /* Operations on Uses */
659 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
660 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
661 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
662 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
664 /* Operations on Users */
665 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
666 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
667 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
669 /* Operations on constants of any type */
670 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
672 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
673 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
675 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
677 /* only for int/vector */
678 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
679 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
680 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
681 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
682 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
684 /* Operations on metadata */
685 pub fn LLVMMDStringInContext(C: ContextRef,
689 pub fn LLVMMDNodeInContext(C: ContextRef,
690 Vals: *const ValueRef,
693 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
697 /* Operations on scalar constants */
698 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
700 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
702 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
707 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
708 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
710 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
714 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
715 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
718 /* Operations on composite constants */
719 pub fn LLVMConstStringInContext(C: ContextRef,
722 DontNullTerminate: Bool)
724 pub fn LLVMConstStructInContext(C: ContextRef,
725 ConstantVals: *const ValueRef,
730 pub fn LLVMConstArray(ElementTy: TypeRef,
731 ConstantVals: *const ValueRef,
734 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
737 /* Constant expressions */
738 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
739 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
740 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
741 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
742 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
743 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
744 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
745 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
747 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
749 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
751 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
753 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
755 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
757 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
759 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
761 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
763 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
765 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
767 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
769 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
771 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
773 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
774 RHSConstant: ValueRef)
776 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
778 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
780 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
782 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
784 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
786 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
788 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
790 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
792 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
794 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
796 pub fn LLVMConstGEP(ConstantVal: ValueRef,
797 ConstantIndices: *const ValueRef,
800 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
801 ConstantIndices: *const ValueRef,
804 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
806 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
808 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
810 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
812 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
814 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
816 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
818 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
820 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
822 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
824 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
826 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
828 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
830 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
832 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
834 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
836 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
840 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
842 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
843 ConstantIfTrue: ValueRef,
844 ConstantIfFalse: ValueRef)
846 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
847 IndexConstant: ValueRef)
849 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
850 ElementValueConstant: ValueRef,
851 IndexConstant: ValueRef)
853 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
854 VectorBConstant: ValueRef,
855 MaskConstant: ValueRef)
857 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
858 IdxList: *const c_uint,
861 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
862 ElementValueConstant: ValueRef,
863 IdxList: *const c_uint,
866 pub fn LLVMConstInlineAsm(Ty: TypeRef,
867 AsmString: *const c_char,
868 Constraints: *const c_char,
869 HasSideEffects: Bool,
872 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
876 /* Operations on global variables, functions, and aliases (globals) */
877 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
878 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
879 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
880 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
881 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
882 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
883 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
884 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
885 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
886 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
889 /* Operations on global variables */
890 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
892 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
895 AddressSpace: c_uint)
897 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
898 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
899 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
900 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
901 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
902 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
903 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
904 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
905 ConstantVal: ValueRef);
906 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
907 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
908 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
909 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
911 /* Operations on aliases */
912 pub fn LLVMAddAlias(M: ModuleRef,
918 /* Operations on functions */
919 pub fn LLVMAddFunction(M: ModuleRef,
923 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
924 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
925 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
926 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
927 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
928 pub fn LLVMDeleteFunction(Fn: ValueRef);
929 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
933 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
934 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
935 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
936 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
937 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
938 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
939 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
940 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
941 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
942 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
944 /* Operations on parameters */
945 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
946 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
947 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
948 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
949 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
950 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
951 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
952 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
953 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
954 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
955 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
956 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
958 /* Operations on basic blocks */
959 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
960 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
961 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
962 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
963 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
964 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
965 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
966 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
967 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
968 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
969 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
971 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
975 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
979 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
981 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
982 MoveAfter: BasicBlockRef);
984 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
985 MoveBefore: BasicBlockRef);
987 /* Operations on instructions */
988 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
989 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
990 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
991 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
992 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
993 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
995 /* Operations on call sites */
996 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
997 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
998 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
1001 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1004 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1007 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1010 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1014 /* Operations on call instructions (only) */
1015 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1016 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1018 /* Operations on load/store instructions (only) */
1019 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1020 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1022 /* Operations on phi nodes */
1023 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1024 IncomingValues: *const ValueRef,
1025 IncomingBlocks: *const BasicBlockRef,
1027 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1028 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1030 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1033 /* Instruction builders */
1034 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1035 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1036 Block: BasicBlockRef,
1038 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1040 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1041 Block: BasicBlockRef);
1042 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1043 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1044 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1045 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1047 Name: *const c_char);
1048 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1050 /* Execution engine */
1051 pub fn LLVMRustCreateJITMemoryManager(morestack: *const ())
1052 -> RustJITMemoryManagerRef;
1053 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef,
1054 MM: RustJITMemoryManagerRef) -> ExecutionEngineRef;
1055 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1056 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1057 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1058 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1059 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1063 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1064 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1065 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1068 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1069 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1070 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1071 RetVals: *const ValueRef,
1074 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1075 pub fn LLVMBuildCondBr(B: BuilderRef,
1077 Then: BasicBlockRef,
1078 Else: BasicBlockRef)
1080 pub fn LLVMBuildSwitch(B: BuilderRef,
1082 Else: BasicBlockRef,
1085 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1089 pub fn LLVMBuildInvoke(B: BuilderRef,
1091 Args: *const ValueRef,
1093 Then: BasicBlockRef,
1094 Catch: BasicBlockRef,
1095 Name: *const c_char)
1097 pub fn LLVMBuildLandingPad(B: BuilderRef,
1101 Name: *const c_char)
1103 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1104 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1106 /* Add a case to the switch instruction */
1107 pub fn LLVMAddCase(Switch: ValueRef,
1109 Dest: BasicBlockRef);
1111 /* Add a destination to the indirectbr instruction */
1112 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1114 /* Add a clause to the landing pad instruction */
1115 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1117 /* Set the cleanup on a landing pad instruction */
1118 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1121 pub fn LLVMBuildAdd(B: BuilderRef,
1124 Name: *const c_char)
1126 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1129 Name: *const c_char)
1131 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1134 Name: *const c_char)
1136 pub fn LLVMBuildFAdd(B: BuilderRef,
1139 Name: *const c_char)
1141 pub fn LLVMBuildSub(B: BuilderRef,
1144 Name: *const c_char)
1146 pub fn LLVMBuildNSWSub(B: BuilderRef,
1149 Name: *const c_char)
1151 pub fn LLVMBuildNUWSub(B: BuilderRef,
1154 Name: *const c_char)
1156 pub fn LLVMBuildFSub(B: BuilderRef,
1159 Name: *const c_char)
1161 pub fn LLVMBuildMul(B: BuilderRef,
1164 Name: *const c_char)
1166 pub fn LLVMBuildNSWMul(B: BuilderRef,
1169 Name: *const c_char)
1171 pub fn LLVMBuildNUWMul(B: BuilderRef,
1174 Name: *const c_char)
1176 pub fn LLVMBuildFMul(B: BuilderRef,
1179 Name: *const c_char)
1181 pub fn LLVMBuildUDiv(B: BuilderRef,
1184 Name: *const c_char)
1186 pub fn LLVMBuildSDiv(B: BuilderRef,
1189 Name: *const c_char)
1191 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1194 Name: *const c_char)
1196 pub fn LLVMBuildFDiv(B: BuilderRef,
1199 Name: *const c_char)
1201 pub fn LLVMBuildURem(B: BuilderRef,
1204 Name: *const c_char)
1206 pub fn LLVMBuildSRem(B: BuilderRef,
1209 Name: *const c_char)
1211 pub fn LLVMBuildFRem(B: BuilderRef,
1214 Name: *const c_char)
1216 pub fn LLVMBuildShl(B: BuilderRef,
1219 Name: *const c_char)
1221 pub fn LLVMBuildLShr(B: BuilderRef,
1224 Name: *const c_char)
1226 pub fn LLVMBuildAShr(B: BuilderRef,
1229 Name: *const c_char)
1231 pub fn LLVMBuildAnd(B: BuilderRef,
1234 Name: *const c_char)
1236 pub fn LLVMBuildOr(B: BuilderRef,
1239 Name: *const c_char)
1241 pub fn LLVMBuildXor(B: BuilderRef,
1244 Name: *const c_char)
1246 pub fn LLVMBuildBinOp(B: BuilderRef,
1250 Name: *const c_char)
1252 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1254 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1256 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1258 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1260 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1264 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1266 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1269 Name: *const c_char)
1271 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1273 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1276 Name: *const c_char)
1278 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1279 pub fn LLVMBuildLoad(B: BuilderRef,
1280 PointerVal: ValueRef,
1281 Name: *const c_char)
1284 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1287 pub fn LLVMBuildGEP(B: BuilderRef,
1289 Indices: *const ValueRef,
1291 Name: *const c_char)
1293 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1295 Indices: *const ValueRef,
1297 Name: *const c_char)
1299 pub fn LLVMBuildStructGEP(B: BuilderRef,
1302 Name: *const c_char)
1304 pub fn LLVMBuildGlobalString(B: BuilderRef,
1306 Name: *const c_char)
1308 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1310 Name: *const c_char)
1314 pub fn LLVMBuildTrunc(B: BuilderRef,
1317 Name: *const c_char)
1319 pub fn LLVMBuildZExt(B: BuilderRef,
1322 Name: *const c_char)
1324 pub fn LLVMBuildSExt(B: BuilderRef,
1327 Name: *const c_char)
1329 pub fn LLVMBuildFPToUI(B: BuilderRef,
1332 Name: *const c_char)
1334 pub fn LLVMBuildFPToSI(B: BuilderRef,
1337 Name: *const c_char)
1339 pub fn LLVMBuildUIToFP(B: BuilderRef,
1342 Name: *const c_char)
1344 pub fn LLVMBuildSIToFP(B: BuilderRef,
1347 Name: *const c_char)
1349 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1352 Name: *const c_char)
1354 pub fn LLVMBuildFPExt(B: BuilderRef,
1357 Name: *const c_char)
1359 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1362 Name: *const c_char)
1364 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1367 Name: *const c_char)
1369 pub fn LLVMBuildBitCast(B: BuilderRef,
1372 Name: *const c_char)
1374 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1377 Name: *const c_char)
1379 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1382 Name: *const c_char)
1384 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1387 Name: *const c_char)
1389 pub fn LLVMBuildCast(B: BuilderRef,
1393 Name: *const c_char) -> ValueRef;
1394 pub fn LLVMBuildPointerCast(B: BuilderRef,
1397 Name: *const c_char)
1399 pub fn LLVMBuildIntCast(B: BuilderRef,
1402 Name: *const c_char)
1404 pub fn LLVMBuildFPCast(B: BuilderRef,
1407 Name: *const c_char)
1411 pub fn LLVMBuildICmp(B: BuilderRef,
1415 Name: *const c_char)
1417 pub fn LLVMBuildFCmp(B: BuilderRef,
1421 Name: *const c_char)
1424 /* Miscellaneous instructions */
1425 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1427 pub fn LLVMBuildCall(B: BuilderRef,
1429 Args: *const ValueRef,
1431 Name: *const c_char)
1433 pub fn LLVMBuildSelect(B: BuilderRef,
1437 Name: *const c_char)
1439 pub fn LLVMBuildVAArg(B: BuilderRef,
1442 Name: *const c_char)
1444 pub fn LLVMBuildExtractElement(B: BuilderRef,
1447 Name: *const c_char)
1449 pub fn LLVMBuildInsertElement(B: BuilderRef,
1453 Name: *const c_char)
1455 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1459 Name: *const c_char)
1461 pub fn LLVMBuildExtractValue(B: BuilderRef,
1464 Name: *const c_char)
1466 pub fn LLVMBuildInsertValue(B: BuilderRef,
1470 Name: *const c_char)
1473 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1475 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1477 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1480 Name: *const c_char)
1483 /* Atomic Operations */
1484 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1485 PointerVal: ValueRef,
1486 Name: *const c_char,
1487 Order: AtomicOrdering,
1491 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1494 Order: AtomicOrdering,
1498 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1502 Order: AtomicOrdering,
1503 FailureOrder: AtomicOrdering)
1505 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1509 Order: AtomicOrdering,
1510 SingleThreaded: Bool)
1513 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1516 /* Selected entries from the downcasts. */
1517 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1518 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1520 /// Writes a module to the specified path. Returns 0 on success.
1521 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1523 /// Creates target data from a target layout string.
1524 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1525 /// Adds the target data to the given pass manager. The pass manager
1526 /// references the target data only weakly.
1527 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1528 /// Number of bytes clobbered when doing a Store to *T.
1529 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1532 /// Number of bytes clobbered when doing a Store to *T.
1533 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1536 /// Distance between successive elements in an array of T. Includes ABI padding.
1537 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1539 /// Returns the preferred alignment of a type.
1540 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1542 /// Returns the minimum alignment of a type.
1543 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1546 /// Computes the byte offset of the indexed struct element for a
1548 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1553 /// Returns the minimum alignment of a type when part of a call frame.
1554 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1557 /// Disposes target data.
1558 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1560 /// Creates a pass manager.
1561 pub fn LLVMCreatePassManager() -> PassManagerRef;
1563 /// Creates a function-by-function pass manager
1564 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1567 /// Disposes a pass manager.
1568 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1570 /// Runs a pass manager on a module.
1571 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1573 /// Runs the function passes on the provided function.
1574 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1577 /// Initializes all the function passes scheduled in the manager
1578 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1580 /// Finalizes all the function passes scheduled in the manager
1581 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1583 pub fn LLVMInitializePasses();
1585 /// Adds a verification pass.
1586 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1588 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1589 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1590 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1591 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1592 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1593 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1594 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1595 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1596 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1597 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1598 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1599 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1600 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1601 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1602 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1603 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1604 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1605 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1606 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1607 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1608 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1609 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1610 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1611 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1612 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1613 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1614 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1615 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1616 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1617 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1618 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1619 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1620 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1621 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1622 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1624 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1625 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1626 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1627 OptimizationLevel: c_uint);
1628 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1630 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1631 PMB: PassManagerBuilderRef,
1633 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1634 PMB: PassManagerBuilderRef,
1636 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1637 PMB: PassManagerBuilderRef,
1639 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1640 PMB: PassManagerBuilderRef,
1642 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1643 PMB: PassManagerBuilderRef,
1644 PM: PassManagerRef);
1646 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1647 PMB: PassManagerBuilderRef,
1648 PM: PassManagerRef);
1649 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1650 PMB: PassManagerBuilderRef,
1655 /// Destroys a memory buffer.
1656 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1659 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1661 /// Opens an object file.
1662 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1663 /// Closes an object file.
1664 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1666 /// Enumerates the sections in an object file.
1667 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1668 /// Destroys a section iterator.
1669 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1670 /// Returns true if the section iterator is at the end of the section
1672 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1673 SI: SectionIteratorRef)
1675 /// Moves the section iterator to point to the next section.
1676 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1677 /// Returns the current section size.
1678 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1679 /// Returns the current section contents as a string buffer.
1680 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1682 /// Reads the given file and returns it as a memory buffer. Use
1683 /// LLVMDisposeMemoryBuffer() to get rid of it.
1684 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1686 /// Borrows the contents of the memory buffer (doesn't copy it)
1687 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1688 InputDataLength: size_t,
1689 BufferName: *const c_char,
1692 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1693 InputDataLength: size_t,
1694 BufferName: *const c_char)
1697 pub fn LLVMIsMultithreaded() -> Bool;
1698 pub fn LLVMStartMultithreaded() -> Bool;
1700 /// Returns a string describing the last error caused by an LLVMRust* call.
1701 pub fn LLVMRustGetLastError() -> *const c_char;
1703 /// Print the pass timings since static dtors aren't picking them up.
1704 pub fn LLVMRustPrintPassTimings();
1706 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1708 pub fn LLVMStructSetBody(StructTy: TypeRef,
1709 ElementTypes: *const TypeRef,
1710 ElementCount: c_uint,
1713 pub fn LLVMConstNamedStruct(S: TypeRef,
1714 ConstantVals: *const ValueRef,
1718 /// Enables LLVM debug output.
1719 pub fn LLVMSetDebug(Enabled: c_int);
1721 /// Prepares inline assembly.
1722 pub fn LLVMInlineAsm(Ty: TypeRef,
1723 AsmString: *const c_char,
1724 Constraints: *const c_char,
1730 pub static LLVMRustDebugMetadataVersion: u32;
1732 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1733 name: *const c_char,
1736 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1738 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1740 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1742 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1744 File: *const c_char,
1746 Producer: *const c_char,
1748 Flags: *const c_char,
1750 SplitName: *const c_char)
1753 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1754 Filename: *const c_char,
1755 Directory: *const c_char)
1758 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1760 ParameterTypes: DIArray)
1763 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1764 Scope: DIDescriptor,
1765 Name: *const c_char,
1766 LinkageName: *const c_char,
1770 isLocalToUnit: bool,
1780 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1781 Name: *const c_char,
1782 SizeInBits: c_ulonglong,
1783 AlignInBits: c_ulonglong,
1787 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1789 SizeInBits: c_ulonglong,
1790 AlignInBits: c_ulonglong,
1791 Name: *const c_char)
1794 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1795 Scope: DIDescriptor,
1796 Name: *const c_char,
1799 SizeInBits: c_ulonglong,
1800 AlignInBits: c_ulonglong,
1802 DerivedFrom: DIType,
1804 RunTimeLang: c_uint,
1805 VTableHolder: ValueRef,
1806 UniqueId: *const c_char)
1809 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1810 Scope: DIDescriptor,
1811 Name: *const c_char,
1814 SizeInBits: c_ulonglong,
1815 AlignInBits: c_ulonglong,
1816 OffsetInBits: c_ulonglong,
1821 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1822 Scope: DIDescriptor,
1828 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1829 Context: DIDescriptor,
1830 Name: *const c_char,
1831 LinkageName: *const c_char,
1835 isLocalToUnit: bool,
1838 -> DIGlobalVariable;
1840 pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
1842 Scope: DIDescriptor,
1843 Name: *const c_char,
1847 AlwaysPreserve: bool,
1852 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1854 AlignInBits: c_ulonglong,
1856 Subscripts: DIArray)
1859 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1861 AlignInBits: c_ulonglong,
1863 Subscripts: DIArray)
1866 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1871 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1872 Ptr: *const DIDescriptor,
1876 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1878 VarInfo: DIVariable,
1879 InsertAtEnd: BasicBlockRef)
1882 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1884 VarInfo: DIVariable,
1885 InsertBefore: ValueRef)
1888 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1889 Name: *const c_char,
1893 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1895 Name: *const c_char,
1898 SizeInBits: c_ulonglong,
1899 AlignInBits: c_ulonglong,
1901 ClassType: ValueRef)
1904 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1906 Name: *const c_char,
1909 SizeInBits: c_ulonglong,
1910 AlignInBits: c_ulonglong,
1913 RunTimeLang: c_uint,
1914 UniqueId: *const c_char)
1917 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1919 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1921 Name: *const c_char,
1928 pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
1930 pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
1932 pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
1935 Name: *const c_char,
1939 AddrOps: *const ValueRef,
1940 AddrOpsCount: c_uint,
1944 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1946 Name: *const c_char,
1951 pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
1952 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1953 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1955 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1957 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1959 pub fn LLVMInitializeX86TargetInfo();
1960 pub fn LLVMInitializeX86Target();
1961 pub fn LLVMInitializeX86TargetMC();
1962 pub fn LLVMInitializeX86AsmPrinter();
1963 pub fn LLVMInitializeX86AsmParser();
1964 pub fn LLVMInitializeARMTargetInfo();
1965 pub fn LLVMInitializeARMTarget();
1966 pub fn LLVMInitializeARMTargetMC();
1967 pub fn LLVMInitializeARMAsmPrinter();
1968 pub fn LLVMInitializeARMAsmParser();
1969 pub fn LLVMInitializeAArch64TargetInfo();
1970 pub fn LLVMInitializeAArch64Target();
1971 pub fn LLVMInitializeAArch64TargetMC();
1972 pub fn LLVMInitializeAArch64AsmPrinter();
1973 pub fn LLVMInitializeAArch64AsmParser();
1974 pub fn LLVMInitializeMipsTargetInfo();
1975 pub fn LLVMInitializeMipsTarget();
1976 pub fn LLVMInitializeMipsTargetMC();
1977 pub fn LLVMInitializeMipsAsmPrinter();
1978 pub fn LLVMInitializeMipsAsmParser();
1979 pub fn LLVMInitializePowerPCTargetInfo();
1980 pub fn LLVMInitializePowerPCTarget();
1981 pub fn LLVMInitializePowerPCTargetMC();
1982 pub fn LLVMInitializePowerPCAsmPrinter();
1983 pub fn LLVMInitializePowerPCAsmParser();
1985 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
1986 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1988 Features: *const c_char,
1989 Model: CodeGenModel,
1991 Level: CodeGenOptLevel,
1994 NoFramePointerElim: bool,
1995 PositionIndependentExecutable: bool,
1996 FunctionSections: bool,
1997 DataSections: bool) -> TargetMachineRef;
1998 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1999 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
2002 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
2004 DisableSimplifyLibCalls: bool);
2005 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
2006 DisableSimplifyLibCalls: bool);
2007 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
2008 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2011 Output: *const c_char,
2012 FileType: FileType) -> bool;
2013 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2015 Output: *const c_char);
2016 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2017 pub fn LLVMRustPrintPasses();
2018 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2019 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2020 AddLifetimes: bool);
2021 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2023 len: size_t) -> bool;
2024 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2025 syms: *const *const c_char,
2027 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2029 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2030 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
2031 out_len: *mut size_t) -> *const c_char;
2032 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2034 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
2035 pub fn LLVMVersionMajor() -> c_int;
2036 pub fn LLVMVersionMinor() -> c_int;
2038 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2039 data: *mut *const c_char) -> c_int;
2041 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2043 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2044 Handler: DiagnosticHandler,
2045 DiagnosticContext: *mut c_void);
2047 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2048 pass_name_out: *mut *const c_char,
2049 function_out: *mut ValueRef,
2050 debugloc_out: *mut DebugLocRef,
2051 message_out: *mut TwineRef);
2053 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2054 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2055 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2057 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2059 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2060 H: InlineAsmDiagHandler,
2063 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2066 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2068 LLVMSetInstructionCallConv(instr, cc as c_uint);
2071 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2073 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2076 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2078 LLVMSetLinkage(global, link as c_uint);
2082 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2084 LLVMSetUnnamedAddr(global, unnamed as Bool);
2088 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2090 LLVMSetThreadLocal(global, is_thread_local as Bool);
2094 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2096 LLVMConstICmp(pred as c_ushort, v1, v2)
2099 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2101 LLVMConstFCmp(pred as c_ushort, v1, v2)
2105 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2107 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
2111 /* Memory-managed interface to target data. */
2113 pub struct TargetData {
2114 pub lltd: TargetDataRef
2117 impl Drop for TargetData {
2118 fn drop(&mut self) {
2120 LLVMDisposeTargetData(self.lltd);
2125 pub fn mk_target_data(string_rep: &str) -> TargetData {
2126 let string_rep = CString::from_slice(string_rep.as_bytes());
2128 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2132 /* Memory-managed interface to object files. */
2134 pub struct ObjectFile {
2135 pub llof: ObjectFileRef,
2139 // This will take ownership of llmb
2140 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2142 let llof = LLVMCreateObjectFile(llmb);
2143 if llof as int == 0 {
2144 // LLVMCreateObjectFile took ownership of llmb
2155 impl Drop for ObjectFile {
2156 fn drop(&mut self) {
2158 LLVMDisposeObjectFile(self.llof);
2163 /* Memory-managed interface to section iterators. */
2165 pub struct SectionIter {
2166 pub llsi: SectionIteratorRef
2169 impl Drop for SectionIter {
2170 fn drop(&mut self) {
2172 LLVMDisposeSectionIterator(self.llsi);
2177 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2180 llsi: LLVMGetSections(llof)
2185 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2186 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2188 assert!(index < LLVMCountParams(llfn));
2189 LLVMGetParam(llfn, index)
2193 #[allow(missing_copy_implementations)]
2194 pub enum RustString_opaque {}
2195 pub type RustStringRef = *mut RustString_opaque;
2196 type RustStringRepr = *mut RefCell<Vec<u8>>;
2198 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2200 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2203 let slice: &[u8] = mem::transmute(raw::Slice {
2204 data: ptr as *const u8,
2208 let sr: RustStringRepr = mem::transmute(sr);
2209 (*sr).borrow_mut().push_all(slice);
2212 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2213 let mut buf = RefCell::new(Vec::new());
2214 f(&mut buf as RustStringRepr as RustStringRef);
2215 String::from_utf8(buf.into_inner()).ok()
2218 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2219 build_string(|s| LLVMWriteTwineToString(tr, s))
2220 .expect("got a non-UTF8 Twine from LLVM")
2223 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2224 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2225 .expect("got a non-UTF8 DebugLoc from LLVM")
2228 // FIXME #15460 - create a public function that actually calls our
2229 // static LLVM symbols. Otherwise the linker will just throw llvm
2230 // away. We're just calling lots of stuff until we transitively get
2231 // all of LLVM. This is worse than anything.
2232 pub unsafe fn static_link_hack_this_sucks() {
2233 LLVMInitializePasses();
2235 LLVMInitializeX86TargetInfo();
2236 LLVMInitializeX86Target();
2237 LLVMInitializeX86TargetMC();
2238 LLVMInitializeX86AsmPrinter();
2239 LLVMInitializeX86AsmParser();
2241 LLVMInitializeARMTargetInfo();
2242 LLVMInitializeARMTarget();
2243 LLVMInitializeARMTargetMC();
2244 LLVMInitializeARMAsmPrinter();
2245 LLVMInitializeARMAsmParser();
2247 LLVMInitializeAArch64TargetInfo();
2248 LLVMInitializeAArch64Target();
2249 LLVMInitializeAArch64TargetMC();
2250 LLVMInitializeAArch64AsmPrinter();
2251 LLVMInitializeAArch64AsmParser();
2253 LLVMInitializeMipsTargetInfo();
2254 LLVMInitializeMipsTarget();
2255 LLVMInitializeMipsTargetMC();
2256 LLVMInitializeMipsAsmPrinter();
2257 LLVMInitializeMipsAsmParser();
2259 LLVMInitializePowerPCTargetInfo();
2260 LLVMInitializePowerPCTarget();
2261 LLVMInitializePowerPCTargetMC();
2262 LLVMInitializePowerPCAsmPrinter();
2263 LLVMInitializePowerPCAsmParser();
2265 LLVMRustSetLLVMOptions(0 as c_int,
2268 LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
2269 LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
2270 LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
2271 LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
2272 LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
2273 LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
2274 LLVMPassManagerBuilderCreate();
2275 LLVMPassManagerBuilderDispose(0 as *mut _);
2277 LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
2280 LLVMLinkInInterpreter();
2283 fn LLVMLinkInMCJIT();
2284 fn LLVMLinkInInterpreter();
2288 // The module containing the native LLVM dependencies, generated by the build system
2289 // Note that this must come after the rustllvm extern declaration so that
2290 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2291 // Works to the above fix for #15460 to ensure LLVM dependencies that
2292 // are only used by rustllvm don't get stripped by the linker.
2294 include! { env!("CFG_LLVM_LINKAGE_FILE") }