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"]
17 #![unstable(feature = "rustc_private")]
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(box_syntax)]
26 #![feature(collections)]
31 #![feature(link_args)]
33 #![feature(staged_api)]
37 #[macro_use] #[no_link] extern crate rustc_bitflags;
39 pub use self::OtherAttribute::*;
40 pub use self::SpecialAttribute::*;
41 pub use self::AttributeSet::*;
42 pub use self::IntPredicate::*;
43 pub use self::RealPredicate::*;
44 pub use self::TypeKind::*;
45 pub use self::AtomicBinOp::*;
46 pub use self::AtomicOrdering::*;
47 pub use self::FileType::*;
48 pub use self::MetadataType::*;
49 pub use self::AsmDialect::*;
50 pub use self::CodeGenOptLevel::*;
51 pub use self::RelocMode::*;
52 pub use self::CodeGenModel::*;
53 pub use self::DiagnosticKind::*;
54 pub use self::CallConv::*;
55 pub use self::Visibility::*;
56 pub use self::DiagnosticSeverity::*;
57 pub use self::Linkage::*;
59 use std::ffi::CString;
60 use std::cell::RefCell;
61 use std::{raw, mem, ptr};
62 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
63 use libc::{c_longlong, c_ulonglong, c_void};
64 use debuginfo::{DIBuilderRef, DIDescriptor,
65 DIFile, DILexicalBlock, DISubprogram, DIType,
66 DIBasicType, DIDerivedType, DICompositeType, DIScope,
67 DIVariable, DIGlobalVariable, DIArray, DISubrange,
68 DITemplateTypeParameter, DIEnumerator, DINameSpace};
73 pub type Opcode = u32;
74 pub type Bool = c_uint;
76 pub const True: Bool = 1 as Bool;
77 pub const False: Bool = 0 as Bool;
79 // Consts for the LLVM CallConv type, pre-cast to uint.
81 #[derive(Copy, PartialEq)]
86 X86StdcallCallConv = 64,
87 X86FastcallCallConv = 65,
93 LLVMDefaultVisibility = 0,
95 ProtectedVisibility = 2,
98 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
99 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
100 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
101 // they've been removed in upstream LLVM commit r203866.
105 AvailableExternallyLinkage = 1,
106 LinkOnceAnyLinkage = 2,
107 LinkOnceODRLinkage = 3,
110 AppendingLinkage = 7,
113 ExternalWeakLinkage = 12,
118 #[derive(Copy, Debug)]
119 pub enum DiagnosticSeverity {
127 flags Attribute : u32 {
128 const ZExtAttribute = 1 << 0,
129 const SExtAttribute = 1 << 1,
130 const NoReturnAttribute = 1 << 2,
131 const InRegAttribute = 1 << 3,
132 const StructRetAttribute = 1 << 4,
133 const NoUnwindAttribute = 1 << 5,
134 const NoAliasAttribute = 1 << 6,
135 const ByValAttribute = 1 << 7,
136 const NestAttribute = 1 << 8,
137 const ReadNoneAttribute = 1 << 9,
138 const ReadOnlyAttribute = 1 << 10,
139 const NoInlineAttribute = 1 << 11,
140 const AlwaysInlineAttribute = 1 << 12,
141 const OptimizeForSizeAttribute = 1 << 13,
142 const StackProtectAttribute = 1 << 14,
143 const StackProtectReqAttribute = 1 << 15,
144 const AlignmentAttribute = 31 << 16,
145 const NoCaptureAttribute = 1 << 21,
146 const NoRedZoneAttribute = 1 << 22,
147 const NoImplicitFloatAttribute = 1 << 23,
148 const NakedAttribute = 1 << 24,
149 const InlineHintAttribute = 1 << 25,
150 const StackAttribute = 7 << 26,
151 const ReturnsTwiceAttribute = 1 << 29,
152 const UWTableAttribute = 1 << 30,
153 const NonLazyBindAttribute = 1 << 31,
160 pub enum OtherAttribute {
161 // The following are not really exposed in
162 // the LLVM c api so instead to add these
163 // we call a wrapper function in RustWrapper
164 // that uses the C++ api.
165 SanitizeAddressAttribute = 1 << 32,
166 MinSizeAttribute = 1 << 33,
167 NoDuplicateAttribute = 1 << 34,
168 StackProtectStrongAttribute = 1 << 35,
169 SanitizeThreadAttribute = 1 << 36,
170 SanitizeMemoryAttribute = 1 << 37,
171 NoBuiltinAttribute = 1 << 38,
172 ReturnedAttribute = 1 << 39,
173 ColdAttribute = 1 << 40,
174 BuiltinAttribute = 1 << 41,
175 OptimizeNoneAttribute = 1 << 42,
176 InAllocaAttribute = 1 << 43,
177 NonNullAttribute = 1 << 44,
181 pub enum SpecialAttribute {
182 DereferenceableAttribute(u64)
187 pub enum AttributeSet {
192 pub trait AttrHelper {
193 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
194 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
197 impl AttrHelper for Attribute {
198 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
200 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
204 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
206 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
211 impl AttrHelper for OtherAttribute {
212 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
214 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
218 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
220 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
225 impl AttrHelper for SpecialAttribute {
226 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
228 DereferenceableAttribute(bytes) => unsafe {
229 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
234 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
236 DereferenceableAttribute(bytes) => unsafe {
237 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
243 pub struct AttrBuilder {
244 attrs: Vec<(uint, Box<AttrHelper+'static>)>
248 pub fn new() -> AttrBuilder {
254 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
255 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
259 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
260 self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
264 pub fn apply_llfn(&self, llfn: ValueRef) {
265 for &(idx, ref attr) in self.attrs.iter() {
266 attr.apply_llfn(idx as c_uint, llfn);
270 pub fn apply_callsite(&self, callsite: ValueRef) {
271 for &(idx, ref attr) in self.attrs.iter() {
272 attr.apply_callsite(idx as c_uint, callsite);
277 // enum for the LLVM IntPredicate type
279 pub enum IntPredicate {
292 // enum for the LLVM RealPredicate type
294 pub enum RealPredicate {
295 RealPredicateFalse = 0,
310 RealPredicateTrue = 15,
313 // The LLVM TypeKind type - must stay in sync with the def of
314 // LLVMTypeKind in llvm/include/llvm-c/Core.h
315 #[derive(Copy, PartialEq, Debug)]
338 pub enum AtomicBinOp {
354 pub enum AtomicOrdering {
358 // Consume = 3, // Not specified yet.
362 SequentiallyConsistent = 7
365 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
369 AssemblyFileType = 0,
374 pub enum MetadataType {
383 // Inline Asm Dialect
385 pub enum AsmDialect {
390 #[derive(Copy, PartialEq, Clone)]
392 pub enum CodeGenOptLevel {
393 CodeGenLevelNone = 0,
394 CodeGenLevelLess = 1,
395 CodeGenLevelDefault = 2,
396 CodeGenLevelAggressive = 3,
399 #[derive(Copy, PartialEq)]
405 RelocDynamicNoPic = 3,
410 pub enum CodeGenModel {
411 CodeModelDefault = 0,
412 CodeModelJITDefault = 1,
421 pub enum DiagnosticKind {
424 DK_DebugMetadataVersion,
426 DK_OptimizationRemark,
427 DK_OptimizationRemarkMissed,
428 DK_OptimizationRemarkAnalysis,
429 DK_OptimizationFailure,
432 // Opaque pointer types
433 #[allow(missing_copy_implementations)]
434 pub enum Module_opaque {}
435 pub type ModuleRef = *mut Module_opaque;
436 #[allow(missing_copy_implementations)]
437 pub enum Context_opaque {}
438 pub type ContextRef = *mut Context_opaque;
439 #[allow(missing_copy_implementations)]
440 pub enum Type_opaque {}
441 pub type TypeRef = *mut Type_opaque;
442 #[allow(missing_copy_implementations)]
443 pub enum Value_opaque {}
444 pub type ValueRef = *mut Value_opaque;
445 #[allow(missing_copy_implementations)]
446 pub enum Metadata_opaque {}
447 pub type MetadataRef = *mut Metadata_opaque;
448 #[allow(missing_copy_implementations)]
449 pub enum BasicBlock_opaque {}
450 pub type BasicBlockRef = *mut BasicBlock_opaque;
451 #[allow(missing_copy_implementations)]
452 pub enum Builder_opaque {}
453 pub type BuilderRef = *mut Builder_opaque;
454 #[allow(missing_copy_implementations)]
455 pub enum ExecutionEngine_opaque {}
456 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
457 #[allow(missing_copy_implementations)]
458 pub enum RustJITMemoryManager_opaque {}
459 pub type RustJITMemoryManagerRef = *mut RustJITMemoryManager_opaque;
460 #[allow(missing_copy_implementations)]
461 pub enum MemoryBuffer_opaque {}
462 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
463 #[allow(missing_copy_implementations)]
464 pub enum PassManager_opaque {}
465 pub type PassManagerRef = *mut PassManager_opaque;
466 #[allow(missing_copy_implementations)]
467 pub enum PassManagerBuilder_opaque {}
468 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
469 #[allow(missing_copy_implementations)]
470 pub enum Use_opaque {}
471 pub type UseRef = *mut Use_opaque;
472 #[allow(missing_copy_implementations)]
473 pub enum TargetData_opaque {}
474 pub type TargetDataRef = *mut TargetData_opaque;
475 #[allow(missing_copy_implementations)]
476 pub enum ObjectFile_opaque {}
477 pub type ObjectFileRef = *mut ObjectFile_opaque;
478 #[allow(missing_copy_implementations)]
479 pub enum SectionIterator_opaque {}
480 pub type SectionIteratorRef = *mut SectionIterator_opaque;
481 #[allow(missing_copy_implementations)]
482 pub enum Pass_opaque {}
483 pub type PassRef = *mut Pass_opaque;
484 #[allow(missing_copy_implementations)]
485 pub enum TargetMachine_opaque {}
486 pub type TargetMachineRef = *mut TargetMachine_opaque;
487 #[allow(missing_copy_implementations)]
488 pub enum Archive_opaque {}
489 pub type ArchiveRef = *mut Archive_opaque;
490 #[allow(missing_copy_implementations)]
491 pub enum Twine_opaque {}
492 pub type TwineRef = *mut Twine_opaque;
493 #[allow(missing_copy_implementations)]
494 pub enum DiagnosticInfo_opaque {}
495 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
496 #[allow(missing_copy_implementations)]
497 pub enum DebugLoc_opaque {}
498 pub type DebugLocRef = *mut DebugLoc_opaque;
499 #[allow(missing_copy_implementations)]
500 pub enum SMDiagnostic_opaque {}
501 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
503 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
504 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
507 pub use self::DIDescriptorFlags::*;
508 use super::{MetadataRef};
510 #[allow(missing_copy_implementations)]
511 pub enum DIBuilder_opaque {}
512 pub type DIBuilderRef = *mut DIBuilder_opaque;
514 pub type DIDescriptor = MetadataRef;
515 pub type DIScope = DIDescriptor;
516 pub type DILocation = DIDescriptor;
517 pub type DIFile = DIScope;
518 pub type DILexicalBlock = DIScope;
519 pub type DISubprogram = DIScope;
520 pub type DINameSpace = DIScope;
521 pub type DIType = DIDescriptor;
522 pub type DIBasicType = DIType;
523 pub type DIDerivedType = DIType;
524 pub type DICompositeType = DIDerivedType;
525 pub type DIVariable = DIDescriptor;
526 pub type DIGlobalVariable = DIDescriptor;
527 pub type DIArray = DIDescriptor;
528 pub type DISubrange = DIDescriptor;
529 pub type DIEnumerator = DIDescriptor;
530 pub type DITemplateTypeParameter = DIDescriptor;
533 pub enum DIDescriptorFlags {
534 FlagPrivate = 1 << 0,
535 FlagProtected = 1 << 1,
536 FlagFwdDecl = 1 << 2,
537 FlagAppleBlock = 1 << 3,
538 FlagBlockByrefStruct = 1 << 4,
539 FlagVirtual = 1 << 5,
540 FlagArtificial = 1 << 6,
541 FlagExplicit = 1 << 7,
542 FlagPrototyped = 1 << 8,
543 FlagObjcClassComplete = 1 << 9,
544 FlagObjectPointer = 1 << 10,
545 FlagVector = 1 << 11,
546 FlagStaticMember = 1 << 12,
547 FlagIndirectVariable = 1 << 13,
548 FlagLValueReference = 1 << 14,
549 FlagRValueReference = 1 << 15
554 // Link to our native llvm bindings (things that we need to use the C++ api
555 // for) and because llvm is written in C++ we need to link against libstdc++
557 // You'll probably notice that there is an omission of all LLVM libraries
558 // from this location. This is because the set of LLVM libraries that we
559 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
560 // figure out the exact set of libraries. To do this, the build system
561 // generates an llvmdeps.rs file next to this one which will be
562 // automatically updated whenever LLVM is updated to include an up-to-date
563 // set of the libraries we need to link to LLVM for.
564 #[link(name = "rustllvm", kind = "static")]
566 /* Create and destroy contexts. */
567 pub fn LLVMContextCreate() -> ContextRef;
568 pub fn LLVMContextDispose(C: ContextRef);
569 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
574 /* Create and destroy modules. */
575 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
578 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
579 pub fn LLVMDisposeModule(M: ModuleRef);
581 /// Data layout. See Module::getDataLayout.
582 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
583 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
585 /// Target triple. See Module::getTargetTriple.
586 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
587 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
589 /// See Module::dump.
590 pub fn LLVMDumpModule(M: ModuleRef);
592 /// See Module::setModuleInlineAsm.
593 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
595 /// See llvm::LLVMTypeKind::getTypeID.
596 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
598 /// See llvm::LLVMType::getContext.
599 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
601 /* Operations on integer types */
602 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
603 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
604 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
605 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
606 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
607 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
610 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
612 /* Operations on real types */
613 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
614 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
615 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
616 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
617 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
619 /* Operations on function types */
620 pub fn LLVMFunctionType(ReturnType: TypeRef,
621 ParamTypes: *const TypeRef,
625 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
626 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
627 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
628 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
630 /* Operations on struct types */
631 pub fn LLVMStructTypeInContext(C: ContextRef,
632 ElementTypes: *const TypeRef,
633 ElementCount: c_uint,
636 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
637 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
639 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
641 /* Operations on array, pointer, and vector types (sequence types) */
642 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
643 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
645 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
648 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
649 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
650 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
651 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
653 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
655 /* Operations on other types */
656 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
657 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
658 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
660 /* Operations on all values */
661 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
662 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
663 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
664 pub fn LLVMDumpValue(Val: ValueRef);
665 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
666 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
667 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
668 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
670 /* Operations on Uses */
671 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
672 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
673 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
674 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
676 /* Operations on Users */
677 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
678 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
679 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
681 /* Operations on constants of any type */
682 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
684 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
685 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
687 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
689 /* only for int/vector */
690 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
691 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
692 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
693 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
694 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
696 /* Operations on metadata */
697 pub fn LLVMMDStringInContext(C: ContextRef,
701 pub fn LLVMMDNodeInContext(C: ContextRef,
702 Vals: *const ValueRef,
705 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
709 /* Operations on scalar constants */
710 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
712 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
714 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
719 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
720 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
722 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
726 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
727 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
730 /* Operations on composite constants */
731 pub fn LLVMConstStringInContext(C: ContextRef,
734 DontNullTerminate: Bool)
736 pub fn LLVMConstStructInContext(C: ContextRef,
737 ConstantVals: *const ValueRef,
742 pub fn LLVMConstArray(ElementTy: TypeRef,
743 ConstantVals: *const ValueRef,
746 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
749 /* Constant expressions */
750 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
751 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
752 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
753 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
754 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
755 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
756 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
757 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
759 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
761 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
763 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
765 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
767 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
769 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
771 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
773 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
775 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
777 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
779 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
781 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
783 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
785 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
786 RHSConstant: ValueRef)
788 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
790 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
792 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
794 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
796 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
798 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
800 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
802 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
804 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
806 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
808 pub fn LLVMConstGEP(ConstantVal: ValueRef,
809 ConstantIndices: *const ValueRef,
812 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
813 ConstantIndices: *const ValueRef,
816 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
818 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
820 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
822 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
824 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
826 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
828 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
830 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
832 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
834 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
836 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
838 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
840 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
842 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
844 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
846 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
848 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
852 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
854 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
855 ConstantIfTrue: ValueRef,
856 ConstantIfFalse: ValueRef)
858 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
859 IndexConstant: ValueRef)
861 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
862 ElementValueConstant: ValueRef,
863 IndexConstant: ValueRef)
865 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
866 VectorBConstant: ValueRef,
867 MaskConstant: ValueRef)
869 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
870 IdxList: *const c_uint,
873 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
874 ElementValueConstant: ValueRef,
875 IdxList: *const c_uint,
878 pub fn LLVMConstInlineAsm(Ty: TypeRef,
879 AsmString: *const c_char,
880 Constraints: *const c_char,
881 HasSideEffects: Bool,
884 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
888 /* Operations on global variables, functions, and aliases (globals) */
889 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
890 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
891 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
892 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
893 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
894 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
895 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
896 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
897 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
898 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
901 /* Operations on global variables */
902 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
904 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
907 AddressSpace: c_uint)
909 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
910 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
911 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
912 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
913 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
914 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
915 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
916 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
917 ConstantVal: ValueRef);
918 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
919 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
920 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
921 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
923 /* Operations on aliases */
924 pub fn LLVMAddAlias(M: ModuleRef,
930 /* Operations on functions */
931 pub fn LLVMAddFunction(M: ModuleRef,
935 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
936 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
937 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
938 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
939 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
940 pub fn LLVMDeleteFunction(Fn: ValueRef);
941 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
945 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
946 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
947 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
948 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
949 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
950 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
951 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
952 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
953 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
954 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
956 /* Operations on parameters */
957 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
958 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
959 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
960 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
961 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
962 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
963 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
964 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
965 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
966 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
967 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
968 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
970 /* Operations on basic blocks */
971 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
972 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
973 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
974 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
975 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
976 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
977 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
978 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
979 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
980 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
981 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
983 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
987 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
991 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
993 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
994 MoveAfter: BasicBlockRef);
996 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
997 MoveBefore: BasicBlockRef);
999 /* Operations on instructions */
1000 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
1001 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
1002 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
1003 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
1004 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
1005 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
1007 /* Operations on call sites */
1008 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
1009 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
1010 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
1013 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1016 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1019 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1022 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1026 /* Operations on call instructions (only) */
1027 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1028 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1030 /* Operations on load/store instructions (only) */
1031 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1032 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1034 /* Operations on phi nodes */
1035 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1036 IncomingValues: *const ValueRef,
1037 IncomingBlocks: *const BasicBlockRef,
1039 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1040 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1042 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1045 /* Instruction builders */
1046 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1047 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1048 Block: BasicBlockRef,
1050 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1052 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1053 Block: BasicBlockRef);
1054 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1055 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1056 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1057 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1059 Name: *const c_char);
1060 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1062 /* Execution engine */
1063 pub fn LLVMRustCreateJITMemoryManager(morestack: *const ())
1064 -> RustJITMemoryManagerRef;
1065 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef,
1066 MM: RustJITMemoryManagerRef) -> ExecutionEngineRef;
1067 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1068 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1069 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1070 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1071 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1075 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1076 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1077 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1080 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1081 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1082 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1083 RetVals: *const ValueRef,
1086 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1087 pub fn LLVMBuildCondBr(B: BuilderRef,
1089 Then: BasicBlockRef,
1090 Else: BasicBlockRef)
1092 pub fn LLVMBuildSwitch(B: BuilderRef,
1094 Else: BasicBlockRef,
1097 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1101 pub fn LLVMBuildInvoke(B: BuilderRef,
1103 Args: *const ValueRef,
1105 Then: BasicBlockRef,
1106 Catch: BasicBlockRef,
1107 Name: *const c_char)
1109 pub fn LLVMBuildLandingPad(B: BuilderRef,
1113 Name: *const c_char)
1115 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1116 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1118 /* Add a case to the switch instruction */
1119 pub fn LLVMAddCase(Switch: ValueRef,
1121 Dest: BasicBlockRef);
1123 /* Add a destination to the indirectbr instruction */
1124 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1126 /* Add a clause to the landing pad instruction */
1127 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1129 /* Set the cleanup on a landing pad instruction */
1130 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1133 pub fn LLVMBuildAdd(B: BuilderRef,
1136 Name: *const c_char)
1138 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1141 Name: *const c_char)
1143 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1146 Name: *const c_char)
1148 pub fn LLVMBuildFAdd(B: BuilderRef,
1151 Name: *const c_char)
1153 pub fn LLVMBuildSub(B: BuilderRef,
1156 Name: *const c_char)
1158 pub fn LLVMBuildNSWSub(B: BuilderRef,
1161 Name: *const c_char)
1163 pub fn LLVMBuildNUWSub(B: BuilderRef,
1166 Name: *const c_char)
1168 pub fn LLVMBuildFSub(B: BuilderRef,
1171 Name: *const c_char)
1173 pub fn LLVMBuildMul(B: BuilderRef,
1176 Name: *const c_char)
1178 pub fn LLVMBuildNSWMul(B: BuilderRef,
1181 Name: *const c_char)
1183 pub fn LLVMBuildNUWMul(B: BuilderRef,
1186 Name: *const c_char)
1188 pub fn LLVMBuildFMul(B: BuilderRef,
1191 Name: *const c_char)
1193 pub fn LLVMBuildUDiv(B: BuilderRef,
1196 Name: *const c_char)
1198 pub fn LLVMBuildSDiv(B: BuilderRef,
1201 Name: *const c_char)
1203 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1206 Name: *const c_char)
1208 pub fn LLVMBuildFDiv(B: BuilderRef,
1211 Name: *const c_char)
1213 pub fn LLVMBuildURem(B: BuilderRef,
1216 Name: *const c_char)
1218 pub fn LLVMBuildSRem(B: BuilderRef,
1221 Name: *const c_char)
1223 pub fn LLVMBuildFRem(B: BuilderRef,
1226 Name: *const c_char)
1228 pub fn LLVMBuildShl(B: BuilderRef,
1231 Name: *const c_char)
1233 pub fn LLVMBuildLShr(B: BuilderRef,
1236 Name: *const c_char)
1238 pub fn LLVMBuildAShr(B: BuilderRef,
1241 Name: *const c_char)
1243 pub fn LLVMBuildAnd(B: BuilderRef,
1246 Name: *const c_char)
1248 pub fn LLVMBuildOr(B: BuilderRef,
1251 Name: *const c_char)
1253 pub fn LLVMBuildXor(B: BuilderRef,
1256 Name: *const c_char)
1258 pub fn LLVMBuildBinOp(B: BuilderRef,
1262 Name: *const c_char)
1264 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1266 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1268 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1270 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1272 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1276 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1278 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1281 Name: *const c_char)
1283 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1285 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1288 Name: *const c_char)
1290 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1291 pub fn LLVMBuildLoad(B: BuilderRef,
1292 PointerVal: ValueRef,
1293 Name: *const c_char)
1296 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1299 pub fn LLVMBuildGEP(B: BuilderRef,
1301 Indices: *const ValueRef,
1303 Name: *const c_char)
1305 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1307 Indices: *const ValueRef,
1309 Name: *const c_char)
1311 pub fn LLVMBuildStructGEP(B: BuilderRef,
1314 Name: *const c_char)
1316 pub fn LLVMBuildGlobalString(B: BuilderRef,
1318 Name: *const c_char)
1320 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1322 Name: *const c_char)
1326 pub fn LLVMBuildTrunc(B: BuilderRef,
1329 Name: *const c_char)
1331 pub fn LLVMBuildZExt(B: BuilderRef,
1334 Name: *const c_char)
1336 pub fn LLVMBuildSExt(B: BuilderRef,
1339 Name: *const c_char)
1341 pub fn LLVMBuildFPToUI(B: BuilderRef,
1344 Name: *const c_char)
1346 pub fn LLVMBuildFPToSI(B: BuilderRef,
1349 Name: *const c_char)
1351 pub fn LLVMBuildUIToFP(B: BuilderRef,
1354 Name: *const c_char)
1356 pub fn LLVMBuildSIToFP(B: BuilderRef,
1359 Name: *const c_char)
1361 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1364 Name: *const c_char)
1366 pub fn LLVMBuildFPExt(B: BuilderRef,
1369 Name: *const c_char)
1371 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1374 Name: *const c_char)
1376 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1379 Name: *const c_char)
1381 pub fn LLVMBuildBitCast(B: BuilderRef,
1384 Name: *const c_char)
1386 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1389 Name: *const c_char)
1391 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1394 Name: *const c_char)
1396 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1399 Name: *const c_char)
1401 pub fn LLVMBuildCast(B: BuilderRef,
1405 Name: *const c_char) -> ValueRef;
1406 pub fn LLVMBuildPointerCast(B: BuilderRef,
1409 Name: *const c_char)
1411 pub fn LLVMBuildIntCast(B: BuilderRef,
1414 Name: *const c_char)
1416 pub fn LLVMBuildFPCast(B: BuilderRef,
1419 Name: *const c_char)
1423 pub fn LLVMBuildICmp(B: BuilderRef,
1427 Name: *const c_char)
1429 pub fn LLVMBuildFCmp(B: BuilderRef,
1433 Name: *const c_char)
1436 /* Miscellaneous instructions */
1437 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1439 pub fn LLVMBuildCall(B: BuilderRef,
1441 Args: *const ValueRef,
1443 Name: *const c_char)
1445 pub fn LLVMBuildSelect(B: BuilderRef,
1449 Name: *const c_char)
1451 pub fn LLVMBuildVAArg(B: BuilderRef,
1454 Name: *const c_char)
1456 pub fn LLVMBuildExtractElement(B: BuilderRef,
1459 Name: *const c_char)
1461 pub fn LLVMBuildInsertElement(B: BuilderRef,
1465 Name: *const c_char)
1467 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1471 Name: *const c_char)
1473 pub fn LLVMBuildExtractValue(B: BuilderRef,
1476 Name: *const c_char)
1478 pub fn LLVMBuildInsertValue(B: BuilderRef,
1482 Name: *const c_char)
1485 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1487 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1489 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1492 Name: *const c_char)
1495 /* Atomic Operations */
1496 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1497 PointerVal: ValueRef,
1498 Name: *const c_char,
1499 Order: AtomicOrdering,
1503 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1506 Order: AtomicOrdering,
1510 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1514 Order: AtomicOrdering,
1515 FailureOrder: AtomicOrdering)
1517 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1521 Order: AtomicOrdering,
1522 SingleThreaded: Bool)
1525 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1528 /* Selected entries from the downcasts. */
1529 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1530 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1532 /// Writes a module to the specified path. Returns 0 on success.
1533 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1535 /// Creates target data from a target layout string.
1536 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1537 /// Adds the target data to the given pass manager. The pass manager
1538 /// references the target data only weakly.
1539 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1540 /// Number of bytes clobbered when doing a Store to *T.
1541 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1544 /// Number of bytes clobbered when doing a Store to *T.
1545 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1548 /// Distance between successive elements in an array of T. Includes ABI padding.
1549 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1551 /// Returns the preferred alignment of a type.
1552 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1554 /// Returns the minimum alignment of a type.
1555 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1558 /// Computes the byte offset of the indexed struct element for a
1560 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1565 /// Returns the minimum alignment of a type when part of a call frame.
1566 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1569 /// Disposes target data.
1570 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1572 /// Creates a pass manager.
1573 pub fn LLVMCreatePassManager() -> PassManagerRef;
1575 /// Creates a function-by-function pass manager
1576 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1579 /// Disposes a pass manager.
1580 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1582 /// Runs a pass manager on a module.
1583 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1585 /// Runs the function passes on the provided function.
1586 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1589 /// Initializes all the function passes scheduled in the manager
1590 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1592 /// Finalizes all the function passes scheduled in the manager
1593 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1595 pub fn LLVMInitializePasses();
1597 /// Adds a verification pass.
1598 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1600 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1601 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1602 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1603 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1604 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1605 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1606 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1607 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1608 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1609 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1610 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1611 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1612 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1613 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1614 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1615 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1616 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1617 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1618 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1619 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1620 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1621 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1622 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1623 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1624 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1625 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1626 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1627 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1628 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1629 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1630 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1631 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1632 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1633 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1634 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1636 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1637 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1638 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1639 OptimizationLevel: c_uint);
1640 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1642 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1643 PMB: PassManagerBuilderRef,
1645 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1646 PMB: PassManagerBuilderRef,
1648 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1649 PMB: PassManagerBuilderRef,
1651 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1652 PMB: PassManagerBuilderRef,
1654 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1655 PMB: PassManagerBuilderRef,
1656 PM: PassManagerRef);
1658 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1659 PMB: PassManagerBuilderRef,
1660 PM: PassManagerRef);
1661 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1662 PMB: PassManagerBuilderRef,
1667 /// Destroys a memory buffer.
1668 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1671 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1673 /// Opens an object file.
1674 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1675 /// Closes an object file.
1676 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1678 /// Enumerates the sections in an object file.
1679 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1680 /// Destroys a section iterator.
1681 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1682 /// Returns true if the section iterator is at the end of the section
1684 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1685 SI: SectionIteratorRef)
1687 /// Moves the section iterator to point to the next section.
1688 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1689 /// Returns the current section size.
1690 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1691 /// Returns the current section contents as a string buffer.
1692 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1694 /// Reads the given file and returns it as a memory buffer. Use
1695 /// LLVMDisposeMemoryBuffer() to get rid of it.
1696 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1698 /// Borrows the contents of the memory buffer (doesn't copy it)
1699 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1700 InputDataLength: size_t,
1701 BufferName: *const c_char,
1704 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1705 InputDataLength: size_t,
1706 BufferName: *const c_char)
1709 pub fn LLVMIsMultithreaded() -> Bool;
1710 pub fn LLVMStartMultithreaded() -> Bool;
1712 /// Returns a string describing the last error caused by an LLVMRust* call.
1713 pub fn LLVMRustGetLastError() -> *const c_char;
1715 /// Print the pass timings since static dtors aren't picking them up.
1716 pub fn LLVMRustPrintPassTimings();
1718 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1720 pub fn LLVMStructSetBody(StructTy: TypeRef,
1721 ElementTypes: *const TypeRef,
1722 ElementCount: c_uint,
1725 pub fn LLVMConstNamedStruct(S: TypeRef,
1726 ConstantVals: *const ValueRef,
1730 /// Enables LLVM debug output.
1731 pub fn LLVMSetDebug(Enabled: c_int);
1733 /// Prepares inline assembly.
1734 pub fn LLVMInlineAsm(Ty: TypeRef,
1735 AsmString: *const c_char,
1736 Constraints: *const c_char,
1742 pub static LLVMRustDebugMetadataVersion: u32;
1744 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1745 name: *const c_char,
1748 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1750 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1752 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1754 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1756 File: *const c_char,
1758 Producer: *const c_char,
1760 Flags: *const c_char,
1762 SplitName: *const c_char)
1765 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1766 Filename: *const c_char,
1767 Directory: *const c_char)
1770 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1772 ParameterTypes: DIArray)
1775 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1776 Scope: DIDescriptor,
1777 Name: *const c_char,
1778 LinkageName: *const c_char,
1782 isLocalToUnit: bool,
1792 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1793 Name: *const c_char,
1794 SizeInBits: c_ulonglong,
1795 AlignInBits: c_ulonglong,
1799 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1801 SizeInBits: c_ulonglong,
1802 AlignInBits: c_ulonglong,
1803 Name: *const c_char)
1806 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1807 Scope: DIDescriptor,
1808 Name: *const c_char,
1811 SizeInBits: c_ulonglong,
1812 AlignInBits: c_ulonglong,
1814 DerivedFrom: DIType,
1816 RunTimeLang: c_uint,
1817 VTableHolder: DIType,
1818 UniqueId: *const c_char)
1821 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1822 Scope: DIDescriptor,
1823 Name: *const c_char,
1826 SizeInBits: c_ulonglong,
1827 AlignInBits: c_ulonglong,
1828 OffsetInBits: c_ulonglong,
1833 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1840 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1842 Name: *const c_char,
1843 LinkageName: *const c_char,
1847 isLocalToUnit: bool,
1850 -> DIGlobalVariable;
1852 pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef,
1854 Scope: DIDescriptor,
1855 Name: *const c_char,
1859 AlwaysPreserve: bool,
1861 AddrOps: *const i64,
1862 AddrOpsCount: c_uint,
1866 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1868 AlignInBits: c_ulonglong,
1870 Subscripts: DIArray)
1873 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1875 AlignInBits: c_ulonglong,
1877 Subscripts: DIArray)
1880 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1885 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1886 Ptr: *const DIDescriptor,
1890 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1892 VarInfo: DIVariable,
1893 AddrOps: *const i64,
1894 AddrOpsCount: c_uint,
1895 InsertAtEnd: BasicBlockRef)
1898 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1900 VarInfo: DIVariable,
1901 AddrOps: *const i64,
1902 AddrOpsCount: c_uint,
1903 InsertBefore: ValueRef)
1906 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1907 Name: *const c_char,
1911 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1913 Name: *const c_char,
1916 SizeInBits: c_ulonglong,
1917 AlignInBits: c_ulonglong,
1922 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1924 Name: *const c_char,
1927 SizeInBits: c_ulonglong,
1928 AlignInBits: c_ulonglong,
1931 RunTimeLang: c_uint,
1932 UniqueId: *const c_char)
1935 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1937 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1939 Name: *const c_char,
1944 -> DITemplateTypeParameter;
1946 pub fn LLVMDIBuilderCreateOpDeref() -> i64;
1948 pub fn LLVMDIBuilderCreateOpPlus() -> i64;
1950 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1952 Name: *const c_char,
1957 pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef,
1961 InlinedAt: MetadataRef)
1964 pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1965 CompositeType: DIType,
1966 TypeArray: DIArray);
1967 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1968 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1970 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1972 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1974 pub fn LLVMInitializeX86TargetInfo();
1975 pub fn LLVMInitializeX86Target();
1976 pub fn LLVMInitializeX86TargetMC();
1977 pub fn LLVMInitializeX86AsmPrinter();
1978 pub fn LLVMInitializeX86AsmParser();
1979 pub fn LLVMInitializeARMTargetInfo();
1980 pub fn LLVMInitializeARMTarget();
1981 pub fn LLVMInitializeARMTargetMC();
1982 pub fn LLVMInitializeARMAsmPrinter();
1983 pub fn LLVMInitializeARMAsmParser();
1984 pub fn LLVMInitializeAArch64TargetInfo();
1985 pub fn LLVMInitializeAArch64Target();
1986 pub fn LLVMInitializeAArch64TargetMC();
1987 pub fn LLVMInitializeAArch64AsmPrinter();
1988 pub fn LLVMInitializeAArch64AsmParser();
1989 pub fn LLVMInitializeMipsTargetInfo();
1990 pub fn LLVMInitializeMipsTarget();
1991 pub fn LLVMInitializeMipsTargetMC();
1992 pub fn LLVMInitializeMipsAsmPrinter();
1993 pub fn LLVMInitializeMipsAsmParser();
1994 pub fn LLVMInitializePowerPCTargetInfo();
1995 pub fn LLVMInitializePowerPCTarget();
1996 pub fn LLVMInitializePowerPCTargetMC();
1997 pub fn LLVMInitializePowerPCAsmPrinter();
1998 pub fn LLVMInitializePowerPCAsmParser();
2000 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
2001 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
2003 Features: *const c_char,
2004 Model: CodeGenModel,
2006 Level: CodeGenOptLevel,
2009 NoFramePointerElim: bool,
2010 PositionIndependentExecutable: bool,
2011 FunctionSections: bool,
2012 DataSections: bool) -> TargetMachineRef;
2013 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
2014 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
2017 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
2019 DisableSimplifyLibCalls: bool);
2020 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
2021 DisableSimplifyLibCalls: bool);
2022 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
2023 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2026 Output: *const c_char,
2027 FileType: FileType) -> bool;
2028 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2030 Output: *const c_char);
2031 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2032 pub fn LLVMRustPrintPasses();
2033 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2034 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2035 AddLifetimes: bool);
2036 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2038 len: size_t) -> bool;
2039 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2040 syms: *const *const c_char,
2042 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2044 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2045 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
2046 out_len: *mut size_t) -> *const c_char;
2047 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2049 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
2050 pub fn LLVMVersionMajor() -> c_int;
2051 pub fn LLVMVersionMinor() -> c_int;
2053 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2054 data: *mut *const c_char) -> c_int;
2056 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2058 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2059 Handler: DiagnosticHandler,
2060 DiagnosticContext: *mut c_void);
2062 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2063 pass_name_out: *mut *const c_char,
2064 function_out: *mut ValueRef,
2065 debugloc_out: *mut DebugLocRef,
2066 message_out: *mut TwineRef);
2067 pub fn LLVMUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
2068 cookie_out: *mut c_uint,
2069 message_out: *mut TwineRef,
2070 instruction_out: *mut ValueRef);
2072 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2073 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2074 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2076 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2078 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2079 H: InlineAsmDiagHandler,
2082 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2085 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2087 LLVMSetInstructionCallConv(instr, cc as c_uint);
2090 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2092 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2095 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2097 LLVMSetLinkage(global, link as c_uint);
2101 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2103 LLVMSetUnnamedAddr(global, unnamed as Bool);
2107 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2109 LLVMSetThreadLocal(global, is_thread_local as Bool);
2113 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2115 LLVMConstICmp(pred as c_ushort, v1, v2)
2118 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2120 LLVMConstFCmp(pred as c_ushort, v1, v2)
2124 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2126 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
2130 /* Memory-managed interface to target data. */
2132 pub struct TargetData {
2133 pub lltd: TargetDataRef
2136 impl Drop for TargetData {
2137 fn drop(&mut self) {
2139 LLVMDisposeTargetData(self.lltd);
2144 pub fn mk_target_data(string_rep: &str) -> TargetData {
2145 let string_rep = CString::from_slice(string_rep.as_bytes());
2147 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2151 /* Memory-managed interface to object files. */
2153 pub struct ObjectFile {
2154 pub llof: ObjectFileRef,
2158 // This will take ownership of llmb
2159 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2161 let llof = LLVMCreateObjectFile(llmb);
2162 if llof as int == 0 {
2163 // LLVMCreateObjectFile took ownership of llmb
2174 impl Drop for ObjectFile {
2175 fn drop(&mut self) {
2177 LLVMDisposeObjectFile(self.llof);
2182 /* Memory-managed interface to section iterators. */
2184 pub struct SectionIter {
2185 pub llsi: SectionIteratorRef
2188 impl Drop for SectionIter {
2189 fn drop(&mut self) {
2191 LLVMDisposeSectionIterator(self.llsi);
2196 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2199 llsi: LLVMGetSections(llof)
2204 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2205 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2207 assert!(index < LLVMCountParams(llfn));
2208 LLVMGetParam(llfn, index)
2212 #[allow(missing_copy_implementations)]
2213 pub enum RustString_opaque {}
2214 pub type RustStringRef = *mut RustString_opaque;
2215 type RustStringRepr = *mut RefCell<Vec<u8>>;
2217 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2219 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2222 let slice: &[u8] = mem::transmute(raw::Slice {
2223 data: ptr as *const u8,
2227 let sr: RustStringRepr = mem::transmute(sr);
2228 (*sr).borrow_mut().push_all(slice);
2231 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2232 let mut buf = RefCell::new(Vec::new());
2233 f(&mut buf as RustStringRepr as RustStringRef);
2234 String::from_utf8(buf.into_inner()).ok()
2237 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2238 build_string(|s| LLVMWriteTwineToString(tr, s))
2239 .expect("got a non-UTF8 Twine from LLVM")
2242 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2243 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2244 .expect("got a non-UTF8 DebugLoc from LLVM")
2247 // FIXME #15460 - create a public function that actually calls our
2248 // static LLVM symbols. Otherwise the linker will just throw llvm
2249 // away. We're just calling lots of stuff until we transitively get
2250 // all of LLVM. This is worse than anything.
2251 pub unsafe fn static_link_hack_this_sucks() {
2252 LLVMInitializePasses();
2254 LLVMInitializeX86TargetInfo();
2255 LLVMInitializeX86Target();
2256 LLVMInitializeX86TargetMC();
2257 LLVMInitializeX86AsmPrinter();
2258 LLVMInitializeX86AsmParser();
2260 LLVMInitializeARMTargetInfo();
2261 LLVMInitializeARMTarget();
2262 LLVMInitializeARMTargetMC();
2263 LLVMInitializeARMAsmPrinter();
2264 LLVMInitializeARMAsmParser();
2266 LLVMInitializeAArch64TargetInfo();
2267 LLVMInitializeAArch64Target();
2268 LLVMInitializeAArch64TargetMC();
2269 LLVMInitializeAArch64AsmPrinter();
2270 LLVMInitializeAArch64AsmParser();
2272 LLVMInitializeMipsTargetInfo();
2273 LLVMInitializeMipsTarget();
2274 LLVMInitializeMipsTargetMC();
2275 LLVMInitializeMipsAsmPrinter();
2276 LLVMInitializeMipsAsmParser();
2278 LLVMInitializePowerPCTargetInfo();
2279 LLVMInitializePowerPCTarget();
2280 LLVMInitializePowerPCTargetMC();
2281 LLVMInitializePowerPCAsmPrinter();
2282 LLVMInitializePowerPCAsmParser();
2284 LLVMRustSetLLVMOptions(0 as c_int, ptr::null());
2286 LLVMPassManagerBuilderPopulateModulePassManager(ptr::null_mut(), ptr::null_mut());
2287 LLVMPassManagerBuilderPopulateLTOPassManager(ptr::null_mut(), ptr::null_mut(), False, False);
2288 LLVMPassManagerBuilderPopulateFunctionPassManager(ptr::null_mut(), ptr::null_mut());
2289 LLVMPassManagerBuilderSetOptLevel(ptr::null_mut(), 0 as c_uint);
2290 LLVMPassManagerBuilderUseInlinerWithThreshold(ptr::null_mut(), 0 as c_uint);
2291 LLVMWriteBitcodeToFile(ptr::null_mut(), ptr::null());
2292 LLVMPassManagerBuilderCreate();
2293 LLVMPassManagerBuilderDispose(ptr::null_mut());
2295 LLVMRustLinkInExternalBitcode(ptr::null_mut(), ptr::null(), 0 as size_t);
2298 LLVMLinkInInterpreter();
2301 fn LLVMLinkInMCJIT();
2302 fn LLVMLinkInInterpreter();
2306 // The module containing the native LLVM dependencies, generated by the build system
2307 // Note that this must come after the rustllvm extern declaration so that
2308 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2309 // Works to the above fix for #15460 to ensure LLVM dependencies that
2310 // are only used by rustllvm don't get stripped by the linker.
2312 include! { env!("CFG_LLVM_LINKAGE_FILE") }