start adding no inline flag to functions

This commit is contained in:
microproofs 2024-03-01 11:10:37 -05:00 committed by Kasey
parent 2aaa46e54c
commit 4e928f39db
3 changed files with 21 additions and 18 deletions

View File

@ -4419,7 +4419,7 @@ impl<'a> CodeGenerator<'a> {
} }
if !recursive { if !recursive {
term = term.lambda(func_name).apply(func_body); term = term.lambda(func_name).apply(func_body.lambda(NO_INLINE));
Some(term) Some(term)
} else { } else {
@ -4431,7 +4431,7 @@ impl<'a> CodeGenerator<'a> {
.lambda(func_name.clone()) .lambda(func_name.clone())
.apply(Term::var(func_name.clone()).apply(Term::var(func_name.clone()))) .apply(Term::var(func_name.clone()).apply(Term::var(func_name.clone())))
.lambda(func_name) .lambda(func_name)
.apply(func_body); .apply(func_body.lambda(NO_INLINE));
} else { } else {
// If we have parameters that remain static in each recursive call, // If we have parameters that remain static in each recursive call,
// we can construct an *outer* function to take those in // we can construct an *outer* function to take those in
@ -4452,7 +4452,9 @@ impl<'a> CodeGenerator<'a> {
} }
// And finally, fold that definition into the rest of our program // And finally, fold that definition into the rest of our program
term = term.lambda(&func_name).apply(outer_func_body); term = term
.lambda(&func_name)
.apply(outer_func_body.lambda(NO_INLINE));
} }
Some(term) Some(term)
@ -4500,7 +4502,12 @@ impl<'a> CodeGenerator<'a> {
.lambda(&func_name) .lambda(&func_name)
.apply(Term::var(&func_name).apply(Term::var(&func_name))) .apply(Term::var(&func_name).apply(Term::var(&func_name)))
.lambda(&func_name) .lambda(&func_name)
.apply(cyclic_body.lambda("__chooser").lambda(func_name)); .apply(
cyclic_body
.lambda("__chooser")
.lambda(func_name)
.lambda(NO_INLINE),
);
Some(term) Some(term)
} }

View File

@ -4,7 +4,7 @@ mod interner;
pub mod shrinker; pub mod shrinker;
pub fn aiken_optimize_and_intern(program: Program<Name>) -> Program<Name> { pub fn aiken_optimize_and_intern(program: Program<Name>) -> Program<Name> {
let w = program program
.builtin_force_reducer() .builtin_force_reducer()
.lambda_reducer() .lambda_reducer()
.inline_reducer() .inline_reducer()
@ -12,17 +12,11 @@ pub fn aiken_optimize_and_intern(program: Program<Name>) -> Program<Name> {
.inline_reducer() .inline_reducer()
.force_delay_reducer() .force_delay_reducer()
.cast_data_reducer() .cast_data_reducer()
.convert_arithmetic_ops(); .convert_arithmetic_ops()
.builtin_curry_reducer()
// println!("{:#?}", w); .lambda_reducer()
.inline_reducer()
let x = w.builtin_curry_reducer(); .builtin_curry_reducer()
.lambda_reducer()
// println!("{:#?}", x); .inline_reducer()
let y = x.lambda_reducer().inline_reducer().builtin_curry_reducer();
// println!("{:#?}", y);
y.lambda_reducer().inline_reducer()
} }

View File

@ -86,6 +86,8 @@ impl Default for IdGen {
} }
} }
pub const NO_INLINE: &str = "__no_inline__";
#[derive(PartialEq, PartialOrd, Default, Debug, Clone)] #[derive(PartialEq, PartialOrd, Default, Debug, Clone)]
pub struct VarLookup { pub struct VarLookup {
found: bool, found: bool,