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 use super::debuginfo::{
12 DIBuilder, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType,
13 DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
14 DIGlobalVariableExpression, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
18 use libc::{c_uint, c_int, size_t, c_char};
19 use libc::{c_ulonglong, c_void};
21 use std::marker::PhantomData;
24 use super::RustString;
26 pub type Bool = c_uint;
28 pub const True: Bool = 1 as Bool;
29 pub const False: Bool = 0 as Bool;
31 #[derive(Copy, Clone, PartialEq)]
33 #[allow(dead_code)] // Variants constructed by C++.
34 pub enum LLVMRustResult {
38 // Consts for the LLVM CallConv type, pre-cast to usize.
40 /// LLVM CallingConv::ID. Should we wrap this?
41 #[derive(Copy, Clone, PartialEq, Debug)]
47 X86StdcallCallConv = 64,
48 X86FastcallCallConv = 65,
49 ArmAapcsCallConv = 67,
61 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
65 AvailableExternallyLinkage = 1,
66 LinkOnceAnyLinkage = 2,
67 LinkOnceODRLinkage = 3,
73 ExternalWeakLinkage = 9,
78 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
86 /// LLVMDLLStorageClass
87 #[derive(Copy, Clone)]
89 pub enum DLLStorageClass {
92 DllImport = 1, // Function to be imported from DLL.
94 DllExport = 2, // Function to be accessible from DLL.
97 /// Matches LLVMRustAttribute in rustllvm.h
98 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
99 /// though it is not ABI compatible (since it's a C++ enum)
101 #[derive(Copy, Clone, Debug)]
116 OptimizeForSize = 13,
124 SanitizeAddress = 21,
130 #[derive(Copy, Clone)]
132 pub enum IntPredicate {
146 pub fn from_generic(intpre: traits::IntPredicate) -> Self {
148 traits::IntPredicate::IntEQ => IntPredicate::IntEQ,
149 traits::IntPredicate::IntNE => IntPredicate::IntNE,
150 traits::IntPredicate::IntUGT => IntPredicate::IntUGT,
151 traits::IntPredicate::IntUGE => IntPredicate::IntUGE,
152 traits::IntPredicate::IntULT => IntPredicate::IntULT,
153 traits::IntPredicate::IntULE => IntPredicate::IntULE,
154 traits::IntPredicate::IntSGT => IntPredicate::IntSGT,
155 traits::IntPredicate::IntSGE => IntPredicate::IntSGE,
156 traits::IntPredicate::IntSLT => IntPredicate::IntSLT,
157 traits::IntPredicate::IntSLE => IntPredicate::IntSLE,
162 /// LLVMRealPredicate
163 #[derive(Copy, Clone)]
165 pub enum RealPredicate {
166 RealPredicateFalse = 0,
181 RealPredicateTrue = 15,
185 pub fn from_generic(realpred: traits::RealPredicate) -> Self {
187 traits::RealPredicate::RealPredicateFalse => RealPredicate::RealPredicateFalse,
188 traits::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
189 traits::RealPredicate::RealOGT => RealPredicate::RealOGT,
190 traits::RealPredicate::RealOGE => RealPredicate::RealOGE,
191 traits::RealPredicate::RealOLT => RealPredicate::RealOLT,
192 traits::RealPredicate::RealOLE => RealPredicate::RealOLE,
193 traits::RealPredicate::RealONE => RealPredicate::RealONE,
194 traits::RealPredicate::RealORD => RealPredicate::RealORD,
195 traits::RealPredicate::RealUNO => RealPredicate::RealUNO,
196 traits::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
197 traits::RealPredicate::RealUGT => RealPredicate::RealUGT,
198 traits::RealPredicate::RealUGE => RealPredicate::RealUGE,
199 traits::RealPredicate::RealULT => RealPredicate::RealULT,
200 traits::RealPredicate::RealULE => RealPredicate::RealULE,
201 traits::RealPredicate::RealUNE => RealPredicate::RealUNE,
202 traits::RealPredicate::RealPredicateTrue => RealPredicate::RealPredicateTrue
208 #[derive(Copy, Clone, PartialEq, Debug)]
230 /// LLVMAtomicRmwBinOp
231 #[derive(Copy, Clone)]
233 pub enum AtomicRmwBinOp {
247 impl AtomicRmwBinOp {
248 pub fn from_generic(op : traits::AtomicRmwBinOp) -> Self {
250 traits::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
251 traits::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
252 traits::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
253 traits::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
254 traits::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
255 traits::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
256 traits::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
257 traits::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
258 traits::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
259 traits::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
260 traits::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin
265 /// LLVMAtomicOrdering
266 #[derive(Copy, Clone)]
268 pub enum AtomicOrdering {
273 // Consume = 3, // Not specified yet.
277 SequentiallyConsistent = 7,
280 impl AtomicOrdering {
281 pub fn from_generic(ao : traits::AtomicOrdering) -> Self {
283 traits::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
284 traits::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
285 traits::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
286 traits::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
287 traits::AtomicOrdering::Release => AtomicOrdering::Release,
288 traits::AtomicOrdering::AcquireRelease => AtomicOrdering::AcquireRelease,
289 traits::AtomicOrdering::SequentiallyConsistent =>
290 AtomicOrdering::SequentiallyConsistent
296 /// LLVMRustSynchronizationScope
297 #[derive(Copy, Clone)]
299 pub enum SynchronizationScope {
300 // FIXME: figure out if this variant is needed at all.
307 impl SynchronizationScope {
308 pub fn from_generic(sc : traits::SynchronizationScope) -> Self {
310 traits::SynchronizationScope::Other => SynchronizationScope::Other,
311 traits::SynchronizationScope::SingleThread => SynchronizationScope::SingleThread,
312 traits::SynchronizationScope::CrossThread => SynchronizationScope::CrossThread,
318 #[derive(Copy, Clone)]
321 // FIXME: figure out if this variant is needed at all.
329 #[derive(Copy, Clone)]
331 pub enum MetadataType {
338 MD_invariant_load = 6,
342 MD_mem_parallel_loop_access = 10,
346 /// LLVMRustAsmDialect
347 #[derive(Copy, Clone)]
349 pub enum AsmDialect {
350 // FIXME: figure out if this variant is needed at all.
357 /// LLVMRustCodeGenOptLevel
358 #[derive(Copy, Clone, PartialEq)]
360 pub enum CodeGenOptLevel {
361 // FIXME: figure out if this variant is needed at all.
371 #[derive(Copy, Clone, PartialEq)]
383 /// LLVMRustCodeModel
384 #[derive(Copy, Clone)]
387 // FIXME: figure out if this variant is needed at all.
397 /// LLVMRustDiagnosticKind
398 #[derive(Copy, Clone)]
400 #[allow(dead_code)] // Variants constructed by C++.
401 pub enum DiagnosticKind {
405 DebugMetadataVersion,
408 OptimizationRemarkMissed,
409 OptimizationRemarkAnalysis,
410 OptimizationRemarkAnalysisFPCommute,
411 OptimizationRemarkAnalysisAliasing,
412 OptimizationRemarkOther,
418 /// LLVMRustArchiveKind
419 #[derive(Copy, Clone)]
421 pub enum ArchiveKind {
422 // FIXME: figure out if this variant is needed at all.
431 #[derive(Copy, Clone, PartialEq, Debug)]
433 #[allow(dead_code)] // Variants constructed by C++.
440 /// LLVMRustThinLTOData
441 extern { pub type ThinLTOData; }
443 /// LLVMRustThinLTOBuffer
444 extern { pub type ThinLTOBuffer; }
446 // LLVMRustModuleNameCallback
447 pub type ThinLTOModuleNameCallback =
448 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
450 /// LLVMRustThinLTOModule
452 pub struct ThinLTOModule {
453 pub identifier: *const c_char,
458 /// LLVMThreadLocalMode
459 #[derive(Copy, Clone)]
461 pub enum ThreadLocalMode {
469 extern { type Opaque; }
471 struct InvariantOpaque<'a> {
472 _marker: PhantomData<&'a mut &'a ()>,
476 // Opaque pointer types
477 extern { pub type Module; }
478 extern { pub type Context; }
479 extern { pub type Type; }
480 extern { pub type Value; }
481 extern { pub type Metadata; }
482 extern { pub type BasicBlock; }
484 pub struct Builder<'a>(InvariantOpaque<'a>);
485 extern { pub type MemoryBuffer; }
487 pub struct PassManager<'a>(InvariantOpaque<'a>);
488 extern { pub type PassManagerBuilder; }
489 extern { pub type ObjectFile; }
491 pub struct SectionIterator<'a>(InvariantOpaque<'a>);
492 extern { pub type Pass; }
493 extern { pub type TargetMachine; }
494 extern { pub type Archive; }
496 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
498 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
499 extern { pub type Twine; }
500 extern { pub type DiagnosticInfo; }
501 extern { pub type SMDiagnostic; }
503 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
505 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
507 pub struct Linker<'a>(InvariantOpaque<'a>);
509 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
510 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
514 use super::{InvariantOpaque, Metadata};
517 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
519 pub type DIDescriptor = Metadata;
520 pub type DIScope = DIDescriptor;
521 pub type DIFile = DIScope;
522 pub type DILexicalBlock = DIScope;
523 pub type DISubprogram = DIScope;
524 pub type DINameSpace = DIScope;
525 pub type DIType = DIDescriptor;
526 pub type DIBasicType = DIType;
527 pub type DIDerivedType = DIType;
528 pub type DICompositeType = DIDerivedType;
529 pub type DIVariable = DIDescriptor;
530 pub type DIGlobalVariableExpression = DIDescriptor;
531 pub type DIArray = DIDescriptor;
532 pub type DISubrange = DIDescriptor;
533 pub type DIEnumerator = DIDescriptor;
534 pub type DITemplateTypeParameter = DIDescriptor;
536 // These values **must** match with LLVMRustDIFlags!!
540 pub struct DIFlags: ::libc::uint32_t {
542 const FlagPrivate = 1;
543 const FlagProtected = 2;
544 const FlagPublic = 3;
545 const FlagFwdDecl = (1 << 2);
546 const FlagAppleBlock = (1 << 3);
547 const FlagBlockByrefStruct = (1 << 4);
548 const FlagVirtual = (1 << 5);
549 const FlagArtificial = (1 << 6);
550 const FlagExplicit = (1 << 7);
551 const FlagPrototyped = (1 << 8);
552 const FlagObjcClassComplete = (1 << 9);
553 const FlagObjectPointer = (1 << 10);
554 const FlagVector = (1 << 11);
555 const FlagStaticMember = (1 << 12);
556 const FlagLValueReference = (1 << 13);
557 const FlagRValueReference = (1 << 14);
558 const FlagExternalTypeRef = (1 << 15);
559 const FlagIntroducedVirtual = (1 << 18);
560 const FlagBitField = (1 << 19);
561 const FlagNoReturn = (1 << 20);
562 const FlagMainSubprogram = (1 << 21);
567 extern { pub type ModuleBuffer; }
570 pub fn LLVMRustInstallFatalErrorHandler();
572 // Create and destroy contexts.
573 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
574 pub fn LLVMContextDispose(C: &'static mut Context);
575 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
578 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
579 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
580 pub fn LLVMCloneModule(M: &Module) -> &Module;
582 /// Data layout. See Module::getDataLayout.
583 pub fn LLVMGetDataLayout(M: &Module) -> *const c_char;
584 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
586 /// See Module::setModuleInlineAsm.
587 pub fn LLVMSetModuleInlineAsm(M: &Module, Asm: *const c_char);
588 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char);
590 /// See llvm::LLVMTypeKind::getTypeID.
591 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
593 // Operations on integer types
594 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
595 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
596 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
597 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
598 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
599 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
601 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
603 // Operations on real types
604 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
605 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
607 // Operations on function types
608 pub fn LLVMFunctionType(ReturnType: &'a Type,
609 ParamTypes: *const &'a Type,
613 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
614 pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
616 // Operations on struct types
617 pub fn LLVMStructTypeInContext(C: &'a Context,
618 ElementTypes: *const &'a Type,
619 ElementCount: c_uint,
623 // Operations on array, pointer, and vector types (sequence types)
624 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
625 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
626 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
628 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
629 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
631 // Operations on other types
632 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
633 pub fn LLVMX86MMXTypeInContext(C: &Context) -> &Type;
634 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
636 // Operations on all values
637 pub fn LLVMTypeOf(Val: &Value) -> &Type;
638 pub fn LLVMGetValueName(Val: &Value) -> *const c_char;
639 pub fn LLVMSetValueName(Val: &Value, Name: *const c_char);
640 pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
641 pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
643 // Operations on constants of any type
644 pub fn LLVMConstNull(Ty: &Type) -> &Value;
645 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
647 // Operations on metadata
648 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
649 pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
650 pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
652 // Operations on scalar constants
653 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
654 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
655 pub fn LLVMConstIntGetZExtValue(ConstantVal: &Value) -> c_ulonglong;
656 pub fn LLVMRustConstInt128Get(ConstantVal: &Value, SExt: bool,
657 high: &mut u64, low: &mut u64) -> bool;
658 pub fn LLVMConstRealGetDouble (ConstantVal: &Value, losesInfo: &mut Bool) -> f64;
661 // Operations on composite constants
662 pub fn LLVMConstStringInContext(C: &Context,
665 DontNullTerminate: Bool)
667 pub fn LLVMConstStructInContext(C: &'a Context,
668 ConstantVals: *const &'a Value,
673 pub fn LLVMConstArray(ElementTy: &'a Type,
674 ConstantVals: *const &'a Value,
677 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
679 // Constant expressions
680 pub fn LLVMConstInBoundsGEP(
681 ConstantVal: &'a Value,
682 ConstantIndices: *const &'a Value,
685 pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
686 pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
687 pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
688 pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
689 pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
690 pub fn LLVMConstExtractValue(AggConstant: &Value,
691 IdxList: *const c_uint,
695 // Operations on global variables, functions, and aliases (globals)
696 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
697 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
698 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
699 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
700 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
701 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
702 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
703 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
704 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
707 // Operations on global variables
708 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
709 pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
710 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
711 pub fn LLVMRustGetOrInsertGlobal(M: &'a Module, Name: *const c_char, T: &'a Type) -> &'a Value;
712 pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
713 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
714 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
715 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
716 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
717 pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
718 pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
719 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
720 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
721 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
722 pub fn LLVMRustGetNamedValue(M: &Module, Name: *const c_char) -> Option<&Value>;
723 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
725 // Operations on functions
726 pub fn LLVMRustGetOrInsertFunction(M: &'a Module,
728 FunctionTy: &'a Type)
730 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
731 pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
732 pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
733 pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
734 pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
735 pub fn LLVMRustAddFunctionAttrStringValue(Fn: &Value,
738 Value: *const c_char);
739 pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
741 // Operations on parameters
742 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
743 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
745 // Operations on basic blocks
746 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
747 pub fn LLVMAppendBasicBlockInContext(C: &'a Context,
751 pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
753 // Operations on instructions
754 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
756 // Operations on call sites
757 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
758 pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
759 pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
760 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
761 pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value,
765 // Operations on load/store instructions (only)
766 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
768 // Operations on phi nodes
769 pub fn LLVMAddIncoming(PhiNode: &'a Value,
770 IncomingValues: *const &'a Value,
771 IncomingBlocks: *const &'a BasicBlock,
774 // Instruction builders
775 pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
776 pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
777 pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
778 pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
781 pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: Option<&'a Value>);
782 pub fn LLVMGetCurrentDebugLocation(Builder: &Builder<'a>) -> &'a Value;
783 pub fn LLVMSetInstDebugLocation(Builder: &Builder<'a>, Inst: &'a Value);
786 pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
787 pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
788 pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
789 pub fn LLVMBuildCondBr(B: &Builder<'a>,
791 Then: &'a BasicBlock,
792 Else: &'a BasicBlock)
794 pub fn LLVMBuildSwitch(B: &Builder<'a>,
796 Else: &'a BasicBlock,
799 pub fn LLVMRustBuildInvoke(B: &Builder<'a>,
801 Args: *const &'a Value,
803 Then: &'a BasicBlock,
804 Catch: &'a BasicBlock,
805 Bundle: Option<&OperandBundleDef<'a>>,
808 pub fn LLVMBuildLandingPad(B: &Builder<'a>,
814 pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
815 pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
817 pub fn LLVMRustBuildCleanupPad(B: &Builder<'a>,
818 ParentPad: Option<&'a Value>,
820 Args: *const &'a Value,
822 -> Option<&'a Value>;
823 pub fn LLVMRustBuildCleanupRet(B: &Builder<'a>,
824 CleanupPad: &'a Value,
825 UnwindBB: Option<&'a BasicBlock>)
826 -> Option<&'a Value>;
827 pub fn LLVMRustBuildCatchPad(B: &Builder<'a>,
828 ParentPad: &'a Value,
830 Args: *const &'a Value,
832 -> Option<&'a Value>;
833 pub fn LLVMRustBuildCatchRet(
837 ) -> Option<&'a Value>;
838 pub fn LLVMRustBuildCatchSwitch(Builder: &Builder<'a>,
839 ParentPad: Option<&'a Value>,
840 BB: Option<&'a BasicBlock>,
843 -> Option<&'a Value>;
844 pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
845 pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
847 // Add a case to the switch instruction
848 pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
850 // Add a clause to the landing pad instruction
851 pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
853 // Set the cleanup on a landing pad instruction
854 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
857 pub fn LLVMBuildAdd(B: &Builder<'a>,
862 pub fn LLVMBuildFAdd(B: &Builder<'a>,
867 pub fn LLVMBuildSub(B: &Builder<'a>,
872 pub fn LLVMBuildFSub(B: &Builder<'a>,
877 pub fn LLVMBuildMul(B: &Builder<'a>,
882 pub fn LLVMBuildFMul(B: &Builder<'a>,
887 pub fn LLVMBuildUDiv(B: &Builder<'a>,
892 pub fn LLVMBuildExactUDiv(B: &Builder<'a>,
897 pub fn LLVMBuildSDiv(B: &Builder<'a>,
902 pub fn LLVMBuildExactSDiv(B: &Builder<'a>,
907 pub fn LLVMBuildFDiv(B: &Builder<'a>,
912 pub fn LLVMBuildURem(B: &Builder<'a>,
917 pub fn LLVMBuildSRem(B: &Builder<'a>,
922 pub fn LLVMBuildFRem(B: &Builder<'a>,
927 pub fn LLVMBuildShl(B: &Builder<'a>,
932 pub fn LLVMBuildLShr(B: &Builder<'a>,
937 pub fn LLVMBuildAShr(B: &Builder<'a>,
942 pub fn LLVMBuildAnd(B: &Builder<'a>,
947 pub fn LLVMBuildOr(B: &Builder<'a>,
952 pub fn LLVMBuildXor(B: &Builder<'a>,
957 pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
958 pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
959 pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
960 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: &Value);
963 pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
964 pub fn LLVMBuildArrayAlloca(B: &Builder<'a>,
969 pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
971 pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
973 pub fn LLVMBuildGEP(B: &Builder<'a>,
975 Indices: *const &'a Value,
979 pub fn LLVMBuildInBoundsGEP(B: &Builder<'a>,
981 Indices: *const &'a Value,
985 pub fn LLVMBuildStructGEP(B: &Builder<'a>,
992 pub fn LLVMBuildTrunc(B: &Builder<'a>,
997 pub fn LLVMBuildZExt(B: &Builder<'a>,
1000 Name: *const c_char)
1002 pub fn LLVMBuildSExt(B: &Builder<'a>,
1005 Name: *const c_char)
1007 pub fn LLVMBuildFPToUI(B: &Builder<'a>,
1010 Name: *const c_char)
1012 pub fn LLVMBuildFPToSI(B: &Builder<'a>,
1015 Name: *const c_char)
1017 pub fn LLVMBuildUIToFP(B: &Builder<'a>,
1020 Name: *const c_char)
1022 pub fn LLVMBuildSIToFP(B: &Builder<'a>,
1025 Name: *const c_char)
1027 pub fn LLVMBuildFPTrunc(B: &Builder<'a>,
1030 Name: *const c_char)
1032 pub fn LLVMBuildFPExt(B: &Builder<'a>,
1035 Name: *const c_char)
1037 pub fn LLVMBuildPtrToInt(B: &Builder<'a>,
1040 Name: *const c_char)
1042 pub fn LLVMBuildIntToPtr(B: &Builder<'a>,
1045 Name: *const c_char)
1047 pub fn LLVMBuildBitCast(B: &Builder<'a>,
1050 Name: *const c_char)
1052 pub fn LLVMBuildPointerCast(B: &Builder<'a>,
1055 Name: *const c_char)
1057 pub fn LLVMRustBuildIntCast(B: &Builder<'a>,
1064 pub fn LLVMBuildICmp(B: &Builder<'a>,
1068 Name: *const c_char)
1070 pub fn LLVMBuildFCmp(B: &Builder<'a>,
1074 Name: *const c_char)
1077 // Miscellaneous instructions
1078 pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1079 pub fn LLVMRustBuildCall(B: &Builder<'a>,
1081 Args: *const &'a Value,
1083 Bundle: Option<&OperandBundleDef<'a>>,
1084 Name: *const c_char)
1086 pub fn LLVMRustBuildMemCpy(B: &Builder<'a>,
1094 pub fn LLVMRustBuildMemMove(B: &Builder<'a>,
1102 pub fn LLVMBuildSelect(B: &Builder<'a>,
1106 Name: *const c_char)
1108 pub fn LLVMBuildVAArg(B: &Builder<'a>,
1111 Name: *const c_char)
1113 pub fn LLVMBuildExtractElement(B: &Builder<'a>,
1116 Name: *const c_char)
1118 pub fn LLVMBuildInsertElement(B: &Builder<'a>,
1122 Name: *const c_char)
1124 pub fn LLVMBuildShuffleVector(B: &Builder<'a>,
1128 Name: *const c_char)
1130 pub fn LLVMBuildExtractValue(B: &Builder<'a>,
1133 Name: *const c_char)
1135 pub fn LLVMBuildInsertValue(B: &Builder<'a>,
1139 Name: *const c_char)
1142 pub fn LLVMRustBuildVectorReduceFAdd(B: &Builder<'a>,
1146 pub fn LLVMRustBuildVectorReduceFMul(B: &Builder<'a>,
1150 pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>,
1153 pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>,
1156 pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>,
1159 pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>,
1162 pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>,
1165 pub fn LLVMRustBuildVectorReduceMin(B: &Builder<'a>,
1169 pub fn LLVMRustBuildVectorReduceMax(B: &Builder<'a>,
1173 pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>,
1177 pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>,
1182 pub fn LLVMRustBuildMinNum(
1186 ) -> Option<&'a Value>;
1187 pub fn LLVMRustBuildMaxNum(
1191 ) -> Option<&'a Value>;
1193 // Atomic Operations
1194 pub fn LLVMRustBuildAtomicLoad(B: &Builder<'a>,
1195 PointerVal: &'a Value,
1196 Name: *const c_char,
1197 Order: AtomicOrdering)
1200 pub fn LLVMRustBuildAtomicStore(B: &Builder<'a>,
1203 Order: AtomicOrdering)
1206 pub fn LLVMRustBuildAtomicCmpXchg(B: &Builder<'a>,
1210 Order: AtomicOrdering,
1211 FailureOrder: AtomicOrdering,
1215 pub fn LLVMBuildAtomicRMW(B: &Builder<'a>,
1219 Order: AtomicOrdering,
1220 SingleThreaded: Bool)
1223 pub fn LLVMRustBuildAtomicFence(B: &Builder,
1224 Order: AtomicOrdering,
1225 Scope: SynchronizationScope);
1227 /// Writes a module to the specified path. Returns 0 on success.
1228 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1230 /// Creates a pass manager.
1231 pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1233 /// Creates a function-by-function pass manager
1234 pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1236 /// Disposes a pass manager.
1237 pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1239 /// Runs a pass manager on a module.
1240 pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1242 pub fn LLVMInitializePasses();
1244 pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1245 pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1246 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1247 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1248 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: &PassManagerBuilder,
1250 pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: &PassManagerBuilder,
1253 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: &PassManagerBuilder,
1255 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: &PassManagerBuilder,
1259 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1260 PMB: &PassManagerBuilder,
1263 // Stuff that's in rustllvm/ because it's not upstream yet.
1265 /// Opens an object file.
1266 pub fn LLVMCreateObjectFile(
1267 MemBuf: &'static mut MemoryBuffer,
1268 ) -> Option<&'static mut ObjectFile>;
1269 /// Closes an object file.
1270 pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1272 /// Enumerates the sections in an object file.
1273 pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1274 /// Destroys a section iterator.
1275 pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1276 /// Returns true if the section iterator is at the end of the section
1278 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1279 /// Moves the section iterator to point to the next section.
1280 pub fn LLVMMoveToNextSection(SI: &SectionIterator);
1281 /// Returns the current section size.
1282 pub fn LLVMGetSectionSize(SI: &SectionIterator) -> c_ulonglong;
1283 /// Returns the current section contents as a string buffer.
1284 pub fn LLVMGetSectionContents(SI: &SectionIterator) -> *const c_char;
1286 /// Reads the given file and returns it as a memory buffer. Use
1287 /// LLVMDisposeMemoryBuffer() to get rid of it.
1288 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1289 Path: *const c_char,
1290 ) -> Option<&'static mut MemoryBuffer>;
1292 pub fn LLVMStartMultithreaded() -> Bool;
1294 /// Returns a string describing the last error caused by an LLVMRust* call.
1295 pub fn LLVMRustGetLastError() -> *const c_char;
1297 /// Print the pass timings since static dtors aren't picking them up.
1298 pub fn LLVMRustPrintPassTimings();
1300 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1302 pub fn LLVMStructSetBody(StructTy: &'a Type,
1303 ElementTypes: *const &'a Type,
1304 ElementCount: c_uint,
1307 /// Prepares inline assembly.
1308 pub fn LLVMRustInlineAsm(Ty: &Type,
1309 AsmString: *const c_char,
1310 Constraints: *const c_char,
1313 Dialect: AsmDialect)
1315 pub fn LLVMRustInlineAsmVerify(Ty: &Type,
1316 Constraints: *const c_char)
1319 pub fn LLVMRustDebugMetadataVersion() -> u32;
1320 pub fn LLVMRustVersionMajor() -> u32;
1321 pub fn LLVMRustVersionMinor() -> u32;
1323 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1325 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1327 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1329 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1331 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder);
1333 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: &DIBuilder<'a>,
1336 Producer: *const c_char,
1338 Flags: *const c_char,
1340 SplitName: *const c_char)
1341 -> &'a DIDescriptor;
1343 pub fn LLVMRustDIBuilderCreateFile(Builder: &DIBuilder<'a>,
1344 Filename: *const c_char,
1345 Directory: *const c_char)
1348 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: &DIBuilder<'a>,
1350 ParameterTypes: &'a DIArray)
1351 -> &'a DICompositeType;
1353 pub fn LLVMRustDIBuilderCreateFunction(Builder: &DIBuilder<'a>,
1354 Scope: &'a DIDescriptor,
1355 Name: *const c_char,
1356 LinkageName: *const c_char,
1360 isLocalToUnit: bool,
1366 TParam: &'a DIArray,
1367 Decl: Option<&'a DIDescriptor>)
1368 -> &'a DISubprogram;
1370 pub fn LLVMRustDIBuilderCreateBasicType(Builder: &DIBuilder<'a>,
1371 Name: *const c_char,
1377 pub fn LLVMRustDIBuilderCreatePointerType(Builder: &DIBuilder<'a>,
1378 PointeeTy: &'a DIType,
1381 Name: *const c_char)
1382 -> &'a DIDerivedType;
1384 pub fn LLVMRustDIBuilderCreateStructType(Builder: &DIBuilder<'a>,
1385 Scope: Option<&'a DIDescriptor>,
1386 Name: *const c_char,
1392 DerivedFrom: Option<&'a DIType>,
1393 Elements: &'a DIArray,
1394 RunTimeLang: c_uint,
1395 VTableHolder: Option<&'a DIType>,
1396 UniqueId: *const c_char)
1397 -> &'a DICompositeType;
1399 pub fn LLVMRustDIBuilderCreateMemberType(Builder: &DIBuilder<'a>,
1400 Scope: &'a DIDescriptor,
1401 Name: *const c_char,
1409 -> &'a DIDerivedType;
1411 pub fn LLVMRustDIBuilderCreateVariantMemberType(Builder: &DIBuilder<'a>,
1413 Name: *const c_char,
1419 Discriminant: Option<&'a Value>,
1424 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: &DIBuilder<'a>,
1429 -> &'a DILexicalBlock;
1431 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: &DIBuilder<'a>,
1434 -> &'a DILexicalBlock;
1436 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: &DIBuilder<'a>,
1437 Context: Option<&'a DIScope>,
1438 Name: *const c_char,
1439 LinkageName: *const c_char,
1443 isLocalToUnit: bool,
1445 Decl: Option<&'a DIDescriptor>,
1447 -> &'a DIGlobalVariableExpression;
1449 pub fn LLVMRustDIBuilderCreateVariable(Builder: &DIBuilder<'a>,
1451 Scope: &'a DIDescriptor,
1452 Name: *const c_char,
1456 AlwaysPreserve: bool,
1462 pub fn LLVMRustDIBuilderCreateArrayType(Builder: &DIBuilder<'a>,
1466 Subscripts: &'a DIArray)
1469 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: &DIBuilder<'a>,
1474 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: &DIBuilder<'a>,
1475 Ptr: *const Option<&'a DIDescriptor>,
1479 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: &DIBuilder<'a>,
1481 VarInfo: &'a DIVariable,
1482 AddrOps: *const i64,
1483 AddrOpsCount: c_uint,
1485 InsertAtEnd: &'a BasicBlock)
1488 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: &DIBuilder<'a>,
1489 Name: *const c_char,
1491 -> &'a DIEnumerator;
1493 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: &DIBuilder<'a>,
1495 Name: *const c_char,
1500 Elements: &'a DIArray,
1501 ClassType: &'a DIType,
1505 pub fn LLVMRustDIBuilderCreateUnionType(Builder: &DIBuilder<'a>,
1507 Name: *const c_char,
1513 Elements: Option<&'a DIArray>,
1514 RunTimeLang: c_uint,
1515 UniqueId: *const c_char)
1518 pub fn LLVMRustDIBuilderCreateVariantPart(Builder: &DIBuilder<'a>,
1520 Name: *const c_char,
1526 Discriminator: Option<&'a DIDerivedType>,
1527 Elements: &'a DIArray,
1528 UniqueId: *const c_char)
1529 -> &'a DIDerivedType;
1531 pub fn LLVMSetUnnamedAddr(GlobalVar: &Value, UnnamedAddr: Bool);
1533 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: &DIBuilder<'a>,
1534 Scope: Option<&'a DIScope>,
1535 Name: *const c_char,
1540 -> &'a DITemplateTypeParameter;
1543 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: &DIBuilder<'a>,
1544 Scope: Option<&'a DIScope>,
1545 Name: *const c_char,
1550 pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: &DIBuilder<'a>,
1551 CompositeType: &'a DIType,
1552 TypeArray: &'a DIArray);
1555 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: &'a Context,
1559 InlinedAt: Option<&'a Metadata>)
1561 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1562 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
1565 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1567 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
1568 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
1572 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&Value>;
1573 pub fn LLVMIsAConstantFP(value_ref: &Value) -> Option<&Value>;
1575 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
1576 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
1577 pub fn LLVMRustAddPass(PM: &PassManager, Pass: &'static mut Pass);
1579 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
1581 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
1582 pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
1584 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
1585 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1587 Features: *const c_char,
1590 Level: CodeGenOptLevel,
1592 PositionIndependentExecutable: bool,
1593 FunctionSections: bool,
1595 TrapUnreachable: bool,
1598 EmitStackSizeSection: bool)
1599 -> Option<&'static mut TargetMachine>;
1600 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
1601 pub fn LLVMRustAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>, M: &'a Module);
1602 pub fn LLVMRustAddBuilderLibraryInfo(PMB: &'a PassManagerBuilder,
1604 DisableSimplifyLibCalls: bool);
1605 pub fn LLVMRustConfigurePassManagerBuilder(PMB: &PassManagerBuilder,
1606 OptLevel: CodeGenOptLevel,
1607 MergeFunctions: bool,
1609 LoopVectorize: bool,
1610 PrepareForThinLTO: bool,
1611 PGOGenPath: *const c_char,
1612 PGOUsePath: *const c_char);
1613 pub fn LLVMRustAddLibraryInfo(PM: &PassManager<'a>,
1615 DisableSimplifyLibCalls: bool);
1616 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
1617 pub fn LLVMRustWriteOutputFile(T: &'a TargetMachine,
1618 PM: &PassManager<'a>,
1620 Output: *const c_char,
1623 pub fn LLVMRustPrintModule(PM: &PassManager<'a>,
1625 Output: *const c_char,
1626 Demangle: extern fn(*const c_char,
1630 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1631 pub fn LLVMRustPrintPasses();
1632 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
1633 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
1634 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
1635 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
1637 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
1638 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
1639 pub fn LLVMRustArchiveIteratorNext(
1640 AIR: &ArchiveIterator<'a>,
1641 ) -> Option<&'a mut ArchiveChild<'a>>;
1642 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
1643 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
1644 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
1645 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
1646 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
1648 pub fn LLVMRustGetSectionName(SI: &SectionIterator, data: &mut *const c_char) -> size_t;
1651 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1653 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
1657 pub fn LLVMContextSetDiagnosticHandler(C: &Context,
1658 Handler: DiagnosticHandler,
1659 DiagnosticContext: *mut c_void);
1662 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1664 pub fn LLVMRustUnpackOptimizationDiagnostic(DI: &'a DiagnosticInfo,
1665 pass_name_out: &RustString,
1666 function_out: &mut Option<&'a Value>,
1667 loc_line_out: &mut c_uint,
1668 loc_column_out: &mut c_uint,
1669 loc_filename_out: &RustString,
1670 message_out: &RustString);
1674 pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: &'a DiagnosticInfo,
1675 cookie_out: &mut c_uint,
1676 message_out: &mut Option<&'a Twine>,
1677 instruction_out: &mut Option<&'a Value>);
1680 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1682 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
1686 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
1688 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: &Context,
1689 H: InlineAsmDiagHandler,
1693 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1695 pub fn LLVMRustWriteSMDiagnosticToString(d: &SMDiagnostic, s: &RustString);
1699 pub fn LLVMRustWriteArchive(Dst: *const c_char,
1701 Members: *const &RustArchiveMember,
1705 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1706 Name: *const c_char,
1707 Child: Option<&ArchiveChild<'a>>)
1708 -> &'a mut RustArchiveMember<'a>;
1709 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
1711 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
1713 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1714 Inputs: *const &'a Value,
1716 -> &'a mut OperandBundleDef<'a>;
1717 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
1719 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
1721 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char);
1722 pub fn LLVMRustUnsetComdat(V: &Value);
1723 pub fn LLVMRustSetModulePIELevel(M: &Module);
1724 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
1725 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
1726 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
1727 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
1728 pub fn LLVMRustModuleCost(M: &Module) -> u64;
1730 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
1731 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
1732 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
1733 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
1734 pub fn LLVMRustCreateThinLTOData(
1735 Modules: *const ThinLTOModule,
1737 PreservedSymbols: *const *const c_char,
1738 PreservedSymbolsLen: c_uint,
1739 ) -> Option<&'static mut ThinLTOData>;
1740 pub fn LLVMRustPrepareThinLTORename(
1744 pub fn LLVMRustPrepareThinLTOResolveWeak(
1748 pub fn LLVMRustPrepareThinLTOInternalize(
1752 pub fn LLVMRustPrepareThinLTOImport(
1756 pub fn LLVMRustGetThinLTOModuleImports(
1757 Data: *const ThinLTOData,
1758 ModuleNameCallback: ThinLTOModuleNameCallback,
1759 CallbackPayload: *mut c_void,
1761 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
1762 pub fn LLVMRustParseBitcodeForThinLTO(
1766 Identifier: *const c_char,
1767 ) -> Option<&Module>;
1768 pub fn LLVMRustThinLTOGetDICompileUnit(M: &Module,
1769 CU1: &mut *mut c_void,
1770 CU2: &mut *mut c_void);
1771 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
1773 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
1774 pub fn LLVMRustLinkerAdd(linker: &Linker,
1775 bytecode: *const c_char,
1776 bytecode_len: usize) -> bool;
1777 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);