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)]
31 pub use self::OtherAttribute::*;
32 pub use self::SpecialAttribute::*;
33 pub use self::AttributeSet::*;
34 pub use self::IntPredicate::*;
35 pub use self::RealPredicate::*;
36 pub use self::TypeKind::*;
37 pub use self::AtomicBinOp::*;
38 pub use self::AtomicOrdering::*;
39 pub use self::FileType::*;
40 pub use self::MetadataType::*;
41 pub use self::AsmDialect::*;
42 pub use self::CodeGenOptLevel::*;
43 pub use self::RelocMode::*;
44 pub use self::CodeGenModel::*;
45 pub use self::DiagnosticKind::*;
46 pub use self::CallConv::*;
47 pub use self::Visibility::*;
48 pub use self::DiagnosticSeverity::*;
49 pub use self::Linkage::*;
51 use std::ffi::CString;
52 use std::cell::RefCell;
54 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
55 use libc::{c_longlong, c_ulonglong, c_void};
56 use debuginfo::{DIBuilderRef, DIDescriptor,
57 DIFile, DILexicalBlock, DISubprogram, DIType,
58 DIBasicType, DIDerivedType, DICompositeType,
59 DIVariable, DIGlobalVariable, DIArray, DISubrange};
64 pub type Opcode = u32;
65 pub type Bool = c_uint;
67 pub const True: Bool = 1 as Bool;
68 pub const False: Bool = 0 as Bool;
70 // Consts for the LLVM CallConv type, pre-cast to uint.
72 #[derive(Copy, PartialEq)]
77 X86StdcallCallConv = 64,
78 X86FastcallCallConv = 65,
84 LLVMDefaultVisibility = 0,
86 ProtectedVisibility = 2,
89 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
90 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
91 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
92 // they've been removed in upstream LLVM commit r203866.
96 AvailableExternallyLinkage = 1,
97 LinkOnceAnyLinkage = 2,
98 LinkOnceODRLinkage = 3,
101 AppendingLinkage = 7,
104 ExternalWeakLinkage = 12,
109 #[derive(Copy, Show)]
110 pub enum DiagnosticSeverity {
118 flags Attribute : u32 {
119 const ZExtAttribute = 1 << 0,
120 const SExtAttribute = 1 << 1,
121 const NoReturnAttribute = 1 << 2,
122 const InRegAttribute = 1 << 3,
123 const StructRetAttribute = 1 << 4,
124 const NoUnwindAttribute = 1 << 5,
125 const NoAliasAttribute = 1 << 6,
126 const ByValAttribute = 1 << 7,
127 const NestAttribute = 1 << 8,
128 const ReadNoneAttribute = 1 << 9,
129 const ReadOnlyAttribute = 1 << 10,
130 const NoInlineAttribute = 1 << 11,
131 const AlwaysInlineAttribute = 1 << 12,
132 const OptimizeForSizeAttribute = 1 << 13,
133 const StackProtectAttribute = 1 << 14,
134 const StackProtectReqAttribute = 1 << 15,
135 const AlignmentAttribute = 31 << 16,
136 const NoCaptureAttribute = 1 << 21,
137 const NoRedZoneAttribute = 1 << 22,
138 const NoImplicitFloatAttribute = 1 << 23,
139 const NakedAttribute = 1 << 24,
140 const InlineHintAttribute = 1 << 25,
141 const StackAttribute = 7 << 26,
142 const ReturnsTwiceAttribute = 1 << 29,
143 const UWTableAttribute = 1 << 30,
144 const NonLazyBindAttribute = 1 << 31,
151 pub enum OtherAttribute {
152 // The following are not really exposed in
153 // the LLVM c api so instead to add these
154 // we call a wrapper function in RustWrapper
155 // that uses the C++ api.
156 SanitizeAddressAttribute = 1 << 32,
157 MinSizeAttribute = 1 << 33,
158 NoDuplicateAttribute = 1 << 34,
159 StackProtectStrongAttribute = 1 << 35,
160 SanitizeThreadAttribute = 1 << 36,
161 SanitizeMemoryAttribute = 1 << 37,
162 NoBuiltinAttribute = 1 << 38,
163 ReturnedAttribute = 1 << 39,
164 ColdAttribute = 1 << 40,
165 BuiltinAttribute = 1 << 41,
166 OptimizeNoneAttribute = 1 << 42,
167 InAllocaAttribute = 1 << 43,
168 NonNullAttribute = 1 << 44,
172 pub enum SpecialAttribute {
173 DereferenceableAttribute(u64)
178 pub enum AttributeSet {
183 pub trait AttrHelper {
184 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
185 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
188 impl AttrHelper for Attribute {
189 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
191 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
195 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
197 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
202 impl AttrHelper for OtherAttribute {
203 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
205 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
209 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
211 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
216 impl AttrHelper for SpecialAttribute {
217 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
219 DereferenceableAttribute(bytes) => unsafe {
220 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
225 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
227 DereferenceableAttribute(bytes) => unsafe {
228 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
234 pub struct AttrBuilder {
235 attrs: Vec<(uint, Box<AttrHelper+'static>)>
239 pub fn new() -> AttrBuilder {
245 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
246 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
250 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
251 self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
255 pub fn apply_llfn(&self, llfn: ValueRef) {
256 for &(idx, ref attr) in self.attrs.iter() {
257 attr.apply_llfn(idx as c_uint, llfn);
261 pub fn apply_callsite(&self, callsite: ValueRef) {
262 for &(idx, ref attr) in self.attrs.iter() {
263 attr.apply_callsite(idx as c_uint, callsite);
268 // enum for the LLVM IntPredicate type
270 pub enum IntPredicate {
283 // enum for the LLVM RealPredicate type
285 pub enum RealPredicate {
286 RealPredicateFalse = 0,
301 RealPredicateTrue = 15,
304 // The LLVM TypeKind type - must stay in sync with the def of
305 // LLVMTypeKind in llvm/include/llvm-c/Core.h
306 #[derive(Copy, PartialEq)]
329 pub enum AtomicBinOp {
345 pub enum AtomicOrdering {
349 // Consume = 3, // Not specified yet.
353 SequentiallyConsistent = 7
356 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
360 AssemblyFileType = 0,
365 pub enum MetadataType {
374 // Inline Asm Dialect
376 pub enum AsmDialect {
381 #[derive(Copy, PartialEq, Clone)]
383 pub enum CodeGenOptLevel {
384 CodeGenLevelNone = 0,
385 CodeGenLevelLess = 1,
386 CodeGenLevelDefault = 2,
387 CodeGenLevelAggressive = 3,
390 #[derive(Copy, PartialEq)]
396 RelocDynamicNoPic = 3,
401 pub enum CodeGenModel {
402 CodeModelDefault = 0,
403 CodeModelJITDefault = 1,
412 pub enum DiagnosticKind {
415 DK_DebugMetadataVersion,
417 DK_OptimizationRemark,
418 DK_OptimizationRemarkMissed,
419 DK_OptimizationRemarkAnalysis,
420 DK_OptimizationFailure,
423 // Opaque pointer types
424 #[allow(missing_copy_implementations)]
425 pub enum Module_opaque {}
426 pub type ModuleRef = *mut Module_opaque;
427 #[allow(missing_copy_implementations)]
428 pub enum Context_opaque {}
429 pub type ContextRef = *mut Context_opaque;
430 #[allow(missing_copy_implementations)]
431 pub enum Type_opaque {}
432 pub type TypeRef = *mut Type_opaque;
433 #[allow(missing_copy_implementations)]
434 pub enum Value_opaque {}
435 pub type ValueRef = *mut Value_opaque;
436 #[allow(missing_copy_implementations)]
437 pub enum BasicBlock_opaque {}
438 pub type BasicBlockRef = *mut BasicBlock_opaque;
439 #[allow(missing_copy_implementations)]
440 pub enum Builder_opaque {}
441 pub type BuilderRef = *mut Builder_opaque;
442 #[allow(missing_copy_implementations)]
443 pub enum ExecutionEngine_opaque {}
444 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
445 #[allow(missing_copy_implementations)]
446 pub enum RustJITMemoryManager_opaque {}
447 pub type RustJITMemoryManagerRef = *mut RustJITMemoryManager_opaque;
448 #[allow(missing_copy_implementations)]
449 pub enum MemoryBuffer_opaque {}
450 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
451 #[allow(missing_copy_implementations)]
452 pub enum PassManager_opaque {}
453 pub type PassManagerRef = *mut PassManager_opaque;
454 #[allow(missing_copy_implementations)]
455 pub enum PassManagerBuilder_opaque {}
456 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
457 #[allow(missing_copy_implementations)]
458 pub enum Use_opaque {}
459 pub type UseRef = *mut Use_opaque;
460 #[allow(missing_copy_implementations)]
461 pub enum TargetData_opaque {}
462 pub type TargetDataRef = *mut TargetData_opaque;
463 #[allow(missing_copy_implementations)]
464 pub enum ObjectFile_opaque {}
465 pub type ObjectFileRef = *mut ObjectFile_opaque;
466 #[allow(missing_copy_implementations)]
467 pub enum SectionIterator_opaque {}
468 pub type SectionIteratorRef = *mut SectionIterator_opaque;
469 #[allow(missing_copy_implementations)]
470 pub enum Pass_opaque {}
471 pub type PassRef = *mut Pass_opaque;
472 #[allow(missing_copy_implementations)]
473 pub enum TargetMachine_opaque {}
474 pub type TargetMachineRef = *mut TargetMachine_opaque;
475 #[allow(missing_copy_implementations)]
476 pub enum Archive_opaque {}
477 pub type ArchiveRef = *mut Archive_opaque;
478 #[allow(missing_copy_implementations)]
479 pub enum Twine_opaque {}
480 pub type TwineRef = *mut Twine_opaque;
481 #[allow(missing_copy_implementations)]
482 pub enum DiagnosticInfo_opaque {}
483 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
484 #[allow(missing_copy_implementations)]
485 pub enum DebugLoc_opaque {}
486 pub type DebugLocRef = *mut DebugLoc_opaque;
487 #[allow(missing_copy_implementations)]
488 pub enum SMDiagnostic_opaque {}
489 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
491 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
492 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
495 pub use self::DIDescriptorFlags::*;
496 use super::{ValueRef};
498 #[allow(missing_copy_implementations)]
499 pub enum DIBuilder_opaque {}
500 pub type DIBuilderRef = *mut DIBuilder_opaque;
502 pub type DIDescriptor = ValueRef;
503 pub type DIScope = DIDescriptor;
504 pub type DILocation = DIDescriptor;
505 pub type DIFile = DIScope;
506 pub type DILexicalBlock = DIScope;
507 pub type DISubprogram = DIScope;
508 pub type DIType = DIDescriptor;
509 pub type DIBasicType = DIType;
510 pub type DIDerivedType = DIType;
511 pub type DICompositeType = DIDerivedType;
512 pub type DIVariable = DIDescriptor;
513 pub type DIGlobalVariable = DIDescriptor;
514 pub type DIArray = DIDescriptor;
515 pub type DISubrange = DIDescriptor;
518 pub enum DIDescriptorFlags {
519 FlagPrivate = 1 << 0,
520 FlagProtected = 1 << 1,
521 FlagFwdDecl = 1 << 2,
522 FlagAppleBlock = 1 << 3,
523 FlagBlockByrefStruct = 1 << 4,
524 FlagVirtual = 1 << 5,
525 FlagArtificial = 1 << 6,
526 FlagExplicit = 1 << 7,
527 FlagPrototyped = 1 << 8,
528 FlagObjcClassComplete = 1 << 9,
529 FlagObjectPointer = 1 << 10,
530 FlagVector = 1 << 11,
531 FlagStaticMember = 1 << 12,
532 FlagIndirectVariable = 1 << 13,
533 FlagLValueReference = 1 << 14,
534 FlagRValueReference = 1 << 15
539 // Link to our native llvm bindings (things that we need to use the C++ api
540 // for) and because llvm is written in C++ we need to link against libstdc++
542 // You'll probably notice that there is an omission of all LLVM libraries
543 // from this location. This is because the set of LLVM libraries that we
544 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
545 // figure out the exact set of libraries. To do this, the build system
546 // generates an llvmdeps.rs file next to this one which will be
547 // automatically updated whenever LLVM is updated to include an up-to-date
548 // set of the libraries we need to link to LLVM for.
549 #[link(name = "rustllvm", kind = "static")]
551 /* Create and destroy contexts. */
552 pub fn LLVMContextCreate() -> ContextRef;
553 pub fn LLVMContextDispose(C: ContextRef);
554 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
559 /* Create and destroy modules. */
560 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
563 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
564 pub fn LLVMDisposeModule(M: ModuleRef);
566 /// Data layout. See Module::getDataLayout.
567 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
568 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
570 /// Target triple. See Module::getTargetTriple.
571 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
572 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
574 /// See Module::dump.
575 pub fn LLVMDumpModule(M: ModuleRef);
577 /// See Module::setModuleInlineAsm.
578 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
580 /// See llvm::LLVMTypeKind::getTypeID.
581 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
583 /// See llvm::LLVMType::getContext.
584 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
586 /* Operations on integer types */
587 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
588 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
589 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
590 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
591 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
592 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
595 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
597 /* Operations on real types */
598 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
599 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
600 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
601 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
602 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
604 /* Operations on function types */
605 pub fn LLVMFunctionType(ReturnType: TypeRef,
606 ParamTypes: *const TypeRef,
610 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
611 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
612 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
613 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
615 /* Operations on struct types */
616 pub fn LLVMStructTypeInContext(C: ContextRef,
617 ElementTypes: *const TypeRef,
618 ElementCount: c_uint,
621 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
622 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
624 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
626 /* Operations on array, pointer, and vector types (sequence types) */
627 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
628 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
630 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
633 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
634 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
635 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
636 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
638 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
640 /* Operations on other types */
641 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
642 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
643 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
645 /* Operations on all values */
646 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
647 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
648 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
649 pub fn LLVMDumpValue(Val: ValueRef);
650 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
651 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
652 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
653 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
655 /* Operations on Uses */
656 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
657 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
658 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
659 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
661 /* Operations on Users */
662 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
663 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
664 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
666 /* Operations on constants of any type */
667 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
669 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
670 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
672 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
674 /* only for int/vector */
675 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
676 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
677 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
678 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
679 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
681 /* Operations on metadata */
682 pub fn LLVMMDStringInContext(C: ContextRef,
686 pub fn LLVMMDNodeInContext(C: ContextRef,
687 Vals: *const ValueRef,
690 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
694 /* Operations on scalar constants */
695 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
697 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
699 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
704 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
705 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
707 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
711 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
712 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
715 /* Operations on composite constants */
716 pub fn LLVMConstStringInContext(C: ContextRef,
719 DontNullTerminate: Bool)
721 pub fn LLVMConstStructInContext(C: ContextRef,
722 ConstantVals: *const ValueRef,
727 pub fn LLVMConstArray(ElementTy: TypeRef,
728 ConstantVals: *const ValueRef,
731 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
734 /* Constant expressions */
735 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
736 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
737 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
738 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
739 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
740 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
741 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
742 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
744 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
746 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
748 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
750 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
752 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
754 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
756 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
758 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
760 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
762 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
764 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
766 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
768 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
770 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
771 RHSConstant: ValueRef)
773 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
775 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
777 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
779 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
781 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
783 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
785 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
787 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
789 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
791 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
793 pub fn LLVMConstGEP(ConstantVal: ValueRef,
794 ConstantIndices: *const ValueRef,
797 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
798 ConstantIndices: *const ValueRef,
801 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
803 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
805 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
807 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
809 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
811 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
813 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
815 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
817 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
819 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
821 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
823 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
825 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
827 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
829 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
831 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
833 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
837 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
839 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
840 ConstantIfTrue: ValueRef,
841 ConstantIfFalse: ValueRef)
843 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
844 IndexConstant: ValueRef)
846 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
847 ElementValueConstant: ValueRef,
848 IndexConstant: ValueRef)
850 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
851 VectorBConstant: ValueRef,
852 MaskConstant: ValueRef)
854 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
855 IdxList: *const c_uint,
858 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
859 ElementValueConstant: ValueRef,
860 IdxList: *const c_uint,
863 pub fn LLVMConstInlineAsm(Ty: TypeRef,
864 AsmString: *const c_char,
865 Constraints: *const c_char,
866 HasSideEffects: Bool,
869 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
873 /* Operations on global variables, functions, and aliases (globals) */
874 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
875 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
876 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
877 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
878 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
879 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
880 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
881 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
882 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
883 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
886 /* Operations on global variables */
887 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
889 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
892 AddressSpace: c_uint)
894 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
895 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
896 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
897 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
898 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
899 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
900 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
901 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
902 ConstantVal: ValueRef);
903 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
904 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
905 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
906 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
908 /* Operations on aliases */
909 pub fn LLVMAddAlias(M: ModuleRef,
915 /* Operations on functions */
916 pub fn LLVMAddFunction(M: ModuleRef,
920 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
921 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
922 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
923 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
924 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
925 pub fn LLVMDeleteFunction(Fn: ValueRef);
926 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
930 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
931 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
932 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
933 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
934 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
935 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
936 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
937 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
938 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
939 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
941 /* Operations on parameters */
942 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
943 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
944 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
945 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
946 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
947 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
948 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
949 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
950 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
951 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
952 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
953 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
955 /* Operations on basic blocks */
956 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
957 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
958 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
959 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
960 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
961 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
962 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
963 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
964 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
965 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
966 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
968 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
972 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
976 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
978 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
979 MoveAfter: BasicBlockRef);
981 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
982 MoveBefore: BasicBlockRef);
984 /* Operations on instructions */
985 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
986 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
987 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
988 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
989 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
990 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
992 /* Operations on call sites */
993 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
994 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
995 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
998 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1001 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1004 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1007 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1011 /* Operations on call instructions (only) */
1012 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1013 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1015 /* Operations on load/store instructions (only) */
1016 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1017 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1019 /* Operations on phi nodes */
1020 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1021 IncomingValues: *const ValueRef,
1022 IncomingBlocks: *const BasicBlockRef,
1024 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1025 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1027 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1030 /* Instruction builders */
1031 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1032 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1033 Block: BasicBlockRef,
1035 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1037 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1038 Block: BasicBlockRef);
1039 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1040 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1041 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1042 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1044 Name: *const c_char);
1045 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1047 /* Execution engine */
1048 pub fn LLVMRustCreateJITMemoryManager(morestack: *const ())
1049 -> RustJITMemoryManagerRef;
1050 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef,
1051 MM: RustJITMemoryManagerRef) -> ExecutionEngineRef;
1052 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1053 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1054 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1055 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1056 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1060 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1061 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1062 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1065 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1066 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1067 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1068 RetVals: *const ValueRef,
1071 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1072 pub fn LLVMBuildCondBr(B: BuilderRef,
1074 Then: BasicBlockRef,
1075 Else: BasicBlockRef)
1077 pub fn LLVMBuildSwitch(B: BuilderRef,
1079 Else: BasicBlockRef,
1082 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1086 pub fn LLVMBuildInvoke(B: BuilderRef,
1088 Args: *const ValueRef,
1090 Then: BasicBlockRef,
1091 Catch: BasicBlockRef,
1092 Name: *const c_char)
1094 pub fn LLVMBuildLandingPad(B: BuilderRef,
1098 Name: *const c_char)
1100 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1101 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1103 /* Add a case to the switch instruction */
1104 pub fn LLVMAddCase(Switch: ValueRef,
1106 Dest: BasicBlockRef);
1108 /* Add a destination to the indirectbr instruction */
1109 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1111 /* Add a clause to the landing pad instruction */
1112 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1114 /* Set the cleanup on a landing pad instruction */
1115 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1118 pub fn LLVMBuildAdd(B: BuilderRef,
1121 Name: *const c_char)
1123 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1126 Name: *const c_char)
1128 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1131 Name: *const c_char)
1133 pub fn LLVMBuildFAdd(B: BuilderRef,
1136 Name: *const c_char)
1138 pub fn LLVMBuildSub(B: BuilderRef,
1141 Name: *const c_char)
1143 pub fn LLVMBuildNSWSub(B: BuilderRef,
1146 Name: *const c_char)
1148 pub fn LLVMBuildNUWSub(B: BuilderRef,
1151 Name: *const c_char)
1153 pub fn LLVMBuildFSub(B: BuilderRef,
1156 Name: *const c_char)
1158 pub fn LLVMBuildMul(B: BuilderRef,
1161 Name: *const c_char)
1163 pub fn LLVMBuildNSWMul(B: BuilderRef,
1166 Name: *const c_char)
1168 pub fn LLVMBuildNUWMul(B: BuilderRef,
1171 Name: *const c_char)
1173 pub fn LLVMBuildFMul(B: BuilderRef,
1176 Name: *const c_char)
1178 pub fn LLVMBuildUDiv(B: BuilderRef,
1181 Name: *const c_char)
1183 pub fn LLVMBuildSDiv(B: BuilderRef,
1186 Name: *const c_char)
1188 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1191 Name: *const c_char)
1193 pub fn LLVMBuildFDiv(B: BuilderRef,
1196 Name: *const c_char)
1198 pub fn LLVMBuildURem(B: BuilderRef,
1201 Name: *const c_char)
1203 pub fn LLVMBuildSRem(B: BuilderRef,
1206 Name: *const c_char)
1208 pub fn LLVMBuildFRem(B: BuilderRef,
1211 Name: *const c_char)
1213 pub fn LLVMBuildShl(B: BuilderRef,
1216 Name: *const c_char)
1218 pub fn LLVMBuildLShr(B: BuilderRef,
1221 Name: *const c_char)
1223 pub fn LLVMBuildAShr(B: BuilderRef,
1226 Name: *const c_char)
1228 pub fn LLVMBuildAnd(B: BuilderRef,
1231 Name: *const c_char)
1233 pub fn LLVMBuildOr(B: BuilderRef,
1236 Name: *const c_char)
1238 pub fn LLVMBuildXor(B: BuilderRef,
1241 Name: *const c_char)
1243 pub fn LLVMBuildBinOp(B: BuilderRef,
1247 Name: *const c_char)
1249 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1251 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1253 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1255 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1257 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1261 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1263 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1266 Name: *const c_char)
1268 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1270 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1273 Name: *const c_char)
1275 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1276 pub fn LLVMBuildLoad(B: BuilderRef,
1277 PointerVal: ValueRef,
1278 Name: *const c_char)
1281 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1284 pub fn LLVMBuildGEP(B: BuilderRef,
1286 Indices: *const ValueRef,
1288 Name: *const c_char)
1290 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1292 Indices: *const ValueRef,
1294 Name: *const c_char)
1296 pub fn LLVMBuildStructGEP(B: BuilderRef,
1299 Name: *const c_char)
1301 pub fn LLVMBuildGlobalString(B: BuilderRef,
1303 Name: *const c_char)
1305 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1307 Name: *const c_char)
1311 pub fn LLVMBuildTrunc(B: BuilderRef,
1314 Name: *const c_char)
1316 pub fn LLVMBuildZExt(B: BuilderRef,
1319 Name: *const c_char)
1321 pub fn LLVMBuildSExt(B: BuilderRef,
1324 Name: *const c_char)
1326 pub fn LLVMBuildFPToUI(B: BuilderRef,
1329 Name: *const c_char)
1331 pub fn LLVMBuildFPToSI(B: BuilderRef,
1334 Name: *const c_char)
1336 pub fn LLVMBuildUIToFP(B: BuilderRef,
1339 Name: *const c_char)
1341 pub fn LLVMBuildSIToFP(B: BuilderRef,
1344 Name: *const c_char)
1346 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1349 Name: *const c_char)
1351 pub fn LLVMBuildFPExt(B: BuilderRef,
1354 Name: *const c_char)
1356 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1359 Name: *const c_char)
1361 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1364 Name: *const c_char)
1366 pub fn LLVMBuildBitCast(B: BuilderRef,
1369 Name: *const c_char)
1371 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1374 Name: *const c_char)
1376 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1379 Name: *const c_char)
1381 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1384 Name: *const c_char)
1386 pub fn LLVMBuildCast(B: BuilderRef,
1390 Name: *const c_char) -> ValueRef;
1391 pub fn LLVMBuildPointerCast(B: BuilderRef,
1394 Name: *const c_char)
1396 pub fn LLVMBuildIntCast(B: BuilderRef,
1399 Name: *const c_char)
1401 pub fn LLVMBuildFPCast(B: BuilderRef,
1404 Name: *const c_char)
1408 pub fn LLVMBuildICmp(B: BuilderRef,
1412 Name: *const c_char)
1414 pub fn LLVMBuildFCmp(B: BuilderRef,
1418 Name: *const c_char)
1421 /* Miscellaneous instructions */
1422 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1424 pub fn LLVMBuildCall(B: BuilderRef,
1426 Args: *const ValueRef,
1428 Name: *const c_char)
1430 pub fn LLVMBuildSelect(B: BuilderRef,
1434 Name: *const c_char)
1436 pub fn LLVMBuildVAArg(B: BuilderRef,
1439 Name: *const c_char)
1441 pub fn LLVMBuildExtractElement(B: BuilderRef,
1444 Name: *const c_char)
1446 pub fn LLVMBuildInsertElement(B: BuilderRef,
1450 Name: *const c_char)
1452 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1456 Name: *const c_char)
1458 pub fn LLVMBuildExtractValue(B: BuilderRef,
1461 Name: *const c_char)
1463 pub fn LLVMBuildInsertValue(B: BuilderRef,
1467 Name: *const c_char)
1470 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1472 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1474 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1477 Name: *const c_char)
1480 /* Atomic Operations */
1481 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1482 PointerVal: ValueRef,
1483 Name: *const c_char,
1484 Order: AtomicOrdering,
1488 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1491 Order: AtomicOrdering,
1495 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1499 Order: AtomicOrdering,
1500 FailureOrder: AtomicOrdering)
1502 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1506 Order: AtomicOrdering,
1507 SingleThreaded: Bool)
1510 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1513 /* Selected entries from the downcasts. */
1514 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1515 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1517 /// Writes a module to the specified path. Returns 0 on success.
1518 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1520 /// Creates target data from a target layout string.
1521 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1522 /// Adds the target data to the given pass manager. The pass manager
1523 /// references the target data only weakly.
1524 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1525 /// Number of bytes clobbered when doing a Store to *T.
1526 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1529 /// Number of bytes clobbered when doing a Store to *T.
1530 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1533 /// Distance between successive elements in an array of T. Includes ABI padding.
1534 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1536 /// Returns the preferred alignment of a type.
1537 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1539 /// Returns the minimum alignment of a type.
1540 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1543 /// Computes the byte offset of the indexed struct element for a
1545 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1550 /// Returns the minimum alignment of a type when part of a call frame.
1551 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1554 /// Disposes target data.
1555 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1557 /// Creates a pass manager.
1558 pub fn LLVMCreatePassManager() -> PassManagerRef;
1560 /// Creates a function-by-function pass manager
1561 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1564 /// Disposes a pass manager.
1565 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1567 /// Runs a pass manager on a module.
1568 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1570 /// Runs the function passes on the provided function.
1571 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1574 /// Initializes all the function passes scheduled in the manager
1575 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1577 /// Finalizes all the function passes scheduled in the manager
1578 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1580 pub fn LLVMInitializePasses();
1582 /// Adds a verification pass.
1583 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1585 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1586 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1587 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1588 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1589 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1590 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1591 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1592 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1593 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1594 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1595 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1596 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1597 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1598 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1599 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1600 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1601 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1602 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1603 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1604 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1605 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1606 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1607 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1608 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1609 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1610 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1611 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1612 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1613 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1614 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1615 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1616 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1617 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1618 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1619 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1621 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1622 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1623 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1624 OptimizationLevel: c_uint);
1625 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1627 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1628 PMB: PassManagerBuilderRef,
1630 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1631 PMB: PassManagerBuilderRef,
1633 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1634 PMB: PassManagerBuilderRef,
1636 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1637 PMB: PassManagerBuilderRef,
1639 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1640 PMB: PassManagerBuilderRef,
1641 PM: PassManagerRef);
1643 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1644 PMB: PassManagerBuilderRef,
1645 PM: PassManagerRef);
1646 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1647 PMB: PassManagerBuilderRef,
1652 /// Destroys a memory buffer.
1653 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1656 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1658 /// Opens an object file.
1659 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1660 /// Closes an object file.
1661 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1663 /// Enumerates the sections in an object file.
1664 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1665 /// Destroys a section iterator.
1666 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1667 /// Returns true if the section iterator is at the end of the section
1669 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1670 SI: SectionIteratorRef)
1672 /// Moves the section iterator to point to the next section.
1673 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1674 /// Returns the current section size.
1675 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1676 /// Returns the current section contents as a string buffer.
1677 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1679 /// Reads the given file and returns it as a memory buffer. Use
1680 /// LLVMDisposeMemoryBuffer() to get rid of it.
1681 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1683 /// Borrows the contents of the memory buffer (doesn't copy it)
1684 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1685 InputDataLength: size_t,
1686 BufferName: *const c_char,
1689 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1690 InputDataLength: size_t,
1691 BufferName: *const c_char)
1694 pub fn LLVMIsMultithreaded() -> Bool;
1695 pub fn LLVMStartMultithreaded() -> Bool;
1697 /// Returns a string describing the last error caused by an LLVMRust* call.
1698 pub fn LLVMRustGetLastError() -> *const c_char;
1700 /// Print the pass timings since static dtors aren't picking them up.
1701 pub fn LLVMRustPrintPassTimings();
1703 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1705 pub fn LLVMStructSetBody(StructTy: TypeRef,
1706 ElementTypes: *const TypeRef,
1707 ElementCount: c_uint,
1710 pub fn LLVMConstNamedStruct(S: TypeRef,
1711 ConstantVals: *const ValueRef,
1715 /// Enables LLVM debug output.
1716 pub fn LLVMSetDebug(Enabled: c_int);
1718 /// Prepares inline assembly.
1719 pub fn LLVMInlineAsm(Ty: TypeRef,
1720 AsmString: *const c_char,
1721 Constraints: *const c_char,
1727 pub static LLVMRustDebugMetadataVersion: u32;
1729 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1730 name: *const c_char,
1733 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1735 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1737 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1739 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1741 File: *const c_char,
1743 Producer: *const c_char,
1745 Flags: *const c_char,
1747 SplitName: *const c_char)
1750 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1751 Filename: *const c_char,
1752 Directory: *const c_char)
1755 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1757 ParameterTypes: DIArray)
1760 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1761 Scope: DIDescriptor,
1762 Name: *const c_char,
1763 LinkageName: *const c_char,
1767 isLocalToUnit: bool,
1777 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1778 Name: *const c_char,
1779 SizeInBits: c_ulonglong,
1780 AlignInBits: c_ulonglong,
1784 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1786 SizeInBits: c_ulonglong,
1787 AlignInBits: c_ulonglong,
1788 Name: *const c_char)
1791 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1792 Scope: DIDescriptor,
1793 Name: *const c_char,
1796 SizeInBits: c_ulonglong,
1797 AlignInBits: c_ulonglong,
1799 DerivedFrom: DIType,
1801 RunTimeLang: c_uint,
1802 VTableHolder: ValueRef,
1803 UniqueId: *const c_char)
1806 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1807 Scope: DIDescriptor,
1808 Name: *const c_char,
1811 SizeInBits: c_ulonglong,
1812 AlignInBits: c_ulonglong,
1813 OffsetInBits: c_ulonglong,
1818 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1819 Scope: DIDescriptor,
1825 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1826 Context: DIDescriptor,
1827 Name: *const c_char,
1828 LinkageName: *const c_char,
1832 isLocalToUnit: bool,
1835 -> DIGlobalVariable;
1837 pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
1839 Scope: DIDescriptor,
1840 Name: *const c_char,
1844 AlwaysPreserve: bool,
1849 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1851 AlignInBits: c_ulonglong,
1853 Subscripts: DIArray)
1856 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1858 AlignInBits: c_ulonglong,
1860 Subscripts: DIArray)
1863 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1868 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1869 Ptr: *const DIDescriptor,
1873 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1875 VarInfo: DIVariable,
1876 InsertAtEnd: BasicBlockRef)
1879 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1881 VarInfo: DIVariable,
1882 InsertBefore: ValueRef)
1885 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1886 Name: *const c_char,
1890 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1892 Name: *const c_char,
1895 SizeInBits: c_ulonglong,
1896 AlignInBits: c_ulonglong,
1898 ClassType: ValueRef)
1901 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1903 Name: *const c_char,
1906 SizeInBits: c_ulonglong,
1907 AlignInBits: c_ulonglong,
1910 RunTimeLang: c_uint,
1911 UniqueId: *const c_char)
1914 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1916 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1918 Name: *const c_char,
1925 pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
1927 pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
1929 pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
1932 Name: *const c_char,
1936 AddrOps: *const ValueRef,
1937 AddrOpsCount: c_uint,
1941 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1943 Name: *const c_char,
1948 pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
1949 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1950 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1952 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1954 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1956 pub fn LLVMInitializeX86TargetInfo();
1957 pub fn LLVMInitializeX86Target();
1958 pub fn LLVMInitializeX86TargetMC();
1959 pub fn LLVMInitializeX86AsmPrinter();
1960 pub fn LLVMInitializeX86AsmParser();
1961 pub fn LLVMInitializeARMTargetInfo();
1962 pub fn LLVMInitializeARMTarget();
1963 pub fn LLVMInitializeARMTargetMC();
1964 pub fn LLVMInitializeARMAsmPrinter();
1965 pub fn LLVMInitializeARMAsmParser();
1966 pub fn LLVMInitializeAArch64TargetInfo();
1967 pub fn LLVMInitializeAArch64Target();
1968 pub fn LLVMInitializeAArch64TargetMC();
1969 pub fn LLVMInitializeAArch64AsmPrinter();
1970 pub fn LLVMInitializeAArch64AsmParser();
1971 pub fn LLVMInitializeMipsTargetInfo();
1972 pub fn LLVMInitializeMipsTarget();
1973 pub fn LLVMInitializeMipsTargetMC();
1974 pub fn LLVMInitializeMipsAsmPrinter();
1975 pub fn LLVMInitializeMipsAsmParser();
1977 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
1978 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1980 Features: *const c_char,
1981 Model: CodeGenModel,
1983 Level: CodeGenOptLevel,
1986 NoFramePointerElim: bool,
1987 PositionIndependentExecutable: bool,
1988 FunctionSections: bool,
1989 DataSections: bool) -> TargetMachineRef;
1990 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1991 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1994 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1996 DisableSimplifyLibCalls: bool);
1997 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
1998 DisableSimplifyLibCalls: bool);
1999 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
2000 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2003 Output: *const c_char,
2004 FileType: FileType) -> bool;
2005 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2007 Output: *const c_char);
2008 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2009 pub fn LLVMRustPrintPasses();
2010 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2011 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2012 AddLifetimes: bool);
2013 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2015 len: size_t) -> bool;
2016 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2017 syms: *const *const c_char,
2019 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2021 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2022 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
2023 out_len: *mut size_t) -> *const c_char;
2024 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2026 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
2027 pub fn LLVMVersionMajor() -> c_int;
2028 pub fn LLVMVersionMinor() -> c_int;
2030 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2031 data: *mut *const c_char) -> c_int;
2033 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2035 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2036 Handler: DiagnosticHandler,
2037 DiagnosticContext: *mut c_void);
2039 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2040 pass_name_out: *mut *const c_char,
2041 function_out: *mut ValueRef,
2042 debugloc_out: *mut DebugLocRef,
2043 message_out: *mut TwineRef);
2045 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2046 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2047 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2049 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2051 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2052 H: InlineAsmDiagHandler,
2055 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2058 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2060 LLVMSetInstructionCallConv(instr, cc as c_uint);
2063 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2065 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2068 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2070 LLVMSetLinkage(global, link as c_uint);
2074 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2076 LLVMSetUnnamedAddr(global, unnamed as Bool);
2080 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2082 LLVMSetThreadLocal(global, is_thread_local as Bool);
2086 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2088 LLVMConstICmp(pred as c_ushort, v1, v2)
2091 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2093 LLVMConstFCmp(pred as c_ushort, v1, v2)
2097 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2099 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
2103 /* Memory-managed interface to target data. */
2105 pub struct TargetData {
2106 pub lltd: TargetDataRef
2109 impl Drop for TargetData {
2110 fn drop(&mut self) {
2112 LLVMDisposeTargetData(self.lltd);
2117 pub fn mk_target_data(string_rep: &str) -> TargetData {
2118 let string_rep = CString::from_slice(string_rep.as_bytes());
2120 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
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") }