compiler.cfg.linear-scan.linear-scan: refactoring of word so that locals doesn't need to be used and more docs (by moving comments)
parent
6c6f85428c
commit
043b6d5377
|
@ -37,3 +37,8 @@ IN: compiler.cfg.linear-scan.assignment.tests
|
|||
pending-interval-heap set 90 expire-old-intervals
|
||||
pending-interval-heap get heap-size
|
||||
] unit-test
|
||||
|
||||
{ } [
|
||||
V{ T{ ##inc { loc D 3 } { insn# 7 } } } 0 insns>block block>cfg { }
|
||||
assign-registers
|
||||
] unit-test
|
||||
|
|
|
@ -136,9 +136,9 @@ M: insn assign-registers-in-insn drop ;
|
|||
} cleave ;
|
||||
|
||||
:: assign-registers-in-block ( bb -- )
|
||||
bb begin-block
|
||||
bb [
|
||||
[
|
||||
bb begin-block
|
||||
[
|
||||
{
|
||||
[ insn#>> 1 - prepare-insn ]
|
||||
|
@ -147,11 +147,11 @@ M: insn assign-registers-in-insn drop ;
|
|||
[ , ]
|
||||
} cleave
|
||||
] each
|
||||
bb compute-live-out
|
||||
] V{ } make
|
||||
] change-instructions drop ;
|
||||
] change-instructions drop
|
||||
bb compute-live-out ;
|
||||
|
||||
: assign-registers ( live-intervals cfg -- )
|
||||
[ init-assignment ] dip
|
||||
: assign-registers ( cfg live-intervals -- )
|
||||
init-assignment
|
||||
linearization-order [ kill-block?>> not ] filter
|
||||
[ assign-registers-in-block ] each ;
|
||||
|
|
|
@ -4,3 +4,16 @@ IN: compiler.cfg.linear-scan
|
|||
HELP: admissible-registers
|
||||
{ $values { "cfg" cfg } { "regs" assoc } }
|
||||
{ $description "Lists all registers usable by the cfg by register class. In general, that's all registers except the frame pointer register that might be used by the cfg for other purposes." } ;
|
||||
|
||||
ARTICLE: "compiler.cfg.linear-scan" "Linear-scan register allocation"
|
||||
"Linear scan to assign physical registers. SSA liveness must have been computed already."
|
||||
$nl
|
||||
"References:"
|
||||
{ $list
|
||||
"Linear Scan Register Allocation by Massimiliano Poletto and Vivek Sarkar http://www.cs.ucla.edu/~palsberg/course/cs132/linearscan.pdf"
|
||||
"Linear Scan Register Allocation for the Java HotSpot Client Compiler by Christian Wimmer and http://www.ssw.uni-linz.ac.at/Research/Papers/Wimmer04Master/"
|
||||
"Quality and Speed in Linear-scan Register Allocation by Omri Traub, Glenn Holloway, Michael D. Smith http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.8435"
|
||||
} ;
|
||||
|
||||
|
||||
ABOUT: "compiler.cfg.linear-scan"
|
||||
|
|
|
@ -4,37 +4,23 @@ USING: accessors assocs compiler.cfg.linear-scan.allocation
|
|||
compiler.cfg.linear-scan.assignment
|
||||
compiler.cfg.linear-scan.live-intervals
|
||||
compiler.cfg.linear-scan.numbering
|
||||
compiler.cfg.linear-scan.resolve cpu.architecture kernel locals
|
||||
sequences ;
|
||||
compiler.cfg.linear-scan.resolve compiler.cfg.utilities cpu.architecture
|
||||
kernel sequences ;
|
||||
IN: compiler.cfg.linear-scan
|
||||
|
||||
! References:
|
||||
|
||||
! Linear Scan Register Allocation
|
||||
! by Massimiliano Poletto and Vivek Sarkar
|
||||
! http://www.cs.ucla.edu/~palsberg/course/cs132/linearscan.pdf
|
||||
|
||||
! Linear Scan Register Allocation for the Java HotSpot Client Compiler
|
||||
! by Christian Wimmer
|
||||
! and http://www.ssw.uni-linz.ac.at/Research/Papers/Wimmer04Master/
|
||||
|
||||
! Quality and Speed in Linear-scan Register Allocation
|
||||
! by Omri Traub, Glenn Holloway, Michael D. Smith
|
||||
! http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.8435
|
||||
|
||||
! SSA liveness must have been computed already
|
||||
|
||||
:: (linear-scan) ( cfg machine-registers -- )
|
||||
cfg number-instructions
|
||||
cfg compute-live-intervals machine-registers allocate-registers
|
||||
cfg assign-registers
|
||||
cfg resolve-data-flow
|
||||
cfg check-numbering ;
|
||||
|
||||
: admissible-registers ( cfg -- regs )
|
||||
machine-registers swap frame-pointer?>> [
|
||||
[ [ frame-reg = not ] filter ] assoc-map
|
||||
] when ;
|
||||
|
||||
: allocate-and-assign-registers ( cfg -- )
|
||||
[ ] [ compute-live-intervals ] [ admissible-registers ] tri
|
||||
allocate-registers assign-registers ;
|
||||
|
||||
: linear-scan ( cfg -- )
|
||||
dup admissible-registers (linear-scan) ;
|
||||
{
|
||||
number-instructions
|
||||
allocate-and-assign-registers
|
||||
resolve-data-flow
|
||||
check-numbering
|
||||
} apply-passes ;
|
||||
|
|
Loading…
Reference in New Issue