mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
Add Caches to FunctionCx
This commit is contained in:
parent
42887dfdd9
commit
6f58f94cdb
13
src/base.rs
13
src/base.rs
@ -16,8 +16,6 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(
|
|||||||
ccx: &mut crate::constant::ConstantCx,
|
ccx: &mut crate::constant::ConstantCx,
|
||||||
mono_item: MonoItem<'tcx>,
|
mono_item: MonoItem<'tcx>,
|
||||||
) {
|
) {
|
||||||
let context = &mut caches.context;
|
|
||||||
|
|
||||||
match mono_item {
|
match mono_item {
|
||||||
MonoItem::Fn(inst) => {
|
MonoItem::Fn(inst) => {
|
||||||
let _print_guard = PrintOnPanic(format!("{:?}", inst));
|
let _print_guard = PrintOnPanic(format!("{:?}", inst));
|
||||||
@ -40,7 +38,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(
|
|||||||
"target/out/mir/".to_string() + &format!("{:?}", inst.def_id()).replace('/', "@");
|
"target/out/mir/".to_string() + &format!("{:?}", inst.def_id()).replace('/', "@");
|
||||||
::std::fs::write(mir_file_name, mir).unwrap();
|
::std::fs::write(mir_file_name, mir).unwrap();
|
||||||
|
|
||||||
trans_fn(tcx, module, ccx, context, inst);
|
trans_fn(tcx, module, ccx, caches, inst);
|
||||||
}
|
}
|
||||||
MonoItem::Static(def_id) => {
|
MonoItem::Static(def_id) => {
|
||||||
crate::constant::codegen_static(ccx, def_id);
|
crate::constant::codegen_static(ccx, def_id);
|
||||||
@ -55,7 +53,7 @@ fn trans_fn<'a, 'tcx: 'a>(
|
|||||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
module: &mut Module<impl Backend>,
|
module: &mut Module<impl Backend>,
|
||||||
constants: &mut crate::constant::ConstantCx,
|
constants: &mut crate::constant::ConstantCx,
|
||||||
context: &mut Context,
|
caches: &mut Caches,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
) {
|
) {
|
||||||
// Step 1. Get mir
|
// Step 1. Get mir
|
||||||
@ -94,6 +92,7 @@ fn trans_fn<'a, 'tcx: 'a>(
|
|||||||
local_map: HashMap::new(),
|
local_map: HashMap::new(),
|
||||||
comments: HashMap::new(),
|
comments: HashMap::new(),
|
||||||
constants,
|
constants,
|
||||||
|
caches,
|
||||||
|
|
||||||
top_nop: None,
|
top_nop: None,
|
||||||
};
|
};
|
||||||
@ -117,9 +116,9 @@ fn trans_fn<'a, 'tcx: 'a>(
|
|||||||
// Step 9. Define function
|
// Step 9. Define function
|
||||||
// TODO: cranelift doesn't yet support some of the things needed
|
// TODO: cranelift doesn't yet support some of the things needed
|
||||||
if should_codegen(tcx.sess) {
|
if should_codegen(tcx.sess) {
|
||||||
context.func = func;
|
caches.context.func = func;
|
||||||
module.define_function(func_id, context).unwrap();
|
module.define_function(func_id, &mut caches.context).unwrap();
|
||||||
context.clear();
|
caches.context.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,6 +427,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> {
|
|||||||
pub local_map: HashMap<Local, CPlace<'tcx>>,
|
pub local_map: HashMap<Local, CPlace<'tcx>>,
|
||||||
pub comments: HashMap<Inst, String>,
|
pub comments: HashMap<Inst, String>,
|
||||||
pub constants: &'a mut crate::constant::ConstantCx,
|
pub constants: &'a mut crate::constant::ConstantCx,
|
||||||
|
pub caches: &'a mut Caches,
|
||||||
|
|
||||||
/// add_global_comment inserts a comment here
|
/// add_global_comment inserts a comment here
|
||||||
pub top_nop: Option<Inst>,
|
pub top_nop: Option<Inst>,
|
||||||
|
Loading…
Reference in New Issue
Block a user