compiler.cfg.gvn: annotate portions of code where availability will be an issue

db4
Alex Vondrak 2011-06-27 23:27:13 -07:00 committed by John Benediktsson
parent e379feeb45
commit caab84061d
6 changed files with 20 additions and 0 deletions

View File

@ -34,6 +34,7 @@ M: ##box-displaced-alien rewrite
##add ##add
] { } make ; ] { } make ;
! XXX the vregs that src>> vreg>insn uses are not necessarily available
: rewrite-unbox-any-c-ptr ( insn -- insn/f ) : rewrite-unbox-any-c-ptr ( insn -- insn/f )
dup src>> vreg>insn dup src>> vreg>insn
{ {
@ -51,6 +52,7 @@ M: ##unbox-alien rewrite rewrite-unbox-any-c-ptr ;
: fuse-base-offset? ( insn -- ? ) : fuse-base-offset? ( insn -- ? )
base>> vreg>insn ##add-imm? ; base>> vreg>insn ##add-imm? ;
! XXX base>> vreg>insn src1>> not necessarily available
: fuse-base-offset ( insn -- insn' ) : fuse-base-offset ( insn -- insn' )
clone dup base>> vreg>insn clone dup base>> vreg>insn
[ src1>> ] [ src2>> ] bi [ src1>> ] [ src2>> ] bi
@ -61,6 +63,7 @@ M: ##unbox-alien rewrite rewrite-unbox-any-c-ptr ;
: fuse-displacement-offset? ( insn -- ? ) : fuse-displacement-offset? ( insn -- ? )
{ [ scale>> 0 = ] [ displacement>> vreg>insn ##add-imm? ] } 1&& ; { [ scale>> 0 = ] [ displacement>> vreg>insn ##add-imm? ] } 1&& ;
! XXX displacement>> vreg>insn src1>> not necessarily available
: fuse-displacement-offset ( insn -- insn' ) : fuse-displacement-offset ( insn -- insn' )
clone dup displacement>> vreg>insn clone dup displacement>> vreg>insn
[ src1>> ] [ src2>> ] bi [ src1>> ] [ src2>> ] bi
@ -85,6 +88,8 @@ GENERIC: new-alien-insn ( value base displacement scale offset rep c-type insn -
M: ##load-memory-imm new-alien-insn drop \ ##load-memory new-insn ; M: ##load-memory-imm new-alien-insn drop \ ##load-memory new-insn ;
M: ##store-memory-imm new-alien-insn drop \ ##store-memory new-insn ; M: ##store-memory-imm new-alien-insn drop \ ##store-memory new-insn ;
! XXX base>> vreg>insn src1>> & src2>> not necessarily
! available
: fuse-displacement ( insn -- insn' ) : fuse-displacement ( insn -- insn' )
{ {
[ alien-insn-value ] [ alien-insn-value ]
@ -103,6 +108,7 @@ M: ##store-memory-imm new-alien-insn drop \ ##store-memory new-insn ;
: fuse-scale? ( insn -- ? ) : fuse-scale? ( insn -- ? )
{ [ scale>> 0 = ] [ displacement>> vreg>insn scale-insn? ] } 1&& ; { [ scale>> 0 = ] [ displacement>> vreg>insn scale-insn? ] } 1&& ;
! XXX displacement>> vreg>insn src1>> not necessarily available
: fuse-scale ( insn -- insn' ) : fuse-scale ( insn -- insn' )
clone dup displacement>> vreg>insn clone dup displacement>> vreg>insn
[ src1>> ] [ src2>> ] bi [ src1>> ] [ src2>> ] bi

View File

@ -217,6 +217,7 @@ M: ##compare-integer rewrite
[ cc>> { cc= cc/= } member? ] [ cc>> { cc= cc/= } member? ]
} 1&& ; inline } 1&& ; inline
! XXX the vregs that src1>> vreg>insn uses are not necessarily available
: rewrite-redundant-comparison ( insn -- insn' ) : rewrite-redundant-comparison ( insn -- insn' )
[ cc>> ] [ dst>> ] [ src1>> vreg>insn ] tri { [ cc>> ] [ dst>> ] [ src1>> vreg>insn ] tri {
{ [ dup ##compare? ] [ >compare< next-vreg \ ##compare new-insn ] } { [ dup ##compare? ] [ >compare< next-vreg \ ##compare new-insn ] }
@ -254,6 +255,8 @@ M: ##compare-integer-imm rewrite
[ drop f ] [ drop f ]
} cond ; } cond ;
! XXX the vregs (src1>> and src2>>) that src1>> vreg>insn uses
! are not necessarily available
: (simplify-test) ( insn -- src1 src2 cc ) : (simplify-test) ( insn -- src1 src2 cc )
[ src1>> vreg>insn [ src1>> ] [ src2>> ] bi ] [ cc>> ] bi ; inline [ src1>> vreg>insn [ src1>> ] [ src2>> ] bi ] [ cc>> ] bi ; inline
@ -263,6 +266,8 @@ M: ##compare-integer-imm rewrite
: simplify-test-branch ( insn -- insn ) : simplify-test-branch ( insn -- insn )
(simplify-test) \ ##test-branch new-insn ; inline (simplify-test) \ ##test-branch new-insn ; inline
! XXX the vregs (src1>> and src2>>) that src1>> vreg>insn uses
! are not necessarily available
: (simplify-test-imm) ( insn -- src1 src2 cc ) : (simplify-test-imm) ( insn -- src1 src2 cc )
[ src1>> vreg>insn [ src1>> ] [ src2>> ] bi ] [ cc>> ] bi ; inline [ src1>> vreg>insn [ src1>> ] [ src2>> ] bi ] [ cc>> ] bi ; inline

View File

@ -23,6 +23,7 @@ M: ##tagged>integer rewrite
[ 2drop f ] [ 2drop f ]
} cond ; } cond ;
! XXX src>> vreg>insn src>> not necessarily available
: self-inverse ( insn -- insn' ) : self-inverse ( insn -- insn' )
[ dst>> ] [ src>> vreg>insn src>> ] bi <copy> ; [ dst>> ] [ src>> vreg>insn src>> ] bi <copy> ;
@ -101,6 +102,7 @@ M: ##sub-imm rewrite sub-imm>add-imm ;
: mul-to-shl ( insn -- insn' ) : mul-to-shl ( insn -- insn' )
[ [ dst>> ] [ src1>> ] bi ] [ src2>> log2 ] bi \ ##shl-imm new-insn ; [ [ dst>> ] [ src1>> ] bi ] [ src2>> log2 ] bi \ ##shl-imm new-insn ;
! XXX not sure if availability is an issue
! Distribution converts ! Distribution converts
! ##+-imm 2 1 X ! ##+-imm 2 1 X
! ##*-imm 3 2 Y ! ##*-imm 3 2 Y

View File

@ -15,6 +15,9 @@ M: ##replace rewrite
[ swap \ ##replace-imm new-insn ] [ 2drop f ] if [ swap \ ##replace-imm new-insn ] [ 2drop f ] if
] [ 2drop f ] if ; ] [ 2drop f ] if ;
! XXX any particular input's vn isn't necessarily available, so
! can't just return a straight-up <copy>; might just do
! this with a set-vn in gvn.factor:value-number
M: ##phi rewrite M: ##phi rewrite
[ dst>> ] [ inputs>> values [ vreg>vn ] map sift ] bi [ dst>> ] [ inputs>> values [ vreg>vn ] map sift ] bi
dup all-equal? [ dup all-equal? [

View File

@ -18,6 +18,9 @@ IN: compiler.cfg.gvn.simd
! Some lame constant folding for SIMD intrinsics. Eventually this ! Some lame constant folding for SIMD intrinsics. Eventually this
! should be redone completely. ! should be redone completely.
! XXX pretty much all of these rely on the vregs used by some
! vreg>insn, but they aren't necessarily available
: useless-shuffle-vector-imm? ( insn -- ? ) : useless-shuffle-vector-imm? ( insn -- ? )
[ shuffle>> ] [ rep>> rep-length iota ] bi sequence= ; [ shuffle>> ] [ rep>> rep-length iota ] bi sequence= ;

View File

@ -11,6 +11,7 @@ IN: compiler.cfg.gvn.slots
complex-addressing? complex-addressing?
[ slot>> vreg>insn ##add-imm? ] [ drop f ] if ; [ slot>> vreg>insn ##add-imm? ] [ drop f ] if ;
! XXX the vregs that slot>> vreg>insn uses are not necessarily available
: simplify-slot-addressing ( insn -- insn/f ) : simplify-slot-addressing ( insn -- insn/f )
dup simplify-slot-addressing? [ dup simplify-slot-addressing? [
clone dup slot>> vreg>insn clone dup slot>> vreg>insn