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 #![feature(link_args)]
29 pub use self::OtherAttribute::*;
30 pub use self::SpecialAttribute::*;
31 pub use self::AttributeSet::*;
32 pub use self::IntPredicate::*;
33 pub use self::RealPredicate::*;
34 pub use self::TypeKind::*;
35 pub use self::AtomicBinOp::*;
36 pub use self::AtomicOrdering::*;
37 pub use self::FileType::*;
38 pub use self::MetadataType::*;
39 pub use self::AsmDialect::*;
40 pub use self::CodeGenOptLevel::*;
41 pub use self::RelocMode::*;
42 pub use self::CodeGenModel::*;
43 pub use self::DiagnosticKind::*;
44 pub use self::CallConv::*;
45 pub use self::Visibility::*;
46 pub use self::DiagnosticSeverity::*;
47 pub use self::Linkage::*;
49 use std::ffi::CString;
50 use std::cell::RefCell;
52 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
53 use libc::{c_longlong, c_ulonglong, c_void};
54 use debuginfo::{DIBuilderRef, DIDescriptor,
55 DIFile, DILexicalBlock, DISubprogram, DIType,
56 DIBasicType, DIDerivedType, DICompositeType,
57 DIVariable, DIGlobalVariable, DIArray, DISubrange};
62 pub type Opcode = u32;
63 pub type Bool = c_uint;
65 pub const True: Bool = 1 as Bool;
66 pub const False: Bool = 0 as Bool;
68 // Consts for the LLVM CallConv type, pre-cast to uint.
70 #[derive(Copy, PartialEq)]
75 X86StdcallCallConv = 64,
76 X86FastcallCallConv = 65,
82 LLVMDefaultVisibility = 0,
84 ProtectedVisibility = 2,
87 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
88 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
89 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
90 // they've been removed in upstream LLVM commit r203866.
94 AvailableExternallyLinkage = 1,
95 LinkOnceAnyLinkage = 2,
96 LinkOnceODRLinkage = 3,
102 ExternalWeakLinkage = 12,
107 #[derive(Copy, Show)]
108 pub enum DiagnosticSeverity {
116 flags Attribute : u32 {
117 const ZExtAttribute = 1 << 0,
118 const SExtAttribute = 1 << 1,
119 const NoReturnAttribute = 1 << 2,
120 const InRegAttribute = 1 << 3,
121 const StructRetAttribute = 1 << 4,
122 const NoUnwindAttribute = 1 << 5,
123 const NoAliasAttribute = 1 << 6,
124 const ByValAttribute = 1 << 7,
125 const NestAttribute = 1 << 8,
126 const ReadNoneAttribute = 1 << 9,
127 const ReadOnlyAttribute = 1 << 10,
128 const NoInlineAttribute = 1 << 11,
129 const AlwaysInlineAttribute = 1 << 12,
130 const OptimizeForSizeAttribute = 1 << 13,
131 const StackProtectAttribute = 1 << 14,
132 const StackProtectReqAttribute = 1 << 15,
133 const AlignmentAttribute = 31 << 16,
134 const NoCaptureAttribute = 1 << 21,
135 const NoRedZoneAttribute = 1 << 22,
136 const NoImplicitFloatAttribute = 1 << 23,
137 const NakedAttribute = 1 << 24,
138 const InlineHintAttribute = 1 << 25,
139 const StackAttribute = 7 << 26,
140 const ReturnsTwiceAttribute = 1 << 29,
141 const UWTableAttribute = 1 << 30,
142 const NonLazyBindAttribute = 1 << 31,
149 pub enum OtherAttribute {
150 // The following are not really exposed in
151 // the LLVM c api so instead to add these
152 // we call a wrapper function in RustWrapper
153 // that uses the C++ api.
154 SanitizeAddressAttribute = 1 << 32,
155 MinSizeAttribute = 1 << 33,
156 NoDuplicateAttribute = 1 << 34,
157 StackProtectStrongAttribute = 1 << 35,
158 SanitizeThreadAttribute = 1 << 36,
159 SanitizeMemoryAttribute = 1 << 37,
160 NoBuiltinAttribute = 1 << 38,
161 ReturnedAttribute = 1 << 39,
162 ColdAttribute = 1 << 40,
163 BuiltinAttribute = 1 << 41,
164 OptimizeNoneAttribute = 1 << 42,
165 InAllocaAttribute = 1 << 43,
166 NonNullAttribute = 1 << 44,
170 pub enum SpecialAttribute {
171 DereferenceableAttribute(u64)
176 pub enum AttributeSet {
181 pub trait AttrHelper {
182 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
183 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
186 impl AttrHelper for Attribute {
187 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
189 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
193 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
195 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
200 impl AttrHelper for OtherAttribute {
201 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
203 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
207 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
209 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
214 impl AttrHelper for SpecialAttribute {
215 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
217 DereferenceableAttribute(bytes) => unsafe {
218 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
223 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
225 DereferenceableAttribute(bytes) => unsafe {
226 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
232 pub struct AttrBuilder {
233 attrs: Vec<(uint, Box<AttrHelper+'static>)>
237 pub fn new() -> AttrBuilder {
243 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
244 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
248 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
249 self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
253 pub fn apply_llfn(&self, llfn: ValueRef) {
254 for &(idx, ref attr) in self.attrs.iter() {
255 attr.apply_llfn(idx as c_uint, llfn);
259 pub fn apply_callsite(&self, callsite: ValueRef) {
260 for &(idx, ref attr) in self.attrs.iter() {
261 attr.apply_callsite(idx as c_uint, callsite);
266 // enum for the LLVM IntPredicate type
268 pub enum IntPredicate {
281 // enum for the LLVM RealPredicate type
283 pub enum RealPredicate {
284 RealPredicateFalse = 0,
299 RealPredicateTrue = 15,
302 // The LLVM TypeKind type - must stay in sync with the def of
303 // LLVMTypeKind in llvm/include/llvm-c/Core.h
304 #[derive(Copy, PartialEq)]
327 pub enum AtomicBinOp {
343 pub enum AtomicOrdering {
347 // Consume = 3, // Not specified yet.
351 SequentiallyConsistent = 7
354 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
358 AssemblyFileType = 0,
363 pub enum MetadataType {
372 // Inline Asm Dialect
374 pub enum AsmDialect {
379 #[derive(Copy, PartialEq, Clone)]
381 pub enum CodeGenOptLevel {
382 CodeGenLevelNone = 0,
383 CodeGenLevelLess = 1,
384 CodeGenLevelDefault = 2,
385 CodeGenLevelAggressive = 3,
388 #[derive(Copy, PartialEq)]
394 RelocDynamicNoPic = 3,
399 pub enum CodeGenModel {
400 CodeModelDefault = 0,
401 CodeModelJITDefault = 1,
410 pub enum DiagnosticKind {
413 DK_DebugMetadataVersion,
415 DK_OptimizationRemark,
416 DK_OptimizationRemarkMissed,
417 DK_OptimizationRemarkAnalysis,
418 DK_OptimizationFailure,
421 // Opaque pointer types
422 #[allow(missing_copy_implementations)]
423 pub enum Module_opaque {}
424 pub type ModuleRef = *mut Module_opaque;
425 #[allow(missing_copy_implementations)]
426 pub enum Context_opaque {}
427 pub type ContextRef = *mut Context_opaque;
428 #[allow(missing_copy_implementations)]
429 pub enum Type_opaque {}
430 pub type TypeRef = *mut Type_opaque;
431 #[allow(missing_copy_implementations)]
432 pub enum Value_opaque {}
433 pub type ValueRef = *mut Value_opaque;
434 #[allow(missing_copy_implementations)]
435 pub enum BasicBlock_opaque {}
436 pub type BasicBlockRef = *mut BasicBlock_opaque;
437 #[allow(missing_copy_implementations)]
438 pub enum Builder_opaque {}
439 pub type BuilderRef = *mut Builder_opaque;
440 #[allow(missing_copy_implementations)]
441 pub enum ExecutionEngine_opaque {}
442 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
443 #[allow(missing_copy_implementations)]
444 pub enum RustJITMemoryManager_opaque {}
445 pub type RustJITMemoryManagerRef = *mut RustJITMemoryManager_opaque;
446 #[allow(missing_copy_implementations)]
447 pub enum MemoryBuffer_opaque {}
448 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
449 #[allow(missing_copy_implementations)]
450 pub enum PassManager_opaque {}
451 pub type PassManagerRef = *mut PassManager_opaque;
452 #[allow(missing_copy_implementations)]
453 pub enum PassManagerBuilder_opaque {}
454 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
455 #[allow(missing_copy_implementations)]
456 pub enum Use_opaque {}
457 pub type UseRef = *mut Use_opaque;
458 #[allow(missing_copy_implementations)]
459 pub enum TargetData_opaque {}
460 pub type TargetDataRef = *mut TargetData_opaque;
461 #[allow(missing_copy_implementations)]
462 pub enum ObjectFile_opaque {}
463 pub type ObjectFileRef = *mut ObjectFile_opaque;
464 #[allow(missing_copy_implementations)]
465 pub enum SectionIterator_opaque {}
466 pub type SectionIteratorRef = *mut SectionIterator_opaque;
467 #[allow(missing_copy_implementations)]
468 pub enum Pass_opaque {}
469 pub type PassRef = *mut Pass_opaque;
470 #[allow(missing_copy_implementations)]
471 pub enum TargetMachine_opaque {}
472 pub type TargetMachineRef = *mut TargetMachine_opaque;
473 #[allow(missing_copy_implementations)]
474 pub enum Archive_opaque {}
475 pub type ArchiveRef = *mut Archive_opaque;
476 #[allow(missing_copy_implementations)]
477 pub enum Twine_opaque {}
478 pub type TwineRef = *mut Twine_opaque;
479 #[allow(missing_copy_implementations)]
480 pub enum DiagnosticInfo_opaque {}
481 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
482 #[allow(missing_copy_implementations)]
483 pub enum DebugLoc_opaque {}
484 pub type DebugLocRef = *mut DebugLoc_opaque;
485 #[allow(missing_copy_implementations)]
486 pub enum SMDiagnostic_opaque {}
487 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
489 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
490 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
493 pub use self::DIDescriptorFlags::*;
494 use super::{ValueRef};
496 #[allow(missing_copy_implementations)]
497 pub enum DIBuilder_opaque {}
498 pub type DIBuilderRef = *mut DIBuilder_opaque;
500 pub type DIDescriptor = ValueRef;
501 pub type DIScope = DIDescriptor;
502 pub type DILocation = DIDescriptor;
503 pub type DIFile = DIScope;
504 pub type DILexicalBlock = DIScope;
505 pub type DISubprogram = DIScope;
506 pub type DIType = DIDescriptor;
507 pub type DIBasicType = DIType;
508 pub type DIDerivedType = DIType;
509 pub type DICompositeType = DIDerivedType;
510 pub type DIVariable = DIDescriptor;
511 pub type DIGlobalVariable = DIDescriptor;
512 pub type DIArray = DIDescriptor;
513 pub type DISubrange = DIDescriptor;
516 pub enum DIDescriptorFlags {
517 FlagPrivate = 1 << 0,
518 FlagProtected = 1 << 1,
519 FlagFwdDecl = 1 << 2,
520 FlagAppleBlock = 1 << 3,
521 FlagBlockByrefStruct = 1 << 4,
522 FlagVirtual = 1 << 5,
523 FlagArtificial = 1 << 6,
524 FlagExplicit = 1 << 7,
525 FlagPrototyped = 1 << 8,
526 FlagObjcClassComplete = 1 << 9,
527 FlagObjectPointer = 1 << 10,
528 FlagVector = 1 << 11,
529 FlagStaticMember = 1 << 12,
530 FlagIndirectVariable = 1 << 13,
531 FlagLValueReference = 1 << 14,
532 FlagRValueReference = 1 << 15
537 // Link to our native llvm bindings (things that we need to use the C++ api
538 // for) and because llvm is written in C++ we need to link against libstdc++
540 // You'll probably notice that there is an omission of all LLVM libraries
541 // from this location. This is because the set of LLVM libraries that we
542 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
543 // figure out the exact set of libraries. To do this, the build system
544 // generates an llvmdeps.rs file next to this one which will be
545 // automatically updated whenever LLVM is updated to include an up-to-date
546 // set of the libraries we need to link to LLVM for.
547 #[link(name = "rustllvm", kind = "static")]
549 /* Create and destroy contexts. */
550 pub fn LLVMContextCreate() -> ContextRef;
551 pub fn LLVMContextDispose(C: ContextRef);
552 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
557 /* Create and destroy modules. */
558 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
561 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
562 pub fn LLVMDisposeModule(M: ModuleRef);
564 /// Data layout. See Module::getDataLayout.
565 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
566 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
568 /// Target triple. See Module::getTargetTriple.
569 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
570 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
572 /// See Module::dump.
573 pub fn LLVMDumpModule(M: ModuleRef);
575 /// See Module::setModuleInlineAsm.
576 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
578 /// See llvm::LLVMTypeKind::getTypeID.
579 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
581 /// See llvm::LLVMType::getContext.
582 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
584 /* Operations on integer types */
585 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
586 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
587 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
588 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
589 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
590 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
593 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
595 /* Operations on real types */
596 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
597 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
598 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
599 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
600 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
602 /* Operations on function types */
603 pub fn LLVMFunctionType(ReturnType: TypeRef,
604 ParamTypes: *const TypeRef,
608 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
609 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
610 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
611 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
613 /* Operations on struct types */
614 pub fn LLVMStructTypeInContext(C: ContextRef,
615 ElementTypes: *const TypeRef,
616 ElementCount: c_uint,
619 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
620 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
622 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
624 /* Operations on array, pointer, and vector types (sequence types) */
625 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
626 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
628 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
631 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
632 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
633 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
634 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
636 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
638 /* Operations on other types */
639 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
640 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
641 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
643 /* Operations on all values */
644 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
645 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
646 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
647 pub fn LLVMDumpValue(Val: ValueRef);
648 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
649 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
650 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
651 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
653 /* Operations on Uses */
654 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
655 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
656 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
657 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
659 /* Operations on Users */
660 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
661 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
662 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
664 /* Operations on constants of any type */
665 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
667 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
668 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
670 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
672 /* only for int/vector */
673 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
674 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
675 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
676 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
677 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
679 /* Operations on metadata */
680 pub fn LLVMMDStringInContext(C: ContextRef,
684 pub fn LLVMMDNodeInContext(C: ContextRef,
685 Vals: *const ValueRef,
688 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
692 /* Operations on scalar constants */
693 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
695 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
697 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
702 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
703 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
705 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
709 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
710 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
713 /* Operations on composite constants */
714 pub fn LLVMConstStringInContext(C: ContextRef,
717 DontNullTerminate: Bool)
719 pub fn LLVMConstStructInContext(C: ContextRef,
720 ConstantVals: *const ValueRef,
725 pub fn LLVMConstArray(ElementTy: TypeRef,
726 ConstantVals: *const ValueRef,
729 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
732 /* Constant expressions */
733 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
734 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
735 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
736 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
737 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
738 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
739 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
740 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
742 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
744 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
746 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
748 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
750 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
752 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
754 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
756 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
758 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
760 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
762 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
764 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
766 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
768 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
769 RHSConstant: ValueRef)
771 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
773 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
775 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
777 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
779 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
781 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
783 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
785 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
787 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
789 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
791 pub fn LLVMConstGEP(ConstantVal: ValueRef,
792 ConstantIndices: *const ValueRef,
795 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
796 ConstantIndices: *const ValueRef,
799 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
801 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
803 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
805 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
807 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
809 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
811 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
813 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
815 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
817 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
819 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
821 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
823 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
825 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
827 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
829 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
831 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
835 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
837 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
838 ConstantIfTrue: ValueRef,
839 ConstantIfFalse: ValueRef)
841 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
842 IndexConstant: ValueRef)
844 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
845 ElementValueConstant: ValueRef,
846 IndexConstant: ValueRef)
848 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
849 VectorBConstant: ValueRef,
850 MaskConstant: ValueRef)
852 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
853 IdxList: *const c_uint,
856 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
857 ElementValueConstant: ValueRef,
858 IdxList: *const c_uint,
861 pub fn LLVMConstInlineAsm(Ty: TypeRef,
862 AsmString: *const c_char,
863 Constraints: *const c_char,
864 HasSideEffects: Bool,
867 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
871 /* Operations on global variables, functions, and aliases (globals) */
872 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
873 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
874 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
875 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
876 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
877 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
878 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
879 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
880 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
881 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
884 /* Operations on global variables */
885 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
887 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
890 AddressSpace: c_uint)
892 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
893 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
894 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
895 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
896 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
897 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
898 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
899 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
900 ConstantVal: ValueRef);
901 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
902 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
903 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
904 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
906 /* Operations on aliases */
907 pub fn LLVMAddAlias(M: ModuleRef,
913 /* Operations on functions */
914 pub fn LLVMAddFunction(M: ModuleRef,
918 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
919 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
920 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
921 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
922 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
923 pub fn LLVMDeleteFunction(Fn: ValueRef);
924 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
928 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
929 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
930 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
931 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
932 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
933 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
934 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
935 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
936 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
937 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
939 /* Operations on parameters */
940 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
941 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
942 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
943 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
944 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
945 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
946 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
947 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
948 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
949 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
950 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
951 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
953 /* Operations on basic blocks */
954 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
955 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
956 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
957 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
958 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
959 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
960 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
961 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
962 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
963 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
964 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
966 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
970 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
974 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
976 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
977 MoveAfter: BasicBlockRef);
979 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
980 MoveBefore: BasicBlockRef);
982 /* Operations on instructions */
983 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
984 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
985 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
986 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
987 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
988 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
990 /* Operations on call sites */
991 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
992 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
993 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
996 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
999 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1002 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1005 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1009 /* Operations on call instructions (only) */
1010 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1011 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1013 /* Operations on load/store instructions (only) */
1014 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1015 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1017 /* Operations on phi nodes */
1018 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1019 IncomingValues: *const ValueRef,
1020 IncomingBlocks: *const BasicBlockRef,
1022 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1023 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1025 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1028 /* Instruction builders */
1029 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1030 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1031 Block: BasicBlockRef,
1033 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1035 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1036 Block: BasicBlockRef);
1037 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1038 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1039 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1040 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1042 Name: *const c_char);
1043 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1045 /* Execution engine */
1046 pub fn LLVMRustCreateJITMemoryManager(morestack: *const ())
1047 -> RustJITMemoryManagerRef;
1048 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef,
1049 MM: RustJITMemoryManagerRef) -> ExecutionEngineRef;
1050 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1051 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1052 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1053 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1054 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1058 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1059 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1060 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1063 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1064 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1065 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1066 RetVals: *const ValueRef,
1069 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1070 pub fn LLVMBuildCondBr(B: BuilderRef,
1072 Then: BasicBlockRef,
1073 Else: BasicBlockRef)
1075 pub fn LLVMBuildSwitch(B: BuilderRef,
1077 Else: BasicBlockRef,
1080 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1084 pub fn LLVMBuildInvoke(B: BuilderRef,
1086 Args: *const ValueRef,
1088 Then: BasicBlockRef,
1089 Catch: BasicBlockRef,
1090 Name: *const c_char)
1092 pub fn LLVMBuildLandingPad(B: BuilderRef,
1096 Name: *const c_char)
1098 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1099 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1101 /* Add a case to the switch instruction */
1102 pub fn LLVMAddCase(Switch: ValueRef,
1104 Dest: BasicBlockRef);
1106 /* Add a destination to the indirectbr instruction */
1107 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1109 /* Add a clause to the landing pad instruction */
1110 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1112 /* Set the cleanup on a landing pad instruction */
1113 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1116 pub fn LLVMBuildAdd(B: BuilderRef,
1119 Name: *const c_char)
1121 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1124 Name: *const c_char)
1126 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1129 Name: *const c_char)
1131 pub fn LLVMBuildFAdd(B: BuilderRef,
1134 Name: *const c_char)
1136 pub fn LLVMBuildSub(B: BuilderRef,
1139 Name: *const c_char)
1141 pub fn LLVMBuildNSWSub(B: BuilderRef,
1144 Name: *const c_char)
1146 pub fn LLVMBuildNUWSub(B: BuilderRef,
1149 Name: *const c_char)
1151 pub fn LLVMBuildFSub(B: BuilderRef,
1154 Name: *const c_char)
1156 pub fn LLVMBuildMul(B: BuilderRef,
1159 Name: *const c_char)
1161 pub fn LLVMBuildNSWMul(B: BuilderRef,
1164 Name: *const c_char)
1166 pub fn LLVMBuildNUWMul(B: BuilderRef,
1169 Name: *const c_char)
1171 pub fn LLVMBuildFMul(B: BuilderRef,
1174 Name: *const c_char)
1176 pub fn LLVMBuildUDiv(B: BuilderRef,
1179 Name: *const c_char)
1181 pub fn LLVMBuildSDiv(B: BuilderRef,
1184 Name: *const c_char)
1186 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1189 Name: *const c_char)
1191 pub fn LLVMBuildFDiv(B: BuilderRef,
1194 Name: *const c_char)
1196 pub fn LLVMBuildURem(B: BuilderRef,
1199 Name: *const c_char)
1201 pub fn LLVMBuildSRem(B: BuilderRef,
1204 Name: *const c_char)
1206 pub fn LLVMBuildFRem(B: BuilderRef,
1209 Name: *const c_char)
1211 pub fn LLVMBuildShl(B: BuilderRef,
1214 Name: *const c_char)
1216 pub fn LLVMBuildLShr(B: BuilderRef,
1219 Name: *const c_char)
1221 pub fn LLVMBuildAShr(B: BuilderRef,
1224 Name: *const c_char)
1226 pub fn LLVMBuildAnd(B: BuilderRef,
1229 Name: *const c_char)
1231 pub fn LLVMBuildOr(B: BuilderRef,
1234 Name: *const c_char)
1236 pub fn LLVMBuildXor(B: BuilderRef,
1239 Name: *const c_char)
1241 pub fn LLVMBuildBinOp(B: BuilderRef,
1245 Name: *const c_char)
1247 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1249 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1251 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1253 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1255 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1259 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1261 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1264 Name: *const c_char)
1266 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1268 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1271 Name: *const c_char)
1273 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1274 pub fn LLVMBuildLoad(B: BuilderRef,
1275 PointerVal: ValueRef,
1276 Name: *const c_char)
1279 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1282 pub fn LLVMBuildGEP(B: BuilderRef,
1284 Indices: *const ValueRef,
1286 Name: *const c_char)
1288 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1290 Indices: *const ValueRef,
1292 Name: *const c_char)
1294 pub fn LLVMBuildStructGEP(B: BuilderRef,
1297 Name: *const c_char)
1299 pub fn LLVMBuildGlobalString(B: BuilderRef,
1301 Name: *const c_char)
1303 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1305 Name: *const c_char)
1309 pub fn LLVMBuildTrunc(B: BuilderRef,
1312 Name: *const c_char)
1314 pub fn LLVMBuildZExt(B: BuilderRef,
1317 Name: *const c_char)
1319 pub fn LLVMBuildSExt(B: BuilderRef,
1322 Name: *const c_char)
1324 pub fn LLVMBuildFPToUI(B: BuilderRef,
1327 Name: *const c_char)
1329 pub fn LLVMBuildFPToSI(B: BuilderRef,
1332 Name: *const c_char)
1334 pub fn LLVMBuildUIToFP(B: BuilderRef,
1337 Name: *const c_char)
1339 pub fn LLVMBuildSIToFP(B: BuilderRef,
1342 Name: *const c_char)
1344 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1347 Name: *const c_char)
1349 pub fn LLVMBuildFPExt(B: BuilderRef,
1352 Name: *const c_char)
1354 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1357 Name: *const c_char)
1359 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1362 Name: *const c_char)
1364 pub fn LLVMBuildBitCast(B: BuilderRef,
1367 Name: *const c_char)
1369 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1372 Name: *const c_char)
1374 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1377 Name: *const c_char)
1379 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1382 Name: *const c_char)
1384 pub fn LLVMBuildCast(B: BuilderRef,
1388 Name: *const c_char) -> ValueRef;
1389 pub fn LLVMBuildPointerCast(B: BuilderRef,
1392 Name: *const c_char)
1394 pub fn LLVMBuildIntCast(B: BuilderRef,
1397 Name: *const c_char)
1399 pub fn LLVMBuildFPCast(B: BuilderRef,
1402 Name: *const c_char)
1406 pub fn LLVMBuildICmp(B: BuilderRef,
1410 Name: *const c_char)
1412 pub fn LLVMBuildFCmp(B: BuilderRef,
1416 Name: *const c_char)
1419 /* Miscellaneous instructions */
1420 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1422 pub fn LLVMBuildCall(B: BuilderRef,
1424 Args: *const ValueRef,
1426 Name: *const c_char)
1428 pub fn LLVMBuildSelect(B: BuilderRef,
1432 Name: *const c_char)
1434 pub fn LLVMBuildVAArg(B: BuilderRef,
1437 Name: *const c_char)
1439 pub fn LLVMBuildExtractElement(B: BuilderRef,
1442 Name: *const c_char)
1444 pub fn LLVMBuildInsertElement(B: BuilderRef,
1448 Name: *const c_char)
1450 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1454 Name: *const c_char)
1456 pub fn LLVMBuildExtractValue(B: BuilderRef,
1459 Name: *const c_char)
1461 pub fn LLVMBuildInsertValue(B: BuilderRef,
1465 Name: *const c_char)
1468 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1470 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1472 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1475 Name: *const c_char)
1478 /* Atomic Operations */
1479 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1480 PointerVal: ValueRef,
1481 Name: *const c_char,
1482 Order: AtomicOrdering,
1486 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1489 Order: AtomicOrdering,
1493 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1497 Order: AtomicOrdering,
1498 FailureOrder: AtomicOrdering)
1500 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1504 Order: AtomicOrdering,
1505 SingleThreaded: Bool)
1508 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1511 /* Selected entries from the downcasts. */
1512 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1513 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1515 /// Writes a module to the specified path. Returns 0 on success.
1516 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1518 /// Creates target data from a target layout string.
1519 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1520 /// Adds the target data to the given pass manager. The pass manager
1521 /// references the target data only weakly.
1522 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1523 /// Number of bytes clobbered when doing a Store to *T.
1524 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1527 /// Number of bytes clobbered when doing a Store to *T.
1528 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1531 /// Distance between successive elements in an array of T. Includes ABI padding.
1532 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1534 /// Returns the preferred alignment of a type.
1535 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1537 /// Returns the minimum alignment of a type.
1538 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1541 /// Computes the byte offset of the indexed struct element for a
1543 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1548 /// Returns the minimum alignment of a type when part of a call frame.
1549 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1552 /// Disposes target data.
1553 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1555 /// Creates a pass manager.
1556 pub fn LLVMCreatePassManager() -> PassManagerRef;
1558 /// Creates a function-by-function pass manager
1559 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1562 /// Disposes a pass manager.
1563 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1565 /// Runs a pass manager on a module.
1566 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1568 /// Runs the function passes on the provided function.
1569 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1572 /// Initializes all the function passes scheduled in the manager
1573 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1575 /// Finalizes all the function passes scheduled in the manager
1576 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1578 pub fn LLVMInitializePasses();
1580 /// Adds a verification pass.
1581 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1583 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1584 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1585 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1586 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1587 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1588 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1589 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1590 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1591 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1592 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1593 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1594 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1595 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1596 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1597 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1598 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1599 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1600 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1601 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1602 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1603 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1604 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1605 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1606 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1607 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1608 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1609 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1610 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1611 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1612 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1613 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1614 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1615 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1616 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1617 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1619 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1620 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1621 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1622 OptimizationLevel: c_uint);
1623 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1625 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1626 PMB: PassManagerBuilderRef,
1628 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1629 PMB: PassManagerBuilderRef,
1631 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1632 PMB: PassManagerBuilderRef,
1634 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1635 PMB: PassManagerBuilderRef,
1637 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1638 PMB: PassManagerBuilderRef,
1639 PM: PassManagerRef);
1641 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1642 PMB: PassManagerBuilderRef,
1643 PM: PassManagerRef);
1644 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1645 PMB: PassManagerBuilderRef,
1650 /// Destroys a memory buffer.
1651 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1654 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1656 /// Opens an object file.
1657 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1658 /// Closes an object file.
1659 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1661 /// Enumerates the sections in an object file.
1662 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1663 /// Destroys a section iterator.
1664 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1665 /// Returns true if the section iterator is at the end of the section
1667 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1668 SI: SectionIteratorRef)
1670 /// Moves the section iterator to point to the next section.
1671 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1672 /// Returns the current section size.
1673 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1674 /// Returns the current section contents as a string buffer.
1675 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1677 /// Reads the given file and returns it as a memory buffer. Use
1678 /// LLVMDisposeMemoryBuffer() to get rid of it.
1679 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1681 /// Borrows the contents of the memory buffer (doesn't copy it)
1682 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1683 InputDataLength: size_t,
1684 BufferName: *const c_char,
1687 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1688 InputDataLength: size_t,
1689 BufferName: *const c_char)
1692 pub fn LLVMIsMultithreaded() -> Bool;
1693 pub fn LLVMStartMultithreaded() -> Bool;
1695 /// Returns a string describing the last error caused by an LLVMRust* call.
1696 pub fn LLVMRustGetLastError() -> *const c_char;
1698 /// Print the pass timings since static dtors aren't picking them up.
1699 pub fn LLVMRustPrintPassTimings();
1701 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1703 pub fn LLVMStructSetBody(StructTy: TypeRef,
1704 ElementTypes: *const TypeRef,
1705 ElementCount: c_uint,
1708 pub fn LLVMConstNamedStruct(S: TypeRef,
1709 ConstantVals: *const ValueRef,
1713 /// Enables LLVM debug output.
1714 pub fn LLVMSetDebug(Enabled: c_int);
1716 /// Prepares inline assembly.
1717 pub fn LLVMInlineAsm(Ty: TypeRef,
1718 AsmString: *const c_char,
1719 Constraints: *const c_char,
1725 pub static LLVMRustDebugMetadataVersion: u32;
1727 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1728 name: *const c_char,
1731 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1733 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1735 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1737 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1739 File: *const c_char,
1741 Producer: *const c_char,
1743 Flags: *const c_char,
1745 SplitName: *const c_char)
1748 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1749 Filename: *const c_char,
1750 Directory: *const c_char)
1753 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1755 ParameterTypes: DIArray)
1758 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1759 Scope: DIDescriptor,
1760 Name: *const c_char,
1761 LinkageName: *const c_char,
1765 isLocalToUnit: bool,
1775 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1776 Name: *const c_char,
1777 SizeInBits: c_ulonglong,
1778 AlignInBits: c_ulonglong,
1782 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1784 SizeInBits: c_ulonglong,
1785 AlignInBits: c_ulonglong,
1786 Name: *const c_char)
1789 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1790 Scope: DIDescriptor,
1791 Name: *const c_char,
1794 SizeInBits: c_ulonglong,
1795 AlignInBits: c_ulonglong,
1797 DerivedFrom: DIType,
1799 RunTimeLang: c_uint,
1800 VTableHolder: ValueRef,
1801 UniqueId: *const c_char)
1804 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1805 Scope: DIDescriptor,
1806 Name: *const c_char,
1809 SizeInBits: c_ulonglong,
1810 AlignInBits: c_ulonglong,
1811 OffsetInBits: c_ulonglong,
1816 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1817 Scope: DIDescriptor,
1823 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1824 Context: DIDescriptor,
1825 Name: *const c_char,
1826 LinkageName: *const c_char,
1830 isLocalToUnit: bool,
1833 -> DIGlobalVariable;
1835 pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
1837 Scope: DIDescriptor,
1838 Name: *const c_char,
1842 AlwaysPreserve: bool,
1847 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1849 AlignInBits: c_ulonglong,
1851 Subscripts: DIArray)
1854 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1856 AlignInBits: c_ulonglong,
1858 Subscripts: DIArray)
1861 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1866 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1867 Ptr: *const DIDescriptor,
1871 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1873 VarInfo: DIVariable,
1874 InsertAtEnd: BasicBlockRef)
1877 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1879 VarInfo: DIVariable,
1880 InsertBefore: ValueRef)
1883 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1884 Name: *const c_char,
1888 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1890 Name: *const c_char,
1893 SizeInBits: c_ulonglong,
1894 AlignInBits: c_ulonglong,
1896 ClassType: ValueRef)
1899 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1901 Name: *const c_char,
1904 SizeInBits: c_ulonglong,
1905 AlignInBits: c_ulonglong,
1908 RunTimeLang: c_uint,
1909 UniqueId: *const c_char)
1912 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1914 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1916 Name: *const c_char,
1923 pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
1925 pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
1927 pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
1930 Name: *const c_char,
1934 AddrOps: *const ValueRef,
1935 AddrOpsCount: c_uint,
1939 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1941 Name: *const c_char,
1946 pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
1947 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1948 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1950 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1952 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1954 pub fn LLVMInitializeX86TargetInfo();
1955 pub fn LLVMInitializeX86Target();
1956 pub fn LLVMInitializeX86TargetMC();
1957 pub fn LLVMInitializeX86AsmPrinter();
1958 pub fn LLVMInitializeX86AsmParser();
1959 pub fn LLVMInitializeARMTargetInfo();
1960 pub fn LLVMInitializeARMTarget();
1961 pub fn LLVMInitializeARMTargetMC();
1962 pub fn LLVMInitializeARMAsmPrinter();
1963 pub fn LLVMInitializeARMAsmParser();
1964 pub fn LLVMInitializeAArch64TargetInfo();
1965 pub fn LLVMInitializeAArch64Target();
1966 pub fn LLVMInitializeAArch64TargetMC();
1967 pub fn LLVMInitializeAArch64AsmPrinter();
1968 pub fn LLVMInitializeAArch64AsmParser();
1969 pub fn LLVMInitializeMipsTargetInfo();
1970 pub fn LLVMInitializeMipsTarget();
1971 pub fn LLVMInitializeMipsTargetMC();
1972 pub fn LLVMInitializeMipsAsmPrinter();
1973 pub fn LLVMInitializeMipsAsmParser();
1975 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
1976 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1978 Features: *const c_char,
1979 Model: CodeGenModel,
1981 Level: CodeGenOptLevel,
1984 NoFramePointerElim: bool,
1985 PositionIndependentExecutable: bool,
1986 FunctionSections: bool,
1987 DataSections: bool) -> TargetMachineRef;
1988 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1989 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1992 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1994 DisableSimplifyLibCalls: bool);
1995 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
1996 DisableSimplifyLibCalls: bool);
1997 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1998 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2001 Output: *const c_char,
2002 FileType: FileType) -> bool;
2003 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2005 Output: *const c_char);
2006 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2007 pub fn LLVMRustPrintPasses();
2008 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2009 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2010 AddLifetimes: bool);
2011 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2013 len: size_t) -> bool;
2014 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2015 syms: *const *const c_char,
2017 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2019 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2020 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
2021 out_len: *mut size_t) -> *const c_char;
2022 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2024 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
2025 pub fn LLVMVersionMajor() -> c_int;
2026 pub fn LLVMVersionMinor() -> c_int;
2028 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2029 data: *mut *const c_char) -> c_int;
2031 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2033 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2034 Handler: DiagnosticHandler,
2035 DiagnosticContext: *mut c_void);
2037 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2038 pass_name_out: *mut *const c_char,
2039 function_out: *mut ValueRef,
2040 debugloc_out: *mut DebugLocRef,
2041 message_out: *mut TwineRef);
2043 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2044 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2045 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2047 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2049 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2050 H: InlineAsmDiagHandler,
2053 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2056 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2058 LLVMSetInstructionCallConv(instr, cc as c_uint);
2061 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2063 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2066 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2068 LLVMSetLinkage(global, link as c_uint);
2072 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2074 LLVMSetUnnamedAddr(global, unnamed as Bool);
2078 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2080 LLVMSetThreadLocal(global, is_thread_local as Bool);
2084 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2086 LLVMConstICmp(pred as c_ushort, v1, v2)
2089 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2091 LLVMConstFCmp(pred as c_ushort, v1, v2)
2095 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2097 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
2101 /* Memory-managed interface to target data. */
2103 pub struct TargetData {
2104 pub lltd: TargetDataRef
2107 impl Drop for TargetData {
2108 fn drop(&mut self) {
2110 LLVMDisposeTargetData(self.lltd);
2115 pub fn mk_target_data(string_rep: &str) -> TargetData {
2116 let string_rep = CString::from_slice(string_rep.as_bytes());
2118 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2122 /* Memory-managed interface to object files. */
2124 pub struct ObjectFile {
2125 pub llof: ObjectFileRef,
2129 // This will take ownership of llmb
2130 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2132 let llof = LLVMCreateObjectFile(llmb);
2133 if llof as int == 0 {
2134 // LLVMCreateObjectFile took ownership of llmb
2145 impl Drop for ObjectFile {
2146 fn drop(&mut self) {
2148 LLVMDisposeObjectFile(self.llof);
2153 /* Memory-managed interface to section iterators. */
2155 pub struct SectionIter {
2156 pub llsi: SectionIteratorRef
2159 impl Drop for SectionIter {
2160 fn drop(&mut self) {
2162 LLVMDisposeSectionIterator(self.llsi);
2167 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2170 llsi: LLVMGetSections(llof)
2175 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2176 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2178 assert!(index < LLVMCountParams(llfn));
2179 LLVMGetParam(llfn, index)
2183 #[allow(missing_copy_implementations)]
2184 pub enum RustString_opaque {}
2185 pub type RustStringRef = *mut RustString_opaque;
2186 type RustStringRepr = *mut RefCell<Vec<u8>>;
2188 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2190 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2193 let slice: &[u8] = mem::transmute(raw::Slice {
2194 data: ptr as *const u8,
2198 let sr: RustStringRepr = mem::transmute(sr);
2199 (*sr).borrow_mut().push_all(slice);
2202 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2203 let mut buf = RefCell::new(Vec::new());
2204 f(&mut buf as RustStringRepr as RustStringRef);
2205 String::from_utf8(buf.into_inner()).ok()
2208 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2209 build_string(|s| LLVMWriteTwineToString(tr, s))
2210 .expect("got a non-UTF8 Twine from LLVM")
2213 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2214 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2215 .expect("got a non-UTF8 DebugLoc from LLVM")
2218 // FIXME #15460 - create a public function that actually calls our
2219 // static LLVM symbols. Otherwise the linker will just throw llvm
2220 // away. We're just calling lots of stuff until we transitively get
2221 // all of LLVM. This is worse than anything.
2222 pub unsafe fn static_link_hack_this_sucks() {
2223 LLVMInitializePasses();
2225 LLVMInitializeX86TargetInfo();
2226 LLVMInitializeX86Target();
2227 LLVMInitializeX86TargetMC();
2228 LLVMInitializeX86AsmPrinter();
2229 LLVMInitializeX86AsmParser();
2231 LLVMInitializeARMTargetInfo();
2232 LLVMInitializeARMTarget();
2233 LLVMInitializeARMTargetMC();
2234 LLVMInitializeARMAsmPrinter();
2235 LLVMInitializeARMAsmParser();
2237 LLVMInitializeAArch64TargetInfo();
2238 LLVMInitializeAArch64Target();
2239 LLVMInitializeAArch64TargetMC();
2240 LLVMInitializeAArch64AsmPrinter();
2241 LLVMInitializeAArch64AsmParser();
2243 LLVMInitializeMipsTargetInfo();
2244 LLVMInitializeMipsTarget();
2245 LLVMInitializeMipsTargetMC();
2246 LLVMInitializeMipsAsmPrinter();
2247 LLVMInitializeMipsAsmParser();
2249 LLVMRustSetLLVMOptions(0 as c_int,
2252 LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
2253 LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
2254 LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
2255 LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
2256 LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
2257 LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
2258 LLVMPassManagerBuilderCreate();
2259 LLVMPassManagerBuilderDispose(0 as *mut _);
2261 LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
2264 LLVMLinkInInterpreter();
2267 fn LLVMLinkInMCJIT();
2268 fn LLVMLinkInInterpreter();
2272 // The module containing the native LLVM dependencies, generated by the build system
2273 // Note that this must come after the rustllvm extern declaration so that
2274 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2275 // Works to the above fix for #15460 to ensure LLVM dependencies that
2276 // are only used by rustllvm don't get stripped by the linker.
2278 include! { env!("CFG_LLVM_LINKAGE_FILE") }