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;
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 {
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 {
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 {
381 MD_invariant_load = 6,
385 MD_mem_parallel_loop_access = 10,
389 // Inline Asm Dialect
391 pub enum AsmDialect {
396 #[derive(Copy, PartialEq, Clone)]
398 pub enum CodeGenOptLevel {
399 CodeGenLevelNone = 0,
400 CodeGenLevelLess = 1,
401 CodeGenLevelDefault = 2,
402 CodeGenLevelAggressive = 3,
405 #[derive(Copy, PartialEq)]
411 RelocDynamicNoPic = 3,
416 pub enum CodeGenModel {
417 CodeModelDefault = 0,
418 CodeModelJITDefault = 1,
427 pub enum DiagnosticKind {
430 DK_DebugMetadataVersion,
432 DK_OptimizationRemark,
433 DK_OptimizationRemarkMissed,
434 DK_OptimizationRemarkAnalysis,
435 DK_OptimizationFailure,
438 // Opaque pointer types
439 #[allow(missing_copy_implementations)]
440 pub enum Module_opaque {}
441 pub type ModuleRef = *mut Module_opaque;
442 #[allow(missing_copy_implementations)]
443 pub enum Context_opaque {}
444 pub type ContextRef = *mut Context_opaque;
445 #[allow(missing_copy_implementations)]
446 pub enum Type_opaque {}
447 pub type TypeRef = *mut Type_opaque;
448 #[allow(missing_copy_implementations)]
449 pub enum Value_opaque {}
450 pub type ValueRef = *mut Value_opaque;
451 #[allow(missing_copy_implementations)]
452 pub enum Metadata_opaque {}
453 pub type MetadataRef = *mut Metadata_opaque;
454 #[allow(missing_copy_implementations)]
455 pub enum BasicBlock_opaque {}
456 pub type BasicBlockRef = *mut BasicBlock_opaque;
457 #[allow(missing_copy_implementations)]
458 pub enum Builder_opaque {}
459 pub type BuilderRef = *mut Builder_opaque;
460 #[allow(missing_copy_implementations)]
461 pub enum ExecutionEngine_opaque {}
462 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
463 #[allow(missing_copy_implementations)]
464 pub enum RustJITMemoryManager_opaque {}
465 pub type RustJITMemoryManagerRef = *mut RustJITMemoryManager_opaque;
466 #[allow(missing_copy_implementations)]
467 pub enum MemoryBuffer_opaque {}
468 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
469 #[allow(missing_copy_implementations)]
470 pub enum PassManager_opaque {}
471 pub type PassManagerRef = *mut PassManager_opaque;
472 #[allow(missing_copy_implementations)]
473 pub enum PassManagerBuilder_opaque {}
474 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
475 #[allow(missing_copy_implementations)]
476 pub enum Use_opaque {}
477 pub type UseRef = *mut Use_opaque;
478 #[allow(missing_copy_implementations)]
479 pub enum TargetData_opaque {}
480 pub type TargetDataRef = *mut TargetData_opaque;
481 #[allow(missing_copy_implementations)]
482 pub enum ObjectFile_opaque {}
483 pub type ObjectFileRef = *mut ObjectFile_opaque;
484 #[allow(missing_copy_implementations)]
485 pub enum SectionIterator_opaque {}
486 pub type SectionIteratorRef = *mut SectionIterator_opaque;
487 #[allow(missing_copy_implementations)]
488 pub enum Pass_opaque {}
489 pub type PassRef = *mut Pass_opaque;
490 #[allow(missing_copy_implementations)]
491 pub enum TargetMachine_opaque {}
492 pub type TargetMachineRef = *mut TargetMachine_opaque;
493 #[allow(missing_copy_implementations)]
494 pub enum Archive_opaque {}
495 pub type ArchiveRef = *mut Archive_opaque;
496 #[allow(missing_copy_implementations)]
497 pub enum Twine_opaque {}
498 pub type TwineRef = *mut Twine_opaque;
499 #[allow(missing_copy_implementations)]
500 pub enum DiagnosticInfo_opaque {}
501 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
502 #[allow(missing_copy_implementations)]
503 pub enum DebugLoc_opaque {}
504 pub type DebugLocRef = *mut DebugLoc_opaque;
505 #[allow(missing_copy_implementations)]
506 pub enum SMDiagnostic_opaque {}
507 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
509 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
510 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
513 pub use self::DIDescriptorFlags::*;
514 use super::{MetadataRef};
516 #[allow(missing_copy_implementations)]
517 pub enum DIBuilder_opaque {}
518 pub type DIBuilderRef = *mut DIBuilder_opaque;
520 pub type DIDescriptor = MetadataRef;
521 pub type DIScope = DIDescriptor;
522 pub type DILocation = DIDescriptor;
523 pub type DIFile = DIScope;
524 pub type DILexicalBlock = DIScope;
525 pub type DISubprogram = DIScope;
526 pub type DINameSpace = DIScope;
527 pub type DIType = DIDescriptor;
528 pub type DIBasicType = DIType;
529 pub type DIDerivedType = DIType;
530 pub type DICompositeType = DIDerivedType;
531 pub type DIVariable = DIDescriptor;
532 pub type DIGlobalVariable = DIDescriptor;
533 pub type DIArray = DIDescriptor;
534 pub type DISubrange = DIDescriptor;
535 pub type DIEnumerator = DIDescriptor;
536 pub type DITemplateTypeParameter = DIDescriptor;
539 pub enum DIDescriptorFlags {
540 FlagPrivate = 1 << 0,
541 FlagProtected = 1 << 1,
542 FlagFwdDecl = 1 << 2,
543 FlagAppleBlock = 1 << 3,
544 FlagBlockByrefStruct = 1 << 4,
545 FlagVirtual = 1 << 5,
546 FlagArtificial = 1 << 6,
547 FlagExplicit = 1 << 7,
548 FlagPrototyped = 1 << 8,
549 FlagObjcClassComplete = 1 << 9,
550 FlagObjectPointer = 1 << 10,
551 FlagVector = 1 << 11,
552 FlagStaticMember = 1 << 12,
553 FlagIndirectVariable = 1 << 13,
554 FlagLValueReference = 1 << 14,
555 FlagRValueReference = 1 << 15
560 // Link to our native llvm bindings (things that we need to use the C++ api
561 // for) and because llvm is written in C++ we need to link against libstdc++
563 // You'll probably notice that there is an omission of all LLVM libraries
564 // from this location. This is because the set of LLVM libraries that we
565 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
566 // figure out the exact set of libraries. To do this, the build system
567 // generates an llvmdeps.rs file next to this one which will be
568 // automatically updated whenever LLVM is updated to include an up-to-date
569 // set of the libraries we need to link to LLVM for.
570 #[link(name = "rustllvm", kind = "static")]
572 /* Create and destroy contexts. */
573 pub fn LLVMContextCreate() -> ContextRef;
574 pub fn LLVMContextDispose(C: ContextRef);
575 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
580 /* Create and destroy modules. */
581 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
584 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
585 pub fn LLVMDisposeModule(M: ModuleRef);
587 /// Data layout. See Module::getDataLayout.
588 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
589 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
591 /// Target triple. See Module::getTargetTriple.
592 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
593 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
595 /// See Module::dump.
596 pub fn LLVMDumpModule(M: ModuleRef);
598 /// See Module::setModuleInlineAsm.
599 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
601 /// See llvm::LLVMTypeKind::getTypeID.
602 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
604 /// See llvm::LLVMType::getContext.
605 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
607 /* Operations on integer types */
608 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
609 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
610 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
611 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
612 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
613 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
616 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
618 /* Operations on real types */
619 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
620 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
621 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
622 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
623 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
625 /* Operations on function types */
626 pub fn LLVMFunctionType(ReturnType: TypeRef,
627 ParamTypes: *const TypeRef,
631 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
632 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
633 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
634 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
636 /* Operations on struct types */
637 pub fn LLVMStructTypeInContext(C: ContextRef,
638 ElementTypes: *const TypeRef,
639 ElementCount: c_uint,
642 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
643 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
645 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
647 /* Operations on array, pointer, and vector types (sequence types) */
648 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
649 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
651 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
654 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
655 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
656 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
657 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
659 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
661 /* Operations on other types */
662 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
663 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
664 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
666 /* Operations on all values */
667 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
668 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
669 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
670 pub fn LLVMDumpValue(Val: ValueRef);
671 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
672 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
673 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
674 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
676 /* Operations on Uses */
677 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
678 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
679 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
680 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
682 /* Operations on Users */
683 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
684 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
685 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
687 /* Operations on constants of any type */
688 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
690 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
691 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
693 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
695 /* only for int/vector */
696 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
697 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
698 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
699 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
700 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
702 /* Operations on metadata */
703 pub fn LLVMMDStringInContext(C: ContextRef,
707 pub fn LLVMMDNodeInContext(C: ContextRef,
708 Vals: *const ValueRef,
711 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
715 /* Operations on scalar constants */
716 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
718 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
720 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
725 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
726 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
728 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
732 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
733 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
736 /* Operations on composite constants */
737 pub fn LLVMConstStringInContext(C: ContextRef,
740 DontNullTerminate: Bool)
742 pub fn LLVMConstStructInContext(C: ContextRef,
743 ConstantVals: *const ValueRef,
748 pub fn LLVMConstArray(ElementTy: TypeRef,
749 ConstantVals: *const ValueRef,
752 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
755 /* Constant expressions */
756 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
757 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
758 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
759 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
760 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
761 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
762 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
763 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
765 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
767 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
769 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
771 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
773 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
775 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
777 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
779 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
781 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
783 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
785 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
787 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
789 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
791 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
792 RHSConstant: ValueRef)
794 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
796 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
798 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
800 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
802 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
804 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
806 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
808 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
810 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
812 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
814 pub fn LLVMConstGEP(ConstantVal: ValueRef,
815 ConstantIndices: *const ValueRef,
818 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
819 ConstantIndices: *const ValueRef,
822 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
824 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
826 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
828 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
830 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
832 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
834 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
836 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
838 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
840 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
842 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
844 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
846 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
848 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
850 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
852 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
854 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
858 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
860 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
861 ConstantIfTrue: ValueRef,
862 ConstantIfFalse: ValueRef)
864 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
865 IndexConstant: ValueRef)
867 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
868 ElementValueConstant: ValueRef,
869 IndexConstant: ValueRef)
871 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
872 VectorBConstant: ValueRef,
873 MaskConstant: ValueRef)
875 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
876 IdxList: *const c_uint,
879 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
880 ElementValueConstant: ValueRef,
881 IdxList: *const c_uint,
884 pub fn LLVMConstInlineAsm(Ty: TypeRef,
885 AsmString: *const c_char,
886 Constraints: *const c_char,
887 HasSideEffects: Bool,
890 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
894 /* Operations on global variables, functions, and aliases (globals) */
895 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
896 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
897 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
898 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
899 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
900 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
901 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
902 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
903 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
904 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
907 /* Operations on global variables */
908 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
909 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
911 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
914 AddressSpace: c_uint)
916 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
917 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
918 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
919 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
920 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
921 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
922 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
923 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
924 ConstantVal: ValueRef);
925 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
926 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
927 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
928 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
930 /* Operations on aliases */
931 pub fn LLVMAddAlias(M: ModuleRef,
937 /* Operations on functions */
938 pub fn LLVMAddFunction(M: ModuleRef,
942 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
943 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
944 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
945 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
946 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
947 pub fn LLVMDeleteFunction(Fn: ValueRef);
948 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
952 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
953 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
954 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
955 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
956 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
957 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
958 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
959 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
960 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
961 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
963 /* Operations on parameters */
964 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
965 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
966 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
967 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
968 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
969 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
970 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
971 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
972 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
973 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
974 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
975 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
977 /* Operations on basic blocks */
978 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
979 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
980 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
981 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
982 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
983 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
984 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
985 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
986 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
987 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
988 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
990 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
994 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
998 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
1000 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
1001 MoveAfter: BasicBlockRef);
1003 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
1004 MoveBefore: BasicBlockRef);
1006 /* Operations on instructions */
1007 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
1008 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
1009 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
1010 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
1011 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
1012 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
1014 /* Operations on call sites */
1015 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
1016 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
1017 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
1020 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
1023 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
1026 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
1029 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
1033 /* Operations on call instructions (only) */
1034 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
1035 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
1037 /* Operations on load/store instructions (only) */
1038 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
1039 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
1041 /* Operations on phi nodes */
1042 pub fn LLVMAddIncoming(PhiNode: ValueRef,
1043 IncomingValues: *const ValueRef,
1044 IncomingBlocks: *const BasicBlockRef,
1046 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
1047 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
1049 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
1052 /* Instruction builders */
1053 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
1054 pub fn LLVMPositionBuilder(Builder: BuilderRef,
1055 Block: BasicBlockRef,
1057 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1059 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1060 Block: BasicBlockRef);
1061 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1062 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1063 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1064 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1066 Name: *const c_char);
1067 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1069 /* Execution engine */
1070 pub fn LLVMRustCreateJITMemoryManager(morestack: *const ())
1071 -> RustJITMemoryManagerRef;
1072 pub fn LLVMBuildExecutionEngine(Mod: ModuleRef,
1073 MM: RustJITMemoryManagerRef) -> ExecutionEngineRef;
1074 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
1075 pub fn LLVMExecutionEngineFinalizeObject(EE: ExecutionEngineRef);
1076 pub fn LLVMRustLoadDynamicLibrary(path: *const c_char) -> Bool;
1077 pub fn LLVMExecutionEngineAddModule(EE: ExecutionEngineRef, M: ModuleRef);
1078 pub fn LLVMExecutionEngineRemoveModule(EE: ExecutionEngineRef, M: ModuleRef)
1082 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1083 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1084 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1087 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1088 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1089 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1090 RetVals: *const ValueRef,
1093 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1094 pub fn LLVMBuildCondBr(B: BuilderRef,
1096 Then: BasicBlockRef,
1097 Else: BasicBlockRef)
1099 pub fn LLVMBuildSwitch(B: BuilderRef,
1101 Else: BasicBlockRef,
1104 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1108 pub fn LLVMBuildInvoke(B: BuilderRef,
1110 Args: *const ValueRef,
1112 Then: BasicBlockRef,
1113 Catch: BasicBlockRef,
1114 Name: *const c_char)
1116 pub fn LLVMBuildLandingPad(B: BuilderRef,
1120 Name: *const c_char)
1122 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1123 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1125 /* Add a case to the switch instruction */
1126 pub fn LLVMAddCase(Switch: ValueRef,
1128 Dest: BasicBlockRef);
1130 /* Add a destination to the indirectbr instruction */
1131 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1133 /* Add a clause to the landing pad instruction */
1134 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1136 /* Set the cleanup on a landing pad instruction */
1137 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1140 pub fn LLVMBuildAdd(B: BuilderRef,
1143 Name: *const c_char)
1145 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1148 Name: *const c_char)
1150 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1153 Name: *const c_char)
1155 pub fn LLVMBuildFAdd(B: BuilderRef,
1158 Name: *const c_char)
1160 pub fn LLVMBuildSub(B: BuilderRef,
1163 Name: *const c_char)
1165 pub fn LLVMBuildNSWSub(B: BuilderRef,
1168 Name: *const c_char)
1170 pub fn LLVMBuildNUWSub(B: BuilderRef,
1173 Name: *const c_char)
1175 pub fn LLVMBuildFSub(B: BuilderRef,
1178 Name: *const c_char)
1180 pub fn LLVMBuildMul(B: BuilderRef,
1183 Name: *const c_char)
1185 pub fn LLVMBuildNSWMul(B: BuilderRef,
1188 Name: *const c_char)
1190 pub fn LLVMBuildNUWMul(B: BuilderRef,
1193 Name: *const c_char)
1195 pub fn LLVMBuildFMul(B: BuilderRef,
1198 Name: *const c_char)
1200 pub fn LLVMBuildUDiv(B: BuilderRef,
1203 Name: *const c_char)
1205 pub fn LLVMBuildSDiv(B: BuilderRef,
1208 Name: *const c_char)
1210 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1213 Name: *const c_char)
1215 pub fn LLVMBuildFDiv(B: BuilderRef,
1218 Name: *const c_char)
1220 pub fn LLVMBuildURem(B: BuilderRef,
1223 Name: *const c_char)
1225 pub fn LLVMBuildSRem(B: BuilderRef,
1228 Name: *const c_char)
1230 pub fn LLVMBuildFRem(B: BuilderRef,
1233 Name: *const c_char)
1235 pub fn LLVMBuildShl(B: BuilderRef,
1238 Name: *const c_char)
1240 pub fn LLVMBuildLShr(B: BuilderRef,
1243 Name: *const c_char)
1245 pub fn LLVMBuildAShr(B: BuilderRef,
1248 Name: *const c_char)
1250 pub fn LLVMBuildAnd(B: BuilderRef,
1253 Name: *const c_char)
1255 pub fn LLVMBuildOr(B: BuilderRef,
1258 Name: *const c_char)
1260 pub fn LLVMBuildXor(B: BuilderRef,
1263 Name: *const c_char)
1265 pub fn LLVMBuildBinOp(B: BuilderRef,
1269 Name: *const c_char)
1271 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1273 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1275 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1277 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1279 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1283 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1285 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1288 Name: *const c_char)
1290 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1292 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1295 Name: *const c_char)
1297 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1298 pub fn LLVMBuildLoad(B: BuilderRef,
1299 PointerVal: ValueRef,
1300 Name: *const c_char)
1303 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1306 pub fn LLVMBuildGEP(B: BuilderRef,
1308 Indices: *const ValueRef,
1310 Name: *const c_char)
1312 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1314 Indices: *const ValueRef,
1316 Name: *const c_char)
1318 pub fn LLVMBuildStructGEP(B: BuilderRef,
1321 Name: *const c_char)
1323 pub fn LLVMBuildGlobalString(B: BuilderRef,
1325 Name: *const c_char)
1327 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1329 Name: *const c_char)
1333 pub fn LLVMBuildTrunc(B: BuilderRef,
1336 Name: *const c_char)
1338 pub fn LLVMBuildZExt(B: BuilderRef,
1341 Name: *const c_char)
1343 pub fn LLVMBuildSExt(B: BuilderRef,
1346 Name: *const c_char)
1348 pub fn LLVMBuildFPToUI(B: BuilderRef,
1351 Name: *const c_char)
1353 pub fn LLVMBuildFPToSI(B: BuilderRef,
1356 Name: *const c_char)
1358 pub fn LLVMBuildUIToFP(B: BuilderRef,
1361 Name: *const c_char)
1363 pub fn LLVMBuildSIToFP(B: BuilderRef,
1366 Name: *const c_char)
1368 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1371 Name: *const c_char)
1373 pub fn LLVMBuildFPExt(B: BuilderRef,
1376 Name: *const c_char)
1378 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1381 Name: *const c_char)
1383 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1386 Name: *const c_char)
1388 pub fn LLVMBuildBitCast(B: BuilderRef,
1391 Name: *const c_char)
1393 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1396 Name: *const c_char)
1398 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1401 Name: *const c_char)
1403 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1406 Name: *const c_char)
1408 pub fn LLVMBuildCast(B: BuilderRef,
1412 Name: *const c_char) -> ValueRef;
1413 pub fn LLVMBuildPointerCast(B: BuilderRef,
1416 Name: *const c_char)
1418 pub fn LLVMBuildIntCast(B: BuilderRef,
1421 Name: *const c_char)
1423 pub fn LLVMBuildFPCast(B: BuilderRef,
1426 Name: *const c_char)
1430 pub fn LLVMBuildICmp(B: BuilderRef,
1434 Name: *const c_char)
1436 pub fn LLVMBuildFCmp(B: BuilderRef,
1440 Name: *const c_char)
1443 /* Miscellaneous instructions */
1444 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1446 pub fn LLVMBuildCall(B: BuilderRef,
1448 Args: *const ValueRef,
1450 Name: *const c_char)
1452 pub fn LLVMBuildSelect(B: BuilderRef,
1456 Name: *const c_char)
1458 pub fn LLVMBuildVAArg(B: BuilderRef,
1461 Name: *const c_char)
1463 pub fn LLVMBuildExtractElement(B: BuilderRef,
1466 Name: *const c_char)
1468 pub fn LLVMBuildInsertElement(B: BuilderRef,
1472 Name: *const c_char)
1474 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1478 Name: *const c_char)
1480 pub fn LLVMBuildExtractValue(B: BuilderRef,
1483 Name: *const c_char)
1485 pub fn LLVMBuildInsertValue(B: BuilderRef,
1489 Name: *const c_char)
1492 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1494 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1496 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1499 Name: *const c_char)
1502 /* Atomic Operations */
1503 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1504 PointerVal: ValueRef,
1505 Name: *const c_char,
1506 Order: AtomicOrdering,
1510 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1513 Order: AtomicOrdering,
1517 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1521 Order: AtomicOrdering,
1522 FailureOrder: AtomicOrdering)
1524 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1528 Order: AtomicOrdering,
1529 SingleThreaded: Bool)
1532 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1535 /* Selected entries from the downcasts. */
1536 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1537 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1539 /// Writes a module to the specified path. Returns 0 on success.
1540 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1542 /// Creates target data from a target layout string.
1543 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1544 /// Adds the target data to the given pass manager. The pass manager
1545 /// references the target data only weakly.
1546 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1547 /// Number of bytes clobbered when doing a Store to *T.
1548 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1551 /// Number of bytes clobbered when doing a Store to *T.
1552 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1555 /// Distance between successive elements in an array of T. Includes ABI padding.
1556 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1558 /// Returns the preferred alignment of a type.
1559 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1561 /// Returns the minimum alignment of a type.
1562 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1565 /// Computes the byte offset of the indexed struct element for a
1567 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1572 /// Returns the minimum alignment of a type when part of a call frame.
1573 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1576 /// Disposes target data.
1577 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1579 /// Creates a pass manager.
1580 pub fn LLVMCreatePassManager() -> PassManagerRef;
1582 /// Creates a function-by-function pass manager
1583 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1586 /// Disposes a pass manager.
1587 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1589 /// Runs a pass manager on a module.
1590 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1592 /// Runs the function passes on the provided function.
1593 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1596 /// Initializes all the function passes scheduled in the manager
1597 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1599 /// Finalizes all the function passes scheduled in the manager
1600 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1602 pub fn LLVMInitializePasses();
1604 /// Adds a verification pass.
1605 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1607 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1608 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1609 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1610 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1611 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1612 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1613 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1614 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1615 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1616 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1617 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1618 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1619 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1620 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1621 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1622 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1623 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1624 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1625 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1626 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1627 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1628 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1629 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1630 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1631 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1632 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1633 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1634 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1635 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1636 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1637 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1638 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1639 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1640 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1641 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1643 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1644 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1645 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1646 OptimizationLevel: c_uint);
1647 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1649 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1650 PMB: PassManagerBuilderRef,
1652 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1653 PMB: PassManagerBuilderRef,
1655 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1656 PMB: PassManagerBuilderRef,
1658 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1659 PMB: PassManagerBuilderRef,
1661 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1662 PMB: PassManagerBuilderRef,
1663 PM: PassManagerRef);
1665 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1666 PMB: PassManagerBuilderRef,
1667 PM: PassManagerRef);
1668 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1669 PMB: PassManagerBuilderRef,
1674 /// Destroys a memory buffer.
1675 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1678 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1680 /// Opens an object file.
1681 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1682 /// Closes an object file.
1683 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1685 /// Enumerates the sections in an object file.
1686 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1687 /// Destroys a section iterator.
1688 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1689 /// Returns true if the section iterator is at the end of the section
1691 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1692 SI: SectionIteratorRef)
1694 /// Moves the section iterator to point to the next section.
1695 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1696 /// Returns the current section size.
1697 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1698 /// Returns the current section contents as a string buffer.
1699 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1701 /// Reads the given file and returns it as a memory buffer. Use
1702 /// LLVMDisposeMemoryBuffer() to get rid of it.
1703 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1705 /// Borrows the contents of the memory buffer (doesn't copy it)
1706 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1707 InputDataLength: size_t,
1708 BufferName: *const c_char,
1711 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1712 InputDataLength: size_t,
1713 BufferName: *const c_char)
1716 pub fn LLVMIsMultithreaded() -> Bool;
1717 pub fn LLVMStartMultithreaded() -> Bool;
1719 /// Returns a string describing the last error caused by an LLVMRust* call.
1720 pub fn LLVMRustGetLastError() -> *const c_char;
1722 /// Print the pass timings since static dtors aren't picking them up.
1723 pub fn LLVMRustPrintPassTimings();
1725 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1727 pub fn LLVMStructSetBody(StructTy: TypeRef,
1728 ElementTypes: *const TypeRef,
1729 ElementCount: c_uint,
1732 pub fn LLVMConstNamedStruct(S: TypeRef,
1733 ConstantVals: *const ValueRef,
1737 /// Enables LLVM debug output.
1738 pub fn LLVMSetDebug(Enabled: c_int);
1740 /// Prepares inline assembly.
1741 pub fn LLVMInlineAsm(Ty: TypeRef,
1742 AsmString: *const c_char,
1743 Constraints: *const c_char,
1749 pub static LLVMRustDebugMetadataVersion: u32;
1751 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1752 name: *const c_char,
1755 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1757 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1759 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1761 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1763 File: *const c_char,
1765 Producer: *const c_char,
1767 Flags: *const c_char,
1769 SplitName: *const c_char)
1772 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1773 Filename: *const c_char,
1774 Directory: *const c_char)
1777 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1779 ParameterTypes: DIArray)
1782 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1783 Scope: DIDescriptor,
1784 Name: *const c_char,
1785 LinkageName: *const c_char,
1789 isLocalToUnit: bool,
1799 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1800 Name: *const c_char,
1801 SizeInBits: c_ulonglong,
1802 AlignInBits: c_ulonglong,
1806 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1808 SizeInBits: c_ulonglong,
1809 AlignInBits: c_ulonglong,
1810 Name: *const c_char)
1813 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1814 Scope: DIDescriptor,
1815 Name: *const c_char,
1818 SizeInBits: c_ulonglong,
1819 AlignInBits: c_ulonglong,
1821 DerivedFrom: DIType,
1823 RunTimeLang: c_uint,
1824 VTableHolder: DIType,
1825 UniqueId: *const c_char)
1828 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1829 Scope: DIDescriptor,
1830 Name: *const c_char,
1833 SizeInBits: c_ulonglong,
1834 AlignInBits: c_ulonglong,
1835 OffsetInBits: c_ulonglong,
1840 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1847 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1849 Name: *const c_char,
1850 LinkageName: *const c_char,
1854 isLocalToUnit: bool,
1857 -> DIGlobalVariable;
1859 pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef,
1861 Scope: DIDescriptor,
1862 Name: *const c_char,
1866 AlwaysPreserve: bool,
1868 AddrOps: *const i64,
1869 AddrOpsCount: c_uint,
1873 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1875 AlignInBits: c_ulonglong,
1877 Subscripts: DIArray)
1880 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1882 AlignInBits: c_ulonglong,
1884 Subscripts: DIArray)
1887 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1892 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1893 Ptr: *const DIDescriptor,
1897 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1899 VarInfo: DIVariable,
1900 AddrOps: *const i64,
1901 AddrOpsCount: c_uint,
1902 InsertAtEnd: BasicBlockRef)
1905 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1907 VarInfo: DIVariable,
1908 AddrOps: *const i64,
1909 AddrOpsCount: c_uint,
1910 InsertBefore: ValueRef)
1913 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1914 Name: *const c_char,
1918 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1920 Name: *const c_char,
1923 SizeInBits: c_ulonglong,
1924 AlignInBits: c_ulonglong,
1929 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1931 Name: *const c_char,
1934 SizeInBits: c_ulonglong,
1935 AlignInBits: c_ulonglong,
1938 RunTimeLang: c_uint,
1939 UniqueId: *const c_char)
1942 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1944 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1946 Name: *const c_char,
1951 -> DITemplateTypeParameter;
1953 pub fn LLVMDIBuilderCreateOpDeref() -> i64;
1955 pub fn LLVMDIBuilderCreateOpPlus() -> i64;
1957 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1959 Name: *const c_char,
1964 pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef,
1968 InlinedAt: MetadataRef)
1971 pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1972 CompositeType: DIType,
1973 TypeArray: DIArray);
1974 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1975 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1977 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1979 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1981 pub fn LLVMInitializeX86TargetInfo();
1982 pub fn LLVMInitializeX86Target();
1983 pub fn LLVMInitializeX86TargetMC();
1984 pub fn LLVMInitializeX86AsmPrinter();
1985 pub fn LLVMInitializeX86AsmParser();
1986 pub fn LLVMInitializeARMTargetInfo();
1987 pub fn LLVMInitializeARMTarget();
1988 pub fn LLVMInitializeARMTargetMC();
1989 pub fn LLVMInitializeARMAsmPrinter();
1990 pub fn LLVMInitializeARMAsmParser();
1991 pub fn LLVMInitializeAArch64TargetInfo();
1992 pub fn LLVMInitializeAArch64Target();
1993 pub fn LLVMInitializeAArch64TargetMC();
1994 pub fn LLVMInitializeAArch64AsmPrinter();
1995 pub fn LLVMInitializeAArch64AsmParser();
1996 pub fn LLVMInitializeMipsTargetInfo();
1997 pub fn LLVMInitializeMipsTarget();
1998 pub fn LLVMInitializeMipsTargetMC();
1999 pub fn LLVMInitializeMipsAsmPrinter();
2000 pub fn LLVMInitializeMipsAsmParser();
2001 pub fn LLVMInitializePowerPCTargetInfo();
2002 pub fn LLVMInitializePowerPCTarget();
2003 pub fn LLVMInitializePowerPCTargetMC();
2004 pub fn LLVMInitializePowerPCAsmPrinter();
2005 pub fn LLVMInitializePowerPCAsmParser();
2007 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
2008 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
2010 Features: *const c_char,
2011 Model: CodeGenModel,
2013 Level: CodeGenOptLevel,
2016 NoFramePointerElim: bool,
2017 PositionIndependentExecutable: bool,
2018 FunctionSections: bool,
2019 DataSections: bool) -> TargetMachineRef;
2020 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
2021 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
2024 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
2026 DisableSimplifyLibCalls: bool);
2027 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
2028 DisableSimplifyLibCalls: bool);
2029 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
2030 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
2033 Output: *const c_char,
2034 FileType: FileType) -> bool;
2035 pub fn LLVMRustPrintModule(PM: PassManagerRef,
2037 Output: *const c_char);
2038 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2039 pub fn LLVMRustPrintPasses();
2040 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
2041 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
2042 AddLifetimes: bool);
2043 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
2045 len: size_t) -> bool;
2046 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
2047 syms: *const *const c_char,
2049 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
2051 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
2052 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
2053 out_len: *mut size_t) -> *const c_char;
2054 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2056 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
2057 pub fn LLVMVersionMajor() -> c_int;
2058 pub fn LLVMVersionMinor() -> c_int;
2060 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2061 data: *mut *const c_char) -> c_int;
2063 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
2065 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2066 Handler: DiagnosticHandler,
2067 DiagnosticContext: *mut c_void);
2069 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2070 pass_name_out: *mut *const c_char,
2071 function_out: *mut ValueRef,
2072 debugloc_out: *mut DebugLocRef,
2073 message_out: *mut TwineRef);
2074 pub fn LLVMUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
2075 cookie_out: *mut c_uint,
2076 message_out: *mut TwineRef,
2077 instruction_out: *mut ValueRef);
2079 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
2080 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2081 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2083 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
2085 pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef,
2086 H: InlineAsmDiagHandler,
2089 pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2092 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
2094 LLVMSetInstructionCallConv(instr, cc as c_uint);
2097 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
2099 LLVMSetFunctionCallConv(fn_, cc as c_uint);
2102 pub fn SetLinkage(global: ValueRef, link: Linkage) {
2104 LLVMSetLinkage(global, link as c_uint);
2108 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
2110 LLVMSetUnnamedAddr(global, unnamed as Bool);
2114 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
2116 LLVMSetThreadLocal(global, is_thread_local as Bool);
2120 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2122 LLVMConstICmp(pred as c_ushort, v1, v2)
2125 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2127 LLVMConstFCmp(pred as c_ushort, v1, v2)
2131 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2133 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
2137 /* Memory-managed interface to target data. */
2139 pub struct TargetData {
2140 pub lltd: TargetDataRef
2143 impl Drop for TargetData {
2144 fn drop(&mut self) {
2146 LLVMDisposeTargetData(self.lltd);
2151 pub fn mk_target_data(string_rep: &str) -> TargetData {
2152 let string_rep = CString::from_slice(string_rep.as_bytes());
2154 lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
2158 /* Memory-managed interface to object files. */
2160 pub struct ObjectFile {
2161 pub llof: ObjectFileRef,
2165 // This will take ownership of llmb
2166 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2168 let llof = LLVMCreateObjectFile(llmb);
2169 if llof as int == 0 {
2170 // LLVMCreateObjectFile took ownership of llmb
2181 impl Drop for ObjectFile {
2182 fn drop(&mut self) {
2184 LLVMDisposeObjectFile(self.llof);
2189 /* Memory-managed interface to section iterators. */
2191 pub struct SectionIter {
2192 pub llsi: SectionIteratorRef
2195 impl Drop for SectionIter {
2196 fn drop(&mut self) {
2198 LLVMDisposeSectionIterator(self.llsi);
2203 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2206 llsi: LLVMGetSections(llof)
2211 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2212 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2214 assert!(index < LLVMCountParams(llfn));
2215 LLVMGetParam(llfn, index)
2219 #[allow(missing_copy_implementations)]
2220 pub enum RustString_opaque {}
2221 pub type RustStringRef = *mut RustString_opaque;
2222 type RustStringRepr = *mut RefCell<Vec<u8>>;
2224 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2226 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2229 let slice: &[u8] = mem::transmute(raw::Slice {
2230 data: ptr as *const u8,
2234 let sr: RustStringRepr = mem::transmute(sr);
2235 (*sr).borrow_mut().push_all(slice);
2238 pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
2239 let mut buf = RefCell::new(Vec::new());
2240 f(&mut buf as RustStringRepr as RustStringRef);
2241 String::from_utf8(buf.into_inner()).ok()
2244 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2245 build_string(|s| LLVMWriteTwineToString(tr, s))
2246 .expect("got a non-UTF8 Twine from LLVM")
2249 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2250 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2251 .expect("got a non-UTF8 DebugLoc from LLVM")
2254 // The module containing the native LLVM dependencies, generated by the build system
2255 // Note that this must come after the rustllvm extern declaration so that
2256 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2257 // Works to the above fix for #15460 to ensure LLVM dependencies that
2258 // are only used by rustllvm don't get stripped by the linker.
2260 include! { env!("CFG_LLVM_LINKAGE_FILE") }