2010-01-06 23:39:22 -05:00
|
|
|
! Copyright (C) 2009, 2010 Slava Pestov.
|
2009-09-08 22:56:28 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: accessors combinators.short-circuit
|
|
|
|
compiler.cfg.instructions compiler.cfg.registers
|
|
|
|
compiler.cfg.rpo cpu.architecture kernel sequences vectors ;
|
|
|
|
IN: compiler.cfg.save-contexts
|
|
|
|
|
|
|
|
! Insert context saves.
|
|
|
|
|
|
|
|
: needs-save-context? ( insns -- ? )
|
|
|
|
[
|
|
|
|
{
|
|
|
|
[ ##unary-float-function? ]
|
|
|
|
[ ##binary-float-function? ]
|
|
|
|
[ ##alien-invoke? ]
|
|
|
|
[ ##alien-indirect? ]
|
2010-01-06 23:39:22 -05:00
|
|
|
[ ##alien-assembly? ]
|
2009-09-08 22:56:28 -04:00
|
|
|
} 1||
|
|
|
|
] any? ;
|
|
|
|
|
|
|
|
: insert-save-context ( bb -- )
|
|
|
|
dup instructions>> dup needs-save-context? [
|
2010-04-19 15:05:55 -04:00
|
|
|
tagged-rep next-vreg-rep
|
|
|
|
tagged-rep next-vreg-rep
|
2009-09-08 22:56:28 -04:00
|
|
|
\ ##save-context new-insn prefix
|
|
|
|
>>instructions drop
|
|
|
|
] [ 2drop ] if ;
|
|
|
|
|
|
|
|
: insert-save-contexts ( cfg -- cfg' )
|
|
|
|
dup [ insert-save-context ] each-basic-block ;
|