compiler.cfg.representations.selection: use a union instead of a generic

to see if an insn is peephole-optimizable + test
db4
Björn Lindqvist 2015-07-27 11:26:48 +02:00 committed by John Benediktsson
parent 44c9b2c8e8
commit aca610813d
2 changed files with 33 additions and 26 deletions

View File

@ -0,0 +1,9 @@
USING: compiler.cfg.instructions
compiler.cfg.representations.selection tools.test ;
IN: compiler.cfg.representations.selection.tests
{ t t f } [
T{ ##load-integer } peephole-optimizable?
T{ ##shr-imm } peephole-optimizable?
T{ ##call } peephole-optimizable?
] unit-test

View File

@ -88,39 +88,37 @@ UNION: inert-arithmetic-tag-untag-insn
##sub-imm ; ##sub-imm ;
UNION: inert-bitwise-tag-untag-insn UNION: inert-bitwise-tag-untag-insn
##and-imm ##and-imm
##or-imm ##or-imm
##xor-imm ; ##xor-imm ;
GENERIC: has-peephole-opts? ( insn -- ? ) UNION: peephole-optimizable
##load-integer
M: insn has-peephole-opts? drop f ; ##load-reference
M: ##load-integer has-peephole-opts? drop t ; ##neg
M: ##load-reference has-peephole-opts? drop t ; ##not
M: ##neg has-peephole-opts? drop t ; inert-tag-untag-insn
M: ##not has-peephole-opts? drop t ; inert-arithmetic-tag-untag-insn
M: inert-tag-untag-insn has-peephole-opts? drop t ; inert-bitwise-tag-untag-insn
M: inert-arithmetic-tag-untag-insn has-peephole-opts? drop t ; ##mul-imm
M: inert-bitwise-tag-untag-insn has-peephole-opts? drop t ; ##shl-imm
M: ##mul-imm has-peephole-opts? drop t ; ##shr-imm
M: ##shl-imm has-peephole-opts? drop t ; ##sar-imm
M: ##shr-imm has-peephole-opts? drop t ; ##compare-integer-imm
M: ##sar-imm has-peephole-opts? drop t ; ##compare-integer
M: ##compare-integer-imm has-peephole-opts? drop t ; ##compare-integer-imm-branch
M: ##compare-integer has-peephole-opts? drop t ; ##compare-integer-branch
M: ##compare-integer-imm-branch has-peephole-opts? drop t ; ##test-imm
M: ##compare-integer-branch has-peephole-opts? drop t ; ##test
M: ##test-imm has-peephole-opts? drop t ; ##test-imm-branch
M: ##test has-peephole-opts? drop t ; ##test-branch ;
M: ##test-imm-branch has-peephole-opts? drop t ;
M: ##test-branch has-peephole-opts? drop t ;
GENERIC: compute-insn-costs ( insn -- ) GENERIC: compute-insn-costs ( insn -- )
M: insn compute-insn-costs drop ; M: insn compute-insn-costs drop ;
M: vreg-insn compute-insn-costs M: vreg-insn compute-insn-costs
dup has-peephole-opts? 2 5 ? '[ _ increase-costs ] each-rep ; dup peephole-optimizable? 2 5 ? '[ _ increase-costs ] each-rep ;
: compute-costs ( cfg -- ) : compute-costs ( cfg -- )
init-costs init-costs