[
{
T{ _copy { dst 5 } { src 4 } { class int-regs } }
- T{ _spill { src 0 } { class int-regs } { n 6 } }
+ T{ _spill { src 0 } { class int-regs } { n spill-temp } }
T{ _copy { dst 0 } { src 1 } { class int-regs } }
- T{ _reload { dst 1 } { class int-regs } { n 6 } }
- T{ _spill { src 0 } { class float-regs } { n 7 } }
+ T{ _reload { dst 1 } { class int-regs } { n spill-temp } }
+ T{ _spill { src 0 } { class float-regs } { n spill-temp } }
T{ _copy { dst 0 } { src 1 } { class float-regs } }
- T{ _reload { dst 1 } { class float-regs } { n 7 } }
+ T{ _reload { dst 1 } { class float-regs } { n spill-temp } }
}
] [
{
[
{
- T{ _spill { src 0 } { class int-regs } { n 3 } }
+ T{ _spill { src 0 } { class int-regs } { n spill-temp } }
T{ _copy { dst 0 } { src 2 } { class int-regs } }
T{ _copy { dst 2 } { src 1 } { class int-regs } }
- T{ _reload { dst 1 } { class int-regs } { n 3 } }
+ T{ _reload { dst 1 } { class int-regs } { n spill-temp } }
}
] [
{
[
{
- T{ _spill { src 0 } { class int-regs } { n 3 } }
+ T{ _spill { src 0 } { class int-regs } { n spill-temp } }
T{ _copy { dst 0 } { src 2 } { class int-regs } }
T{ _copy { dst 2 } { src 1 } { class int-regs } }
- T{ _reload { dst 1 } { class int-regs } { n 3 } }
+ T{ _reload { dst 1 } { class int-regs } { n spill-temp } }
}
] [
{
] unit-test
[
- { T{ _spill { src 4 } { class int-regs } { n 4 } } }
+ { T{ _spill { src 4 } { class int-regs } { n spill-temp } } }
] [
{
T{ register->memory { from 4 } { to 4 } { reg-class int-regs } }
{
T{ _copy { dst 1 } { src 0 } { class int-regs } }
T{ _copy { dst 2 } { src 0 } { class int-regs } }
- T{ _spill { src 3 } { class int-regs } { n 5 } }
+ T{ _spill { src 3 } { class int-regs } { n spill-temp } }
T{ _copy { dst 4 } { src 0 } { class int-regs } }
T{ _copy { dst 3 } { src 4 } { class int-regs } }
- T{ _reload { dst 0 } { class int-regs } { n 5 } }
+ T{ _reload { dst 0 } { class int-regs } { n spill-temp } }
}
] [
{
T{ _copy { dst 2 } { src 0 } { class int-regs } }
T{ _copy { dst 9 } { src 1 } { class int-regs } }
T{ _copy { dst 1 } { src 0 } { class int-regs } }
- T{ _spill { src 3 } { class int-regs } { n 10 } }
+ T{ _spill { src 3 } { class int-regs } { n spill-temp } }
T{ _copy { dst 4 } { src 0 } { class int-regs } }
T{ _copy { dst 3 } { src 4 } { class int-regs } }
- T{ _reload { dst 0 } { class int-regs } { n 10 } }
+ T{ _reload { dst 0 } { class int-regs } { n spill-temp } }
}
] [
{
[ from>> ] [ to>> ] bi = [ "Not allowed" throw ] unless ;
M: register->memory >insn
- [ from>> ] [ reg-class>> ] [ to>> ] tri _spill ;
+ [ from>> ] [ reg-class>> ] bi spill-temp _spill ;
M: memory->register >insn
- [ to>> ] [ reg-class>> ] [ from>> ] tri _reload ;
+ [ to>> ] [ reg-class>> ] bi spill-temp _reload ;
M: register->register >insn
[ to>> ] [ from>> ] [ reg-class>> ] tri _copy ;
[ from>> ] [ to>> ] bi = [ "Not allowed" throw ] unless ;
M: register->memory >collision-table
- [ from>> ] [ reg-class>> ] [ to>> ] tri _spill ;
+ [ from>> ] [ reg-class>> ] bi spill-temp _spill ;
M: memory->register >collision-table
- [ to>> ] [ reg-class>> ] [ from>> ] tri _reload ;
+ [ to>> ] [ reg-class>> ] bi spill-temp _reload ;
M: register->register >collision-table
[ to>> ] [ from>> ] [ reg-class>> ] tri _copy ;
: independent-assignment? ( operations -- pair )
to-reg froms get key? not ;
-: init-temp-spill ( operations -- )
- [ [ to>> ] [ from>> ] bi max ] [ max ] map-reduce
- 1 + temp-spill set ;
-
: set-tos/froms ( operations -- )
[ [ [ from-reg ] keep ] H{ } map>assoc froms set ]
[ [ [ to-reg ] keep ] H{ } map>assoc tos set ]
: break-cycle-n ( operations -- operations' )
unclip [
- [ from>> temp-spill get ]
+ [ from>> spill-temp ]
[ reg-class>> ] bi \ register->memory boa
] [
- [ to>> temp-spill [ get ] [ inc ] bi swap ]
+ [ to>> spill-temp swap ]
[ reg-class>> ] bi \ memory->register boa
] bi [ 1array ] bi@ surround ;
: mapping-instructions ( mappings -- insns )
[
- [ init-temp-spill ]
- [ set-tos/froms ]
- [ parallel-mappings ] tri
+ [ set-tos/froms ] [ parallel-mappings ] bi
[ [ >insn ] each ] { } make
] with-scope ;