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;
23 use rustc_codegen_ssa;
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: rustc_codegen_ssa::common::IntPredicate) -> Self {
149 rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
150 rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
151 rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
152 rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
153 rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
154 rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
155 rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
156 rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
157 rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
158 rustc_codegen_ssa::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: rustc_codegen_ssa::common::RealPredicate) -> Self {
188 rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse =>
189 RealPredicate::RealPredicateFalse,
190 rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
191 rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
192 rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
193 rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
194 rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
195 rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
196 rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
197 rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
198 rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
199 rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
200 rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
201 rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
202 rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
203 rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
204 rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue =>
205 RealPredicate::RealPredicateTrue
211 #[derive(Copy, Clone, PartialEq, Debug)]
234 pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
236 TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
237 TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
238 TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
239 TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
240 TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
241 TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
242 TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
243 TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
244 TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
245 TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
246 TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
247 TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
248 TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
249 TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
250 TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
251 TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
252 TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
257 /// LLVMAtomicRmwBinOp
258 #[derive(Copy, Clone)]
260 pub enum AtomicRmwBinOp {
274 impl AtomicRmwBinOp {
275 pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
277 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
278 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
279 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
280 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
281 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
282 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
283 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
284 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
285 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
286 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
287 rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin
292 /// LLVMAtomicOrdering
293 #[derive(Copy, Clone)]
295 pub enum AtomicOrdering {
300 // Consume = 3, // Not specified yet.
304 SequentiallyConsistent = 7,
307 impl AtomicOrdering {
308 pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
310 rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
311 rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
312 rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
313 rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
314 rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
315 rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease =>
316 AtomicOrdering::AcquireRelease,
317 rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent =>
318 AtomicOrdering::SequentiallyConsistent
324 /// LLVMRustSynchronizationScope
325 #[derive(Copy, Clone)]
327 pub enum SynchronizationScope {
328 // FIXME: figure out if this variant is needed at all.
335 impl SynchronizationScope {
336 pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
338 rustc_codegen_ssa::common::SynchronizationScope::Other => SynchronizationScope::Other,
339 rustc_codegen_ssa::common::SynchronizationScope::SingleThread =>
340 SynchronizationScope::SingleThread,
341 rustc_codegen_ssa::common::SynchronizationScope::CrossThread =>
342 SynchronizationScope::CrossThread,
348 #[derive(Copy, Clone)]
351 // FIXME: figure out if this variant is needed at all.
359 #[derive(Copy, Clone)]
361 pub enum MetadataType {
368 MD_invariant_load = 6,
372 MD_mem_parallel_loop_access = 10,
376 /// LLVMRustAsmDialect
377 #[derive(Copy, Clone)]
379 pub enum AsmDialect {
380 // FIXME: figure out if this variant is needed at all.
388 pub fn from_generic(asm: syntax::ast::AsmDialect) -> Self {
390 syntax::ast::AsmDialect::Att => AsmDialect::Att,
391 syntax::ast::AsmDialect::Intel => AsmDialect::Intel
396 /// LLVMRustCodeGenOptLevel
397 #[derive(Copy, Clone, PartialEq)]
399 pub enum CodeGenOptLevel {
400 // FIXME: figure out if this variant is needed at all.
410 #[derive(Copy, Clone, PartialEq)]
422 /// LLVMRustCodeModel
423 #[derive(Copy, Clone)]
426 // FIXME: figure out if this variant is needed at all.
436 /// LLVMRustDiagnosticKind
437 #[derive(Copy, Clone)]
439 #[allow(dead_code)] // Variants constructed by C++.
440 pub enum DiagnosticKind {
444 DebugMetadataVersion,
447 OptimizationRemarkMissed,
448 OptimizationRemarkAnalysis,
449 OptimizationRemarkAnalysisFPCommute,
450 OptimizationRemarkAnalysisAliasing,
451 OptimizationRemarkOther,
457 /// LLVMRustArchiveKind
458 #[derive(Copy, Clone)]
460 pub enum ArchiveKind {
461 // FIXME: figure out if this variant is needed at all.
470 #[derive(Copy, Clone, PartialEq, Debug)]
472 #[allow(dead_code)] // Variants constructed by C++.
479 /// LLVMRustThinLTOData
480 extern { pub type ThinLTOData; }
482 /// LLVMRustThinLTOBuffer
483 extern { pub type ThinLTOBuffer; }
485 // LLVMRustModuleNameCallback
486 pub type ThinLTOModuleNameCallback =
487 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
489 /// LLVMRustThinLTOModule
491 pub struct ThinLTOModule {
492 pub identifier: *const c_char,
497 /// LLVMThreadLocalMode
498 #[derive(Copy, Clone)]
500 pub enum ThreadLocalMode {
508 extern { type Opaque; }
510 struct InvariantOpaque<'a> {
511 _marker: PhantomData<&'a mut &'a ()>,
515 // Opaque pointer types
516 extern { pub type Module; }
517 extern { pub type Context; }
518 extern { pub type Type; }
519 extern { pub type Value; }
520 extern { pub type Metadata; }
521 extern { pub type BasicBlock; }
523 pub struct Builder<'a>(InvariantOpaque<'a>);
524 extern { pub type MemoryBuffer; }
526 pub struct PassManager<'a>(InvariantOpaque<'a>);
527 extern { pub type PassManagerBuilder; }
528 extern { pub type ObjectFile; }
530 pub struct SectionIterator<'a>(InvariantOpaque<'a>);
531 extern { pub type Pass; }
532 extern { pub type TargetMachine; }
533 extern { pub type Archive; }
535 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
537 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
538 extern { pub type Twine; }
539 extern { pub type DiagnosticInfo; }
540 extern { pub type SMDiagnostic; }
542 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
544 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
546 pub struct Linker<'a>(InvariantOpaque<'a>);
548 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
549 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
553 use super::{InvariantOpaque, Metadata};
556 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
558 pub type DIDescriptor = Metadata;
559 pub type DIScope = DIDescriptor;
560 pub type DIFile = DIScope;
561 pub type DILexicalBlock = DIScope;
562 pub type DISubprogram = DIScope;
563 pub type DINameSpace = DIScope;
564 pub type DIType = DIDescriptor;
565 pub type DIBasicType = DIType;
566 pub type DIDerivedType = DIType;
567 pub type DICompositeType = DIDerivedType;
568 pub type DIVariable = DIDescriptor;
569 pub type DIGlobalVariableExpression = DIDescriptor;
570 pub type DIArray = DIDescriptor;
571 pub type DISubrange = DIDescriptor;
572 pub type DIEnumerator = DIDescriptor;
573 pub type DITemplateTypeParameter = DIDescriptor;
575 // These values **must** match with LLVMRustDIFlags!!
579 pub struct DIFlags: ::libc::uint32_t {
581 const FlagPrivate = 1;
582 const FlagProtected = 2;
583 const FlagPublic = 3;
584 const FlagFwdDecl = (1 << 2);
585 const FlagAppleBlock = (1 << 3);
586 const FlagBlockByrefStruct = (1 << 4);
587 const FlagVirtual = (1 << 5);
588 const FlagArtificial = (1 << 6);
589 const FlagExplicit = (1 << 7);
590 const FlagPrototyped = (1 << 8);
591 const FlagObjcClassComplete = (1 << 9);
592 const FlagObjectPointer = (1 << 10);
593 const FlagVector = (1 << 11);
594 const FlagStaticMember = (1 << 12);
595 const FlagLValueReference = (1 << 13);
596 const FlagRValueReference = (1 << 14);
597 const FlagExternalTypeRef = (1 << 15);
598 const FlagIntroducedVirtual = (1 << 18);
599 const FlagBitField = (1 << 19);
600 const FlagNoReturn = (1 << 20);
601 const FlagMainSubprogram = (1 << 21);
606 extern { pub type ModuleBuffer; }
609 pub fn LLVMRustInstallFatalErrorHandler();
611 // Create and destroy contexts.
612 pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
613 pub fn LLVMContextDispose(C: &'static mut Context);
614 pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
617 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
618 pub fn LLVMGetModuleContext(M: &Module) -> &Context;
619 pub fn LLVMCloneModule(M: &Module) -> &Module;
621 /// Data layout. See Module::getDataLayout.
622 pub fn LLVMGetDataLayout(M: &Module) -> *const c_char;
623 pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
625 /// See Module::setModuleInlineAsm.
626 pub fn LLVMSetModuleInlineAsm(M: &Module, Asm: *const c_char);
627 pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char);
629 /// See llvm::LLVMTypeKind::getTypeID.
630 pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
632 // Operations on integer types
633 pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
634 pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
635 pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
636 pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
637 pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
638 pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
640 pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
642 // Operations on real types
643 pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
644 pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
646 // Operations on function types
647 pub fn LLVMFunctionType(ReturnType: &'a Type,
648 ParamTypes: *const &'a Type,
652 pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
653 pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
655 // Operations on struct types
656 pub fn LLVMStructTypeInContext(C: &'a Context,
657 ElementTypes: *const &'a Type,
658 ElementCount: c_uint,
662 // Operations on array, pointer, and vector types (sequence types)
663 pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
664 pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
665 pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
667 pub fn LLVMGetElementType(Ty: &Type) -> &Type;
668 pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
670 // Operations on other types
671 pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
672 pub fn LLVMX86MMXTypeInContext(C: &Context) -> &Type;
673 pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
675 // Operations on all values
676 pub fn LLVMTypeOf(Val: &Value) -> &Type;
677 pub fn LLVMGetValueName(Val: &Value) -> *const c_char;
678 pub fn LLVMSetValueName(Val: &Value, Name: *const c_char);
679 pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
680 pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
682 // Operations on constants of any type
683 pub fn LLVMConstNull(Ty: &Type) -> &Value;
684 pub fn LLVMGetUndef(Ty: &Type) -> &Value;
686 // Operations on metadata
687 pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
688 pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
689 pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
691 // Operations on scalar constants
692 pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
693 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
694 pub fn LLVMConstIntGetZExtValue(ConstantVal: &Value) -> c_ulonglong;
695 pub fn LLVMRustConstInt128Get(ConstantVal: &Value, SExt: bool,
696 high: &mut u64, low: &mut u64) -> bool;
697 pub fn LLVMConstRealGetDouble (ConstantVal: &Value, losesInfo: &mut Bool) -> f64;
700 // Operations on composite constants
701 pub fn LLVMConstStringInContext(C: &Context,
704 DontNullTerminate: Bool)
706 pub fn LLVMConstStructInContext(C: &'a Context,
707 ConstantVals: *const &'a Value,
712 pub fn LLVMConstArray(ElementTy: &'a Type,
713 ConstantVals: *const &'a Value,
716 pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
718 // Constant expressions
719 pub fn LLVMConstInBoundsGEP(
720 ConstantVal: &'a Value,
721 ConstantIndices: *const &'a Value,
724 pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
725 pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
726 pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
727 pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
728 pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
729 pub fn LLVMConstExtractValue(AggConstant: &Value,
730 IdxList: *const c_uint,
734 // Operations on global variables, functions, and aliases (globals)
735 pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
736 pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
737 pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
738 pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
739 pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
740 pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
741 pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
742 pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
743 pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
746 // Operations on global variables
747 pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
748 pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
749 pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
750 pub fn LLVMRustGetOrInsertGlobal(M: &'a Module, Name: *const c_char, T: &'a Type) -> &'a Value;
751 pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
752 pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
753 pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
754 pub fn LLVMDeleteGlobal(GlobalVar: &Value);
755 pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
756 pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
757 pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
758 pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
759 pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
760 pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
761 pub fn LLVMRustGetNamedValue(M: &Module, Name: *const c_char) -> Option<&Value>;
762 pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
764 // Operations on functions
765 pub fn LLVMRustGetOrInsertFunction(M: &'a Module,
767 FunctionTy: &'a Type)
769 pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
770 pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
771 pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
772 pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
773 pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
774 pub fn LLVMRustAddFunctionAttrStringValue(Fn: &Value,
777 Value: *const c_char);
778 pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
780 // Operations on parameters
781 pub fn LLVMCountParams(Fn: &Value) -> c_uint;
782 pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
784 // Operations on basic blocks
785 pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
786 pub fn LLVMAppendBasicBlockInContext(C: &'a Context,
790 pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
792 // Operations on instructions
793 pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
795 // Operations on call sites
796 pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
797 pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
798 pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
799 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
800 pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value,
804 // Operations on load/store instructions (only)
805 pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
807 // Operations on phi nodes
808 pub fn LLVMAddIncoming(PhiNode: &'a Value,
809 IncomingValues: *const &'a Value,
810 IncomingBlocks: *const &'a BasicBlock,
813 // Instruction builders
814 pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
815 pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
816 pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
817 pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
820 pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: Option<&'a Value>);
821 pub fn LLVMGetCurrentDebugLocation(Builder: &Builder<'a>) -> &'a Value;
822 pub fn LLVMSetInstDebugLocation(Builder: &Builder<'a>, Inst: &'a Value);
825 pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
826 pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
827 pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
828 pub fn LLVMBuildCondBr(B: &Builder<'a>,
830 Then: &'a BasicBlock,
831 Else: &'a BasicBlock)
833 pub fn LLVMBuildSwitch(B: &Builder<'a>,
835 Else: &'a BasicBlock,
838 pub fn LLVMRustBuildInvoke(B: &Builder<'a>,
840 Args: *const &'a Value,
842 Then: &'a BasicBlock,
843 Catch: &'a BasicBlock,
844 Bundle: Option<&OperandBundleDef<'a>>,
847 pub fn LLVMBuildLandingPad(B: &Builder<'a>,
853 pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
854 pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
856 pub fn LLVMRustBuildCleanupPad(B: &Builder<'a>,
857 ParentPad: Option<&'a Value>,
859 Args: *const &'a Value,
861 -> Option<&'a Value>;
862 pub fn LLVMRustBuildCleanupRet(B: &Builder<'a>,
863 CleanupPad: &'a Value,
864 UnwindBB: Option<&'a BasicBlock>)
865 -> Option<&'a Value>;
866 pub fn LLVMRustBuildCatchPad(B: &Builder<'a>,
867 ParentPad: &'a Value,
869 Args: *const &'a Value,
871 -> Option<&'a Value>;
872 pub fn LLVMRustBuildCatchRet(
876 ) -> Option<&'a Value>;
877 pub fn LLVMRustBuildCatchSwitch(Builder: &Builder<'a>,
878 ParentPad: Option<&'a Value>,
879 BB: Option<&'a BasicBlock>,
882 -> Option<&'a Value>;
883 pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
884 pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
886 // Add a case to the switch instruction
887 pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
889 // Add a clause to the landing pad instruction
890 pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
892 // Set the cleanup on a landing pad instruction
893 pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
896 pub fn LLVMBuildAdd(B: &Builder<'a>,
901 pub fn LLVMBuildFAdd(B: &Builder<'a>,
906 pub fn LLVMBuildSub(B: &Builder<'a>,
911 pub fn LLVMBuildFSub(B: &Builder<'a>,
916 pub fn LLVMBuildMul(B: &Builder<'a>,
921 pub fn LLVMBuildFMul(B: &Builder<'a>,
926 pub fn LLVMBuildUDiv(B: &Builder<'a>,
931 pub fn LLVMBuildExactUDiv(B: &Builder<'a>,
936 pub fn LLVMBuildSDiv(B: &Builder<'a>,
941 pub fn LLVMBuildExactSDiv(B: &Builder<'a>,
946 pub fn LLVMBuildFDiv(B: &Builder<'a>,
951 pub fn LLVMBuildURem(B: &Builder<'a>,
956 pub fn LLVMBuildSRem(B: &Builder<'a>,
961 pub fn LLVMBuildFRem(B: &Builder<'a>,
966 pub fn LLVMBuildShl(B: &Builder<'a>,
971 pub fn LLVMBuildLShr(B: &Builder<'a>,
976 pub fn LLVMBuildAShr(B: &Builder<'a>,
981 pub fn LLVMBuildAnd(B: &Builder<'a>,
986 pub fn LLVMBuildOr(B: &Builder<'a>,
991 pub fn LLVMBuildXor(B: &Builder<'a>,
996 pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
997 pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
998 pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
999 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: &Value);
1002 pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1003 pub fn LLVMBuildArrayAlloca(B: &Builder<'a>,
1006 Name: *const c_char)
1008 pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
1010 pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1012 pub fn LLVMBuildGEP(B: &Builder<'a>,
1014 Indices: *const &'a Value,
1016 Name: *const c_char)
1018 pub fn LLVMBuildInBoundsGEP(B: &Builder<'a>,
1020 Indices: *const &'a Value,
1022 Name: *const c_char)
1024 pub fn LLVMBuildStructGEP(B: &Builder<'a>,
1027 Name: *const c_char)
1031 pub fn LLVMBuildTrunc(B: &Builder<'a>,
1034 Name: *const c_char)
1036 pub fn LLVMBuildZExt(B: &Builder<'a>,
1039 Name: *const c_char)
1041 pub fn LLVMBuildSExt(B: &Builder<'a>,
1044 Name: *const c_char)
1046 pub fn LLVMBuildFPToUI(B: &Builder<'a>,
1049 Name: *const c_char)
1051 pub fn LLVMBuildFPToSI(B: &Builder<'a>,
1054 Name: *const c_char)
1056 pub fn LLVMBuildUIToFP(B: &Builder<'a>,
1059 Name: *const c_char)
1061 pub fn LLVMBuildSIToFP(B: &Builder<'a>,
1064 Name: *const c_char)
1066 pub fn LLVMBuildFPTrunc(B: &Builder<'a>,
1069 Name: *const c_char)
1071 pub fn LLVMBuildFPExt(B: &Builder<'a>,
1074 Name: *const c_char)
1076 pub fn LLVMBuildPtrToInt(B: &Builder<'a>,
1079 Name: *const c_char)
1081 pub fn LLVMBuildIntToPtr(B: &Builder<'a>,
1084 Name: *const c_char)
1086 pub fn LLVMBuildBitCast(B: &Builder<'a>,
1089 Name: *const c_char)
1091 pub fn LLVMBuildPointerCast(B: &Builder<'a>,
1094 Name: *const c_char)
1096 pub fn LLVMRustBuildIntCast(B: &Builder<'a>,
1103 pub fn LLVMBuildICmp(B: &Builder<'a>,
1107 Name: *const c_char)
1109 pub fn LLVMBuildFCmp(B: &Builder<'a>,
1113 Name: *const c_char)
1116 // Miscellaneous instructions
1117 pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1118 pub fn LLVMRustBuildCall(B: &Builder<'a>,
1120 Args: *const &'a Value,
1122 Bundle: Option<&OperandBundleDef<'a>>,
1123 Name: *const c_char)
1125 pub fn LLVMRustBuildMemCpy(B: &Builder<'a>,
1133 pub fn LLVMRustBuildMemMove(B: &Builder<'a>,
1141 pub fn LLVMBuildSelect(B: &Builder<'a>,
1145 Name: *const c_char)
1147 pub fn LLVMBuildVAArg(B: &Builder<'a>,
1150 Name: *const c_char)
1152 pub fn LLVMBuildExtractElement(B: &Builder<'a>,
1155 Name: *const c_char)
1157 pub fn LLVMBuildInsertElement(B: &Builder<'a>,
1161 Name: *const c_char)
1163 pub fn LLVMBuildShuffleVector(B: &Builder<'a>,
1167 Name: *const c_char)
1169 pub fn LLVMBuildExtractValue(B: &Builder<'a>,
1172 Name: *const c_char)
1174 pub fn LLVMBuildInsertValue(B: &Builder<'a>,
1178 Name: *const c_char)
1181 pub fn LLVMRustBuildVectorReduceFAdd(B: &Builder<'a>,
1185 pub fn LLVMRustBuildVectorReduceFMul(B: &Builder<'a>,
1189 pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>,
1192 pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>,
1195 pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>,
1198 pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>,
1201 pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>,
1204 pub fn LLVMRustBuildVectorReduceMin(B: &Builder<'a>,
1208 pub fn LLVMRustBuildVectorReduceMax(B: &Builder<'a>,
1212 pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>,
1216 pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>,
1221 pub fn LLVMRustBuildMinNum(
1226 pub fn LLVMRustBuildMaxNum(
1232 // Atomic Operations
1233 pub fn LLVMRustBuildAtomicLoad(B: &Builder<'a>,
1234 PointerVal: &'a Value,
1235 Name: *const c_char,
1236 Order: AtomicOrdering)
1239 pub fn LLVMRustBuildAtomicStore(B: &Builder<'a>,
1242 Order: AtomicOrdering)
1245 pub fn LLVMRustBuildAtomicCmpXchg(B: &Builder<'a>,
1249 Order: AtomicOrdering,
1250 FailureOrder: AtomicOrdering,
1254 pub fn LLVMBuildAtomicRMW(B: &Builder<'a>,
1258 Order: AtomicOrdering,
1259 SingleThreaded: Bool)
1262 pub fn LLVMRustBuildAtomicFence(B: &Builder,
1263 Order: AtomicOrdering,
1264 Scope: SynchronizationScope);
1266 /// Writes a module to the specified path. Returns 0 on success.
1267 pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1269 /// Creates a pass manager.
1270 pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1272 /// Creates a function-by-function pass manager
1273 pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1275 /// Disposes a pass manager.
1276 pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1278 /// Runs a pass manager on a module.
1279 pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1281 pub fn LLVMInitializePasses();
1283 pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1284 pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1285 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1286 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1287 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: &PassManagerBuilder,
1289 pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: &PassManagerBuilder,
1292 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: &PassManagerBuilder,
1294 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: &PassManagerBuilder,
1298 pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1299 PMB: &PassManagerBuilder,
1302 // Stuff that's in rustllvm/ because it's not upstream yet.
1304 /// Opens an object file.
1305 pub fn LLVMCreateObjectFile(
1306 MemBuf: &'static mut MemoryBuffer,
1307 ) -> Option<&'static mut ObjectFile>;
1308 /// Closes an object file.
1309 pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1311 /// Enumerates the sections in an object file.
1312 pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1313 /// Destroys a section iterator.
1314 pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1315 /// Returns true if the section iterator is at the end of the section
1317 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1318 /// Moves the section iterator to point to the next section.
1319 pub fn LLVMMoveToNextSection(SI: &SectionIterator);
1320 /// Returns the current section size.
1321 pub fn LLVMGetSectionSize(SI: &SectionIterator) -> c_ulonglong;
1322 /// Returns the current section contents as a string buffer.
1323 pub fn LLVMGetSectionContents(SI: &SectionIterator) -> *const c_char;
1325 /// Reads the given file and returns it as a memory buffer. Use
1326 /// LLVMDisposeMemoryBuffer() to get rid of it.
1327 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1328 Path: *const c_char,
1329 ) -> Option<&'static mut MemoryBuffer>;
1331 pub fn LLVMStartMultithreaded() -> Bool;
1333 /// Returns a string describing the last error caused by an LLVMRust* call.
1334 pub fn LLVMRustGetLastError() -> *const c_char;
1336 /// Print the pass timings since static dtors aren't picking them up.
1337 pub fn LLVMRustPrintPassTimings();
1339 pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1341 pub fn LLVMStructSetBody(StructTy: &'a Type,
1342 ElementTypes: *const &'a Type,
1343 ElementCount: c_uint,
1346 /// Prepares inline assembly.
1347 pub fn LLVMRustInlineAsm(Ty: &Type,
1348 AsmString: *const c_char,
1349 Constraints: *const c_char,
1352 Dialect: AsmDialect)
1354 pub fn LLVMRustInlineAsmVerify(Ty: &Type,
1355 Constraints: *const c_char)
1358 pub fn LLVMRustDebugMetadataVersion() -> u32;
1359 pub fn LLVMRustVersionMajor() -> u32;
1360 pub fn LLVMRustVersionMinor() -> u32;
1361 pub fn LLVMRustIsRustLLVM() -> bool;
1363 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1365 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1367 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1369 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1371 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder);
1373 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: &DIBuilder<'a>,
1376 Producer: *const c_char,
1378 Flags: *const c_char,
1380 SplitName: *const c_char)
1381 -> &'a DIDescriptor;
1383 pub fn LLVMRustDIBuilderCreateFile(Builder: &DIBuilder<'a>,
1384 Filename: *const c_char,
1385 Directory: *const c_char)
1388 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: &DIBuilder<'a>,
1390 ParameterTypes: &'a DIArray)
1391 -> &'a DICompositeType;
1393 pub fn LLVMRustDIBuilderCreateFunction(Builder: &DIBuilder<'a>,
1394 Scope: &'a DIDescriptor,
1395 Name: *const c_char,
1396 LinkageName: *const c_char,
1400 isLocalToUnit: bool,
1406 TParam: &'a DIArray,
1407 Decl: Option<&'a DIDescriptor>)
1408 -> &'a DISubprogram;
1410 pub fn LLVMRustDIBuilderCreateBasicType(Builder: &DIBuilder<'a>,
1411 Name: *const c_char,
1417 pub fn LLVMRustDIBuilderCreatePointerType(Builder: &DIBuilder<'a>,
1418 PointeeTy: &'a DIType,
1421 Name: *const c_char)
1422 -> &'a DIDerivedType;
1424 pub fn LLVMRustDIBuilderCreateStructType(Builder: &DIBuilder<'a>,
1425 Scope: Option<&'a DIDescriptor>,
1426 Name: *const c_char,
1432 DerivedFrom: Option<&'a DIType>,
1433 Elements: &'a DIArray,
1434 RunTimeLang: c_uint,
1435 VTableHolder: Option<&'a DIType>,
1436 UniqueId: *const c_char)
1437 -> &'a DICompositeType;
1439 pub fn LLVMRustDIBuilderCreateMemberType(Builder: &DIBuilder<'a>,
1440 Scope: &'a DIDescriptor,
1441 Name: *const c_char,
1449 -> &'a DIDerivedType;
1451 pub fn LLVMRustDIBuilderCreateVariantMemberType(Builder: &DIBuilder<'a>,
1453 Name: *const c_char,
1459 Discriminant: Option<&'a Value>,
1464 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: &DIBuilder<'a>,
1469 -> &'a DILexicalBlock;
1471 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: &DIBuilder<'a>,
1474 -> &'a DILexicalBlock;
1476 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: &DIBuilder<'a>,
1477 Context: Option<&'a DIScope>,
1478 Name: *const c_char,
1479 LinkageName: *const c_char,
1483 isLocalToUnit: bool,
1485 Decl: Option<&'a DIDescriptor>,
1487 -> &'a DIGlobalVariableExpression;
1489 pub fn LLVMRustDIBuilderCreateVariable(Builder: &DIBuilder<'a>,
1491 Scope: &'a DIDescriptor,
1492 Name: *const c_char,
1496 AlwaysPreserve: bool,
1502 pub fn LLVMRustDIBuilderCreateArrayType(Builder: &DIBuilder<'a>,
1506 Subscripts: &'a DIArray)
1509 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: &DIBuilder<'a>,
1514 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: &DIBuilder<'a>,
1515 Ptr: *const Option<&'a DIDescriptor>,
1519 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: &DIBuilder<'a>,
1521 VarInfo: &'a DIVariable,
1522 AddrOps: *const i64,
1523 AddrOpsCount: c_uint,
1525 InsertAtEnd: &'a BasicBlock)
1528 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: &DIBuilder<'a>,
1529 Name: *const c_char,
1531 -> &'a DIEnumerator;
1533 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: &DIBuilder<'a>,
1535 Name: *const c_char,
1540 Elements: &'a DIArray,
1541 ClassType: &'a DIType,
1545 pub fn LLVMRustDIBuilderCreateUnionType(Builder: &DIBuilder<'a>,
1547 Name: *const c_char,
1553 Elements: Option<&'a DIArray>,
1554 RunTimeLang: c_uint,
1555 UniqueId: *const c_char)
1558 pub fn LLVMRustDIBuilderCreateVariantPart(Builder: &DIBuilder<'a>,
1560 Name: *const c_char,
1566 Discriminator: Option<&'a DIDerivedType>,
1567 Elements: &'a DIArray,
1568 UniqueId: *const c_char)
1569 -> &'a DIDerivedType;
1571 pub fn LLVMSetUnnamedAddr(GlobalVar: &Value, UnnamedAddr: Bool);
1573 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: &DIBuilder<'a>,
1574 Scope: Option<&'a DIScope>,
1575 Name: *const c_char,
1580 -> &'a DITemplateTypeParameter;
1583 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: &DIBuilder<'a>,
1584 Scope: Option<&'a DIScope>,
1585 Name: *const c_char,
1590 pub fn LLVMRustDICompositeTypeReplaceArrays(Builder: &DIBuilder<'a>,
1591 CompositeType: &'a DIType,
1592 Elements: Option<&'a DIArray>,
1593 Params: Option<&'a DIArray>);
1596 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: &'a Context,
1600 InlinedAt: Option<&'a Metadata>)
1602 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1603 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
1606 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1608 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
1609 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
1613 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&Value>;
1614 pub fn LLVMIsAConstantFP(value_ref: &Value) -> Option<&Value>;
1616 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
1617 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
1618 pub fn LLVMRustAddPass(PM: &PassManager, Pass: &'static mut Pass);
1620 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
1622 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
1623 pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
1625 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
1626 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1628 Features: *const c_char,
1631 Level: CodeGenOptLevel,
1633 PositionIndependentExecutable: bool,
1634 FunctionSections: bool,
1636 TrapUnreachable: bool,
1639 EmitStackSizeSection: bool)
1640 -> Option<&'static mut TargetMachine>;
1641 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
1642 pub fn LLVMRustAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>, M: &'a Module);
1643 pub fn LLVMRustAddBuilderLibraryInfo(PMB: &'a PassManagerBuilder,
1645 DisableSimplifyLibCalls: bool);
1646 pub fn LLVMRustConfigurePassManagerBuilder(PMB: &PassManagerBuilder,
1647 OptLevel: CodeGenOptLevel,
1648 MergeFunctions: bool,
1650 LoopVectorize: bool,
1651 PrepareForThinLTO: bool,
1652 PGOGenPath: *const c_char,
1653 PGOUsePath: *const c_char);
1654 pub fn LLVMRustAddLibraryInfo(PM: &PassManager<'a>,
1656 DisableSimplifyLibCalls: bool);
1657 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
1658 pub fn LLVMRustWriteOutputFile(T: &'a TargetMachine,
1659 PM: &PassManager<'a>,
1661 Output: *const c_char,
1664 pub fn LLVMRustPrintModule(PM: &PassManager<'a>,
1666 Output: *const c_char,
1667 Demangle: extern fn(*const c_char,
1671 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1672 pub fn LLVMRustPrintPasses();
1673 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
1674 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
1675 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
1676 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
1678 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
1679 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
1680 pub fn LLVMRustArchiveIteratorNext(
1681 AIR: &ArchiveIterator<'a>,
1682 ) -> Option<&'a mut ArchiveChild<'a>>;
1683 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
1684 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
1685 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
1686 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
1687 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
1689 pub fn LLVMRustGetSectionName(SI: &SectionIterator, data: &mut *const c_char) -> size_t;
1692 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1694 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
1698 pub fn LLVMContextSetDiagnosticHandler(C: &Context,
1699 Handler: DiagnosticHandler,
1700 DiagnosticContext: *mut c_void);
1703 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1705 pub fn LLVMRustUnpackOptimizationDiagnostic(DI: &'a DiagnosticInfo,
1706 pass_name_out: &RustString,
1707 function_out: &mut Option<&'a Value>,
1708 loc_line_out: &mut c_uint,
1709 loc_column_out: &mut c_uint,
1710 loc_filename_out: &RustString,
1711 message_out: &RustString);
1715 pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: &'a DiagnosticInfo,
1716 cookie_out: &mut c_uint,
1717 message_out: &mut Option<&'a Twine>,
1718 instruction_out: &mut Option<&'a Value>);
1721 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1723 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
1727 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
1729 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: &Context,
1730 H: InlineAsmDiagHandler,
1734 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1736 pub fn LLVMRustWriteSMDiagnosticToString(d: &SMDiagnostic, s: &RustString);
1740 pub fn LLVMRustWriteArchive(Dst: *const c_char,
1742 Members: *const &RustArchiveMember,
1746 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1747 Name: *const c_char,
1748 Child: Option<&ArchiveChild<'a>>)
1749 -> &'a mut RustArchiveMember<'a>;
1750 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
1752 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
1754 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1755 Inputs: *const &'a Value,
1757 -> &'a mut OperandBundleDef<'a>;
1758 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
1760 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
1762 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char);
1763 pub fn LLVMRustUnsetComdat(V: &Value);
1764 pub fn LLVMRustSetModulePIELevel(M: &Module);
1765 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
1766 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
1767 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
1768 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
1769 pub fn LLVMRustModuleCost(M: &Module) -> u64;
1771 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
1772 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
1773 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
1774 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
1775 pub fn LLVMRustCreateThinLTOData(
1776 Modules: *const ThinLTOModule,
1778 PreservedSymbols: *const *const c_char,
1779 PreservedSymbolsLen: c_uint,
1780 ) -> Option<&'static mut ThinLTOData>;
1781 pub fn LLVMRustPrepareThinLTORename(
1785 pub fn LLVMRustPrepareThinLTOResolveWeak(
1789 pub fn LLVMRustPrepareThinLTOInternalize(
1793 pub fn LLVMRustPrepareThinLTOImport(
1797 pub fn LLVMRustGetThinLTOModuleImports(
1798 Data: *const ThinLTOData,
1799 ModuleNameCallback: ThinLTOModuleNameCallback,
1800 CallbackPayload: *mut c_void,
1802 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
1803 pub fn LLVMRustParseBitcodeForThinLTO(
1807 Identifier: *const c_char,
1808 ) -> Option<&Module>;
1809 pub fn LLVMRustThinLTOGetDICompileUnit(M: &Module,
1810 CU1: &mut *mut c_void,
1811 CU2: &mut *mut c_void);
1812 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
1814 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
1815 pub fn LLVMRustLinkerAdd(linker: &Linker,
1816 bytecode: *const c_char,
1817 bytecode_len: usize) -> bool;
1818 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);