Preparing the generalization of base:compile_coodegen_unit

This commit is contained in:
Denis Merigoux
2018-09-26 17:00:01 +02:00
committed by Eduard-Mihai Burtescu
parent 91a2a80692
commit 6819e6e6e1
11 changed files with 114 additions and 57 deletions

View File

@@ -11,13 +11,15 @@
use rustc::ty::layout::{HasTyCtxt, LayoutOf, TyLayout};
use rustc::ty::Ty;
use super::CodegenObject;
use super::{CodegenMethods, CodegenObject};
use monomorphize::partitioning::CodegenUnit;
use rustc::middle::allocator::AllocatorKind;
use rustc::middle::cstore::EncodedMetadata;
use rustc::session::Session;
use rustc::ty::TyCtxt;
use std::any::Any;
use std::sync::mpsc::Receiver;
use std::sync::Arc;
use time_graph::TimeGraph;
use ModuleCodegen;
@@ -40,16 +42,16 @@ impl<'tcx, T> Backend<'tcx> for T where
{}
pub trait BackendMethods {
type Metadata;
type Module;
type OngoingCodegen;
fn new_metadata(&self, sess: &Session, mod_name: &str) -> Self::Metadata;
fn write_metadata<'a, 'gcx>(
fn new_metadata(&self, sess: &Session, mod_name: &str) -> Self::Module;
fn write_metadata<'b, 'gcx>(
&self,
tcx: TyCtxt<'a, 'gcx, 'gcx>,
metadata: &Self::Metadata,
tcx: TyCtxt<'b, 'gcx, 'gcx>,
metadata: &Self::Module,
) -> EncodedMetadata;
fn codegen_allocator(&self, tcx: TyCtxt, mods: &Self::Metadata, kind: AllocatorKind);
fn codegen_allocator(&self, tcx: TyCtxt, mods: &Self::Module, kind: AllocatorKind);
fn start_async_codegen(
&self,
@@ -63,10 +65,21 @@ pub trait BackendMethods {
&self,
codegen: &Self::OngoingCodegen,
tcx: TyCtxt,
module: ModuleCodegen<Self::Metadata>,
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);
}
pub trait BackendCodegenCxMethods<'a, 'tcx: 'a>: BackendMethods {
type CodegenCx: CodegenMethods<'tcx>;
fn new_codegen_context(
&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
codegen_unit: Arc<CodegenUnit<'tcx>>,
llvm_module: &'a Self::Module,
) -> Self::CodegenCx;
}