From 4c07d04417adcf260dc52dd97b8cd78e3b168e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Mon, 24 Nov 2014 06:25:34 +0100 Subject: [PATCH] compiler.cfg.*: getting an instruction sequence from a cfg is used in a few tests so let's make a word for it --- basis/compiler/cfg/debugger/debugger.factor | 3 +-- basis/compiler/cfg/scheduling/scheduling-tests.factor | 5 ++--- basis/compiler/cfg/utilities/utilities.factor | 5 ++++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/basis/compiler/cfg/debugger/debugger.factor b/basis/compiler/cfg/debugger/debugger.factor index 540daa1c8c..853fde3f4e 100644 --- a/basis/compiler/cfg/debugger/debugger.factor +++ b/basis/compiler/cfg/debugger/debugger.factor @@ -124,8 +124,7 @@ M: rs-loc pprint* \ R pprint-loc ; ] map concat >hashtable representations set ; : count-insns ( quot insn-check -- ? ) - [ test-regs [ post-order [ instructions>> ] map concat ] map concat ] dip - count ; inline + [ test-regs [ cfg>insns ] map concat ] dip count ; inline : contains-insn? ( quot insn-check -- ? ) count-insns 0 > ; inline diff --git a/basis/compiler/cfg/scheduling/scheduling-tests.factor b/basis/compiler/cfg/scheduling/scheduling-tests.factor index a7d71efb02..63dfa0e90e 100644 --- a/basis/compiler/cfg/scheduling/scheduling-tests.factor +++ b/basis/compiler/cfg/scheduling/scheduling-tests.factor @@ -1,5 +1,5 @@ USING: accessors arrays assocs compiler.cfg compiler.cfg.dependence -compiler.cfg.dependence.tests compiler.cfg.instructions +compiler.cfg.test-words compiler.cfg.instructions compiler.cfg.linearization compiler.cfg.registers compiler.cfg.scheduling compiler.cfg.utilities grouping kernel math namespaces tools.test random sequences sets splitting vectors words compiler.cfg.test-words ; @@ -55,8 +55,7 @@ IN: compiler.cfg.scheduling.tests T{ ##load-tagged } T{ ##allot } T{ ##set-slot-imm } - } insns>cfg schedule-instructions - linearization-order [ instructions>> ] map concat [ insn#>> ] all? + } insns>cfg schedule-instructions cfg>insns [ insn#>> ] all? ] unit-test : test-1187 ( -- insns ) diff --git a/basis/compiler/cfg/utilities/utilities.factor b/basis/compiler/cfg/utilities/utilities.factor index 7354694ab6..b51b5009af 100644 --- a/basis/compiler/cfg/utilities/utilities.factor +++ b/basis/compiler/cfg/utilities/utilities.factor @@ -3,7 +3,7 @@ USING: accessors assocs combinators combinators.short-circuit cpu.architecture kernel layouts locals make math namespaces sequences sets vectors fry arrays compiler.cfg compiler.cfg.instructions -compiler.cfg.rpo compiler.utilities ; +compiler.cfg.linearization compiler.cfg.rpo compiler.utilities ; IN: compiler.cfg.utilities : block>cfg ( bb -- cfg ) @@ -15,6 +15,9 @@ IN: compiler.cfg.utilities : insns>cfg ( insns -- cfg ) 0 insns>block block>cfg ; +: cfg>insns ( cfg -- insns ) + linearization-order [ instructions>> ] map concat ; + : back-edge? ( from to -- ? ) [ number>> ] bi@ >= ;