compiler.cfg.stacks.*: removing the adjust word which wasn't useful

char-rename
Björn Lindqvist 2016-09-05 10:37:29 +02:00
parent bff165c85c
commit ee5c28f470
5 changed files with 12 additions and 7 deletions

View File

@ -91,7 +91,6 @@ $nl
translate-local-loc }
"Words for writing the stack state:"
{ $subsections
adjust
inc-stack
modify-height
replace-loc

View File

@ -14,9 +14,6 @@ IN: compiler.cfg.stacks.local
: modify-height ( state loc -- )
>loc< 0 1 ? rot nth [ + ] with map! drop ;
: adjust ( state loc -- )
>loc< 0 1 ? rot nth dup first swapd + 0 rot set-nth ;
: reset-emits ( state -- )
[ 0 1 rot set-nth ] each ;

View File

@ -16,8 +16,8 @@ HELP: end-stack-analysis
{ $description "Ends the stack analysis of the current cfg. This is the last step of the cfg construction (but comes before all optimization passes)." } ;
HELP: adjust-d
{ $values { "n" number } }
{ $description "Changes the height of the current data stack. This word is called when other instructions which internally adjust the stack height are emitted, such as " { $link ##call } " and " { $link ##alien-invoke } "." } ;
{ $values { "n" integer } }
{ $description "Changes the current height of the data stack. The word is used when other instructions which adjust the stack height are emitted, such as " { $link ##call } " and " { $link ##alien-invoke } ". Since the stack height is adjusted without emitting " { ##inc } " instructions, the " { $link inc-stack } " word can't be used by them." } ;
HELP: ds-drop
{ $description "Used to signal to the stack analysis that the datastacks height is decreased by one." } ;

View File

@ -3,6 +3,15 @@ compiler.cfg.stacks compiler.cfg.stacks.local compiler.test kernel literals
namespaces tools.test ;
IN: compiler.cfg.stacks.tests
! adjust-d
{
{ { 6 2 } { 3 4 } }
{ { -4 2 } { 3 4 } }
} [
{ { 1 2 } { 3 4 } } [ height-state set 5 adjust-d ] keep
{ { 1 2 } { 3 4 } } [ height-state set -5 adjust-d ] keep
] unit-test
{
H{ { D: 1 4 } { D: 2 3 } { D: 0 5 } }
{ { 0 0 } { 0 0 } }

View File

@ -61,4 +61,4 @@ IN: compiler.cfg.stacks
[ ds-pop ] dip call ds-push ; inline
: adjust-d ( n -- )
<ds-loc> height-state get swap adjust ;
0 height-state get first [ + ] change-nth ;