diff options
| author | Denis Merigoux <denis.merigoux@gmail.com> | 2018-10-02 10:49:54 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-11-16 14:55:47 +0200 |
| commit | 915382f7306be7841c4254cee13fa55a865bdd8b (patch) | |
| tree | 0a183ef670560bd534fcfe3562d29c9793479219 /src/librustc_codegen_llvm | |
| parent | c9f26c21551fdbb8156fd86f00e5e8fecc6c1189 (diff) | |
| download | rust-915382f7306be7841c4254cee13fa55a865bdd8b.tar.gz rust-915382f7306be7841c4254cee13fa55a865bdd8b.zip | |
Moved DeclareMethods, MiscMethods and StaticMethods
Diffstat (limited to 'src/librustc_codegen_llvm')
| -rw-r--r-- | src/librustc_codegen_llvm/interfaces/declare.rs | 89 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/interfaces/misc.rs | 40 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/interfaces/mod.rs | 11 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/interfaces/statics.rs | 23 |
4 files changed, 4 insertions, 159 deletions
diff --git a/src/librustc_codegen_llvm/interfaces/declare.rs b/src/librustc_codegen_llvm/interfaces/declare.rs deleted file mode 100644 index 373220fd345..00000000000 --- a/src/librustc_codegen_llvm/interfaces/declare.rs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::Backend; -use monomorphize::Instance; -use rustc::hir::def_id::DefId; -use rustc::mir::mono::{Linkage, Visibility}; -use rustc::ty; - -pub trait DeclareMethods<'tcx>: Backend<'tcx> { - /// Declare a global value. - /// - /// If there’s a value with the same name already declared, the function will - /// return its Value instead. - fn declare_global(&self, name: &str, ty: Self::Type) -> Self::Value; - - /// Declare a C ABI function. - /// - /// Only use this for foreign function ABIs and glue. For Rust functions use - /// `declare_fn` instead. - /// - /// If there’s a value with the same name already declared, the function will - /// update the declaration and return existing Value instead. - fn declare_cfn(&self, name: &str, fn_type: Self::Type) -> Self::Value; - - /// Declare a Rust function. - /// - /// If there’s a value with the same name already declared, the function will - /// update the declaration and return existing Value instead. - fn declare_fn(&self, name: &str, sig: ty::PolyFnSig<'tcx>) -> Self::Value; - - /// Declare a global with an intention to define it. - /// - /// Use this function when you intend to define a global. This function will - /// return None if the name already has a definition associated with it. In that - /// case an error should be reported to the user, because it usually happens due - /// to user’s fault (e.g. misuse of #[no_mangle] or #[export_name] attributes). - fn define_global(&self, name: &str, ty: Self::Type) -> Option<Self::Value>; - - /// Declare a private global - /// - /// Use this function when you intend to define a global without a name. - fn define_private_global(&self, ty: Self::Type) -> Self::Value; - - /// Declare a Rust function with an intention to define it. - /// - /// Use this function when you intend to define a function. This function will - /// return panic if the name already has a definition associated with it. This - /// can happen with #[no_mangle] or #[export_name], for example. - fn define_fn(&self, name: &str, fn_sig: ty::PolyFnSig<'tcx>) -> Self::Value; - - /// Declare a Rust function with an intention to define it. - /// - /// Use this function when you intend to define a function. This function will - /// return panic if the name already has a definition associated with it. This - /// can happen with #[no_mangle] or #[export_name], for example. - fn define_internal_fn(&self, name: &str, fn_sig: ty::PolyFnSig<'tcx>) -> Self::Value; - - /// Get declared value by name. - fn get_declared_value(&self, name: &str) -> Option<Self::Value>; - - /// Get defined or externally defined (AvailableExternally linkage) value by - /// name. - fn get_defined_value(&self, name: &str) -> Option<Self::Value>; -} - -pub trait PreDefineMethods<'tcx>: Backend<'tcx> { - fn predefine_static( - &self, - def_id: DefId, - linkage: Linkage, - visibility: Visibility, - symbol_name: &str, - ); - fn predefine_fn( - &self, - instance: Instance<'tcx>, - linkage: Linkage, - visibility: Visibility, - symbol_name: &str, - ); -} diff --git a/src/librustc_codegen_llvm/interfaces/misc.rs b/src/librustc_codegen_llvm/interfaces/misc.rs deleted file mode 100644 index 6e6af597a76..00000000000 --- a/src/librustc_codegen_llvm/interfaces/misc.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::Backend; -use libc::c_uint; -use monomorphize::partitioning::CodegenUnit; -use rustc::mir::mono::Stats; -use rustc::session::Session; -use rustc::ty::{self, Instance, Ty}; -use rustc::util::nodemap::FxHashMap; -use std::cell::RefCell; -use std::sync::Arc; - -pub trait MiscMethods<'tcx>: Backend<'tcx> { - fn vtables( - &self, - ) -> &RefCell<FxHashMap<(Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>), Self::Value>>; - fn check_overflow(&self) -> bool; - fn instances(&self) -> &RefCell<FxHashMap<Instance<'tcx>, Self::Value>>; - fn get_fn(&self, instance: Instance<'tcx>) -> Self::Value; - fn get_param(&self, llfn: Self::Value, index: c_uint) -> Self::Value; - fn eh_personality(&self) -> Self::Value; - fn eh_unwind_resume(&self) -> Self::Value; - fn sess(&self) -> &Session; - fn stats(&self) -> &RefCell<Stats>; - fn consume_stats(self) -> RefCell<Stats>; - fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>; - fn statics_to_rauw(&self) -> &RefCell<Vec<(Self::Value, Self::Value)>>; - fn used_statics(&self) -> &RefCell<Vec<Self::Value>>; - fn set_frame_pointer_elimination(&self, llfn: Self::Value); - fn apply_target_cpu_attr(&self, llfn: Self::Value); - fn create_used_variable(&self); -} diff --git a/src/librustc_codegen_llvm/interfaces/mod.rs b/src/librustc_codegen_llvm/interfaces/mod.rs index 0547ce7ce4c..5fff0567585 100644 --- a/src/librustc_codegen_llvm/interfaces/mod.rs +++ b/src/librustc_codegen_llvm/interfaces/mod.rs @@ -13,10 +13,7 @@ mod asm; mod builder; mod consts; mod debuginfo; -mod declare; mod intrinsic; -mod misc; -mod statics; mod type_; pub use self::abi::{AbiBuilderMethods, AbiMethods}; @@ -24,14 +21,14 @@ pub use self::asm::{AsmBuilderMethods, AsmMethods}; pub use self::builder::BuilderMethods; pub use self::consts::ConstMethods; pub use self::debuginfo::{DebugInfoBuilderMethods, DebugInfoMethods}; -pub use self::declare::{DeclareMethods, PreDefineMethods}; pub use self::intrinsic::{IntrinsicCallMethods, IntrinsicDeclarationMethods}; -pub use self::misc::MiscMethods; -pub use self::statics::StaticMethods; pub use self::type_::{ ArgTypeMethods, BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods, TypeMethods, }; -pub use rustc_codegen_ssa::interfaces::{Backend, BackendMethods, BackendTypes, CodegenObject}; +pub use rustc_codegen_ssa::interfaces::{ + Backend, BackendMethods, BackendTypes, CodegenObject, DeclareMethods, MiscMethods, + PreDefineMethods, StaticMethods, +}; pub trait CodegenMethods<'tcx>: Backend<'tcx> diff --git a/src/librustc_codegen_llvm/interfaces/statics.rs b/src/librustc_codegen_llvm/interfaces/statics.rs deleted file mode 100644 index 27748a8dd42..00000000000 --- a/src/librustc_codegen_llvm/interfaces/statics.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::Backend; -use rustc::hir::def_id::DefId; -use rustc::ty::layout::Align; - -pub trait StaticMethods<'tcx>: Backend<'tcx> { - fn static_ptrcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value; - fn static_bitcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value; - fn static_addr_of_mut(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value; - fn static_addr_of(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value; - fn get_static(&self, def_id: DefId) -> Self::Value; - fn codegen_static(&self, def_id: DefId, is_mutable: bool); - fn static_replace_all_uses(&self, old_g: Self::Value, new_g: Self::Value); -} |
