From be342e86382616d1f71f3e750e35bbf889d5dd46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sun, 14 Jun 2015 02:13:31 +0200 Subject: [PATCH] compiler.cfg.ssa.destruction: refactors maybe/must-eliminate-copy into one try-eliminate-copy --- .../ssa/destruction/destruction-docs.factor | 26 ++++++++------ .../cfg/ssa/destruction/destruction.factor | 34 +++++++------------ 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/basis/compiler/cfg/ssa/destruction/destruction-docs.factor b/basis/compiler/cfg/ssa/destruction/destruction-docs.factor index 1c10ca97ac..d4f21aebe0 100644 --- a/basis/compiler/cfg/ssa/destruction/destruction-docs.factor +++ b/basis/compiler/cfg/ssa/destruction/destruction-docs.factor @@ -1,27 +1,31 @@ USING: compiler.cfg compiler.cfg.instructions -compiler.cfg.ssa.destruction.private help.markup help.syntax ; +compiler.cfg.ssa.destruction.private compiler.cfg.ssa.interference help.markup +help.syntax kernel ; IN: compiler.cfg.ssa.destruction HELP: class-element-map -{ $var-description "Maps leaders to equivalence class elements." } ; +{ $var-description "Maps leaders to equivalence class elements which are sequences of " { $link vreg-info } " instances." } ; HELP: cleanup-cfg { $values { "cfg" cfg } } { $description "In this step, " { $link ##parallel-copy } " instructions are substituted with more concreete " { $link ##copy } " instructions. " { $link ##phi } " instructions are removed here." } ; +HELP: coalesce-elements +{ $values { "merged" "??" } { "follower" "vreg" } { "leader" "vreg" } } +{ $description "Delete follower's class, and set leaders's class to merged." } ; + +HELP: coalesce-vregs +{ $values { "merged" "??" } { "follower" "vreg" } { "leader" "vreg" } } +{ $description "Sets 'leader' as the leader of 'follower'." } ; + HELP: copies { $var-description "Sequence of copies (tuples of { vreg-dst vreg-src}) that maybe can be eliminated later." } { $see-also init-coalescing } ; -HELP: maybe-eliminate-copy -{ $values { "vreg1" "vreg" } { "vreg2" "vreg" } } -{ $description "Eliminate a copy if possible." } -{ $see-also must-eliminate-copy } ; - -HELP: must-eliminate-copy -{ $values { "vreg1" "vreg" } { "vreg2" "vreg" } } -{ $description "Eliminates a copy." } -{ $see-also maybe-eliminate-copy } ; +HELP: try-eliminate-copy +{ $values { "follower" "vreg" } { "leader" "vreg" } { "must?" boolean } } +{ $description "Tries to eliminate a vreg copy from 'leader' to 'follower'. If 'must?' is " { $link t } " then a " { $link vregs-shouldn't-interfere } " error is thrown if the vregs interfere." } +{ $see-also vregs-interfere? } ; ARTICLE: "compiler.cfg.ssa.destruction" "SSA Destruction" "Because of the design of the register allocator, this pass has three peculiar properties." diff --git a/basis/compiler/cfg/ssa/destruction/destruction.factor b/basis/compiler/cfg/ssa/destruction/destruction.factor index d806f73771..c5ad460bdb 100644 --- a/basis/compiler/cfg/ssa/destruction/destruction.factor +++ b/basis/compiler/cfg/ssa/destruction/destruction.factor @@ -7,7 +7,7 @@ compiler.cfg.registers compiler.cfg.rpo compiler.cfg.ssa.cssa compiler.cfg.ssa.destruction.leaders compiler.cfg.ssa.interference compiler.cfg.ssa.interference.live-ranges compiler.cfg.utilities -cpu.architecture kernel locals make namespaces sequences sets ; +cpu.architecture kernel make namespaces sequences sets ; FROM: namespaces => set ; IN: compiler.cfg.ssa.destruction @@ -15,7 +15,6 @@ SYMBOL: class-element-map integer prepare-insn - [ dst>> ] [ src>> ] bi leaders must-eliminate-copy ; + [ dst>> ] [ src>> ] bi t try-eliminate-copy ; M: ##phi prepare-insn - [ dst>> ] [ inputs>> values ] bi - [ leaders must-eliminate-copy ] with each ; + [ dst>> ] [ inputs>> values ] bi [ t try-eliminate-copy ] with each ; : prepare-coalescing ( cfg -- ) init-coalescing [ [ prepare-insn ] each ] simple-analysis ; -:: maybe-eliminate-copy ( vreg1 vreg2 -- ) - vreg1 vreg2 = [ - vreg1 vreg2 vregs-interfere? - [ drop ] [ vreg1 vreg2 coalesce-vregs ] if - ] unless ; - : process-copies ( copies -- ) - [ leaders maybe-eliminate-copy ] assoc-each ; + [ f try-eliminate-copy ] assoc-each ; : perform-coalescing ( cfg -- ) prepare-coalescing copies get process-copies ;