compiler.*,cpu.*: add a height slot to ##call nodes, then other compiler

passes can much easier to accurate liveness analysis on stack locations
db4
Björn Lindqvist 2015-05-07 13:34:48 +02:00 committed by John Benediktsson
parent 3887b58c02
commit 8df92abeb9
10 changed files with 16 additions and 19 deletions

View File

@ -35,11 +35,12 @@ IN: compiler.cfg.builder.blocks
: call-height ( #call -- n ) : call-height ( #call -- n )
[ out-d>> length ] [ in-d>> length ] bi - ; [ out-d>> length ] [ in-d>> length ] bi - ;
: emit-call-block ( word height -- )
dup adjust-d ##call, make-kill-block ;
: emit-primitive ( node -- ) : emit-primitive ( node -- )
[ [
[ word>> ##call, ] [ word>> ] [ call-height ] bi emit-call-block
[ call-height adjust-d ] bi
make-kill-block
] emit-trivial-block ; ] emit-trivial-block ;
: begin-branch ( -- ) : begin-branch ( -- )

View File

@ -245,7 +245,7 @@ IN: compiler.cfg.builder.tests
! emit-call ! emit-call
{ {
V{ T{ ##call { word print } } T{ ##branch } } V{ T{ ##call { word print } { height 4 } } T{ ##branch } }
} [ } [
[ \ print 4 emit-call ] V{ } make drop [ \ print 4 emit-call ] V{ } make drop
basic-block get successors>> first instructions>> basic-block get successors>> first instructions>>

View File

@ -69,10 +69,7 @@ GENERIC: emit-node ( node -- )
over loops get key? over loops get key?
[ drop loops get at emit-loop-call ] [ drop loops get at emit-loop-call ]
[ [
[ [ emit-call-block ] emit-trivial-block
[ ##call, ] [ adjust-d ] bi*
make-kill-block
] emit-trivial-block
] if ; ] if ;
! #recursive ! #recursive

View File

@ -62,7 +62,7 @@ literal: loc ;
! Subroutine calls ! Subroutine calls
INSN: ##call INSN: ##call
literal: word ; literal: word height ;
INSN: ##jump INSN: ##jump
literal: word ; literal: word ;

View File

@ -45,9 +45,7 @@ IN: compiler.cfg.intrinsics.fixnum
: emit-overflow-case ( word -- final-bb ) : emit-overflow-case ( word -- final-bb )
[ [
##call, -1 emit-call-block
-1 adjust-d
make-kill-block
] with-branch ; ] with-branch ;
: emit-fixnum-overflow-op ( quot word -- ) : emit-fixnum-overflow-op ( quot word -- )

View File

@ -4,7 +4,7 @@ kernel make compiler.constants words ;
IN: compiler.codegen.tests IN: compiler.codegen.tests
[ ] [ [ ] with-fixup drop ] unit-test [ ] [ [ ] with-fixup drop ] unit-test
[ ] [ [ \ + %call ] with-fixup drop ] unit-test [ ] [ [ \ + 0 %call ] with-fixup drop ] unit-test
[ ] [ [ <label> dup define-label dup resolve-label %jump-label ] with-fixup drop ] unit-test [ ] [ [ <label> dup define-label dup resolve-label %jump-label ] with-fixup drop ] unit-test
[ ] [ [ <label> dup define-label dup resolve-label B{ 0 0 0 0 } % rc-absolute-cell label-fixup ] with-fixup drop ] unit-test [ ] [ [ <label> dup define-label dup resolve-label B{ 0 0 0 0 } % rc-absolute-cell label-fixup ] with-fixup drop ] unit-test

View File

@ -24,6 +24,7 @@ fry namespaces ;
: init-cfg-test ( -- ) : init-cfg-test ( -- )
reset-vreg-counter begin-stack-analysis reset-vreg-counter begin-stack-analysis
<basic-block> dup basic-block set begin-local-analysis <basic-block> dup basic-block set begin-local-analysis
H{ } clone representations set
H{ } clone replaces set ; H{ } clone replaces set ;
: cfg-unit-test ( result quot -- ) : cfg-unit-test ( result quot -- )

View File

@ -234,7 +234,7 @@ HOOK: %replace-imm cpu ( src loc -- )
HOOK: %inc cpu ( loc -- ) HOOK: %inc cpu ( loc -- )
HOOK: stack-frame-size cpu ( stack-frame -- n ) HOOK: stack-frame-size cpu ( stack-frame -- n )
HOOK: %call cpu ( word -- ) HOOK: %call cpu ( word height -- )
HOOK: %jump cpu ( word -- ) HOOK: %jump cpu ( word -- )
HOOK: %jump-label cpu ( label -- ) HOOK: %jump-label cpu ( label -- )
HOOK: %return cpu ( -- ) HOOK: %return cpu ( -- )

View File

@ -195,8 +195,8 @@ M: ppc stack-frame-size ( stack-frame -- i )
factor-area-size + factor-area-size +
16 align ; 16 align ;
M: ppc %call ( word -- ) M: ppc %call ( word height -- )
0 BL rc-relative-ppc-3-pc rel-word-pic ; drop 0 BL rc-relative-ppc-3-pc rel-word-pic ;
: instrs ( n -- b ) 4 * ; inline : instrs ( n -- b ) 4 * ; inline
@ -922,7 +922,7 @@ M:: ppc %check-nursery-branch ( label size cc temp1 temp2 -- )
} case ; } case ;
M: ppc %call-gc ( gc-map -- ) M: ppc %call-gc ( gc-map -- )
\ minor-gc %call gc-map-here ; \ minor-gc 0 %call gc-map-here ;
M:: ppc %prologue ( stack-size -- ) M:: ppc %prologue ( stack-size -- )
0 MFLR 0 MFLR

View File

@ -95,7 +95,7 @@ M: x86 %replace-imm
M: x86 %inc ( loc -- ) M: x86 %inc ( loc -- )
[ n>> ] [ ds-loc? ds-reg rs-reg ? ] bi (%inc) ; [ n>> ] [ ds-loc? ds-reg rs-reg ? ] bi (%inc) ;
M: x86 %call ( word -- ) 0 CALL rc-relative rel-word-pic ; M: x86 %call ( word height -- ) drop 0 CALL rc-relative rel-word-pic ;
: xt-tail-pic-offset ( -- n ) : xt-tail-pic-offset ( -- n )
#! See the comment in vm/cpu-x86.hpp #! See the comment in vm/cpu-x86.hpp
@ -510,7 +510,7 @@ M: x86 gc-root-offset
n>> spill-offset special-offset cell + cell /i ; n>> spill-offset special-offset cell + cell /i ;
M: x86 %call-gc ( gc-map -- ) M: x86 %call-gc ( gc-map -- )
\ minor-gc %call \ minor-gc 0 %call
gc-map-here ; gc-map-here ;
M: x86 %alien-global ( dst symbol library -- ) M: x86 %alien-global ( dst symbol library -- )