shrink higher order with indirection

This commit is contained in:
Folkert 2021-11-13 15:42:47 +01:00
parent 783e425b0c
commit e2f7606f25
9 changed files with 90 additions and 72 deletions

View file

@ -1,5 +1,7 @@
use crate::borrow::{ParamMap, BORROWED, OWNED};
use crate::ir::{Expr, JoinPointId, ModifyRc, Param, Proc, ProcLayout, Stmt};
use crate::ir::{
CallType, Expr, HigherOrderLowLevel, JoinPointId, ModifyRc, Param, Proc, ProcLayout, Stmt,
};
use crate::layout::Layout;
use bumpalo::collections::Vec;
use bumpalo::Bump;
@ -463,7 +465,7 @@ impl<'a> Context<'a> {
&*self.arena.alloc(Stmt::Let(z, v, l, b))
}
HigherOrderLowLevel {
HigherOrder(HigherOrderLowLevel {
op,
closure_env_layout,
specialization_id,
@ -473,7 +475,7 @@ impl<'a> Context<'a> {
function_name,
function_env,
..
} => {
}) => {
// setup
use crate::low_level::HigherOrder::*;
@ -481,7 +483,7 @@ impl<'a> Context<'a> {
($borrows:expr) => {
Expr::Call(crate::ir::Call {
call_type: if let Some(OWNED) = $borrows.map(|p| p.borrow) {
HigherOrderLowLevel {
let higher_order = HigherOrderLowLevel {
op: *op,
closure_env_layout: *closure_env_layout,
function_owns_closure_data: true,
@ -491,7 +493,9 @@ impl<'a> Context<'a> {
function_env: *function_env,
arg_layouts,
ret_layout: *ret_layout,
}
};
CallType::HigherOrder(self.arena.alloc(higher_order))
} else {
call_type
},