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(
1225 ) -> Option<&'a Value>;
1226 pub fn LLVMRustBuildMaxNum(
1230 ) -> Option<&'a Value>;
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;
1362 pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1364 pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1366 pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1368 pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1370 pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder);
1372 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: &DIBuilder<'a>,
1375 Producer: *const c_char,
1377 Flags: *const c_char,
1379 SplitName: *const c_char)
1380 -> &'a DIDescriptor;
1382 pub fn LLVMRustDIBuilderCreateFile(Builder: &DIBuilder<'a>,
1383 Filename: *const c_char,
1384 Directory: *const c_char)
1387 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: &DIBuilder<'a>,
1389 ParameterTypes: &'a DIArray)
1390 -> &'a DICompositeType;
1392 pub fn LLVMRustDIBuilderCreateFunction(Builder: &DIBuilder<'a>,
1393 Scope: &'a DIDescriptor,
1394 Name: *const c_char,
1395 LinkageName: *const c_char,
1399 isLocalToUnit: bool,
1405 TParam: &'a DIArray,
1406 Decl: Option<&'a DIDescriptor>)
1407 -> &'a DISubprogram;
1409 pub fn LLVMRustDIBuilderCreateBasicType(Builder: &DIBuilder<'a>,
1410 Name: *const c_char,
1416 pub fn LLVMRustDIBuilderCreatePointerType(Builder: &DIBuilder<'a>,
1417 PointeeTy: &'a DIType,
1420 Name: *const c_char)
1421 -> &'a DIDerivedType;
1423 pub fn LLVMRustDIBuilderCreateStructType(Builder: &DIBuilder<'a>,
1424 Scope: Option<&'a DIDescriptor>,
1425 Name: *const c_char,
1431 DerivedFrom: Option<&'a DIType>,
1432 Elements: &'a DIArray,
1433 RunTimeLang: c_uint,
1434 VTableHolder: Option<&'a DIType>,
1435 UniqueId: *const c_char)
1436 -> &'a DICompositeType;
1438 pub fn LLVMRustDIBuilderCreateMemberType(Builder: &DIBuilder<'a>,
1439 Scope: &'a DIDescriptor,
1440 Name: *const c_char,
1448 -> &'a DIDerivedType;
1450 pub fn LLVMRustDIBuilderCreateVariantMemberType(Builder: &DIBuilder<'a>,
1452 Name: *const c_char,
1458 Discriminant: Option<&'a Value>,
1463 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: &DIBuilder<'a>,
1468 -> &'a DILexicalBlock;
1470 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: &DIBuilder<'a>,
1473 -> &'a DILexicalBlock;
1475 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: &DIBuilder<'a>,
1476 Context: Option<&'a DIScope>,
1477 Name: *const c_char,
1478 LinkageName: *const c_char,
1482 isLocalToUnit: bool,
1484 Decl: Option<&'a DIDescriptor>,
1486 -> &'a DIGlobalVariableExpression;
1488 pub fn LLVMRustDIBuilderCreateVariable(Builder: &DIBuilder<'a>,
1490 Scope: &'a DIDescriptor,
1491 Name: *const c_char,
1495 AlwaysPreserve: bool,
1501 pub fn LLVMRustDIBuilderCreateArrayType(Builder: &DIBuilder<'a>,
1505 Subscripts: &'a DIArray)
1508 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: &DIBuilder<'a>,
1513 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: &DIBuilder<'a>,
1514 Ptr: *const Option<&'a DIDescriptor>,
1518 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: &DIBuilder<'a>,
1520 VarInfo: &'a DIVariable,
1521 AddrOps: *const i64,
1522 AddrOpsCount: c_uint,
1524 InsertAtEnd: &'a BasicBlock)
1527 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: &DIBuilder<'a>,
1528 Name: *const c_char,
1530 -> &'a DIEnumerator;
1532 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: &DIBuilder<'a>,
1534 Name: *const c_char,
1539 Elements: &'a DIArray,
1540 ClassType: &'a DIType,
1544 pub fn LLVMRustDIBuilderCreateUnionType(Builder: &DIBuilder<'a>,
1546 Name: *const c_char,
1552 Elements: Option<&'a DIArray>,
1553 RunTimeLang: c_uint,
1554 UniqueId: *const c_char)
1557 pub fn LLVMRustDIBuilderCreateVariantPart(Builder: &DIBuilder<'a>,
1559 Name: *const c_char,
1565 Discriminator: Option<&'a DIDerivedType>,
1566 Elements: &'a DIArray,
1567 UniqueId: *const c_char)
1568 -> &'a DIDerivedType;
1570 pub fn LLVMSetUnnamedAddr(GlobalVar: &Value, UnnamedAddr: Bool);
1572 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: &DIBuilder<'a>,
1573 Scope: Option<&'a DIScope>,
1574 Name: *const c_char,
1579 -> &'a DITemplateTypeParameter;
1582 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: &DIBuilder<'a>,
1583 Scope: Option<&'a DIScope>,
1584 Name: *const c_char,
1589 pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: &DIBuilder<'a>,
1590 CompositeType: &'a DIType,
1591 TypeArray: &'a DIArray);
1594 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: &'a Context,
1598 InlinedAt: Option<&'a Metadata>)
1600 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1601 pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
1604 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1606 pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
1607 pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
1611 pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&Value>;
1612 pub fn LLVMIsAConstantFP(value_ref: &Value) -> Option<&Value>;
1614 pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
1615 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
1616 pub fn LLVMRustAddPass(PM: &PassManager, Pass: &'static mut Pass);
1618 pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
1620 pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
1621 pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
1623 pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
1624 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1626 Features: *const c_char,
1629 Level: CodeGenOptLevel,
1631 PositionIndependentExecutable: bool,
1632 FunctionSections: bool,
1634 TrapUnreachable: bool,
1637 EmitStackSizeSection: bool)
1638 -> Option<&'static mut TargetMachine>;
1639 pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
1640 pub fn LLVMRustAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>, M: &'a Module);
1641 pub fn LLVMRustAddBuilderLibraryInfo(PMB: &'a PassManagerBuilder,
1643 DisableSimplifyLibCalls: bool);
1644 pub fn LLVMRustConfigurePassManagerBuilder(PMB: &PassManagerBuilder,
1645 OptLevel: CodeGenOptLevel,
1646 MergeFunctions: bool,
1648 LoopVectorize: bool,
1649 PrepareForThinLTO: bool,
1650 PGOGenPath: *const c_char,
1651 PGOUsePath: *const c_char);
1652 pub fn LLVMRustAddLibraryInfo(PM: &PassManager<'a>,
1654 DisableSimplifyLibCalls: bool);
1655 pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
1656 pub fn LLVMRustWriteOutputFile(T: &'a TargetMachine,
1657 PM: &PassManager<'a>,
1659 Output: *const c_char,
1662 pub fn LLVMRustPrintModule(PM: &PassManager<'a>,
1664 Output: *const c_char,
1665 Demangle: extern fn(*const c_char,
1669 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1670 pub fn LLVMRustPrintPasses();
1671 pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
1672 pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
1673 pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
1674 pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
1676 pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
1677 pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
1678 pub fn LLVMRustArchiveIteratorNext(
1679 AIR: &ArchiveIterator<'a>,
1680 ) -> Option<&'a mut ArchiveChild<'a>>;
1681 pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
1682 pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
1683 pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
1684 pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
1685 pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
1687 pub fn LLVMRustGetSectionName(SI: &SectionIterator, data: &mut *const c_char) -> size_t;
1690 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1692 pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
1696 pub fn LLVMContextSetDiagnosticHandler(C: &Context,
1697 Handler: DiagnosticHandler,
1698 DiagnosticContext: *mut c_void);
1701 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1703 pub fn LLVMRustUnpackOptimizationDiagnostic(DI: &'a DiagnosticInfo,
1704 pass_name_out: &RustString,
1705 function_out: &mut Option<&'a Value>,
1706 loc_line_out: &mut c_uint,
1707 loc_column_out: &mut c_uint,
1708 loc_filename_out: &RustString,
1709 message_out: &RustString);
1713 pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: &'a DiagnosticInfo,
1714 cookie_out: &mut c_uint,
1715 message_out: &mut Option<&'a Twine>,
1716 instruction_out: &mut Option<&'a Value>);
1719 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1721 pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
1725 pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
1727 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: &Context,
1728 H: InlineAsmDiagHandler,
1732 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1734 pub fn LLVMRustWriteSMDiagnosticToString(d: &SMDiagnostic, s: &RustString);
1738 pub fn LLVMRustWriteArchive(Dst: *const c_char,
1740 Members: *const &RustArchiveMember,
1744 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1745 Name: *const c_char,
1746 Child: Option<&ArchiveChild<'a>>)
1747 -> &'a mut RustArchiveMember<'a>;
1748 pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
1750 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
1752 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1753 Inputs: *const &'a Value,
1755 -> &'a mut OperandBundleDef<'a>;
1756 pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
1758 pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
1760 pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char);
1761 pub fn LLVMRustUnsetComdat(V: &Value);
1762 pub fn LLVMRustSetModulePIELevel(M: &Module);
1763 pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
1764 pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
1765 pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
1766 pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
1767 pub fn LLVMRustModuleCost(M: &Module) -> u64;
1769 pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
1770 pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
1771 pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
1772 pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
1773 pub fn LLVMRustCreateThinLTOData(
1774 Modules: *const ThinLTOModule,
1776 PreservedSymbols: *const *const c_char,
1777 PreservedSymbolsLen: c_uint,
1778 ) -> Option<&'static mut ThinLTOData>;
1779 pub fn LLVMRustPrepareThinLTORename(
1783 pub fn LLVMRustPrepareThinLTOResolveWeak(
1787 pub fn LLVMRustPrepareThinLTOInternalize(
1791 pub fn LLVMRustPrepareThinLTOImport(
1795 pub fn LLVMRustGetThinLTOModuleImports(
1796 Data: *const ThinLTOData,
1797 ModuleNameCallback: ThinLTOModuleNameCallback,
1798 CallbackPayload: *mut c_void,
1800 pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
1801 pub fn LLVMRustParseBitcodeForThinLTO(
1805 Identifier: *const c_char,
1806 ) -> Option<&Module>;
1807 pub fn LLVMRustThinLTOGetDICompileUnit(M: &Module,
1808 CU1: &mut *mut c_void,
1809 CU2: &mut *mut c_void);
1810 pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
1812 pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
1813 pub fn LLVMRustLinkerAdd(linker: &Linker,
1814 bytecode: *const c_char,
1815 bytecode_len: usize) -> bool;
1816 pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);