compiler.cfg.representations.selection: use a union instead of a generic
to see if an insn is peephole-optimizable + testdb4
parent
44c9b2c8e8
commit
aca610813d
|
@ -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
|
|
@ -88,39 +88,37 @@ UNION: inert-arithmetic-tag-untag-insn
|
|||
##sub-imm ;
|
||||
|
||||
UNION: inert-bitwise-tag-untag-insn
|
||||
##and-imm
|
||||
##or-imm
|
||||
##xor-imm ;
|
||||
##and-imm
|
||||
##or-imm
|
||||
##xor-imm ;
|
||||
|
||||
GENERIC: has-peephole-opts? ( insn -- ? )
|
||||
|
||||
M: insn has-peephole-opts? drop f ;
|
||||
M: ##load-integer has-peephole-opts? drop t ;
|
||||
M: ##load-reference has-peephole-opts? drop t ;
|
||||
M: ##neg has-peephole-opts? drop t ;
|
||||
M: ##not has-peephole-opts? drop t ;
|
||||
M: inert-tag-untag-insn has-peephole-opts? drop t ;
|
||||
M: inert-arithmetic-tag-untag-insn has-peephole-opts? drop t ;
|
||||
M: inert-bitwise-tag-untag-insn has-peephole-opts? drop t ;
|
||||
M: ##mul-imm has-peephole-opts? drop t ;
|
||||
M: ##shl-imm has-peephole-opts? drop t ;
|
||||
M: ##shr-imm has-peephole-opts? drop t ;
|
||||
M: ##sar-imm has-peephole-opts? drop t ;
|
||||
M: ##compare-integer-imm has-peephole-opts? drop t ;
|
||||
M: ##compare-integer has-peephole-opts? drop t ;
|
||||
M: ##compare-integer-imm-branch has-peephole-opts? drop t ;
|
||||
M: ##compare-integer-branch has-peephole-opts? drop t ;
|
||||
M: ##test-imm has-peephole-opts? drop t ;
|
||||
M: ##test has-peephole-opts? drop t ;
|
||||
M: ##test-imm-branch has-peephole-opts? drop t ;
|
||||
M: ##test-branch has-peephole-opts? drop t ;
|
||||
UNION: peephole-optimizable
|
||||
##load-integer
|
||||
##load-reference
|
||||
##neg
|
||||
##not
|
||||
inert-tag-untag-insn
|
||||
inert-arithmetic-tag-untag-insn
|
||||
inert-bitwise-tag-untag-insn
|
||||
##mul-imm
|
||||
##shl-imm
|
||||
##shr-imm
|
||||
##sar-imm
|
||||
##compare-integer-imm
|
||||
##compare-integer
|
||||
##compare-integer-imm-branch
|
||||
##compare-integer-branch
|
||||
##test-imm
|
||||
##test
|
||||
##test-imm-branch
|
||||
##test-branch ;
|
||||
|
||||
GENERIC: compute-insn-costs ( insn -- )
|
||||
|
||||
M: insn compute-insn-costs drop ;
|
||||
|
||||
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 -- )
|
||||
init-costs
|
||||
|
|
Loading…
Reference in New Issue