1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![allow(non_upper_case_globals)]
12 #![allow(non_camel_case_types)]
13 #![allow(non_snake_case)]
16 #![crate_name = "rustc_llvm"]
19 #![crate_type = "dylib"]
20 #![crate_type = "rlib"]
21 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22 html_favicon_url = "http://www.rust-lang.org/favicon.ico",
23 html_root_url = "http://doc.rust-lang.org/nightly/")]
25 #![allow(unknown_features)]
26 #![feature(link_args)]
27 #![feature(box_syntax)]
28 #![allow(unknown_features)] #![feature(int_uint)]
32 pub use self::OtherAttribute::*;
33 pub use self::SpecialAttribute::*;
34 pub use self::AttributeSet::*;
35 pub use self::IntPredicate::*;
36 pub use self::RealPredicate::*;
37 pub use self::TypeKind::*;
38 pub use self::AtomicBinOp::*;
39 pub use self::AtomicOrdering::*;
40 pub use self::FileType::*;
41 pub use self::MetadataType::*;
42 pub use self::AsmDialect::*;
43 pub use self::CodeGenOptLevel::*;
44 pub use self::RelocMode::*;
45 pub use self::CodeGenModel::*;
46 pub use self::DiagnosticKind::*;
47 pub use self::CallConv::*;
48 pub use self::Visibility::*;
49 pub use self::DiagnosticSeverity::*;
50 pub use self::Linkage::*;
52 use std::ffi::CString;
53 use std::cell::RefCell;
55 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
56 use libc::{c_longlong, c_ulonglong, c_void};
57 use debuginfo::{DIBuilderRef, DIDescriptor,
58 DIFile, DILexicalBlock, DISubprogram, DIType,
59 DIBasicType, DIDerivedType, DICompositeType,
60 DIVariable, DIGlobalVariable, DIArray, DISubrange};
65 pub type Opcode = u32;
66 pub type Bool = c_uint;
68 pub const True: Bool = 1 as Bool;
69 pub const False: Bool = 0 as Bool;
71 // Consts for the LLVM CallConv type, pre-cast to uint.
73 #[derive(Copy, PartialEq)]
78 X86StdcallCallConv = 64,
79 X86FastcallCallConv = 65,
85 LLVMDefaultVisibility = 0,
87 ProtectedVisibility = 2,
90 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
91 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
92 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
93 // they've been removed in upstream LLVM commit r203866.
97 AvailableExternallyLinkage = 1,
98 LinkOnceAnyLinkage = 2,
99 LinkOnceODRLinkage = 3,
102 AppendingLinkage = 7,
105 ExternalWeakLinkage = 12,
110 #[derive(Copy, Show)]
111 pub enum DiagnosticSeverity {
119 flags Attribute : u32 {
120 const ZExtAttribute = 1 << 0,
121 const SExtAttribute = 1 << 1,
122 const NoReturnAttribute = 1 << 2,
123 const InRegAttribute = 1 << 3,
124 const StructRetAttribute = 1 << 4,
125 const NoUnwindAttribute = 1 << 5,
126 const NoAliasAttribute = 1 << 6,
127 const ByValAttribute = 1 << 7,
128 const NestAttribute = 1 << 8,
129 const ReadNoneAttribute = 1 << 9,
130 const ReadOnlyAttribute = 1 << 10,
131 const NoInlineAttribute = 1 << 11,
132 const AlwaysInlineAttribute = 1 << 12,
133 const OptimizeForSizeAttribute = 1 << 13,
134 const StackProtectAttribute = 1 << 14,
135 const StackProtectReqAttribute = 1 << 15,
136 const AlignmentAttribute = 31 << 16,
137 const NoCaptureAttribute = 1 << 21,
138 const NoRedZoneAttribute = 1 << 22,
139 const NoImplicitFloatAttribute = 1 << 23,
140 const NakedAttribute = 1 << 24,
141 const InlineHintAttribute = 1 << 25,
142 const StackAttribute = 7 << 26,
143 const ReturnsTwiceAttribute = 1 << 29,
144 const UWTableAttribute = 1 << 30,
145 const NonLazyBindAttribute = 1 << 31,
152 pub enum OtherAttribute {
153 // The following are not really exposed in
154 // the LLVM c api so instead to add these
155 // we call a wrapper function in RustWrapper
156 // that uses the C++ api.
157 SanitizeAddressAttribute = 1 << 32,
158 MinSizeAttribute = 1 << 33,
159 NoDuplicateAttribute = 1 << 34,
160 StackProtectStrongAttribute = 1 << 35,
161 SanitizeThreadAttribute = 1 << 36,
162 SanitizeMemoryAttribute = 1 << 37,
163 NoBuiltinAttribute = 1 << 38,
164 ReturnedAttribute = 1 << 39,
165 ColdAttribute = 1 << 40,
166 BuiltinAttribute = 1 << 41,
167 OptimizeNoneAttribute = 1 << 42,
168 InAllocaAttribute = 1 << 43,
169 NonNullAttribute = 1 << 44,
173 pub enum SpecialAttribute {
174 DereferenceableAttribute(u64)
179 pub enum AttributeSet {
184 pub trait AttrHelper {
185 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
186 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
189 impl AttrHelper for Attribute {
190 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
192 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
196 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
198 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
203 impl AttrHelper for OtherAttribute {
204 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
206 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
210 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
212 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
217 impl AttrHelper for SpecialAttribute {
218 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
220 DereferenceableAttribute(bytes) => unsafe {
221 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
226 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
228 DereferenceableAttribute(bytes) => unsafe {
229 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
235 pub struct AttrBuilder {
236 attrs: Vec<(uint, Box<AttrHelper+'static>)>
240 pub fn new() -> AttrBuilder {
246 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
247 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
251 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
252 self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
256 pub fn apply_llfn(&self, llfn: ValueRef) {
257 for &(idx, ref attr) in self.attrs.iter() {
258 attr.apply_llfn(idx as c_uint, llfn);
262 pub fn apply_callsite(&self, callsite: ValueRef) {
263 for &(idx, ref attr) in self.attrs.iter() {
264 attr.apply_callsite(idx as c_uint, callsite);
269 // enum for the LLVM IntPredicate type
271 pub enum IntPredicate {
284 // enum for the LLVM RealPredicate type
286 pub enum RealPredicate {
287 RealPredicateFalse = 0,
302 RealPredicateTrue = 15,
305 // The LLVM TypeKind type - must stay in sync with the def of
306 // LLVMTypeKind in llvm/include/llvm-c/Core.h
307 #[derive(Copy, PartialEq)]
330 pub enum AtomicBinOp {
346 pub enum AtomicOrdering {
350 // Consume = 3, // Not specified yet.
354 SequentiallyConsistent = 7
357 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
361 AssemblyFileType = 0,
366 pub enum MetadataType {
375 // Inline Asm Dialect
377 pub enum AsmDialect {
382 #[derive(Copy, PartialEq, Clone)]
384 pub enum CodeGenOptLevel {
385 CodeGenLevelNone = 0,
386 CodeGenLevelLess = 1,
387 CodeGenLevelDefault = 2,
388 CodeGenLevelAggressive = 3,
391 #[derive(Copy, PartialEq)]
397 RelocDynamicNoPic = 3,
402 pub enum CodeGenModel {
403 CodeModelDefault = 0,
404 CodeModelJITDefault = 1,
413 pub enum DiagnosticKind {
416 DK_DebugMetadataVersion,
418 DK_OptimizationRemark,
419 DK_OptimizationRemarkMissed,
420 DK_OptimizationRemarkAnalysis,
421 DK_OptimizationFailure,
424 // Opaque pointer types
425 #[allow(missing_copy_implementations)]
426 pub enum Module_opaque {}
427 pub type ModuleRef = *mut Module_opaque;
428 #[allow(missing_copy_implementations)]
429 pub enum Context_opaque {}
430 pub type ContextRef = *mut Context_opaque;
431 #[allow(missing_copy_implementations)]
432 pub enum Type_opaque {}
433 pub type TypeRef = *mut Type_opaque;
434 #[allow(missing_copy_implementations)]
435 pub enum Value_opaque {}
436 pub type ValueRef = *mut Value_opaque;
437 #[allow(missing_copy_implementations)]
438 pub enum BasicBlock_opaque {}
439 pub type BasicBlockRef = *mut BasicBlock_opaque;
440 #[allow(missing_copy_implementations)]
441 pub enum Builder_opaque {}
442 pub type BuilderRef = *mut Builder_opaque;
443 #[allow(missing_copy_implementations)]
444 pub enum ExecutionEngine_opaque {}
445 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
446 #[allow(missing_copy_implementations)]
447 pub enum RustJITMemoryManager_opaque {}
448 pub type RustJITMemoryManagerRef = *mut RustJITMemoryManager_opaque;
449 #[allow(missing_copy_implementations)]
450 pub enum MemoryBuffer_opaque {}
451 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
452 #[allow(missing_copy_implementations)]
453 pub enum PassManager_opaque {}
454 pub type PassManagerRef = *mut PassManager_opaque;
455 #[allow(missing_copy_implementations)]
456 pub enum PassManagerBuilder_opaque {}
457 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
458 #[allow(missing_copy_implementations)]
459 pub enum Use_opaque {}
460 pub type UseRef = *mut Use_opaque;
461 #[allow(missing_copy_implementations)]
462 pub enum TargetData_opaque {}
463 pub type TargetDataRef = *mut TargetData_opaque;
464 #[allow(missing_copy_implementations)]
465 pub enum ObjectFile_opaque {}
466 pub type ObjectFileRef = *mut ObjectFile_opaque;
467 #[allow(missing_copy_implementations)]
468 pub enum SectionIterator_opaque {}
469 pub type SectionIteratorRef = *mut SectionIterator_opaque;
470 #[allow(missing_copy_implementations)]
471 pub enum Pass_opaque {}
472 pub type PassRef = *mut Pass_opaque;
473 #[allow(missing_copy_implementations)]
474 pub enum TargetMachine_opaque {}
475 pub type TargetMachineRef = *mut TargetMachine_opaque;
476 #[allow(missing_copy_implementations)]
477 pub enum Archive_opaque {}
478 pub type ArchiveRef = *mut Archive_opaque;
479 #[allow(missing_copy_implementations)]
480 pub enum Twine_opaque {}
481 pub type TwineRef = *mut Twine_opaque;
482 #[allow(missing_copy_implementations)]
483 pub enum DiagnosticInfo_opaque {}
484 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
485 #[allow(missing_copy_implementations)]
486 pub enum DebugLoc_opaque {}
487 pub type DebugLocRef = *mut DebugLoc_opaque;
488 #[allow(missing_copy_implementations)]
489 pub enum SMDiagnostic_opaque {}
490 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
492 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
493 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
496 pub use self::DIDescriptorFlags::*;
497 use super::{ValueRef};
499 #[allow(missing_copy_implementations)]
500 pub enum DIBuilder_opaque {}
501 pub type DIBuilderRef = *mut DIBuilder_opaque;
503 pub type DIDescriptor = ValueRef;
504 pub type DIScope = DIDescriptor;
505 pub type DILocation = DIDescriptor;
506 pub type DIFile = DIScope;
507 pub type DILexicalBlock = DIScope;
508 pub type DISubprogram = DIScope;
509 pub type DIType = DIDescriptor;
510 pub type DIBasicType = DIType;
511 pub type DIDerivedType = DIType;
512 pub type DICompositeType = DIDerivedType;
513 pub type DIVariable = DIDescriptor;
514 pub type DIGlobalVariable = DIDescriptor;
515 pub type DIArray = DIDescriptor;
516 pub type DISubrange = DIDescriptor;
519 pub enum DIDescriptorFlags {
520 FlagPrivate = 1 << 0,
521 FlagProtected = 1 << 1,
522 FlagFwdDecl = 1 << 2,
523 FlagAppleBlock = 1 << 3,
524 FlagBlockByrefStruct = 1 << 4,
525 FlagVirtual = 1 << 5,
526 FlagArtificial = 1 << 6,
527 FlagExplicit = 1 << 7,
528 FlagPrototyped = 1 << 8,
529 FlagObjcClassComplete = 1 << 9,
530 FlagObjectPointer = 1 << 10,
531 FlagVector = 1 << 11,
532 FlagStaticMember = 1 << 12,
533 FlagIndirectVariable = 1 << 13,
534 FlagLValueReference = 1 << 14,
535 FlagRValueReference = 1 << 15
540 // Link to our native llvm bindings (things that we need to use the C++ api
541 // for) and because llvm is written in C++ we need to link against libstdc++
543 // You'll probably notice that there is an omission of all LLVM libraries
544 // from this location. This is because the set of LLVM libraries that we
545 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
546 // figure out the exact set of libraries. To do this, the build system
547 // generates an llvmdeps.rs file next to this one which will be
548 // automatically updated whenever LLVM is updated to include an up-to-date
549 // set of the libraries we need to link to LLVM for.
550 #[link(name = "rustllvm", kind = "static")]
552 /* Create and destroy contexts. */
553 pub fn LLVMContextCreate() -> ContextRef;
554 pub fn LLVMContextDispose(C: ContextRef);
555 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
560 /* Create and destroy modules. */
561 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
564 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
565 pub fn LLVMDisposeModule(M: ModuleRef);
567 /// Data layout. See Module::getDataLayout.
568 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
569 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
571 /// Target triple. See Module::getTargetTriple.
572 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
573 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
575 /// See Module::dump.
576 pub fn LLVMDumpModule(M: ModuleRef);
578 /// See Module::setModuleInlineAsm.
579 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
581 /// See llvm::LLVMTypeKind::getTypeID.
582 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
584 /// See llvm::LLVMType::getContext.
585 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
587 /* Operations on integer types */
588 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
589 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
590 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
591 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
592 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
593 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
596 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
598 /* Operations on real types */
599 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
600 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
601 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
602 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
603 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
605 /* Operations on function types */
606 pub fn LLVMFunctionType(ReturnType: TypeRef,
607 ParamTypes: *const TypeRef,
611 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
612 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
613 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
614 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
616 /* Operations on struct types */
617 pub fn LLVMStructTypeInContext(C: ContextRef,
618 ElementTypes: *const TypeRef,
619 ElementCount: c_uint,
622 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
623 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
625 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
627 /* Operations on array, pointer, and vector types (sequence types) */
628 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
629 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
631 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
634 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
635 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
636 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
637 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
639 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
641 /* Operations on other types */
642 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
643 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
644 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
646 /* Operations on all values */
647 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
648 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
649 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
650 pub fn LLVMDumpValue(Val: ValueRef);
651 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
652 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
653 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
654 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
656 /* Operations on Uses */
657 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
658 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
659 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
660 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
662 /* Operations on Users */
663 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
664 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
665 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
667 /* Operations on constants of any type */
668 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
670 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
671 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
673 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
675 /* only for int/vector */
676 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
677 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
678 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
679 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
680 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
682 /* Operations on metadata */
683 pub fn LLVMMDStringInContext(C: ContextRef,
687 pub fn LLVMMDNodeInContext(C: ContextRef,
688 Vals: *const ValueRef,
691 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
695 /* Operations on scalar constants */
696 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
698 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
700 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
705 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
706 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
708 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
712 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
713 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
716 /* Operations on composite constants */
717 pub fn LLVMConstStringInContext(C: ContextRef,
720 DontNullTerminate: Bool)
722 pub fn LLVMConstStructInContext(C: ContextRef,
723 ConstantVals: *const ValueRef,
728 pub fn LLVMConstArray(ElementTy: TypeRef,
729 ConstantVals: *const ValueRef,
732 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
735 /* Constant expressions */
736 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
737 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
738 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
739 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
740 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
741 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
742 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
743 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
745 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
747 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
749 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
751 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
753 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
755 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
757 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
759 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
761 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
763 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
765 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
767 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
769 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
771 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
772 RHSConstant: ValueRef)
774 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
776 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
778 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
780 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
782 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
784 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
786 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
788 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
790 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
792 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
794 pub fn LLVMConstGEP(ConstantVal: ValueRef,
795 ConstantIndices: *const ValueRef,
798 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
799 ConstantIndices: *const ValueRef,
802 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
804 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
806 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
808 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
810 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
812 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
814 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
816 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
818 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
820 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
822 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
824 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
826 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
828 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
830 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
832 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
834 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
838 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
840 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
841 ConstantIfTrue: ValueRef,
842 ConstantIfFalse: ValueRef)
844 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
845 IndexConstant: ValueRef)
847 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
848 ElementValueConstant: ValueRef,
849 IndexConstant: ValueRef)
851 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
852 VectorBConstant: ValueRef,
853 MaskConstant: ValueRef)
855 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
856 IdxList: *const c_uint,
859 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
860 ElementValueConstant: ValueRef,
861 IdxList: *const c_uint,
864 pub fn LLVMConstInlineAsm(Ty: TypeRef,
865 AsmString: *const c_char,
866 Constraints: *const c_char,
867 HasSideEffects: Bool,
870 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
874 /* Operations on global variables, functions, and aliases (globals) */
875 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
876 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
877 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
878 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
879 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
880 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
881 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
882 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
883 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
884 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
887 /* Operations on global variables */
888 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
890 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
893 AddressSpace: c_uint)
895 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
896 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
897 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
898 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
899 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
900 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
901 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
902 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
903 ConstantVal: ValueRef);
904 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
905 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
906 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
907 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
909 /* Operations on aliases */
910 pub fn LLVMAddAlias(M: ModuleRef,
916 /* Operations on functions */
917 pub fn LLVMAddFunction(M: ModuleRef,
921 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
922 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
923 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
924 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
925 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
926 pub fn LLVMDeleteFunction(Fn: ValueRef);
927 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
931 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
932 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
933 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
934 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
935 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
936 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
937 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
938 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
939 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
940 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
942 /* Operations on parameters */
943 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
944 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
945 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
946 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
947 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
948 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
949 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
950 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
951 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
952 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
953 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
954 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
956 /* Operations on basic blocks */
957 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
958 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
959 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
960 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
961 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
962 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
963 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
964 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
965 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
966 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
967 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
969 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
973 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
977 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
979 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
980 MoveAfter: BasicBlockRef);
982 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
983 MoveBefore: BasicBlockRef);
985 /* Operations on instructions */
986 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
987 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
988 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
989 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
990 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
991 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
993 /* Operations on call sites */
994 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
995 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
996 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
999 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1002 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1005 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1008 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1012 /* Operations on call instructions (only) */
1013 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1014 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1016 /* Operations on load/store instructions (only) */
1017 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1018 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1020 /* Operations on phi nodes */
1021 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1022 IncomingValues: *const ValueRef,
1023 IncomingBlocks: *const BasicBlockRef,
1025 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1026 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1028 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1031 /* Instruction builders */
1032 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1033 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1034 Block: BasicBlockRef,
1036 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1038 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1039 Block: BasicBlockRef);
1040 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1041 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1042 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1043 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1045 Name: *const c_char);
1046 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1048 /* Execution engine */
1049 pub fn LLVMRustCreateJITMemoryManager(morestack: *const ())
1050 -> RustJITMemoryManagerRef;
1051 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef,
1052 MM: RustJITMemoryManagerRef) -> ExecutionEngineRef;
1053 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1054 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1055 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1056 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1057 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1061 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1062 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1063 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1066 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1067 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1068 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1069 RetVals: *const ValueRef,
1072 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1073 pub fn LLVMBuildCondBr(B: BuilderRef,
1075 Then: BasicBlockRef,
1076 Else: BasicBlockRef)
1078 pub fn LLVMBuildSwitch(B: BuilderRef,
1080 Else: BasicBlockRef,
1083 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1087 pub fn LLVMBuildInvoke(B: BuilderRef,
1089 Args: *const ValueRef,
1091 Then: BasicBlockRef,
1092 Catch: BasicBlockRef,
1093 Name: *const c_char)
1095 pub fn LLVMBuildLandingPad(B: BuilderRef,
1099 Name: *const c_char)
1101 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1102 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1104 /* Add a case to the switch instruction */
1105 pub fn LLVMAddCase(Switch: ValueRef,
1107 Dest: BasicBlockRef);
1109 /* Add a destination to the indirectbr instruction */
1110 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1112 /* Add a clause to the landing pad instruction */
1113 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1115 /* Set the cleanup on a landing pad instruction */
1116 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1119 pub fn LLVMBuildAdd(B: BuilderRef,
1122 Name: *const c_char)
1124 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1127 Name: *const c_char)
1129 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1132 Name: *const c_char)
1134 pub fn LLVMBuildFAdd(B: BuilderRef,
1137 Name: *const c_char)
1139 pub fn LLVMBuildSub(B: BuilderRef,
1142 Name: *const c_char)
1144 pub fn LLVMBuildNSWSub(B: BuilderRef,
1147 Name: *const c_char)
1149 pub fn LLVMBuildNUWSub(B: BuilderRef,
1152 Name: *const c_char)
1154 pub fn LLVMBuildFSub(B: BuilderRef,
1157 Name: *const c_char)
1159 pub fn LLVMBuildMul(B: BuilderRef,
1162 Name: *const c_char)
1164 pub fn LLVMBuildNSWMul(B: BuilderRef,
1167 Name: *const c_char)
1169 pub fn LLVMBuildNUWMul(B: BuilderRef,
1172 Name: *const c_char)
1174 pub fn LLVMBuildFMul(B: BuilderRef,
1177 Name: *const c_char)
1179 pub fn LLVMBuildUDiv(B: BuilderRef,
1182 Name: *const c_char)
1184 pub fn LLVMBuildSDiv(B: BuilderRef,
1187 Name: *const c_char)
1189 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1192 Name: *const c_char)
1194 pub fn LLVMBuildFDiv(B: BuilderRef,
1197 Name: *const c_char)
1199 pub fn LLVMBuildURem(B: BuilderRef,
1202 Name: *const c_char)
1204 pub fn LLVMBuildSRem(B: BuilderRef,
1207 Name: *const c_char)
1209 pub fn LLVMBuildFRem(B: BuilderRef,
1212 Name: *const c_char)
1214 pub fn LLVMBuildShl(B: BuilderRef,
1217 Name: *const c_char)
1219 pub fn LLVMBuildLShr(B: BuilderRef,
1222 Name: *const c_char)
1224 pub fn LLVMBuildAShr(B: BuilderRef,
1227 Name: *const c_char)
1229 pub fn LLVMBuildAnd(B: BuilderRef,
1232 Name: *const c_char)
1234 pub fn LLVMBuildOr(B: BuilderRef,
1237 Name: *const c_char)
1239 pub fn LLVMBuildXor(B: BuilderRef,
1242 Name: *const c_char)
1244 pub fn LLVMBuildBinOp(B: BuilderRef,
1248 Name: *const c_char)
1250 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1252 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1254 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1256 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1258 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1262 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1264 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1267 Name: *const c_char)
1269 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1271 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1274 Name: *const c_char)
1276 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1277 pub fn LLVMBuildLoad(B: BuilderRef,
1278 PointerVal: ValueRef,
1279 Name: *const c_char)
1282 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1285 pub fn LLVMBuildGEP(B: BuilderRef,
1287 Indices: *const ValueRef,
1289 Name: *const c_char)
1291 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1293 Indices: *const ValueRef,
1295 Name: *const c_char)
1297 pub fn LLVMBuildStructGEP(B: BuilderRef,
1300 Name: *const c_char)
1302 pub fn LLVMBuildGlobalString(B: BuilderRef,
1304 Name: *const c_char)
1306 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1308 Name: *const c_char)
1312 pub fn LLVMBuildTrunc(B: BuilderRef,
1315 Name: *const c_char)
1317 pub fn LLVMBuildZExt(B: BuilderRef,
1320 Name: *const c_char)
1322 pub fn LLVMBuildSExt(B: BuilderRef,
1325 Name: *const c_char)
1327 pub fn LLVMBuildFPToUI(B: BuilderRef,
1330 Name: *const c_char)
1332 pub fn LLVMBuildFPToSI(B: BuilderRef,
1335 Name: *const c_char)
1337 pub fn LLVMBuildUIToFP(B: BuilderRef,
1340 Name: *const c_char)
1342 pub fn LLVMBuildSIToFP(B: BuilderRef,
1345 Name: *const c_char)
1347 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1350 Name: *const c_char)
1352 pub fn LLVMBuildFPExt(B: BuilderRef,
1355 Name: *const c_char)
1357 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1360 Name: *const c_char)
1362 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1365 Name: *const c_char)
1367 pub fn LLVMBuildBitCast(B: BuilderRef,
1370 Name: *const c_char)
1372 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1375 Name: *const c_char)
1377 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1380 Name: *const c_char)
1382 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1385 Name: *const c_char)
1387 pub fn LLVMBuildCast(B: BuilderRef,
1391 Name: *const c_char) -> ValueRef;
1392 pub fn LLVMBuildPointerCast(B: BuilderRef,
1395 Name: *const c_char)
1397 pub fn LLVMBuildIntCast(B: BuilderRef,
1400 Name: *const c_char)
1402 pub fn LLVMBuildFPCast(B: BuilderRef,
1405 Name: *const c_char)
1409 pub fn LLVMBuildICmp(B: BuilderRef,
1413 Name: *const c_char)
1415 pub fn LLVMBuildFCmp(B: BuilderRef,
1419 Name: *const c_char)
1422 /* Miscellaneous instructions */
1423 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1425 pub fn LLVMBuildCall(B: BuilderRef,
1427 Args: *const ValueRef,
1429 Name: *const c_char)
1431 pub fn LLVMBuildSelect(B: BuilderRef,
1435 Name: *const c_char)
1437 pub fn LLVMBuildVAArg(B: BuilderRef,
1440 Name: *const c_char)
1442 pub fn LLVMBuildExtractElement(B: BuilderRef,
1445 Name: *const c_char)
1447 pub fn LLVMBuildInsertElement(B: BuilderRef,
1451 Name: *const c_char)
1453 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1457 Name: *const c_char)
1459 pub fn LLVMBuildExtractValue(B: BuilderRef,
1462 Name: *const c_char)
1464 pub fn LLVMBuildInsertValue(B: BuilderRef,
1468 Name: *const c_char)
1471 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1473 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1475 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1478 Name: *const c_char)
1481 /* Atomic Operations */
1482 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1483 PointerVal: ValueRef,
1484 Name: *const c_char,
1485 Order: AtomicOrdering,
1489 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1492 Order: AtomicOrdering,
1496 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1500 Order: AtomicOrdering,
1501 FailureOrder: AtomicOrdering)
1503 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1507 Order: AtomicOrdering,
1508 SingleThreaded: Bool)
1511 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1514 /* Selected entries from the downcasts. */
1515 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1516 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1518 /// Writes a module to the specified path. Returns 0 on success.
1519 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1521 /// Creates target data from a target layout string.
1522 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1523 /// Adds the target data to the given pass manager. The pass manager
1524 /// references the target data only weakly.
1525 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1526 /// Number of bytes clobbered when doing a Store to *T.
1527 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1530 /// Number of bytes clobbered when doing a Store to *T.
1531 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1534 /// Distance between successive elements in an array of T. Includes ABI padding.
1535 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1537 /// Returns the preferred alignment of a type.
1538 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1540 /// Returns the minimum alignment of a type.
1541 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1544 /// Computes the byte offset of the indexed struct element for a
1546 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1551 /// Returns the minimum alignment of a type when part of a call frame.
1552 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1555 /// Disposes target data.
1556 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1558 /// Creates a pass manager.
1559 pub fn LLVMCreatePassManager() -> PassManagerRef;
1561 /// Creates a function-by-function pass manager
1562 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1565 /// Disposes a pass manager.
1566 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1568 /// Runs a pass manager on a module.
1569 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1571 /// Runs the function passes on the provided function.
1572 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1575 /// Initializes all the function passes scheduled in the manager
1576 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1578 /// Finalizes all the function passes scheduled in the manager
1579 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1581 pub fn LLVMInitializePasses();
1583 /// Adds a verification pass.
1584 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1586 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1587 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1588 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1589 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1590 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1591 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1592 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1593 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1594 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1595 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1596 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1597 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1598 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1599 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1600 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1601 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1602 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1603 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1604 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1605 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1606 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1607 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1608 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1609 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1610 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1611 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1612 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1613 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1614 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1615 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1616 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1617 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1618 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1619 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1620 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1622 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1623 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1624 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1625 OptimizationLevel: c_uint);
1626 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1628 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1629 PMB: PassManagerBuilderRef,
1631 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1632 PMB: PassManagerBuilderRef,
1634 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1635 PMB: PassManagerBuilderRef,
1637 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1638 PMB: PassManagerBuilderRef,
1640 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1641 PMB: PassManagerBuilderRef,
1642 PM: PassManagerRef);
1644 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1645 PMB: PassManagerBuilderRef,
1646 PM: PassManagerRef);
1647 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1648 PMB: PassManagerBuilderRef,
1653 /// Destroys a memory buffer.
1654 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1657 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1659 /// Opens an object file.
1660 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1661 /// Closes an object file.
1662 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1664 /// Enumerates the sections in an object file.
1665 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1666 /// Destroys a section iterator.
1667 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1668 /// Returns true if the section iterator is at the end of the section
1670 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1671 SI: SectionIteratorRef)
1673 /// Moves the section iterator to point to the next section.
1674 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1675 /// Returns the current section size.
1676 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1677 /// Returns the current section contents as a string buffer.
1678 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1680 /// Reads the given file and returns it as a memory buffer. Use
1681 /// LLVMDisposeMemoryBuffer() to get rid of it.
1682 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1684 /// Borrows the contents of the memory buffer (doesn't copy it)
1685 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1686 InputDataLength: size_t,
1687 BufferName: *const c_char,
1690 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1691 InputDataLength: size_t,
1692 BufferName: *const c_char)
1695 pub fn LLVMIsMultithreaded() -> Bool;
1696 pub fn LLVMStartMultithreaded() -> Bool;
1698 /// Returns a string describing the last error caused by an LLVMRust* call.
1699 pub fn LLVMRustGetLastError() -> *const c_char;
1701 /// Print the pass timings since static dtors aren't picking them up.
1702 pub fn LLVMRustPrintPassTimings();
1704 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1706 pub fn LLVMStructSetBody(StructTy: TypeRef,
1707 ElementTypes: *const TypeRef,
1708 ElementCount: c_uint,
1711 pub fn LLVMConstNamedStruct(S: TypeRef,
1712 ConstantVals: *const ValueRef,
1716 /// Enables LLVM debug output.
1717 pub fn LLVMSetDebug(Enabled: c_int);
1719 /// Prepares inline assembly.
1720 pub fn LLVMInlineAsm(Ty: TypeRef,
1721 AsmString: *const c_char,
1722 Constraints: *const c_char,
1728 pub static LLVMRustDebugMetadataVersion: u32;
1730 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1731 name: *const c_char,
1734 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1736 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1738 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1740 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1742 File: *const c_char,
1744 Producer: *const c_char,
1746 Flags: *const c_char,
1748 SplitName: *const c_char)
1751 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1752 Filename: *const c_char,
1753 Directory: *const c_char)
1756 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1758 ParameterTypes: DIArray)
1761 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1762 Scope: DIDescriptor,
1763 Name: *const c_char,
1764 LinkageName: *const c_char,
1768 isLocalToUnit: bool,
1778 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1779 Name: *const c_char,
1780 SizeInBits: c_ulonglong,
1781 AlignInBits: c_ulonglong,
1785 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1787 SizeInBits: c_ulonglong,
1788 AlignInBits: c_ulonglong,
1789 Name: *const c_char)
1792 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1793 Scope: DIDescriptor,
1794 Name: *const c_char,
1797 SizeInBits: c_ulonglong,
1798 AlignInBits: c_ulonglong,
1800 DerivedFrom: DIType,
1802 RunTimeLang: c_uint,
1803 VTableHolder: ValueRef,
1804 UniqueId: *const c_char)
1807 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1808 Scope: DIDescriptor,
1809 Name: *const c_char,
1812 SizeInBits: c_ulonglong,
1813 AlignInBits: c_ulonglong,
1814 OffsetInBits: c_ulonglong,
1819 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1820 Scope: DIDescriptor,
1826 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1827 Context: DIDescriptor,
1828 Name: *const c_char,
1829 LinkageName: *const c_char,
1833 isLocalToUnit: bool,
1836 -> DIGlobalVariable;
1838 pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
1840 Scope: DIDescriptor,
1841 Name: *const c_char,
1845 AlwaysPreserve: bool,
1850 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1852 AlignInBits: c_ulonglong,
1854 Subscripts: DIArray)
1857 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1859 AlignInBits: c_ulonglong,
1861 Subscripts: DIArray)
1864 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1869 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1870 Ptr: *const DIDescriptor,
1874 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1876 VarInfo: DIVariable,
1877 InsertAtEnd: BasicBlockRef)
1880 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1882 VarInfo: DIVariable,
1883 InsertBefore: ValueRef)
1886 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1887 Name: *const c_char,
1891 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1893 Name: *const c_char,
1896 SizeInBits: c_ulonglong,
1897 AlignInBits: c_ulonglong,
1899 ClassType: ValueRef)
1902 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1904 Name: *const c_char,
1907 SizeInBits: c_ulonglong,
1908 AlignInBits: c_ulonglong,
1911 RunTimeLang: c_uint,
1912 UniqueId: *const c_char)
1915 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1917 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1919 Name: *const c_char,
1926 pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
1928 pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
1930 pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
1933 Name: *const c_char,
1937 AddrOps: *const ValueRef,
1938 AddrOpsCount: c_uint,
1942 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1944 Name: *const c_char,
1949 pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
1950 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1951 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1953 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1955 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1957 pub fn LLVMInitializeX86TargetInfo();
1958 pub fn LLVMInitializeX86Target();
1959 pub fn LLVMInitializeX86TargetMC();
1960 pub fn LLVMInitializeX86AsmPrinter();
1961 pub fn LLVMInitializeX86AsmParser();
1962 pub fn LLVMInitializeARMTargetInfo();
1963 pub fn LLVMInitializeARMTarget();
1964 pub fn LLVMInitializeARMTargetMC();
1965 pub fn LLVMInitializeARMAsmPrinter();
1966 pub fn LLVMInitializeARMAsmParser();
1967 pub fn LLVMInitializeAArch64TargetInfo();
1968 pub fn LLVMInitializeAArch64Target();
1969 pub fn LLVMInitializeAArch64TargetMC();
1970 pub fn LLVMInitializeAArch64AsmPrinter();
1971 pub fn LLVMInitializeAArch64AsmParser();
1972 pub fn LLVMInitializeMipsTargetInfo();
1973 pub fn LLVMInitializeMipsTarget();
1974 pub fn LLVMInitializeMipsTargetMC();
1975 pub fn LLVMInitializeMipsAsmPrinter();
1976 pub fn LLVMInitializeMipsAsmParser();
1977 pub fn LLVMInitializePowerPCTargetInfo();
1978 pub fn LLVMInitializePowerPCTarget();
1979 pub fn LLVMInitializePowerPCTargetMC();
1980 pub fn LLVMInitializePowerPCAsmPrinter();
1981 pub fn LLVMInitializePowerPCAsmParser();
1983 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
1984 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1986 Features: *const c_char,
1987 Model: CodeGenModel,
1989 Level: CodeGenOptLevel,
1992 NoFramePointerElim: bool,
1993 PositionIndependentExecutable: bool,
1994 FunctionSections: bool,
1995 DataSections: bool) -> TargetMachineRef;
1996 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1997 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
2000 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
2002 DisableSimplifyLibCalls: bool);
2003 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
2004 DisableSimplifyLibCalls: bool);
2005 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
2006 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2009 Output: *const c_char,
2010 FileType: FileType) -> bool;
2011 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2013 Output: *const c_char);
2014 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2015 pub fn LLVMRustPrintPasses();
2016 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2017 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2018 AddLifetimes: bool);
2019 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2021 len: size_t) -> bool;
2022 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2023 syms: *const *const c_char,
2025 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2027 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2028 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
2029 out_len: *mut size_t) -> *const c_char;
2030 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2032 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
2033 pub fn LLVMVersionMajor() -> c_int;
2034 pub fn LLVMVersionMinor() -> c_int;
2036 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2037 data: *mut *const c_char) -> c_int;
2039 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2041 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2042 Handler: DiagnosticHandler,
2043 DiagnosticContext: *mut c_void);
2045 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2046 pass_name_out: *mut *const c_char,
2047 function_out: *mut ValueRef,
2048 debugloc_out: *mut DebugLocRef,
2049 message_out: *mut TwineRef);
2051 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2052 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2053 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2055 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2057 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2058 H: InlineAsmDiagHandler,
2061 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2064 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2066 LLVMSetInstructionCallConv(instr, cc as c_uint);
2069 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2071 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2074 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2076 LLVMSetLinkage(global, link as c_uint);
2080 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2082 LLVMSetUnnamedAddr(global, unnamed as Bool);
2086 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2088 LLVMSetThreadLocal(global, is_thread_local as Bool);
2092 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2094 LLVMConstICmp(pred as c_ushort, v1, v2)
2097 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2099 LLVMConstFCmp(pred as c_ushort, v1, v2)
2103 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2105 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
2109 /* Memory-managed interface to target data. */
2111 pub struct TargetData {
2112 pub lltd: TargetDataRef
2115 impl Drop for TargetData {
2116 fn drop(&mut self) {
2118 LLVMDisposeTargetData(self.lltd);
2123 pub fn mk_target_data(string_rep: &str) -> TargetData {
2124 let string_rep = CString::from_slice(string_rep.as_bytes());
2126 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2130 /* Memory-managed interface to object files. */
2132 pub struct ObjectFile {
2133 pub llof: ObjectFileRef,
2137 // This will take ownership of llmb
2138 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2140 let llof = LLVMCreateObjectFile(llmb);
2141 if llof as int == 0 {
2142 // LLVMCreateObjectFile took ownership of llmb
2153 impl Drop for ObjectFile {
2154 fn drop(&mut self) {
2156 LLVMDisposeObjectFile(self.llof);
2161 /* Memory-managed interface to section iterators. */
2163 pub struct SectionIter {
2164 pub llsi: SectionIteratorRef
2167 impl Drop for SectionIter {
2168 fn drop(&mut self) {
2170 LLVMDisposeSectionIterator(self.llsi);
2175 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2178 llsi: LLVMGetSections(llof)
2183 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2184 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2186 assert!(index < LLVMCountParams(llfn));
2187 LLVMGetParam(llfn, index)
2191 #[allow(missing_copy_implementations)]
2192 pub enum RustString_opaque {}
2193 pub type RustStringRef = *mut RustString_opaque;
2194 type RustStringRepr = *mut RefCell<Vec<u8>>;
2196 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2198 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2201 let slice: &[u8] = mem::transmute(raw::Slice {
2202 data: ptr as *const u8,
2206 let sr: RustStringRepr = mem::transmute(sr);
2207 (*sr).borrow_mut().push_all(slice);
2210 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2211 let mut buf = RefCell::new(Vec::new());
2212 f(&mut buf as RustStringRepr as RustStringRef);
2213 String::from_utf8(buf.into_inner()).ok()
2216 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2217 build_string(|s| LLVMWriteTwineToString(tr, s))
2218 .expect("got a non-UTF8 Twine from LLVM")
2221 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2222 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2223 .expect("got a non-UTF8 DebugLoc from LLVM")
2226 // FIXME #15460 - create a public function that actually calls our
2227 // static LLVM symbols. Otherwise the linker will just throw llvm
2228 // away. We're just calling lots of stuff until we transitively get
2229 // all of LLVM. This is worse than anything.
2230 pub unsafe fn static_link_hack_this_sucks() {
2231 LLVMInitializePasses();
2233 LLVMInitializeX86TargetInfo();
2234 LLVMInitializeX86Target();
2235 LLVMInitializeX86TargetMC();
2236 LLVMInitializeX86AsmPrinter();
2237 LLVMInitializeX86AsmParser();
2239 LLVMInitializeARMTargetInfo();
2240 LLVMInitializeARMTarget();
2241 LLVMInitializeARMTargetMC();
2242 LLVMInitializeARMAsmPrinter();
2243 LLVMInitializeARMAsmParser();
2245 LLVMInitializeAArch64TargetInfo();
2246 LLVMInitializeAArch64Target();
2247 LLVMInitializeAArch64TargetMC();
2248 LLVMInitializeAArch64AsmPrinter();
2249 LLVMInitializeAArch64AsmParser();
2251 LLVMInitializeMipsTargetInfo();
2252 LLVMInitializeMipsTarget();
2253 LLVMInitializeMipsTargetMC();
2254 LLVMInitializeMipsAsmPrinter();
2255 LLVMInitializeMipsAsmParser();
2257 LLVMInitializePowerPCTargetInfo();
2258 LLVMInitializePowerPCTarget();
2259 LLVMInitializePowerPCTargetMC();
2260 LLVMInitializePowerPCAsmPrinter();
2261 LLVMInitializePowerPCAsmParser();
2263 LLVMRustSetLLVMOptions(0 as c_int,
2266 LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
2267 LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
2268 LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
2269 LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
2270 LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
2271 LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
2272 LLVMPassManagerBuilderCreate();
2273 LLVMPassManagerBuilderDispose(0 as *mut _);
2275 LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
2278 LLVMLinkInInterpreter();
2281 fn LLVMLinkInMCJIT();
2282 fn LLVMLinkInInterpreter();
2286 // The module containing the native LLVM dependencies, generated by the build system
2287 // Note that this must come after the rustllvm extern declaration so that
2288 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2289 // Works to the above fix for #15460 to ensure LLVM dependencies that
2290 // are only used by rustllvm don't get stripped by the linker.
2292 include! { env!("CFG_LLVM_LINKAGE_FILE") }