compiler.cfg.dataflow-analysis: removes the -analysis from the dfa token
It makes the FORWARD-ANALYSIS: and BACKWARD-ANALYSIS: functors less magical if the generated singletons name is the same as in the syntax.locals-and-roots
parent
4d2afed06d
commit
f80513cd99
|
@ -59,7 +59,7 @@ M: dataflow-analysis ignore-block? drop kill-block?>> ;
|
||||||
|
|
||||||
FUNCTOR: define-analysis ( name -- )
|
FUNCTOR: define-analysis ( name -- )
|
||||||
|
|
||||||
name-analysis DEFINES-CLASS ${name}-analysis
|
name DEFINES-CLASS ${name}
|
||||||
name-ins DEFINES ${name}-ins
|
name-ins DEFINES ${name}-ins
|
||||||
name-outs DEFINES ${name}-outs
|
name-outs DEFINES ${name}-outs
|
||||||
name-in DEFINES ${name}-in
|
name-in DEFINES ${name}-in
|
||||||
|
@ -67,7 +67,7 @@ name-out DEFINES ${name}-out
|
||||||
|
|
||||||
WHERE
|
WHERE
|
||||||
|
|
||||||
SINGLETON: name-analysis
|
SINGLETON: name
|
||||||
|
|
||||||
SYMBOL: name-ins
|
SYMBOL: name-ins
|
||||||
|
|
||||||
|
@ -90,17 +90,17 @@ M: forward-analysis predecessors drop predecessors>> ;
|
||||||
|
|
||||||
FUNCTOR: define-forward-analysis ( name -- )
|
FUNCTOR: define-forward-analysis ( name -- )
|
||||||
|
|
||||||
name-analysis IS ${name}-analysis
|
name IS ${name}
|
||||||
name-ins IS ${name}-ins
|
name-ins IS ${name}-ins
|
||||||
name-outs IS ${name}-outs
|
name-outs IS ${name}-outs
|
||||||
compute-name-sets DEFINES compute-${name}-sets
|
compute-name-sets DEFINES compute-${name}-sets
|
||||||
|
|
||||||
WHERE
|
WHERE
|
||||||
|
|
||||||
INSTANCE: name-analysis forward-analysis
|
INSTANCE: name forward-analysis
|
||||||
|
|
||||||
: compute-name-sets ( cfg -- )
|
: compute-name-sets ( cfg -- )
|
||||||
name-analysis run-dataflow-analysis
|
name run-dataflow-analysis
|
||||||
[ name-ins set ] [ name-outs set ] bi* ;
|
[ name-ins set ] [ name-outs set ] bi* ;
|
||||||
|
|
||||||
;FUNCTOR
|
;FUNCTOR
|
||||||
|
@ -116,17 +116,17 @@ M: backward-analysis predecessors drop successors>> ;
|
||||||
|
|
||||||
FUNCTOR: define-backward-analysis ( name -- )
|
FUNCTOR: define-backward-analysis ( name -- )
|
||||||
|
|
||||||
name-analysis IS ${name}-analysis
|
name IS ${name}
|
||||||
name-ins IS ${name}-ins
|
name-ins IS ${name}-ins
|
||||||
name-outs IS ${name}-outs
|
name-outs IS ${name}-outs
|
||||||
compute-name-sets DEFINES compute-${name}-sets
|
compute-name-sets DEFINES compute-${name}-sets
|
||||||
|
|
||||||
WHERE
|
WHERE
|
||||||
|
|
||||||
INSTANCE: name-analysis backward-analysis
|
INSTANCE: name backward-analysis
|
||||||
|
|
||||||
: compute-name-sets ( cfg -- )
|
: compute-name-sets ( cfg -- )
|
||||||
\ name-analysis run-dataflow-analysis
|
\ name run-dataflow-analysis
|
||||||
[ name-outs set ] [ name-ins set ] bi* ;
|
[ name-outs set ] [ name-ins set ] bi* ;
|
||||||
|
|
||||||
;FUNCTOR
|
;FUNCTOR
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: assocs combinators compiler.cfg.dataflow-analysis
|
USING: assocs compiler.cfg.dataflow-analysis compiler.cfg.stacks.local
|
||||||
compiler.cfg.stacks.local kernel namespaces sequences sets ;
|
kernel namespaces sequences sets ;
|
||||||
IN: compiler.cfg.stacks.global
|
IN: compiler.cfg.stacks.global
|
||||||
|
|
||||||
: peek-set ( bb -- assoc ) peek-sets get at ;
|
: peek-set ( bb -- assoc ) peek-sets get at ;
|
||||||
|
@ -20,38 +20,38 @@ IN: compiler.cfg.stacks.global
|
||||||
! before writing it.
|
! before writing it.
|
||||||
BACKWARD-ANALYSIS: anticip
|
BACKWARD-ANALYSIS: anticip
|
||||||
|
|
||||||
M: anticip-analysis transfer-set drop transfer-peeked-locs ;
|
M: anticip transfer-set drop transfer-peeked-locs ;
|
||||||
M: anticip-analysis join-sets 2drop refine ;
|
M: anticip join-sets 2drop refine ;
|
||||||
|
|
||||||
! A stack location is live at a location if some path from
|
! A stack location is live at a location if some path from
|
||||||
! the location to an exit block will read the stack location
|
! the location to an exit block will read the stack location
|
||||||
! before writing it.
|
! before writing it.
|
||||||
BACKWARD-ANALYSIS: live
|
BACKWARD-ANALYSIS: live
|
||||||
|
|
||||||
M: live-analysis transfer-set drop transfer-peeked-locs ;
|
M: live transfer-set drop transfer-peeked-locs ;
|
||||||
M: live-analysis join-sets 2drop combine ;
|
M: live join-sets 2drop combine ;
|
||||||
|
|
||||||
! A stack location is available at a location if all paths from
|
! A stack location is available at a location if all paths from
|
||||||
! the entry block to the location load the location into a
|
! the entry block to the location load the location into a
|
||||||
! register.
|
! register.
|
||||||
FORWARD-ANALYSIS: avail
|
FORWARD-ANALYSIS: avail
|
||||||
|
|
||||||
M: avail-analysis transfer-set
|
M: avail transfer-set
|
||||||
drop [ peek-set ] [ replace-set ] bi union union ;
|
drop [ peek-set ] [ replace-set ] bi union union ;
|
||||||
M: avail-analysis join-sets 2drop refine ;
|
M: avail join-sets 2drop refine ;
|
||||||
|
|
||||||
! A stack location is pending at a location if all paths from
|
! A stack location is pending at a location if all paths from
|
||||||
! the entry block to the location write the location.
|
! the entry block to the location write the location.
|
||||||
FORWARD-ANALYSIS: pending
|
FORWARD-ANALYSIS: pending
|
||||||
|
|
||||||
M: pending-analysis transfer-set
|
M: pending transfer-set
|
||||||
drop replace-set union ;
|
drop replace-set union ;
|
||||||
M: pending-analysis join-sets 2drop refine ;
|
M: pending join-sets 2drop refine ;
|
||||||
|
|
||||||
! A stack location is dead at a location if no paths from the
|
! A stack location is dead at a location if no paths from the
|
||||||
! location to the exit block read the location before writing it.
|
! location to the exit block read the location before writing it.
|
||||||
BACKWARD-ANALYSIS: dead
|
BACKWARD-ANALYSIS: dead
|
||||||
|
|
||||||
M: dead-analysis transfer-set
|
M: dead transfer-set
|
||||||
drop [ kill-set ] [ replace-set ] bi union union ;
|
drop [ kill-set ] [ replace-set ] bi union union ;
|
||||||
M: dead-analysis join-sets 2drop refine ;
|
M: dead join-sets 2drop refine ;
|
||||||
|
|
|
@ -87,13 +87,13 @@ SYMBOL: stack-record
|
||||||
: visit-insns ( insns state -- state' )
|
: visit-insns ( insns state -- state' )
|
||||||
[ [ register-stack-state ] [ visit-insn ] 2bi ] reduce ;
|
[ [ register-stack-state ] [ visit-insn ] 2bi ] reduce ;
|
||||||
|
|
||||||
M: padding-analysis transfer-set ( in-set bb dfa -- out-set )
|
M: padding transfer-set ( in-set bb dfa -- out-set )
|
||||||
drop instructions>> swap visit-insns ;
|
drop instructions>> swap visit-insns ;
|
||||||
|
|
||||||
M: padding-analysis ignore-block? ( bb dfa -- ? )
|
M: padding ignore-block? ( bb dfa -- ? )
|
||||||
2drop f ;
|
2drop f ;
|
||||||
|
|
||||||
M: padding-analysis join-sets ( sets bb dfa -- set )
|
M: padding join-sets ( sets bb dfa -- set )
|
||||||
2drop combine-states ;
|
2drop combine-states ;
|
||||||
|
|
||||||
: uniquely-number-instructions ( cfg -- )
|
: uniquely-number-instructions ( cfg -- )
|
||||||
|
|
|
@ -20,7 +20,7 @@ IN: compiler.cfg.gvn.avail
|
||||||
|
|
||||||
FORWARD-ANALYSIS: avail
|
FORWARD-ANALYSIS: avail
|
||||||
|
|
||||||
M: avail-analysis transfer-set drop defined assoc-union ;
|
M: avail transfer-set drop defined assoc-union ;
|
||||||
|
|
||||||
: available? ( vn -- ? ) basic-block get avail-in key? ;
|
: available? ( vn -- ? ) basic-block get avail-in key? ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue