From caab84061d0d3cc86bf62d55437a2c1ede317b0a Mon Sep 17 00:00:00 2001 From: Alex Vondrak Date: Mon, 27 Jun 2011 23:27:13 -0700 Subject: [PATCH] compiler.cfg.gvn: annotate portions of code where availability will be an issue --- extra/compiler/cfg/gvn/alien/alien.factor | 6 ++++++ extra/compiler/cfg/gvn/comparisons/comparisons.factor | 5 +++++ extra/compiler/cfg/gvn/math/math.factor | 2 ++ extra/compiler/cfg/gvn/misc/misc.factor | 3 +++ extra/compiler/cfg/gvn/simd/simd.factor | 3 +++ extra/compiler/cfg/gvn/slots/slots.factor | 1 + 6 files changed, 20 insertions(+) diff --git a/extra/compiler/cfg/gvn/alien/alien.factor b/extra/compiler/cfg/gvn/alien/alien.factor index 7b7e235dcc..e197bd5372 100644 --- a/extra/compiler/cfg/gvn/alien/alien.factor +++ b/extra/compiler/cfg/gvn/alien/alien.factor @@ -34,6 +34,7 @@ M: ##box-displaced-alien rewrite ##add ] { } make ; +! XXX the vregs that src>> vreg>insn uses are not necessarily available : rewrite-unbox-any-c-ptr ( insn -- insn/f ) dup src>> vreg>insn { @@ -51,6 +52,7 @@ M: ##unbox-alien rewrite rewrite-unbox-any-c-ptr ; : fuse-base-offset? ( insn -- ? ) base>> vreg>insn ##add-imm? ; +! XXX base>> vreg>insn src1>> not necessarily available : fuse-base-offset ( insn -- insn' ) clone dup base>> vreg>insn [ src1>> ] [ src2>> ] bi @@ -61,6 +63,7 @@ M: ##unbox-alien rewrite rewrite-unbox-any-c-ptr ; : fuse-displacement-offset? ( insn -- ? ) { [ scale>> 0 = ] [ displacement>> vreg>insn ##add-imm? ] } 1&& ; +! XXX displacement>> vreg>insn src1>> not necessarily available : fuse-displacement-offset ( insn -- insn' ) clone dup displacement>> vreg>insn [ 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: ##store-memory-imm new-alien-insn drop \ ##store-memory new-insn ; +! XXX base>> vreg>insn src1>> & src2>> not necessarily +! available : fuse-displacement ( insn -- insn' ) { [ alien-insn-value ] @@ -103,6 +108,7 @@ M: ##store-memory-imm new-alien-insn drop \ ##store-memory new-insn ; : fuse-scale? ( insn -- ? ) { [ scale>> 0 = ] [ displacement>> vreg>insn scale-insn? ] } 1&& ; +! XXX displacement>> vreg>insn src1>> not necessarily available : fuse-scale ( insn -- insn' ) clone dup displacement>> vreg>insn [ src1>> ] [ src2>> ] bi diff --git a/extra/compiler/cfg/gvn/comparisons/comparisons.factor b/extra/compiler/cfg/gvn/comparisons/comparisons.factor index 9437c83a4f..a7b232e891 100644 --- a/extra/compiler/cfg/gvn/comparisons/comparisons.factor +++ b/extra/compiler/cfg/gvn/comparisons/comparisons.factor @@ -217,6 +217,7 @@ M: ##compare-integer rewrite [ cc>> { cc= cc/= } member? ] } 1&& ; inline +! XXX the vregs that src1>> vreg>insn uses are not necessarily available : rewrite-redundant-comparison ( insn -- insn' ) [ cc>> ] [ dst>> ] [ src1>> vreg>insn ] tri { { [ dup ##compare? ] [ >compare< next-vreg \ ##compare new-insn ] } @@ -254,6 +255,8 @@ M: ##compare-integer-imm rewrite [ drop f ] } cond ; +! XXX the vregs (src1>> and src2>>) that src1>> vreg>insn uses +! are not necessarily available : (simplify-test) ( insn -- src1 src2 cc ) [ 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) \ ##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 ) [ src1>> vreg>insn [ src1>> ] [ src2>> ] bi ] [ cc>> ] bi ; inline diff --git a/extra/compiler/cfg/gvn/math/math.factor b/extra/compiler/cfg/gvn/math/math.factor index 63993a8726..65376d80bb 100644 --- a/extra/compiler/cfg/gvn/math/math.factor +++ b/extra/compiler/cfg/gvn/math/math.factor @@ -23,6 +23,7 @@ M: ##tagged>integer rewrite [ 2drop f ] } cond ; +! XXX src>> vreg>insn src>> not necessarily available : self-inverse ( insn -- insn' ) [ dst>> ] [ src>> vreg>insn src>> ] bi ; @@ -101,6 +102,7 @@ M: ##sub-imm rewrite sub-imm>add-imm ; : mul-to-shl ( insn -- insn' ) [ [ dst>> ] [ src1>> ] bi ] [ src2>> log2 ] bi \ ##shl-imm new-insn ; +! XXX not sure if availability is an issue ! Distribution converts ! ##+-imm 2 1 X ! ##*-imm 3 2 Y diff --git a/extra/compiler/cfg/gvn/misc/misc.factor b/extra/compiler/cfg/gvn/misc/misc.factor index 9e23ae3bdd..2a0a30ee18 100644 --- a/extra/compiler/cfg/gvn/misc/misc.factor +++ b/extra/compiler/cfg/gvn/misc/misc.factor @@ -15,6 +15,9 @@ M: ##replace rewrite [ swap \ ##replace-imm new-insn ] [ 2drop f ] if ] [ 2drop f ] if ; +! XXX any particular input's vn isn't necessarily available, so +! can't just return a straight-up ; might just do +! this with a set-vn in gvn.factor:value-number M: ##phi rewrite [ dst>> ] [ inputs>> values [ vreg>vn ] map sift ] bi dup all-equal? [ diff --git a/extra/compiler/cfg/gvn/simd/simd.factor b/extra/compiler/cfg/gvn/simd/simd.factor index 14fd574eb1..ee64b2fbfb 100644 --- a/extra/compiler/cfg/gvn/simd/simd.factor +++ b/extra/compiler/cfg/gvn/simd/simd.factor @@ -18,6 +18,9 @@ IN: compiler.cfg.gvn.simd ! Some lame constant folding for SIMD intrinsics. Eventually this ! 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 -- ? ) [ shuffle>> ] [ rep>> rep-length iota ] bi sequence= ; diff --git a/extra/compiler/cfg/gvn/slots/slots.factor b/extra/compiler/cfg/gvn/slots/slots.factor index 15a1040edd..fae7459db3 100644 --- a/extra/compiler/cfg/gvn/slots/slots.factor +++ b/extra/compiler/cfg/gvn/slots/slots.factor @@ -11,6 +11,7 @@ IN: compiler.cfg.gvn.slots complex-addressing? [ 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 ) dup simplify-slot-addressing? [ clone dup slot>> vreg>insn