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"]
18 #![crate_type = "dylib"]
19 #![crate_type = "rlib"]
20 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
21 html_favicon_url = "http://www.rust-lang.org/favicon.ico",
22 html_root_url = "http://doc.rust-lang.org/nightly/")]
25 #![feature(link_args)]
26 #![feature(unboxed_closures)]
30 pub use self::OtherAttribute::*;
31 pub use self::SpecialAttribute::*;
32 pub use self::AttributeSet::*;
33 pub use self::IntPredicate::*;
34 pub use self::RealPredicate::*;
35 pub use self::TypeKind::*;
36 pub use self::AtomicBinOp::*;
37 pub use self::AtomicOrdering::*;
38 pub use self::FileType::*;
39 pub use self::MetadataType::*;
40 pub use self::AsmDialect::*;
41 pub use self::CodeGenOptLevel::*;
42 pub use self::RelocMode::*;
43 pub use self::CodeGenModel::*;
44 pub use self::DiagnosticKind::*;
45 pub use self::CallConv::*;
46 pub use self::Visibility::*;
47 pub use self::DiagnosticSeverity::*;
48 pub use self::Linkage::*;
50 use std::c_str::ToCStr;
51 use std::cell::RefCell;
53 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
54 use libc::{c_longlong, c_ulonglong, c_void};
55 use debuginfo::{DIBuilderRef, DIDescriptor,
56 DIFile, DILexicalBlock, DISubprogram, DIType,
57 DIBasicType, DIDerivedType, DICompositeType,
58 DIVariable, DIGlobalVariable, DIArray, DISubrange};
63 pub type Opcode = u32;
64 pub type Bool = c_uint;
66 pub const True: Bool = 1 as Bool;
67 pub const False: Bool = 0 as Bool;
69 // Consts for the LLVM CallConv type, pre-cast to uint.
71 #[derive(Copy, PartialEq)]
76 X86StdcallCallConv = 64,
77 X86FastcallCallConv = 65,
83 LLVMDefaultVisibility = 0,
85 ProtectedVisibility = 2,
88 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
89 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
90 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
91 // they've been removed in upstream LLVM commit r203866.
95 AvailableExternallyLinkage = 1,
96 LinkOnceAnyLinkage = 2,
97 LinkOnceODRLinkage = 3,
100 AppendingLinkage = 7,
103 ExternalWeakLinkage = 12,
108 #[derive(Copy, Show)]
109 pub enum DiagnosticSeverity {
117 flags Attribute : u32 {
118 const ZExtAttribute = 1 << 0,
119 const SExtAttribute = 1 << 1,
120 const NoReturnAttribute = 1 << 2,
121 const InRegAttribute = 1 << 3,
122 const StructRetAttribute = 1 << 4,
123 const NoUnwindAttribute = 1 << 5,
124 const NoAliasAttribute = 1 << 6,
125 const ByValAttribute = 1 << 7,
126 const NestAttribute = 1 << 8,
127 const ReadNoneAttribute = 1 << 9,
128 const ReadOnlyAttribute = 1 << 10,
129 const NoInlineAttribute = 1 << 11,
130 const AlwaysInlineAttribute = 1 << 12,
131 const OptimizeForSizeAttribute = 1 << 13,
132 const StackProtectAttribute = 1 << 14,
133 const StackProtectReqAttribute = 1 << 15,
134 const AlignmentAttribute = 31 << 16,
135 const NoCaptureAttribute = 1 << 21,
136 const NoRedZoneAttribute = 1 << 22,
137 const NoImplicitFloatAttribute = 1 << 23,
138 const NakedAttribute = 1 << 24,
139 const InlineHintAttribute = 1 << 25,
140 const StackAttribute = 7 << 26,
141 const ReturnsTwiceAttribute = 1 << 29,
142 const UWTableAttribute = 1 << 30,
143 const NonLazyBindAttribute = 1 << 31,
150 pub enum OtherAttribute {
151 // The following are not really exposed in
152 // the LLVM c api so instead to add these
153 // we call a wrapper function in RustWrapper
154 // that uses the C++ api.
155 SanitizeAddressAttribute = 1 << 32,
156 MinSizeAttribute = 1 << 33,
157 NoDuplicateAttribute = 1 << 34,
158 StackProtectStrongAttribute = 1 << 35,
159 SanitizeThreadAttribute = 1 << 36,
160 SanitizeMemoryAttribute = 1 << 37,
161 NoBuiltinAttribute = 1 << 38,
162 ReturnedAttribute = 1 << 39,
163 ColdAttribute = 1 << 40,
164 BuiltinAttribute = 1 << 41,
165 OptimizeNoneAttribute = 1 << 42,
166 InAllocaAttribute = 1 << 43,
167 NonNullAttribute = 1 << 44,
171 pub enum SpecialAttribute {
172 DereferenceableAttribute(u64)
177 pub enum AttributeSet {
182 pub trait AttrHelper {
183 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
184 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
187 impl AttrHelper for Attribute {
188 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
190 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
194 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
196 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
201 impl AttrHelper for OtherAttribute {
202 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
204 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
208 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
210 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
215 impl AttrHelper for SpecialAttribute {
216 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
218 DereferenceableAttribute(bytes) => unsafe {
219 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
224 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
226 DereferenceableAttribute(bytes) => unsafe {
227 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
233 pub struct AttrBuilder {
234 attrs: Vec<(uint, Box<AttrHelper+'static>)>
238 pub fn new() -> AttrBuilder {
244 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
245 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
249 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
250 self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
254 pub fn apply_llfn(&self, llfn: ValueRef) {
255 for &(idx, ref attr) in self.attrs.iter() {
256 attr.apply_llfn(idx as c_uint, llfn);
260 pub fn apply_callsite(&self, callsite: ValueRef) {
261 for &(idx, ref attr) in self.attrs.iter() {
262 attr.apply_callsite(idx as c_uint, callsite);
267 // enum for the LLVM IntPredicate type
269 pub enum IntPredicate {
282 // enum for the LLVM RealPredicate type
284 pub enum RealPredicate {
285 RealPredicateFalse = 0,
300 RealPredicateTrue = 15,
303 // The LLVM TypeKind type - must stay in sync with the def of
304 // LLVMTypeKind in llvm/include/llvm-c/Core.h
305 #[derive(Copy, PartialEq)]
328 pub enum AtomicBinOp {
344 pub enum AtomicOrdering {
348 // Consume = 3, // Not specified yet.
352 SequentiallyConsistent = 7
355 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
359 AssemblyFileType = 0,
364 pub enum MetadataType {
373 // Inline Asm Dialect
375 pub enum AsmDialect {
380 #[derive(Copy, PartialEq, Clone)]
382 pub enum CodeGenOptLevel {
383 CodeGenLevelNone = 0,
384 CodeGenLevelLess = 1,
385 CodeGenLevelDefault = 2,
386 CodeGenLevelAggressive = 3,
389 #[derive(Copy, PartialEq)]
395 RelocDynamicNoPic = 3,
400 pub enum CodeGenModel {
401 CodeModelDefault = 0,
402 CodeModelJITDefault = 1,
411 pub enum DiagnosticKind {
414 DK_DebugMetadataVersion,
416 DK_OptimizationRemark,
417 DK_OptimizationRemarkMissed,
418 DK_OptimizationRemarkAnalysis,
419 DK_OptimizationFailure,
422 // Opaque pointer types
423 #[allow(missing_copy_implementations)]
424 pub enum Module_opaque {}
425 pub type ModuleRef = *mut Module_opaque;
426 #[allow(missing_copy_implementations)]
427 pub enum Context_opaque {}
428 pub type ContextRef = *mut Context_opaque;
429 #[allow(missing_copy_implementations)]
430 pub enum Type_opaque {}
431 pub type TypeRef = *mut Type_opaque;
432 #[allow(missing_copy_implementations)]
433 pub enum Value_opaque {}
434 pub type ValueRef = *mut Value_opaque;
435 #[allow(missing_copy_implementations)]
436 pub enum BasicBlock_opaque {}
437 pub type BasicBlockRef = *mut BasicBlock_opaque;
438 #[allow(missing_copy_implementations)]
439 pub enum Builder_opaque {}
440 pub type BuilderRef = *mut Builder_opaque;
441 #[allow(missing_copy_implementations)]
442 pub enum ExecutionEngine_opaque {}
443 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
444 #[allow(missing_copy_implementations)]
445 pub enum RustJITMemoryManager_opaque {}
446 pub type RustJITMemoryManagerRef = *mut RustJITMemoryManager_opaque;
447 #[allow(missing_copy_implementations)]
448 pub enum MemoryBuffer_opaque {}
449 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
450 #[allow(missing_copy_implementations)]
451 pub enum PassManager_opaque {}
452 pub type PassManagerRef = *mut PassManager_opaque;
453 #[allow(missing_copy_implementations)]
454 pub enum PassManagerBuilder_opaque {}
455 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
456 #[allow(missing_copy_implementations)]
457 pub enum Use_opaque {}
458 pub type UseRef = *mut Use_opaque;
459 #[allow(missing_copy_implementations)]
460 pub enum TargetData_opaque {}
461 pub type TargetDataRef = *mut TargetData_opaque;
462 #[allow(missing_copy_implementations)]
463 pub enum ObjectFile_opaque {}
464 pub type ObjectFileRef = *mut ObjectFile_opaque;
465 #[allow(missing_copy_implementations)]
466 pub enum SectionIterator_opaque {}
467 pub type SectionIteratorRef = *mut SectionIterator_opaque;
468 #[allow(missing_copy_implementations)]
469 pub enum Pass_opaque {}
470 pub type PassRef = *mut Pass_opaque;
471 #[allow(missing_copy_implementations)]
472 pub enum TargetMachine_opaque {}
473 pub type TargetMachineRef = *mut TargetMachine_opaque;
474 #[allow(missing_copy_implementations)]
475 pub enum Archive_opaque {}
476 pub type ArchiveRef = *mut Archive_opaque;
477 #[allow(missing_copy_implementations)]
478 pub enum Twine_opaque {}
479 pub type TwineRef = *mut Twine_opaque;
480 #[allow(missing_copy_implementations)]
481 pub enum DiagnosticInfo_opaque {}
482 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
483 #[allow(missing_copy_implementations)]
484 pub enum DebugLoc_opaque {}
485 pub type DebugLocRef = *mut DebugLoc_opaque;
486 #[allow(missing_copy_implementations)]
487 pub enum SMDiagnostic_opaque {}
488 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
490 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
491 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
494 pub use self::DIDescriptorFlags::*;
495 use super::{ValueRef};
497 #[allow(missing_copy_implementations)]
498 pub enum DIBuilder_opaque {}
499 pub type DIBuilderRef = *mut DIBuilder_opaque;
501 pub type DIDescriptor = ValueRef;
502 pub type DIScope = DIDescriptor;
503 pub type DILocation = DIDescriptor;
504 pub type DIFile = DIScope;
505 pub type DILexicalBlock = DIScope;
506 pub type DISubprogram = DIScope;
507 pub type DIType = DIDescriptor;
508 pub type DIBasicType = DIType;
509 pub type DIDerivedType = DIType;
510 pub type DICompositeType = DIDerivedType;
511 pub type DIVariable = DIDescriptor;
512 pub type DIGlobalVariable = DIDescriptor;
513 pub type DIArray = DIDescriptor;
514 pub type DISubrange = DIDescriptor;
517 pub enum DIDescriptorFlags {
518 FlagPrivate = 1 << 0,
519 FlagProtected = 1 << 1,
520 FlagFwdDecl = 1 << 2,
521 FlagAppleBlock = 1 << 3,
522 FlagBlockByrefStruct = 1 << 4,
523 FlagVirtual = 1 << 5,
524 FlagArtificial = 1 << 6,
525 FlagExplicit = 1 << 7,
526 FlagPrototyped = 1 << 8,
527 FlagObjcClassComplete = 1 << 9,
528 FlagObjectPointer = 1 << 10,
529 FlagVector = 1 << 11,
530 FlagStaticMember = 1 << 12,
531 FlagIndirectVariable = 1 << 13,
532 FlagLValueReference = 1 << 14,
533 FlagRValueReference = 1 << 15
538 // Link to our native llvm bindings (things that we need to use the C++ api
539 // for) and because llvm is written in C++ we need to link against libstdc++
541 // You'll probably notice that there is an omission of all LLVM libraries
542 // from this location. This is because the set of LLVM libraries that we
543 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
544 // figure out the exact set of libraries. To do this, the build system
545 // generates an llvmdeps.rs file next to this one which will be
546 // automatically updated whenever LLVM is updated to include an up-to-date
547 // set of the libraries we need to link to LLVM for.
548 #[link(name = "rustllvm", kind = "static")]
550 /* Create and destroy contexts. */
551 pub fn LLVMContextCreate() -> ContextRef;
552 pub fn LLVMContextDispose(C: ContextRef);
553 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
558 /* Create and destroy modules. */
559 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
562 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
563 pub fn LLVMDisposeModule(M: ModuleRef);
565 /// Data layout. See Module::getDataLayout.
566 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
567 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
569 /// Target triple. See Module::getTargetTriple.
570 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
571 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
573 /// See Module::dump.
574 pub fn LLVMDumpModule(M: ModuleRef);
576 /// See Module::setModuleInlineAsm.
577 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
579 /// See llvm::LLVMTypeKind::getTypeID.
580 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
582 /// See llvm::LLVMType::getContext.
583 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
585 /* Operations on integer types */
586 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
587 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
588 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
589 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
590 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
591 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
594 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
596 /* Operations on real types */
597 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
598 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
599 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
600 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
601 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
603 /* Operations on function types */
604 pub fn LLVMFunctionType(ReturnType: TypeRef,
605 ParamTypes: *const TypeRef,
609 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
610 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
611 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
612 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
614 /* Operations on struct types */
615 pub fn LLVMStructTypeInContext(C: ContextRef,
616 ElementTypes: *const TypeRef,
617 ElementCount: c_uint,
620 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
621 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
623 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
625 /* Operations on array, pointer, and vector types (sequence types) */
626 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
627 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
629 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
632 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
633 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
634 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
635 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
637 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
639 /* Operations on other types */
640 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
641 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
642 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
644 /* Operations on all values */
645 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
646 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
647 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
648 pub fn LLVMDumpValue(Val: ValueRef);
649 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
650 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
651 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
652 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
654 /* Operations on Uses */
655 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
656 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
657 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
658 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
660 /* Operations on Users */
661 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
662 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
663 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
665 /* Operations on constants of any type */
666 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
668 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
669 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
671 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
673 /* only for int/vector */
674 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
675 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
676 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
677 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
678 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
680 /* Operations on metadata */
681 pub fn LLVMMDStringInContext(C: ContextRef,
685 pub fn LLVMMDNodeInContext(C: ContextRef,
686 Vals: *const ValueRef,
689 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
693 /* Operations on scalar constants */
694 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
696 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
698 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
703 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
704 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
706 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
710 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
711 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
714 /* Operations on composite constants */
715 pub fn LLVMConstStringInContext(C: ContextRef,
718 DontNullTerminate: Bool)
720 pub fn LLVMConstStructInContext(C: ContextRef,
721 ConstantVals: *const ValueRef,
726 pub fn LLVMConstArray(ElementTy: TypeRef,
727 ConstantVals: *const ValueRef,
730 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
733 /* Constant expressions */
734 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
735 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
736 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
737 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
738 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
739 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
740 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
741 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
743 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
745 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
747 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
749 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
751 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
753 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
755 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
757 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
759 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
761 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
763 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
765 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
767 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
769 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
770 RHSConstant: ValueRef)
772 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
774 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
776 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
778 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
780 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
782 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
784 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
786 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
788 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
790 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
792 pub fn LLVMConstGEP(ConstantVal: ValueRef,
793 ConstantIndices: *const ValueRef,
796 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
797 ConstantIndices: *const ValueRef,
800 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
802 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
804 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
806 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
808 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
810 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
812 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
814 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
816 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
818 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
820 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
822 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
824 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
826 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
828 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
830 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
832 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
836 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
838 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
839 ConstantIfTrue: ValueRef,
840 ConstantIfFalse: ValueRef)
842 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
843 IndexConstant: ValueRef)
845 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
846 ElementValueConstant: ValueRef,
847 IndexConstant: ValueRef)
849 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
850 VectorBConstant: ValueRef,
851 MaskConstant: ValueRef)
853 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
854 IdxList: *const c_uint,
857 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
858 ElementValueConstant: ValueRef,
859 IdxList: *const c_uint,
862 pub fn LLVMConstInlineAsm(Ty: TypeRef,
863 AsmString: *const c_char,
864 Constraints: *const c_char,
865 HasSideEffects: Bool,
868 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
872 /* Operations on global variables, functions, and aliases (globals) */
873 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
874 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
875 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
876 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
877 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
878 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
879 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
880 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
881 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
882 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
885 /* Operations on global variables */
886 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
888 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
891 AddressSpace: c_uint)
893 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
894 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
895 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
896 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
897 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
898 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
899 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
900 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
901 ConstantVal: ValueRef);
902 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
903 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
904 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
905 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
907 /* Operations on aliases */
908 pub fn LLVMAddAlias(M: ModuleRef,
914 /* Operations on functions */
915 pub fn LLVMAddFunction(M: ModuleRef,
919 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
920 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
921 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
922 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
923 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
924 pub fn LLVMDeleteFunction(Fn: ValueRef);
925 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
929 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
930 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
931 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
932 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
933 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
934 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
935 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
936 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
937 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
938 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
940 /* Operations on parameters */
941 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
942 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
943 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
944 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
945 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
946 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
947 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
948 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
949 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
950 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
951 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
952 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
954 /* Operations on basic blocks */
955 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
956 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
957 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
958 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
959 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
960 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
961 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
962 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
963 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
964 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
965 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
967 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
971 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
975 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
977 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
978 MoveAfter: BasicBlockRef);
980 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
981 MoveBefore: BasicBlockRef);
983 /* Operations on instructions */
984 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
985 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
986 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
987 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
988 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
989 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
991 /* Operations on call sites */
992 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
993 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
994 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
997 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1000 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1003 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1006 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1010 /* Operations on call instructions (only) */
1011 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1012 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1014 /* Operations on load/store instructions (only) */
1015 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1016 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1018 /* Operations on phi nodes */
1019 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1020 IncomingValues: *const ValueRef,
1021 IncomingBlocks: *const BasicBlockRef,
1023 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1024 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1026 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1029 /* Instruction builders */
1030 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1031 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1032 Block: BasicBlockRef,
1034 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1036 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1037 Block: BasicBlockRef);
1038 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1039 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1040 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1041 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1043 Name: *const c_char);
1044 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1046 /* Execution engine */
1047 pub fn LLVMRustCreateJITMemoryManager(morestack: *const ())
1048 -> RustJITMemoryManagerRef;
1049 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef,
1050 MM: RustJITMemoryManagerRef) -> ExecutionEngineRef;
1051 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1052 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1053 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1054 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1055 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1059 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1060 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1061 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1064 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1065 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1066 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1067 RetVals: *const ValueRef,
1070 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1071 pub fn LLVMBuildCondBr(B: BuilderRef,
1073 Then: BasicBlockRef,
1074 Else: BasicBlockRef)
1076 pub fn LLVMBuildSwitch(B: BuilderRef,
1078 Else: BasicBlockRef,
1081 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1085 pub fn LLVMBuildInvoke(B: BuilderRef,
1087 Args: *const ValueRef,
1089 Then: BasicBlockRef,
1090 Catch: BasicBlockRef,
1091 Name: *const c_char)
1093 pub fn LLVMBuildLandingPad(B: BuilderRef,
1097 Name: *const c_char)
1099 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1100 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1102 /* Add a case to the switch instruction */
1103 pub fn LLVMAddCase(Switch: ValueRef,
1105 Dest: BasicBlockRef);
1107 /* Add a destination to the indirectbr instruction */
1108 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1110 /* Add a clause to the landing pad instruction */
1111 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1113 /* Set the cleanup on a landing pad instruction */
1114 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1117 pub fn LLVMBuildAdd(B: BuilderRef,
1120 Name: *const c_char)
1122 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1125 Name: *const c_char)
1127 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1130 Name: *const c_char)
1132 pub fn LLVMBuildFAdd(B: BuilderRef,
1135 Name: *const c_char)
1137 pub fn LLVMBuildSub(B: BuilderRef,
1140 Name: *const c_char)
1142 pub fn LLVMBuildNSWSub(B: BuilderRef,
1145 Name: *const c_char)
1147 pub fn LLVMBuildNUWSub(B: BuilderRef,
1150 Name: *const c_char)
1152 pub fn LLVMBuildFSub(B: BuilderRef,
1155 Name: *const c_char)
1157 pub fn LLVMBuildMul(B: BuilderRef,
1160 Name: *const c_char)
1162 pub fn LLVMBuildNSWMul(B: BuilderRef,
1165 Name: *const c_char)
1167 pub fn LLVMBuildNUWMul(B: BuilderRef,
1170 Name: *const c_char)
1172 pub fn LLVMBuildFMul(B: BuilderRef,
1175 Name: *const c_char)
1177 pub fn LLVMBuildUDiv(B: BuilderRef,
1180 Name: *const c_char)
1182 pub fn LLVMBuildSDiv(B: BuilderRef,
1185 Name: *const c_char)
1187 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1190 Name: *const c_char)
1192 pub fn LLVMBuildFDiv(B: BuilderRef,
1195 Name: *const c_char)
1197 pub fn LLVMBuildURem(B: BuilderRef,
1200 Name: *const c_char)
1202 pub fn LLVMBuildSRem(B: BuilderRef,
1205 Name: *const c_char)
1207 pub fn LLVMBuildFRem(B: BuilderRef,
1210 Name: *const c_char)
1212 pub fn LLVMBuildShl(B: BuilderRef,
1215 Name: *const c_char)
1217 pub fn LLVMBuildLShr(B: BuilderRef,
1220 Name: *const c_char)
1222 pub fn LLVMBuildAShr(B: BuilderRef,
1225 Name: *const c_char)
1227 pub fn LLVMBuildAnd(B: BuilderRef,
1230 Name: *const c_char)
1232 pub fn LLVMBuildOr(B: BuilderRef,
1235 Name: *const c_char)
1237 pub fn LLVMBuildXor(B: BuilderRef,
1240 Name: *const c_char)
1242 pub fn LLVMBuildBinOp(B: BuilderRef,
1246 Name: *const c_char)
1248 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1250 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1252 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1254 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1256 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1260 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1262 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1265 Name: *const c_char)
1267 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1269 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1272 Name: *const c_char)
1274 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1275 pub fn LLVMBuildLoad(B: BuilderRef,
1276 PointerVal: ValueRef,
1277 Name: *const c_char)
1280 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1283 pub fn LLVMBuildGEP(B: BuilderRef,
1285 Indices: *const ValueRef,
1287 Name: *const c_char)
1289 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1291 Indices: *const ValueRef,
1293 Name: *const c_char)
1295 pub fn LLVMBuildStructGEP(B: BuilderRef,
1298 Name: *const c_char)
1300 pub fn LLVMBuildGlobalString(B: BuilderRef,
1302 Name: *const c_char)
1304 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1306 Name: *const c_char)
1310 pub fn LLVMBuildTrunc(B: BuilderRef,
1313 Name: *const c_char)
1315 pub fn LLVMBuildZExt(B: BuilderRef,
1318 Name: *const c_char)
1320 pub fn LLVMBuildSExt(B: BuilderRef,
1323 Name: *const c_char)
1325 pub fn LLVMBuildFPToUI(B: BuilderRef,
1328 Name: *const c_char)
1330 pub fn LLVMBuildFPToSI(B: BuilderRef,
1333 Name: *const c_char)
1335 pub fn LLVMBuildUIToFP(B: BuilderRef,
1338 Name: *const c_char)
1340 pub fn LLVMBuildSIToFP(B: BuilderRef,
1343 Name: *const c_char)
1345 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1348 Name: *const c_char)
1350 pub fn LLVMBuildFPExt(B: BuilderRef,
1353 Name: *const c_char)
1355 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1358 Name: *const c_char)
1360 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1363 Name: *const c_char)
1365 pub fn LLVMBuildBitCast(B: BuilderRef,
1368 Name: *const c_char)
1370 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1373 Name: *const c_char)
1375 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1378 Name: *const c_char)
1380 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1383 Name: *const c_char)
1385 pub fn LLVMBuildCast(B: BuilderRef,
1389 Name: *const c_char) -> ValueRef;
1390 pub fn LLVMBuildPointerCast(B: BuilderRef,
1393 Name: *const c_char)
1395 pub fn LLVMBuildIntCast(B: BuilderRef,
1398 Name: *const c_char)
1400 pub fn LLVMBuildFPCast(B: BuilderRef,
1403 Name: *const c_char)
1407 pub fn LLVMBuildICmp(B: BuilderRef,
1411 Name: *const c_char)
1413 pub fn LLVMBuildFCmp(B: BuilderRef,
1417 Name: *const c_char)
1420 /* Miscellaneous instructions */
1421 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1423 pub fn LLVMBuildCall(B: BuilderRef,
1425 Args: *const ValueRef,
1427 Name: *const c_char)
1429 pub fn LLVMBuildSelect(B: BuilderRef,
1433 Name: *const c_char)
1435 pub fn LLVMBuildVAArg(B: BuilderRef,
1438 Name: *const c_char)
1440 pub fn LLVMBuildExtractElement(B: BuilderRef,
1443 Name: *const c_char)
1445 pub fn LLVMBuildInsertElement(B: BuilderRef,
1449 Name: *const c_char)
1451 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1455 Name: *const c_char)
1457 pub fn LLVMBuildExtractValue(B: BuilderRef,
1460 Name: *const c_char)
1462 pub fn LLVMBuildInsertValue(B: BuilderRef,
1466 Name: *const c_char)
1469 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1471 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1473 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1476 Name: *const c_char)
1479 /* Atomic Operations */
1480 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1481 PointerVal: ValueRef,
1482 Name: *const c_char,
1483 Order: AtomicOrdering,
1487 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1490 Order: AtomicOrdering,
1494 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1498 Order: AtomicOrdering,
1499 FailureOrder: AtomicOrdering)
1501 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1505 Order: AtomicOrdering,
1506 SingleThreaded: Bool)
1509 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1512 /* Selected entries from the downcasts. */
1513 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1514 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1516 /// Writes a module to the specified path. Returns 0 on success.
1517 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1519 /// Creates target data from a target layout string.
1520 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1521 /// Adds the target data to the given pass manager. The pass manager
1522 /// references the target data only weakly.
1523 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1524 /// Number of bytes clobbered when doing a Store to *T.
1525 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1528 /// Number of bytes clobbered when doing a Store to *T.
1529 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1532 /// Distance between successive elements in an array of T. Includes ABI padding.
1533 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1535 /// Returns the preferred alignment of a type.
1536 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1538 /// Returns the minimum alignment of a type.
1539 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1542 /// Computes the byte offset of the indexed struct element for a
1544 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1549 /// Returns the minimum alignment of a type when part of a call frame.
1550 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1553 /// Disposes target data.
1554 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1556 /// Creates a pass manager.
1557 pub fn LLVMCreatePassManager() -> PassManagerRef;
1559 /// Creates a function-by-function pass manager
1560 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1563 /// Disposes a pass manager.
1564 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1566 /// Runs a pass manager on a module.
1567 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1569 /// Runs the function passes on the provided function.
1570 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1573 /// Initializes all the function passes scheduled in the manager
1574 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1576 /// Finalizes all the function passes scheduled in the manager
1577 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1579 pub fn LLVMInitializePasses();
1581 /// Adds a verification pass.
1582 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1584 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1585 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1586 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1587 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1588 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1589 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1590 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1591 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1592 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1593 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1594 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1595 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1596 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1597 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1598 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1599 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1600 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1601 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1602 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1603 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1604 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1605 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1606 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1607 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1608 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1609 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1610 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1611 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1612 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1613 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1614 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1615 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1616 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1617 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1618 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1620 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1621 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1622 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1623 OptimizationLevel: c_uint);
1624 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1626 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1627 PMB: PassManagerBuilderRef,
1629 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1630 PMB: PassManagerBuilderRef,
1632 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1633 PMB: PassManagerBuilderRef,
1635 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1636 PMB: PassManagerBuilderRef,
1638 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1639 PMB: PassManagerBuilderRef,
1640 PM: PassManagerRef);
1642 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1643 PMB: PassManagerBuilderRef,
1644 PM: PassManagerRef);
1645 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1646 PMB: PassManagerBuilderRef,
1651 /// Destroys a memory buffer.
1652 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1655 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1657 /// Opens an object file.
1658 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1659 /// Closes an object file.
1660 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1662 /// Enumerates the sections in an object file.
1663 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1664 /// Destroys a section iterator.
1665 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1666 /// Returns true if the section iterator is at the end of the section
1668 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1669 SI: SectionIteratorRef)
1671 /// Moves the section iterator to point to the next section.
1672 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1673 /// Returns the current section size.
1674 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1675 /// Returns the current section contents as a string buffer.
1676 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1678 /// Reads the given file and returns it as a memory buffer. Use
1679 /// LLVMDisposeMemoryBuffer() to get rid of it.
1680 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1682 /// Borrows the contents of the memory buffer (doesn't copy it)
1683 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1684 InputDataLength: size_t,
1685 BufferName: *const c_char,
1688 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1689 InputDataLength: size_t,
1690 BufferName: *const c_char)
1693 pub fn LLVMIsMultithreaded() -> Bool;
1694 pub fn LLVMStartMultithreaded() -> Bool;
1696 /// Returns a string describing the last error caused by an LLVMRust* call.
1697 pub fn LLVMRustGetLastError() -> *const c_char;
1699 /// Print the pass timings since static dtors aren't picking them up.
1700 pub fn LLVMRustPrintPassTimings();
1702 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1704 pub fn LLVMStructSetBody(StructTy: TypeRef,
1705 ElementTypes: *const TypeRef,
1706 ElementCount: c_uint,
1709 pub fn LLVMConstNamedStruct(S: TypeRef,
1710 ConstantVals: *const ValueRef,
1714 /// Enables LLVM debug output.
1715 pub fn LLVMSetDebug(Enabled: c_int);
1717 /// Prepares inline assembly.
1718 pub fn LLVMInlineAsm(Ty: TypeRef,
1719 AsmString: *const c_char,
1720 Constraints: *const c_char,
1726 pub static LLVMRustDebugMetadataVersion: u32;
1728 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1729 name: *const c_char,
1732 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1734 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1736 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1738 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1740 File: *const c_char,
1742 Producer: *const c_char,
1744 Flags: *const c_char,
1746 SplitName: *const c_char)
1749 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1750 Filename: *const c_char,
1751 Directory: *const c_char)
1754 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1756 ParameterTypes: DIArray)
1759 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1760 Scope: DIDescriptor,
1761 Name: *const c_char,
1762 LinkageName: *const c_char,
1766 isLocalToUnit: bool,
1776 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1777 Name: *const c_char,
1778 SizeInBits: c_ulonglong,
1779 AlignInBits: c_ulonglong,
1783 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1785 SizeInBits: c_ulonglong,
1786 AlignInBits: c_ulonglong,
1787 Name: *const c_char)
1790 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1791 Scope: DIDescriptor,
1792 Name: *const c_char,
1795 SizeInBits: c_ulonglong,
1796 AlignInBits: c_ulonglong,
1798 DerivedFrom: DIType,
1800 RunTimeLang: c_uint,
1801 VTableHolder: ValueRef,
1802 UniqueId: *const c_char)
1805 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1806 Scope: DIDescriptor,
1807 Name: *const c_char,
1810 SizeInBits: c_ulonglong,
1811 AlignInBits: c_ulonglong,
1812 OffsetInBits: c_ulonglong,
1817 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1818 Scope: DIDescriptor,
1824 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1825 Context: DIDescriptor,
1826 Name: *const c_char,
1827 LinkageName: *const c_char,
1831 isLocalToUnit: bool,
1834 -> DIGlobalVariable;
1836 pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
1838 Scope: DIDescriptor,
1839 Name: *const c_char,
1843 AlwaysPreserve: bool,
1848 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1850 AlignInBits: c_ulonglong,
1852 Subscripts: DIArray)
1855 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1857 AlignInBits: c_ulonglong,
1859 Subscripts: DIArray)
1862 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1867 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1868 Ptr: *const DIDescriptor,
1872 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1874 VarInfo: DIVariable,
1875 InsertAtEnd: BasicBlockRef)
1878 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1880 VarInfo: DIVariable,
1881 InsertBefore: ValueRef)
1884 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1885 Name: *const c_char,
1889 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1891 Name: *const c_char,
1894 SizeInBits: c_ulonglong,
1895 AlignInBits: c_ulonglong,
1897 ClassType: ValueRef)
1900 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1902 Name: *const c_char,
1905 SizeInBits: c_ulonglong,
1906 AlignInBits: c_ulonglong,
1909 RunTimeLang: c_uint,
1910 UniqueId: *const c_char)
1913 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1915 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1917 Name: *const c_char,
1924 pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
1926 pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
1928 pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
1931 Name: *const c_char,
1935 AddrOps: *const ValueRef,
1936 AddrOpsCount: c_uint,
1940 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1942 Name: *const c_char,
1947 pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
1948 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1949 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1951 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1953 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1955 pub fn LLVMInitializeX86TargetInfo();
1956 pub fn LLVMInitializeX86Target();
1957 pub fn LLVMInitializeX86TargetMC();
1958 pub fn LLVMInitializeX86AsmPrinter();
1959 pub fn LLVMInitializeX86AsmParser();
1960 pub fn LLVMInitializeARMTargetInfo();
1961 pub fn LLVMInitializeARMTarget();
1962 pub fn LLVMInitializeARMTargetMC();
1963 pub fn LLVMInitializeARMAsmPrinter();
1964 pub fn LLVMInitializeARMAsmParser();
1965 pub fn LLVMInitializeAArch64TargetInfo();
1966 pub fn LLVMInitializeAArch64Target();
1967 pub fn LLVMInitializeAArch64TargetMC();
1968 pub fn LLVMInitializeAArch64AsmPrinter();
1969 pub fn LLVMInitializeAArch64AsmParser();
1970 pub fn LLVMInitializeMipsTargetInfo();
1971 pub fn LLVMInitializeMipsTarget();
1972 pub fn LLVMInitializeMipsTargetMC();
1973 pub fn LLVMInitializeMipsAsmPrinter();
1974 pub fn LLVMInitializeMipsAsmParser();
1976 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
1977 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1979 Features: *const c_char,
1980 Model: CodeGenModel,
1982 Level: CodeGenOptLevel,
1985 NoFramePointerElim: bool,
1986 PositionIndependentExecutable: bool,
1987 FunctionSections: bool,
1988 DataSections: bool) -> TargetMachineRef;
1989 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1990 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1993 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1995 DisableSimplifyLibCalls: bool);
1996 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
1997 DisableSimplifyLibCalls: bool);
1998 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1999 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2002 Output: *const c_char,
2003 FileType: FileType) -> bool;
2004 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2006 Output: *const c_char);
2007 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2008 pub fn LLVMRustPrintPasses();
2009 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2010 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2011 AddLifetimes: bool);
2012 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2014 len: size_t) -> bool;
2015 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2016 syms: *const *const c_char,
2018 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2020 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2021 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
2022 out_len: *mut size_t) -> *const c_char;
2023 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2025 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
2026 pub fn LLVMVersionMajor() -> c_int;
2027 pub fn LLVMVersionMinor() -> c_int;
2029 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2030 data: *mut *const c_char) -> c_int;
2032 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2034 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2035 Handler: DiagnosticHandler,
2036 DiagnosticContext: *mut c_void);
2038 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2039 pass_name_out: *mut *const c_char,
2040 function_out: *mut ValueRef,
2041 debugloc_out: *mut DebugLocRef,
2042 message_out: *mut TwineRef);
2044 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2045 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2046 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2048 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2050 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2051 H: InlineAsmDiagHandler,
2054 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2057 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2059 LLVMSetInstructionCallConv(instr, cc as c_uint);
2062 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2064 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2067 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2069 LLVMSetLinkage(global, link as c_uint);
2073 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2075 LLVMSetUnnamedAddr(global, unnamed as Bool);
2079 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2081 LLVMSetThreadLocal(global, is_thread_local as Bool);
2085 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2087 LLVMConstICmp(pred as c_ushort, v1, v2)
2090 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2092 LLVMConstFCmp(pred as c_ushort, v1, v2)
2096 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2098 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
2102 /* Memory-managed interface to target data. */
2104 pub struct TargetData {
2105 pub lltd: TargetDataRef
2108 impl Drop for TargetData {
2109 fn drop(&mut self) {
2111 LLVMDisposeTargetData(self.lltd);
2116 pub fn mk_target_data(string_rep: &str) -> TargetData {
2118 lltd: string_rep.with_c_str(|buf| {
2119 unsafe { LLVMCreateTargetData(buf) }
2124 /* Memory-managed interface to object files. */
2126 pub struct ObjectFile {
2127 pub llof: ObjectFileRef,
2131 // This will take ownership of llmb
2132 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2134 let llof = LLVMCreateObjectFile(llmb);
2135 if llof as int == 0 {
2136 // LLVMCreateObjectFile took ownership of llmb
2147 impl Drop for ObjectFile {
2148 fn drop(&mut self) {
2150 LLVMDisposeObjectFile(self.llof);
2155 /* Memory-managed interface to section iterators. */
2157 pub struct SectionIter {
2158 pub llsi: SectionIteratorRef
2161 impl Drop for SectionIter {
2162 fn drop(&mut self) {
2164 LLVMDisposeSectionIterator(self.llsi);
2169 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2172 llsi: LLVMGetSections(llof)
2177 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2178 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2180 assert!(index < LLVMCountParams(llfn));
2181 LLVMGetParam(llfn, index)
2185 #[allow(missing_copy_implementations)]
2186 pub enum RustString_opaque {}
2187 pub type RustStringRef = *mut RustString_opaque;
2188 type RustStringRepr = *mut RefCell<Vec<u8>>;
2190 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2192 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2195 let slice: &[u8] = mem::transmute(raw::Slice {
2196 data: ptr as *const u8,
2200 let sr: RustStringRepr = mem::transmute(sr);
2201 (*sr).borrow_mut().push_all(slice);
2204 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2205 let mut buf = RefCell::new(Vec::new());
2206 f(&mut buf as RustStringRepr as RustStringRef);
2207 String::from_utf8(buf.into_inner()).ok()
2210 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2211 build_string(|s| LLVMWriteTwineToString(tr, s))
2212 .expect("got a non-UTF8 Twine from LLVM")
2215 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2216 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2217 .expect("got a non-UTF8 DebugLoc from LLVM")
2220 // FIXME #15460 - create a public function that actually calls our
2221 // static LLVM symbols. Otherwise the linker will just throw llvm
2222 // away. We're just calling lots of stuff until we transitively get
2223 // all of LLVM. This is worse than anything.
2224 pub unsafe fn static_link_hack_this_sucks() {
2225 LLVMInitializePasses();
2227 LLVMInitializeX86TargetInfo();
2228 LLVMInitializeX86Target();
2229 LLVMInitializeX86TargetMC();
2230 LLVMInitializeX86AsmPrinter();
2231 LLVMInitializeX86AsmParser();
2233 LLVMInitializeARMTargetInfo();
2234 LLVMInitializeARMTarget();
2235 LLVMInitializeARMTargetMC();
2236 LLVMInitializeARMAsmPrinter();
2237 LLVMInitializeARMAsmParser();
2239 LLVMInitializeAArch64TargetInfo();
2240 LLVMInitializeAArch64Target();
2241 LLVMInitializeAArch64TargetMC();
2242 LLVMInitializeAArch64AsmPrinter();
2243 LLVMInitializeAArch64AsmParser();
2245 LLVMInitializeMipsTargetInfo();
2246 LLVMInitializeMipsTarget();
2247 LLVMInitializeMipsTargetMC();
2248 LLVMInitializeMipsAsmPrinter();
2249 LLVMInitializeMipsAsmParser();
2251 LLVMRustSetLLVMOptions(0 as c_int,
2254 LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
2255 LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
2256 LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
2257 LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
2258 LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
2259 LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
2260 LLVMPassManagerBuilderCreate();
2261 LLVMPassManagerBuilderDispose(0 as *mut _);
2263 LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
2266 LLVMLinkInInterpreter();
2269 fn LLVMLinkInMCJIT();
2270 fn LLVMLinkInInterpreter();
2274 // The module containing the native LLVM dependencies, generated by the build system
2275 // Note that this must come after the rustllvm extern declaration so that
2276 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2277 // Works to the above fix for #15460 to ensure LLVM dependencies that
2278 // are only used by rustllvm don't get stripped by the linker.
2280 include! { env!("CFG_LLVM_LINKAGE_FILE") }