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;
25 use super::RustString;
27 pub type Bool = c_uint;
29 pub const True: Bool = 1 as Bool;
30 pub const False: Bool = 0 as Bool;
32 #[derive(Copy, Clone, PartialEq)]
34 #[allow(dead_code)] // Variants constructed by C++.
35 pub enum LLVMRustResult {
39 // Consts for the LLVM CallConv type, pre-cast to usize.
41 /// LLVM CallingConv::ID. Should we wrap this?
42 #[derive(Copy, Clone, PartialEq, Debug)]
48 X86StdcallCallConv = 64,
49 X86FastcallCallConv = 65,
50 ArmAapcsCallConv = 67,
62 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
66 AvailableExternallyLinkage = 1,
67 LinkOnceAnyLinkage = 2,
68 LinkOnceODRLinkage = 3,
74 ExternalWeakLinkage = 9,
79 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
87 /// LLVMDLLStorageClass
88 #[derive(Copy, Clone)]
90 pub enum DLLStorageClass {
93 DllImport = 1, // Function to be imported from DLL.
95 DllExport = 2, // Function to be accessible from DLL.
98 /// Matches LLVMRustAttribute in rustllvm.h
99 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
100 /// though it is not ABI compatible (since it's a C++ enum)
102 #[derive(Copy, Clone, Debug)]
117 OptimizeForSize = 13,
125 SanitizeAddress = 21,
131 #[derive(Copy, Clone)]
133 pub enum IntPredicate {
147 pub fn from_generic(intpre: common::IntPredicate) -> Self {
149 common::IntPredicate::IntEQ => IntPredicate::IntEQ,
150 common::IntPredicate::IntNE => IntPredicate::IntNE,
151 common::IntPredicate::IntUGT => IntPredicate::IntUGT,
152 common::IntPredicate::IntUGE => IntPredicate::IntUGE,
153 common::IntPredicate::IntULT => IntPredicate::IntULT,
154 common::IntPredicate::IntULE => IntPredicate::IntULE,
155 common::IntPredicate::IntSGT => IntPredicate::IntSGT,
156 common::IntPredicate::IntSGE => IntPredicate::IntSGE,
157 common::IntPredicate::IntSLT => IntPredicate::IntSLT,
158 common::IntPredicate::IntSLE => IntPredicate::IntSLE,
163 /// LLVMRealPredicate
164 #[derive(Copy, Clone)]
166 pub enum RealPredicate {
167 RealPredicateFalse = 0,
182 RealPredicateTrue = 15,
186 pub fn from_generic(realpred: common::RealPredicate) -> Self {
188 common::RealPredicate::RealPredicateFalse => RealPredicate::RealPredicateFalse,
189 common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
190 common::RealPredicate::RealOGT => RealPredicate::RealOGT,
191 common::RealPredicate::RealOGE => RealPredicate::RealOGE,
192 common::RealPredicate::RealOLT => RealPredicate::RealOLT,
193 common::RealPredicate::RealOLE => RealPredicate::RealOLE,
194 common::RealPredicate::RealONE => RealPredicate::RealONE,
195 common::RealPredicate::RealORD => RealPredicate::RealORD,
196 common::RealPredicate::RealUNO => RealPredicate::RealUNO,
197 common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
198 common::RealPredicate::RealUGT => RealPredicate::RealUGT,
199 common::RealPredicate::RealUGE => RealPredicate::RealUGE,
200 common::RealPredicate::RealULT => RealPredicate::RealULT,
201 common::RealPredicate::RealULE => RealPredicate::RealULE,
202 common::RealPredicate::RealUNE => RealPredicate::RealUNE,
203 common::RealPredicate::RealPredicateTrue => RealPredicate::RealPredicateTrue
209 #[derive(Copy, Clone, PartialEq, Debug)]
231 /// LLVMAtomicRmwBinOp
232 #[derive(Copy, Clone)]
234 pub enum AtomicRmwBinOp {
248 impl AtomicRmwBinOp {
249 pub fn from_generic(op: common::AtomicRmwBinOp) -> Self {
251 common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
252 common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
253 common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
254 common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
255 common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
256 common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
257 common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
258 common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
259 common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
260 common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
261 common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin
266 /// LLVMAtomicOrdering
267 #[derive(Copy, Clone)]
269 pub enum AtomicOrdering {
274 // Consume = 3, // Not specified yet.
278 SequentiallyConsistent = 7,
281 impl AtomicOrdering {
282 pub fn from_generic(ao: common::AtomicOrdering) -> Self {
284 common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
285 common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
286 common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
287 common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
288 common::AtomicOrdering::Release => AtomicOrdering::Release,
289 common::AtomicOrdering::AcquireRelease => AtomicOrdering::AcquireRelease,
290 common::AtomicOrdering::SequentiallyConsistent =>
291 AtomicOrdering::SequentiallyConsistent
297 /// LLVMRustSynchronizationScope
298 #[derive(Copy, Clone)]
300 pub enum SynchronizationScope {
301 // FIXME: figure out if this variant is needed at all.
308 impl SynchronizationScope {
309 pub fn from_generic(sc: common::SynchronizationScope) -> Self {
311 common::SynchronizationScope::Other => SynchronizationScope::Other,
312 common::SynchronizationScope::SingleThread => SynchronizationScope::SingleThread,
313 common::SynchronizationScope::CrossThread => SynchronizationScope::CrossThread,
319 #[derive(Copy, Clone)]
322 // FIXME: figure out if this variant is needed at all.
330 #[derive(Copy, Clone)]
332 pub enum MetadataType {
339 MD_invariant_load = 6,
343 MD_mem_parallel_loop_access = 10,
347 /// LLVMRustAsmDialect
348 #[derive(Copy, Clone)]
350 pub enum AsmDialect {
351 // FIXME: figure out if this variant is needed at all.
359 pub fn from_generic(asm: syntax::ast::AsmDialect) -> Self {
361 syntax::ast::AsmDialect::Att => AsmDialect::Att,
362 syntax::ast::AsmDialect::Intel => AsmDialect::Intel
367 /// LLVMRustCodeGenOptLevel
368 #[derive(Copy, Clone, PartialEq)]
370 pub enum CodeGenOptLevel {
371 // FIXME: figure out if this variant is needed at all.
381 #[derive(Copy, Clone, PartialEq)]
393 /// LLVMRustCodeModel
394 #[derive(Copy, Clone)]
397 // FIXME: figure out if this variant is needed at all.
407 /// LLVMRustDiagnosticKind
408 #[derive(Copy, Clone)]
410 #[allow(dead_code)] // Variants constructed by C++.
411 pub enum DiagnosticKind {
415 DebugMetadataVersion,
418 OptimizationRemarkMissed,
419 OptimizationRemarkAnalysis,
420 OptimizationRemarkAnalysisFPCommute,
421 OptimizationRemarkAnalysisAliasing,
422 OptimizationRemarkOther,
428 /// LLVMRustArchiveKind
429 #[derive(Copy, Clone)]
431 pub enum ArchiveKind {
432 // FIXME: figure out if this variant is needed at all.
441 #[derive(Copy, Clone, PartialEq, Debug)]
443 #[allow(dead_code)] // Variants constructed by C++.
450 /// LLVMRustThinLTOData
451 extern { pub type ThinLTOData; }
453 /// LLVMRustThinLTOBuffer
454 extern { pub type ThinLTOBuffer; }
456 // LLVMRustModuleNameCallback
457 pub type ThinLTOModuleNameCallback =
458 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
460 /// LLVMRustThinLTOModule
462 pub struct ThinLTOModule {
463 pub identifier: *const c_char,
468 /// LLVMThreadLocalMode
469 #[derive(Copy, Clone)]
471 pub enum ThreadLocalMode {
479 extern { type Opaque; }
481 struct InvariantOpaque<'a> {
482 _marker: PhantomData<&'a mut &'a ()>,
486 // Opaque pointer types
487 extern { pub type Module; }
488 extern { pub type Context; }
489 extern { pub type Type; }
490 extern { pub type Value; }
491 extern { pub type Metadata; }
492 extern { pub type BasicBlock; }
494 pub struct Builder<'a>(InvariantOpaque<'a>);
495 extern { pub type MemoryBuffer; }
497 pub struct PassManager<'a>(InvariantOpaque<'a>);
498 extern { pub type PassManagerBuilder; }
499 extern { pub type ObjectFile; }
501 pub struct SectionIterator<'a>(InvariantOpaque<'a>);
502 extern { pub type Pass; }
503 extern { pub type TargetMachine; }
504 extern { pub type Archive; }
506 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
508 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
509 extern { pub type Twine; }
510 extern { pub type DiagnosticInfo; }
511 extern { pub type SMDiagnostic; }
513 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
515 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
517 pub struct Linker<'a>(InvariantOpaque<'a>);
519 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
520 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
524 use super::{InvariantOpaque, Metadata};
527 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
529 pub type DIDescriptor = Metadata;
530 pub type DIScope = DIDescriptor;
531 pub type DIFile = DIScope;
532 pub type DILexicalBlock = DIScope;
533 pub type DISubprogram = DIScope;
534 pub type DINameSpace = DIScope;
535 pub type DIType = DIDescriptor;
536 pub type DIBasicType = DIType;
537 pub type DIDerivedType = DIType;
538 pub type DICompositeType = DIDerivedType;
539 pub type DIVariable = DIDescriptor;
540 pub type DIGlobalVariableExpression = DIDescriptor;
541 pub type DIArray = DIDescriptor;
542 pub type DISubrange = DIDescriptor;
543 pub type DIEnumerator = DIDescriptor;
544 pub type DITemplateTypeParameter = DIDescriptor;
546 // These values **must** match with LLVMRustDIFlags!!
550 pub struct DIFlags: ::libc::uint32_t {
552 const FlagPrivate = 1;
553 const FlagProtected = 2;
554 const FlagPublic = 3;
555 const FlagFwdDecl = (1 << 2);
556 const FlagAppleBlock = (1 << 3);
557 const FlagBlockByrefStruct = (1 << 4);
558 const FlagVirtual = (1 << 5);
559 const FlagArtificial = (1 << 6);
560 const FlagExplicit = (1 << 7);
561 const FlagPrototyped = (1 << 8);
562 const FlagObjcClassComplete = (1 << 9);
563 const FlagObjectPointer = (1 << 10);
564 const FlagVector = (1 << 11);
565 const FlagStaticMember = (1 << 12);
566 const FlagLValueReference = (1 << 13);
567 const FlagRValueReference = (1 << 14);
568 const FlagExternalTypeRef = (1 << 15);
569 const FlagIntroducedVirtual = (1 << 18);
570 const FlagBitField = (1 << 19);
571 const FlagNoReturn = (1 << 20);
572 const FlagMainSubprogram = (1 << 21);
577 extern { pub type ModuleBuffer; }
580 pub fn LLVMRustInstallFatalErrorHandler();
582 // Create and destroy contexts.
583 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
584 pub fn LLVMContextDispose(C: &'static mut Context);
585 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
588 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
589 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
590 pub fn LLVMCloneModule(M: &Module) -> &Module;
592 /// Data layout. See Module::getDataLayout.
593 pub fn LLVMGetDataLayout(M: &Module) -> *const c_char;
594 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
596 /// See Module::setModuleInlineAsm.
597 pub fn LLVMSetModuleInlineAsm(M: &Module, Asm: *const c_char);
598 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char);
600 /// See llvm::LLVMTypeKind::getTypeID.
601 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
603 // Operations on integer types
604 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
605 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
606 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
607 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
608 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
609 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
611 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
613 // Operations on real types
614 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
615 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
617 // Operations on function types
618 pub fn LLVMFunctionType(ReturnType: &'a Type,
619 ParamTypes: *const &'a Type,
623 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
624 pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
626 // Operations on struct types
627 pub fn LLVMStructTypeInContext(C: &'a Context,
628 ElementTypes: *const &'a Type,
629 ElementCount: c_uint,
633 // Operations on array, pointer, and vector types (sequence types)
634 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
635 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
636 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
638 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
639 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
641 // Operations on other types
642 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
643 pub fn LLVMX86MMXTypeInContext(C: &Context) -> &Type;
644 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
646 // Operations on all values
647 pub fn LLVMTypeOf(Val: &Value) -> &Type;
648 pub fn LLVMGetValueName(Val: &Value) -> *const c_char;
649 pub fn LLVMSetValueName(Val: &Value, Name: *const c_char);
650 pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
651 pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
653 // Operations on constants of any type
654 pub fn LLVMConstNull(Ty: &Type) -> &Value;
655 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
657 // Operations on metadata
658 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
659 pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
660 pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
662 // Operations on scalar constants
663 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
664 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
665 pub fn LLVMConstIntGetZExtValue(ConstantVal: &Value) -> c_ulonglong;
666 pub fn LLVMRustConstInt128Get(ConstantVal: &Value, SExt: bool,
667 high: &mut u64, low: &mut u64) -> bool;
668 pub fn LLVMConstRealGetDouble (ConstantVal: &Value, losesInfo: &mut Bool) -> f64;
671 // Operations on composite constants
672 pub fn LLVMConstStringInContext(C: &Context,
675 DontNullTerminate: Bool)
677 pub fn LLVMConstStructInContext(C: &'a Context,
678 ConstantVals: *const &'a Value,
683 pub fn LLVMConstArray(ElementTy: &'a Type,
684 ConstantVals: *const &'a Value,
687 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
689 // Constant expressions
690 pub fn LLVMConstInBoundsGEP(
691 ConstantVal: &'a Value,
692 ConstantIndices: *const &'a Value,
695 pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
696 pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
697 pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
698 pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
699 pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
700 pub fn LLVMConstExtractValue(AggConstant: &Value,
701 IdxList: *const c_uint,
705 // Operations on global variables, functions, and aliases (globals)
706 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
707 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
708 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
709 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
710 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
711 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
712 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
713 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
714 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
717 // Operations on global variables
718 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
719 pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
720 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
721 pub fn LLVMRustGetOrInsertGlobal(M: &'a Module, Name: *const c_char, T: &'a Type) -> &'a Value;
722 pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
723 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
724 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
725 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
726 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
727 pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
728 pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
729 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
730 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
731 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
732 pub fn LLVMRustGetNamedValue(M: &Module, Name: *const c_char) -> Option<&Value>;
733 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
735 // Operations on functions
736 pub fn LLVMRustGetOrInsertFunction(M: &'a Module,
738 FunctionTy: &'a Type)
740 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
741 pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
742 pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
743 pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
744 pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
745 pub fn LLVMRustAddFunctionAttrStringValue(Fn: &Value,
748 Value: *const c_char);
749 pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
751 // Operations on parameters
752 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
753 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
755 // Operations on basic blocks
756 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
757 pub fn LLVMAppendBasicBlockInContext(C: &'a Context,
761 pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
763 // Operations on instructions
764 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
766 // Operations on call sites
767 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
768 pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
769 pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
770 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
771 pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value,
775 // Operations on load/store instructions (only)
776 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
778 // Operations on phi nodes
779 pub fn LLVMAddIncoming(PhiNode: &'a Value,
780 IncomingValues: *const &'a Value,
781 IncomingBlocks: *const &'a BasicBlock,
784 // Instruction builders
785 pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
786 pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
787 pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
788 pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
791 pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: Option<&'a Value>);
792 pub fn LLVMGetCurrentDebugLocation(Builder: &Builder<'a>) -> &'a Value;
793 pub fn LLVMSetInstDebugLocation(Builder: &Builder<'a>, Inst: &'a Value);
796 pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
797 pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
798 pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
799 pub fn LLVMBuildCondBr(B: &Builder<'a>,
801 Then: &'a BasicBlock,
802 Else: &'a BasicBlock)
804 pub fn LLVMBuildSwitch(B: &Builder<'a>,
806 Else: &'a BasicBlock,
809 pub fn LLVMRustBuildInvoke(B: &Builder<'a>,
811 Args: *const &'a Value,
813 Then: &'a BasicBlock,
814 Catch: &'a BasicBlock,
815 Bundle: Option<&OperandBundleDef<'a>>,
818 pub fn LLVMBuildLandingPad(B: &Builder<'a>,
824 pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
825 pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
827 pub fn LLVMRustBuildCleanupPad(B: &Builder<'a>,
828 ParentPad: Option<&'a Value>,
830 Args: *const &'a Value,
832 -> Option<&'a Value>;
833 pub fn LLVMRustBuildCleanupRet(B: &Builder<'a>,
834 CleanupPad: &'a Value,
835 UnwindBB: Option<&'a BasicBlock>)
836 -> Option<&'a Value>;
837 pub fn LLVMRustBuildCatchPad(B: &Builder<'a>,
838 ParentPad: &'a Value,
840 Args: *const &'a Value,
842 -> Option<&'a Value>;
843 pub fn LLVMRustBuildCatchRet(
847 ) -> Option<&'a Value>;
848 pub fn LLVMRustBuildCatchSwitch(Builder: &Builder<'a>,
849 ParentPad: Option<&'a Value>,
850 BB: Option<&'a BasicBlock>,
853 -> Option<&'a Value>;
854 pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
855 pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
857 // Add a case to the switch instruction
858 pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
860 // Add a clause to the landing pad instruction
861 pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
863 // Set the cleanup on a landing pad instruction
864 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
867 pub fn LLVMBuildAdd(B: &Builder<'a>,
872 pub fn LLVMBuildFAdd(B: &Builder<'a>,
877 pub fn LLVMBuildSub(B: &Builder<'a>,
882 pub fn LLVMBuildFSub(B: &Builder<'a>,
887 pub fn LLVMBuildMul(B: &Builder<'a>,
892 pub fn LLVMBuildFMul(B: &Builder<'a>,
897 pub fn LLVMBuildUDiv(B: &Builder<'a>,
902 pub fn LLVMBuildExactUDiv(B: &Builder<'a>,
907 pub fn LLVMBuildSDiv(B: &Builder<'a>,
912 pub fn LLVMBuildExactSDiv(B: &Builder<'a>,
917 pub fn LLVMBuildFDiv(B: &Builder<'a>,
922 pub fn LLVMBuildURem(B: &Builder<'a>,
927 pub fn LLVMBuildSRem(B: &Builder<'a>,
932 pub fn LLVMBuildFRem(B: &Builder<'a>,
937 pub fn LLVMBuildShl(B: &Builder<'a>,
942 pub fn LLVMBuildLShr(B: &Builder<'a>,
947 pub fn LLVMBuildAShr(B: &Builder<'a>,
952 pub fn LLVMBuildAnd(B: &Builder<'a>,
957 pub fn LLVMBuildOr(B: &Builder<'a>,
962 pub fn LLVMBuildXor(B: &Builder<'a>,
967 pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
968 pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
969 pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
970 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: &Value);
973 pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
974 pub fn LLVMBuildArrayAlloca(B: &Builder<'a>,
979 pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
981 pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
983 pub fn LLVMBuildGEP(B: &Builder<'a>,
985 Indices: *const &'a Value,
989 pub fn LLVMBuildInBoundsGEP(B: &Builder<'a>,
991 Indices: *const &'a Value,
995 pub fn LLVMBuildStructGEP(B: &Builder<'a>,
1002 pub fn LLVMBuildTrunc(B: &Builder<'a>,
1005 Name: *const c_char)
1007 pub fn LLVMBuildZExt(B: &Builder<'a>,
1010 Name: *const c_char)
1012 pub fn LLVMBuildSExt(B: &Builder<'a>,
1015 Name: *const c_char)
1017 pub fn LLVMBuildFPToUI(B: &Builder<'a>,
1020 Name: *const c_char)
1022 pub fn LLVMBuildFPToSI(B: &Builder<'a>,
1025 Name: *const c_char)
1027 pub fn LLVMBuildUIToFP(B: &Builder<'a>,
1030 Name: *const c_char)
1032 pub fn LLVMBuildSIToFP(B: &Builder<'a>,
1035 Name: *const c_char)
1037 pub fn LLVMBuildFPTrunc(B: &Builder<'a>,
1040 Name: *const c_char)
1042 pub fn LLVMBuildFPExt(B: &Builder<'a>,
1045 Name: *const c_char)
1047 pub fn LLVMBuildPtrToInt(B: &Builder<'a>,
1050 Name: *const c_char)
1052 pub fn LLVMBuildIntToPtr(B: &Builder<'a>,
1055 Name: *const c_char)
1057 pub fn LLVMBuildBitCast(B: &Builder<'a>,
1060 Name: *const c_char)
1062 pub fn LLVMBuildPointerCast(B: &Builder<'a>,
1065 Name: *const c_char)
1067 pub fn LLVMRustBuildIntCast(B: &Builder<'a>,
1074 pub fn LLVMBuildICmp(B: &Builder<'a>,
1078 Name: *const c_char)
1080 pub fn LLVMBuildFCmp(B: &Builder<'a>,
1084 Name: *const c_char)
1087 // Miscellaneous instructions
1088 pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1089 pub fn LLVMRustBuildCall(B: &Builder<'a>,
1091 Args: *const &'a Value,
1093 Bundle: Option<&OperandBundleDef<'a>>,
1094 Name: *const c_char)
1096 pub fn LLVMRustBuildMemCpy(B: &Builder<'a>,
1104 pub fn LLVMRustBuildMemMove(B: &Builder<'a>,
1112 pub fn LLVMBuildSelect(B: &Builder<'a>,
1116 Name: *const c_char)
1118 pub fn LLVMBuildVAArg(B: &Builder<'a>,
1121 Name: *const c_char)
1123 pub fn LLVMBuildExtractElement(B: &Builder<'a>,
1126 Name: *const c_char)
1128 pub fn LLVMBuildInsertElement(B: &Builder<'a>,
1132 Name: *const c_char)
1134 pub fn LLVMBuildShuffleVector(B: &Builder<'a>,
1138 Name: *const c_char)
1140 pub fn LLVMBuildExtractValue(B: &Builder<'a>,
1143 Name: *const c_char)
1145 pub fn LLVMBuildInsertValue(B: &Builder<'a>,
1149 Name: *const c_char)
1152 pub fn LLVMRustBuildVectorReduceFAdd(B: &Builder<'a>,
1156 pub fn LLVMRustBuildVectorReduceFMul(B: &Builder<'a>,
1160 pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>,
1163 pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>,
1166 pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>,
1169 pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>,
1172 pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>,
1175 pub fn LLVMRustBuildVectorReduceMin(B: &Builder<'a>,
1179 pub fn LLVMRustBuildVectorReduceMax(B: &Builder<'a>,
1183 pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>,
1187 pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>,
1192 pub fn LLVMRustBuildMinNum(
1196 ) -> Option<&'a Value>;
1197 pub fn LLVMRustBuildMaxNum(
1201 ) -> Option<&'a Value>;
1203 // Atomic Operations
1204 pub fn LLVMRustBuildAtomicLoad(B: &Builder<'a>,
1205 PointerVal: &'a Value,
1206 Name: *const c_char,
1207 Order: AtomicOrdering)
1210 pub fn LLVMRustBuildAtomicStore(B: &Builder<'a>,
1213 Order: AtomicOrdering)
1216 pub fn LLVMRustBuildAtomicCmpXchg(B: &Builder<'a>,
1220 Order: AtomicOrdering,
1221 FailureOrder: AtomicOrdering,
1225 pub fn LLVMBuildAtomicRMW(B: &Builder<'a>,
1229 Order: AtomicOrdering,
1230 SingleThreaded: Bool)
1233 pub fn LLVMRustBuildAtomicFence(B: &Builder,
1234 Order: AtomicOrdering,
1235 Scope: SynchronizationScope);
1237 /// Writes a module to the specified path. Returns 0 on success.
1238 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1240 /// Creates a pass manager.
1241 pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1243 /// Creates a function-by-function pass manager
1244 pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1246 /// Disposes a pass manager.
1247 pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1249 /// Runs a pass manager on a module.
1250 pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1252 pub fn LLVMInitializePasses();
1254 pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1255 pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1256 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1257 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1258 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: &PassManagerBuilder,
1260 pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: &PassManagerBuilder,
1263 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: &PassManagerBuilder,
1265 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: &PassManagerBuilder,
1269 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1270 PMB: &PassManagerBuilder,
1273 // Stuff that's in rustllvm/ because it's not upstream yet.
1275 /// Opens an object file.
1276 pub fn LLVMCreateObjectFile(
1277 MemBuf: &'static mut MemoryBuffer,
1278 ) -> Option<&'static mut ObjectFile>;
1279 /// Closes an object file.
1280 pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1282 /// Enumerates the sections in an object file.
1283 pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1284 /// Destroys a section iterator.
1285 pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1286 /// Returns true if the section iterator is at the end of the section
1288 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1289 /// Moves the section iterator to point to the next section.
1290 pub fn LLVMMoveToNextSection(SI: &SectionIterator);
1291 /// Returns the current section size.
1292 pub fn LLVMGetSectionSize(SI: &SectionIterator) -> c_ulonglong;
1293 /// Returns the current section contents as a string buffer.
1294 pub fn LLVMGetSectionContents(SI: &SectionIterator) -> *const c_char;
1296 /// Reads the given file and returns it as a memory buffer. Use
1297 /// LLVMDisposeMemoryBuffer() to get rid of it.
1298 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1299 Path: *const c_char,
1300 ) -> Option<&'static mut MemoryBuffer>;
1302 pub fn LLVMStartMultithreaded() -> Bool;
1304 /// Returns a string describing the last error caused by an LLVMRust* call.
1305 pub fn LLVMRustGetLastError() -> *const c_char;
1307 /// Print the pass timings since static dtors aren't picking them up.
1308 pub fn LLVMRustPrintPassTimings();
1310 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1312 pub fn LLVMStructSetBody(StructTy: &'a Type,
1313 ElementTypes: *const &'a Type,
1314 ElementCount: c_uint,
1317 /// Prepares inline assembly.
1318 pub fn LLVMRustInlineAsm(Ty: &Type,
1319 AsmString: *const c_char,
1320 Constraints: *const c_char,
1323 Dialect: AsmDialect)
1325 pub fn LLVMRustInlineAsmVerify(Ty: &Type,
1326 Constraints: *const c_char)
1329 pub fn LLVMRustDebugMetadataVersion() -> u32;
1330 pub fn LLVMRustVersionMajor() -> u32;
1331 pub fn LLVMRustVersionMinor() -> u32;
1333 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1335 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1337 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1339 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1341 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder);
1343 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: &DIBuilder<'a>,
1346 Producer: *const c_char,
1348 Flags: *const c_char,
1350 SplitName: *const c_char)
1351 -> &'a DIDescriptor;
1353 pub fn LLVMRustDIBuilderCreateFile(Builder: &DIBuilder<'a>,
1354 Filename: *const c_char,
1355 Directory: *const c_char)
1358 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: &DIBuilder<'a>,
1360 ParameterTypes: &'a DIArray)
1361 -> &'a DICompositeType;
1363 pub fn LLVMRustDIBuilderCreateFunction(Builder: &DIBuilder<'a>,
1364 Scope: &'a DIDescriptor,
1365 Name: *const c_char,
1366 LinkageName: *const c_char,
1370 isLocalToUnit: bool,
1376 TParam: &'a DIArray,
1377 Decl: Option<&'a DIDescriptor>)
1378 -> &'a DISubprogram;
1380 pub fn LLVMRustDIBuilderCreateBasicType(Builder: &DIBuilder<'a>,
1381 Name: *const c_char,
1387 pub fn LLVMRustDIBuilderCreatePointerType(Builder: &DIBuilder<'a>,
1388 PointeeTy: &'a DIType,
1391 Name: *const c_char)
1392 -> &'a DIDerivedType;
1394 pub fn LLVMRustDIBuilderCreateStructType(Builder: &DIBuilder<'a>,
1395 Scope: Option<&'a DIDescriptor>,
1396 Name: *const c_char,
1402 DerivedFrom: Option<&'a DIType>,
1403 Elements: &'a DIArray,
1404 RunTimeLang: c_uint,
1405 VTableHolder: Option<&'a DIType>,
1406 UniqueId: *const c_char)
1407 -> &'a DICompositeType;
1409 pub fn LLVMRustDIBuilderCreateMemberType(Builder: &DIBuilder<'a>,
1410 Scope: &'a DIDescriptor,
1411 Name: *const c_char,
1419 -> &'a DIDerivedType;
1421 pub fn LLVMRustDIBuilderCreateVariantMemberType(Builder: &DIBuilder<'a>,
1423 Name: *const c_char,
1429 Discriminant: Option<&'a Value>,
1434 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: &DIBuilder<'a>,
1439 -> &'a DILexicalBlock;
1441 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: &DIBuilder<'a>,
1444 -> &'a DILexicalBlock;
1446 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: &DIBuilder<'a>,
1447 Context: Option<&'a DIScope>,
1448 Name: *const c_char,
1449 LinkageName: *const c_char,
1453 isLocalToUnit: bool,
1455 Decl: Option<&'a DIDescriptor>,
1457 -> &'a DIGlobalVariableExpression;
1459 pub fn LLVMRustDIBuilderCreateVariable(Builder: &DIBuilder<'a>,
1461 Scope: &'a DIDescriptor,
1462 Name: *const c_char,
1466 AlwaysPreserve: bool,
1472 pub fn LLVMRustDIBuilderCreateArrayType(Builder: &DIBuilder<'a>,
1476 Subscripts: &'a DIArray)
1479 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: &DIBuilder<'a>,
1484 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: &DIBuilder<'a>,
1485 Ptr: *const Option<&'a DIDescriptor>,
1489 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: &DIBuilder<'a>,
1491 VarInfo: &'a DIVariable,
1492 AddrOps: *const i64,
1493 AddrOpsCount: c_uint,
1495 InsertAtEnd: &'a BasicBlock)
1498 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: &DIBuilder<'a>,
1499 Name: *const c_char,
1501 -> &'a DIEnumerator;
1503 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: &DIBuilder<'a>,
1505 Name: *const c_char,
1510 Elements: &'a DIArray,
1511 ClassType: &'a DIType,
1515 pub fn LLVMRustDIBuilderCreateUnionType(Builder: &DIBuilder<'a>,
1517 Name: *const c_char,
1523 Elements: Option<&'a DIArray>,
1524 RunTimeLang: c_uint,
1525 UniqueId: *const c_char)
1528 pub fn LLVMRustDIBuilderCreateVariantPart(Builder: &DIBuilder<'a>,
1530 Name: *const c_char,
1536 Discriminator: Option<&'a DIDerivedType>,
1537 Elements: &'a DIArray,
1538 UniqueId: *const c_char)
1539 -> &'a DIDerivedType;
1541 pub fn LLVMSetUnnamedAddr(GlobalVar: &Value, UnnamedAddr: Bool);
1543 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: &DIBuilder<'a>,
1544 Scope: Option<&'a DIScope>,
1545 Name: *const c_char,
1550 -> &'a DITemplateTypeParameter;
1553 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: &DIBuilder<'a>,
1554 Scope: Option<&'a DIScope>,
1555 Name: *const c_char,
1560 pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: &DIBuilder<'a>,
1561 CompositeType: &'a DIType,
1562 TypeArray: &'a DIArray);
1565 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: &'a Context,
1569 InlinedAt: Option<&'a Metadata>)
1571 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1572 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
1575 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1577 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
1578 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
1582 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&Value>;
1583 pub fn LLVMIsAConstantFP(value_ref: &Value) -> Option<&Value>;
1585 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
1586 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
1587 pub fn LLVMRustAddPass(PM: &PassManager, Pass: &'static mut Pass);
1589 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
1591 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
1592 pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
1594 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
1595 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1597 Features: *const c_char,
1600 Level: CodeGenOptLevel,
1602 PositionIndependentExecutable: bool,
1603 FunctionSections: bool,
1605 TrapUnreachable: bool,
1608 EmitStackSizeSection: bool)
1609 -> Option<&'static mut TargetMachine>;
1610 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
1611 pub fn LLVMRustAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>, M: &'a Module);
1612 pub fn LLVMRustAddBuilderLibraryInfo(PMB: &'a PassManagerBuilder,
1614 DisableSimplifyLibCalls: bool);
1615 pub fn LLVMRustConfigurePassManagerBuilder(PMB: &PassManagerBuilder,
1616 OptLevel: CodeGenOptLevel,
1617 MergeFunctions: bool,
1619 LoopVectorize: bool,
1620 PrepareForThinLTO: bool,
1621 PGOGenPath: *const c_char,
1622 PGOUsePath: *const c_char);
1623 pub fn LLVMRustAddLibraryInfo(PM: &PassManager<'a>,
1625 DisableSimplifyLibCalls: bool);
1626 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
1627 pub fn LLVMRustWriteOutputFile(T: &'a TargetMachine,
1628 PM: &PassManager<'a>,
1630 Output: *const c_char,
1633 pub fn LLVMRustPrintModule(PM: &PassManager<'a>,
1635 Output: *const c_char,
1636 Demangle: extern fn(*const c_char,
1640 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1641 pub fn LLVMRustPrintPasses();
1642 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
1643 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
1644 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
1645 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
1647 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
1648 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
1649 pub fn LLVMRustArchiveIteratorNext(
1650 AIR: &ArchiveIterator<'a>,
1651 ) -> Option<&'a mut ArchiveChild<'a>>;
1652 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
1653 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
1654 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
1655 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
1656 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
1658 pub fn LLVMRustGetSectionName(SI: &SectionIterator, data: &mut *const c_char) -> size_t;
1661 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1663 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
1667 pub fn LLVMContextSetDiagnosticHandler(C: &Context,
1668 Handler: DiagnosticHandler,
1669 DiagnosticContext: *mut c_void);
1672 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1674 pub fn LLVMRustUnpackOptimizationDiagnostic(DI: &'a DiagnosticInfo,
1675 pass_name_out: &RustString,
1676 function_out: &mut Option<&'a Value>,
1677 loc_line_out: &mut c_uint,
1678 loc_column_out: &mut c_uint,
1679 loc_filename_out: &RustString,
1680 message_out: &RustString);
1684 pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: &'a DiagnosticInfo,
1685 cookie_out: &mut c_uint,
1686 message_out: &mut Option<&'a Twine>,
1687 instruction_out: &mut Option<&'a Value>);
1690 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1692 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
1696 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
1698 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: &Context,
1699 H: InlineAsmDiagHandler,
1703 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1705 pub fn LLVMRustWriteSMDiagnosticToString(d: &SMDiagnostic, s: &RustString);
1709 pub fn LLVMRustWriteArchive(Dst: *const c_char,
1711 Members: *const &RustArchiveMember,
1715 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1716 Name: *const c_char,
1717 Child: Option<&ArchiveChild<'a>>)
1718 -> &'a mut RustArchiveMember<'a>;
1719 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
1721 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
1723 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1724 Inputs: *const &'a Value,
1726 -> &'a mut OperandBundleDef<'a>;
1727 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
1729 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
1731 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char);
1732 pub fn LLVMRustUnsetComdat(V: &Value);
1733 pub fn LLVMRustSetModulePIELevel(M: &Module);
1734 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
1735 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
1736 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
1737 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
1738 pub fn LLVMRustModuleCost(M: &Module) -> u64;
1740 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
1741 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
1742 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
1743 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
1744 pub fn LLVMRustCreateThinLTOData(
1745 Modules: *const ThinLTOModule,
1747 PreservedSymbols: *const *const c_char,
1748 PreservedSymbolsLen: c_uint,
1749 ) -> Option<&'static mut ThinLTOData>;
1750 pub fn LLVMRustPrepareThinLTORename(
1754 pub fn LLVMRustPrepareThinLTOResolveWeak(
1758 pub fn LLVMRustPrepareThinLTOInternalize(
1762 pub fn LLVMRustPrepareThinLTOImport(
1766 pub fn LLVMRustGetThinLTOModuleImports(
1767 Data: *const ThinLTOData,
1768 ModuleNameCallback: ThinLTOModuleNameCallback,
1769 CallbackPayload: *mut c_void,
1771 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
1772 pub fn LLVMRustParseBitcodeForThinLTO(
1776 Identifier: *const c_char,
1777 ) -> Option<&Module>;
1778 pub fn LLVMRustThinLTOGetDICompileUnit(M: &Module,
1779 CU1: &mut *mut c_void,
1780 CU2: &mut *mut c_void);
1781 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
1783 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
1784 pub fn LLVMRustLinkerAdd(linker: &Linker,
1785 bytecode: *const c_char,
1786 bytecode_len: usize) -> bool;
1787 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);