vreg-insn


Vocabulary
compiler.cfg.instructions

Definition
IN: compiler.cfg.instructions

TUPLE: vreg-insn < insn ;


Methods
USING: arrays compiler.cfg.instructions
compiler.cfg.representations.preferred
compiler.cfg.representations.selection kernel ;

M: vreg-insn (collect-vreg-reps)
[ [ handle-use ] each-use-rep ]
[ [ 1array handle-def ] each-def-rep ]
[ [ 1array handle-def ] each-temp-rep ] tri ;


USING: compiler.cfg.alias-analysis compiler.cfg.instructions ;

M: vreg-insn analyze-aliases def-acs ;


USING: compiler.cfg.instructions
compiler.cfg.linear-scan.assignment kernel ;

M: vreg-insn assign-registers-in-insn
[ assign-insn-defs ] [ assign-insn-uses ]
[ assign-insn-temps ] tri ;


USING: compiler.cfg.dce compiler.cfg.def-use
compiler.cfg.instructions kernel sequences ;

M: vreg-insn build-liveness-graph
[ uses-vregs ] [ defs-vregs ] bi [ add-edges ] with each ;


USING: compiler.cfg.instructions
compiler.cfg.representations.preferred
compiler.cfg.representations.selection kernel ;

M: vreg-insn compute-insn-costs
dup has-peephole-opts? 2 5 ? [ increase-costs ] curry
each-rep ;


USING: assocs compiler.cfg.def-use compiler.cfg.instructions
compiler.cfg.ssa.construction.private kernel math namespaces
sequences sets ;

M: vreg-insn compute-insn-defs
defs-vregs [
defs get
[ adjoin-at ] [ drop ] [ at cardinality 1 > ] 2tri
[ defs-multi get adjoin ] [ drop ] if
] with each ;


USING: accessors compiler.cfg.def-use compiler.cfg.instructions
compiler.cfg.linear-scan.live-intervals kernel sequences ;

M: vreg-insn compute-live-intervals*
dup insn#>>
[ [ defs-vregs ] dip [ f record-def ] curry each ]
[ [ uses-vregs ] dip [ f record-use ] curry each ]
[ [ temp-vregs ] dip [ record-temp ] curry each ] 2tri ;


USING: compiler.cfg.dce compiler.cfg.instructions ;

M: vreg-insn compute-live-vregs record-live ;


USING: compiler.cfg.instructions
compiler.cfg.representations.peephole
compiler.cfg.representations.rewrite ;

M: vreg-insn conversions-for-insn
init-renaming-set optimize-insn last-insn perform-renaming
;


USING: compiler.cfg.instructions compiler.cfg.liveness kernel ;

M: vreg-insn lookup-base-pointer* 2drop f ;


USING: compiler.cfg.instructions
compiler.cfg.representations.peephole
compiler.cfg.representations.rewrite kernel ;

M: vreg-insn optimize-insn
[ emit-use-conversion ] [ finish ] [ emit-def-conversion ]
tri ;


USING: compiler.cfg.def-use compiler.cfg.instructions
compiler.cfg.registers compiler.cfg.ssa.destruction.leaders
compiler.cfg.ssa.destruction.private cpu.architecture kernel
namespaces sequences sets ;

M: vreg-insn prepare-insn
[ temp-vregs [ leader-map get conjoin ] each ] [
[ defs-vregs ] [ uses-vregs ] bi 2dup
[ empty? not ] both? [
[ first ] bi@ 2dup [ rep-of reg-class-of ] bi@ eq?
[ maybe-eliminate-copy-later ] [ 2drop ] if
] [ 2drop ] if
] bi ;


USING: compiler.cfg.instructions
compiler.cfg.ssa.interference.live-ranges.private kernel math ;

M: vreg-insn record-insn
[ 2 * ] dip [ record-defs ] [ record-uses ] 2bi ;


USING: compiler.cfg.instructions
compiler.cfg.ssa.construction.private kernel ;

M: vreg-insn rename-insn
[ ssa-rename-insn-uses ] [ ssa-rename-insn-defs ] bi ;


USING: compiler.cfg.copy-prop.private compiler.cfg.instructions
compiler.cfg.renaming ;

M: vreg-insn update-insn rename-insn-uses t ;


USING: compiler.cfg.def-use compiler.cfg.instructions
compiler.cfg.linear-scan.live-intervals ;

M: vreg-insn uses-vregs* uses-vregs ;


USING: compiler.cfg.instructions compiler.cfg.liveness kernel ;

M: vreg-insn visit-insn [ kill-defs ] [ gen-uses ] bi ;


USING: compiler.cfg.copy-prop.private compiler.cfg.def-use
compiler.cfg.instructions ;

M: vreg-insn visit-insn defs-vregs record-copies ;