about summary refs log tree commit diff
path: root/src/librustc_codegen_utils
diff options
context:
space:
mode:
authorDenis Merigoux <denis.merigoux@gmail.com>2018-10-01 18:07:04 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2018-11-16 14:55:42 +0200
commitc9f26c21551fdbb8156fd86f00e5e8fecc6c1189 (patch)
tree8f0dca5f6a905d25f671dfe526096a0f55313d92 /src/librustc_codegen_utils
parentb02e5cce169212bd4efe5857bc719d6ed47a53fc (diff)
downloadrust-c9f26c21551fdbb8156fd86f00e5e8fecc6c1189.tar.gz
rust-c9f26c21551fdbb8156fd86f00e5e8fecc6c1189.zip
Beginning of moving all backend-agnostic code to rustc_codegen_ssa
Diffstat (limited to 'src/librustc_codegen_utils')
-rw-r--r--src/librustc_codegen_utils/common.rs137
-rw-r--r--src/librustc_codegen_utils/interfaces/backend.rs80
-rw-r--r--src/librustc_codegen_utils/interfaces/mod.rs18
-rw-r--r--src/librustc_codegen_utils/lib.rs72
4 files changed, 0 insertions, 307 deletions
diff --git a/src/librustc_codegen_utils/common.rs b/src/librustc_codegen_utils/common.rs
deleted file mode 100644
index 3f4389913ae..00000000000
--- a/src/librustc_codegen_utils/common.rs
+++ /dev/null
@@ -1,137 +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.
-#![allow(non_camel_case_types, non_snake_case)]
-
-use rustc::ty::{self, Ty, TyCtxt};
-use syntax_pos::DUMMY_SP;
-
-
-pub fn type_needs_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
-    ty.needs_drop(tcx, ty::ParamEnv::reveal_all())
-}
-
-pub fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
-    ty.is_sized(tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all())
-}
-
-pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
-    ty.is_freeze(tcx, ty::ParamEnv::reveal_all(), DUMMY_SP)
-}
-
-pub enum IntPredicate {
-    IntEQ,
-    IntNE,
-    IntUGT,
-    IntUGE,
-    IntULT,
-    IntULE,
-    IntSGT,
-    IntSGE,
-    IntSLT,
-    IntSLE
-}
-
-
-#[allow(dead_code)]
-pub enum RealPredicate {
-    RealPredicateFalse,
-    RealOEQ,
-    RealOGT,
-    RealOGE,
-    RealOLT,
-    RealOLE,
-    RealONE,
-    RealORD,
-    RealUNO,
-    RealUEQ,
-    RealUGT,
-    RealUGE,
-    RealULT,
-    RealULE,
-    RealUNE,
-    RealPredicateTrue
-}
-
-pub enum AtomicRmwBinOp {
-    AtomicXchg,
-    AtomicAdd,
-    AtomicSub,
-    AtomicAnd,
-    AtomicNand,
-    AtomicOr,
-    AtomicXor,
-    AtomicMax,
-    AtomicMin,
-    AtomicUMax,
-    AtomicUMin
-}
-
-pub enum AtomicOrdering {
-    #[allow(dead_code)]
-    NotAtomic,
-    Unordered,
-    Monotonic,
-    // Consume,  // Not specified yet.
-    Acquire,
-    Release,
-    AcquireRelease,
-    SequentiallyConsistent,
-}
-
-pub enum SynchronizationScope {
-    // FIXME: figure out if this variant is needed at all.
-    #[allow(dead_code)]
-    Other,
-    SingleThread,
-    CrossThread,
-}
-
-#[derive(Copy, Clone, PartialEq, Debug)]
-pub enum TypeKind {
-    Void,
-    Half,
-    Float,
-    Double,
-    X86_FP80,
-    FP128,
-    PPC_FP128,
-    Label,
-    Integer,
-    Function,
-    Struct,
-    Array,
-    Pointer,
-    Vector,
-    Metadata,
-    X86_MMX,
-    Token,
-}
-
-// FIXME(mw): Anything that is produced via DepGraph::with_task() must implement
-//            the HashStable trait. Normally DepGraph::with_task() calls are
-//            hidden behind queries, but CGU creation is a special case in two
-//            ways: (1) it's not a query and (2) CGU are output nodes, so their
-//            Fingerprints are not actually needed. It remains to be clarified
-//            how exactly this case will be handled in the red/green system but
-//            for now we content ourselves with providing a no-op HashStable
-//            implementation for CGUs.
-mod temp_stable_hash_impls {
-    use rustc_data_structures::stable_hasher::{StableHasherResult, StableHasher,
-                                               HashStable};
-    use ModuleCodegen;
-
-    impl<HCX, M> HashStable<HCX> for ModuleCodegen<M> {
-        fn hash_stable<W: StableHasherResult>(&self,
-                                              _: &mut HCX,
-                                              _: &mut StableHasher<W>) {
-            // do nothing
-        }
-    }
-}
diff --git a/src/librustc_codegen_utils/interfaces/backend.rs b/src/librustc_codegen_utils/interfaces/backend.rs
deleted file mode 100644
index 3cdb1c6a0dd..00000000000
--- a/src/librustc_codegen_utils/interfaces/backend.rs
+++ /dev/null
@@ -1,80 +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 rustc::ty::layout::{HasTyCtxt, LayoutOf, TyLayout};
-use rustc::ty::Ty;
-
-use super::CodegenObject;
-use rustc::middle::allocator::AllocatorKind;
-use rustc::middle::cstore::EncodedMetadata;
-use rustc::mir::mono::Stats;
-use rustc::session::Session;
-use rustc::ty::TyCtxt;
-use rustc::util::time_graph::TimeGraph;
-use std::any::Any;
-use std::sync::mpsc::Receiver;
-use syntax_pos::symbol::InternedString;
-use ModuleCodegen;
-
-pub trait BackendTypes {
-    type Value: CodegenObject;
-    type BasicBlock: Copy;
-    type Type: CodegenObject;
-    type Context;
-    type Funclet;
-
-    type DIScope: Copy;
-}
-
-pub trait Backend<'tcx>:
-    BackendTypes + HasTyCtxt<'tcx> + LayoutOf<Ty = Ty<'tcx>, TyLayout = TyLayout<'tcx>>
-{
-}
-
-impl<'tcx, T> Backend<'tcx> for T where
-    Self: BackendTypes + HasTyCtxt<'tcx> + LayoutOf<Ty = Ty<'tcx>, TyLayout = TyLayout<'tcx>>
-{}
-
-pub trait BackendMethods {
-    type Module;
-    type OngoingCodegen;
-
-    fn new_metadata(&self, sess: &Session, mod_name: &str) -> Self::Module;
-    fn write_metadata<'b, 'gcx>(
-        &self,
-        tcx: TyCtxt<'b, 'gcx, 'gcx>,
-        metadata: &Self::Module,
-    ) -> EncodedMetadata;
-    fn codegen_allocator(&self, tcx: TyCtxt, mods: &Self::Module, kind: AllocatorKind);
-
-    fn start_async_codegen(
-        &self,
-        tcx: TyCtxt,
-        time_graph: Option<TimeGraph>,
-        metadata: EncodedMetadata,
-        coordinator_receive: Receiver<Box<dyn Any + Send>>,
-        total_cgus: usize,
-    ) -> Self::OngoingCodegen;
-    fn submit_pre_codegened_module_to_llvm(
-        &self,
-        codegen: &Self::OngoingCodegen,
-        tcx: TyCtxt,
-        module: ModuleCodegen<Self::Module>,
-    );
-    fn codegen_aborted(codegen: Self::OngoingCodegen);
-    fn codegen_finished(&self, codegen: &Self::OngoingCodegen, tcx: TyCtxt);
-    fn check_for_errors(&self, codegen: &Self::OngoingCodegen, sess: &Session);
-    fn wait_for_signal_to_codegen_item(&self, codegen: &Self::OngoingCodegen);
-    fn compile_codegen_unit<'a, 'tcx: 'a>(
-        &self,
-        tcx: TyCtxt<'a, 'tcx, 'tcx>,
-        cgu_name: InternedString,
-    ) -> Stats;
-}
diff --git a/src/librustc_codegen_utils/interfaces/mod.rs b/src/librustc_codegen_utils/interfaces/mod.rs
deleted file mode 100644
index f958dbabe68..00000000000
--- a/src/librustc_codegen_utils/interfaces/mod.rs
+++ /dev/null
@@ -1,18 +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.
-
-mod backend;
-
-pub use self::backend::{Backend, BackendMethods, BackendTypes};
-
-use std::fmt;
-
-pub trait CodegenObject: Copy + PartialEq + fmt::Debug {}
-impl<T: Copy + PartialEq + fmt::Debug> CodegenObject for T {}
diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs
index 4fb182e4f05..8d85c6691c2 100644
--- a/src/librustc_codegen_utils/lib.rs
+++ b/src/librustc_codegen_utils/lib.rs
@@ -47,86 +47,14 @@ use std::path::PathBuf;
 
 use rustc::session::Session;
 use rustc::ty::TyCtxt;
-use rustc::dep_graph::WorkProduct;
-use rustc::session::config::{OutputFilenames, OutputType};
 
 pub mod command;
-pub mod interfaces;
 pub mod link;
 pub mod linker;
 pub mod codegen_backend;
 pub mod symbol_export;
 pub mod symbol_names;
 pub mod symbol_names_test;
-pub mod common;
-
-pub struct ModuleCodegen<M> {
-    /// The name of the module. When the crate may be saved between
-    /// compilations, incremental compilation requires that name be
-    /// unique amongst **all** crates.  Therefore, it should contain
-    /// something unique to this crate (e.g., a module path) as well
-    /// as the crate name and disambiguator.
-    /// We currently generate these names via CodegenUnit::build_cgu_name().
-    pub name: String,
-    pub module_llvm: M,
-    pub kind: ModuleKind,
-}
-
-pub const RLIB_BYTECODE_EXTENSION: &str = "bc.z";
-
-impl<M> ModuleCodegen<M> {
-    pub fn into_compiled_module(self,
-                            emit_obj: bool,
-                            emit_bc: bool,
-                            emit_bc_compressed: bool,
-                            outputs: &OutputFilenames) -> CompiledModule {
-        let object = if emit_obj {
-            Some(outputs.temp_path(OutputType::Object, Some(&self.name)))
-        } else {
-            None
-        };
-        let bytecode = if emit_bc {
-            Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name)))
-        } else {
-            None
-        };
-        let bytecode_compressed = if emit_bc_compressed {
-            Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name))
-                    .with_extension(RLIB_BYTECODE_EXTENSION))
-        } else {
-            None
-        };
-
-        CompiledModule {
-            name: self.name.clone(),
-            kind: self.kind,
-            object,
-            bytecode,
-            bytecode_compressed,
-        }
-    }
-}
-
-#[derive(Debug)]
-pub struct CompiledModule {
-    pub name: String,
-    pub kind: ModuleKind,
-    pub object: Option<PathBuf>,
-    pub bytecode: Option<PathBuf>,
-    pub bytecode_compressed: Option<PathBuf>,
-}
-
-pub struct CachedModuleCodegen {
-    pub name: String,
-    pub source: WorkProduct,
-}
-
-#[derive(Copy, Clone, Debug, PartialEq)]
-pub enum ModuleKind {
-    Regular,
-    Metadata,
-    Allocator,
-}
 
 /// check for the #[rustc_error] annotation, which forces an
 /// error in codegen. This is used to write compile-fail tests