compiler.*: random doc and tests updates

db4
Björn Lindqvist 2015-09-21 12:27:34 +02:00
parent 3e485652fe
commit 4db173cadb
9 changed files with 88 additions and 13 deletions

View File

@ -4,10 +4,10 @@ compiler.cfg.debugger compiler.cfg.instructions compiler.cfg.optimizer
compiler.cfg.predecessors compiler.cfg.registers compiler.cfg.representations compiler.cfg.predecessors compiler.cfg.registers compiler.cfg.representations
compiler.cfg.rpo compiler.cfg.stacks compiler.cfg.stacks.local compiler.cfg.rpo compiler.cfg.stacks compiler.cfg.stacks.local
compiler.cfg.utilities compiler.test compiler.tree compiler.tree.builder compiler.cfg.utilities compiler.test compiler.tree compiler.tree.builder
compiler.tree.optimizer fry hashtables io kernel kernel.private locals make math compiler.tree.optimizer cpu.architecture fry hashtables io kernel kernel.private
math.partial-dispatch math.private namespaces prettyprint sbufs sequences locals make math math.partial-dispatch math.private namespaces prettyprint sbufs
sequences.private slots.private strings strings.private tools.test vectors sequences sequences.private slots.private strings strings.private tools.test
words ; vectors words ;
FROM: alien.c-types => int ; FROM: alien.c-types => int ;
IN: compiler.cfg.builder.tests IN: compiler.cfg.builder.tests
@ -275,6 +275,26 @@ IN: compiler.cfg.builder.tests
replaces get replaces get
] cfg-unit-test ] cfg-unit-test
{
V{
T{ ##load-integer { dst 3 } { val 0 } }
T{ ##add { dst 4 } { src1 3 } { src2 2 } }
T{ ##load-memory-imm
{ dst 5 }
{ base 4 }
{ offset 0 }
{ rep int-rep }
}
T{ ##box-alien { dst 7 } { src 5 } { temp 6 } }
}
} [
T{ #call
{ word alien-cell }
{ in-d V{ 10 20 } }
{ out-d { 30 } }
} [ emit-node ] V{ } make
] cfg-unit-test
{ 1 } [ { 1 } [
V{ } 0 insns>block basic-block set init-cfg-test V{ } 0 insns>block basic-block set init-cfg-test
V{ } 1 insns>block [ emit-loop-call ] V{ } make drop V{ } 1 insns>block [ emit-loop-call ] V{ } make drop

View File

@ -133,22 +133,18 @@ M: #if emit-node
[ emit-actual-if ] [ emit-actual-if ]
} cond ; } cond ;
! #dispatch
M: #dispatch emit-node M: #dispatch emit-node
! Inputs to the final instruction need to be copied because of ! Inputs to the final instruction need to be copied because of
! loc>vreg sync. ^^offset>slot always returns a fresh vreg, ! loc>vreg sync. ^^offset>slot always returns a fresh vreg,
! though. ! though.
ds-pop ^^offset>slot next-vreg ##dispatch, emit-if ; ds-pop ^^offset>slot next-vreg ##dispatch, emit-if ;
! #call
M: #call emit-node M: #call emit-node
dup word>> dup "intrinsic" word-prop dup word>> dup "intrinsic" word-prop
[ emit-intrinsic ] [ swap call-height emit-call ] if ; [ emit-intrinsic ] [ swap call-height emit-call ] if ;
! #call-recursive
M: #call-recursive emit-node [ label>> id>> ] [ call-height ] bi emit-call ; M: #call-recursive emit-node [ label>> id>> ] [ call-height ] bi emit-call ;
! #push
M: #push emit-node M: #push emit-node
literal>> ^^load-literal ds-push ; literal>> ^^load-literal ds-push ;

View File

@ -1,7 +1,7 @@
USING: assocs compiler.cfg compiler.cfg.instructions USING: assocs compiler.cfg compiler.cfg.instructions
compiler.cfg.linear-scan.live-intervals compiler.cfg.linear-scan.live-intervals compiler.cfg.linear-scan.allocation
compiler.cfg.linear-scan.allocation.state compiler.cfg.liveness compiler.cfg.linear-scan.allocation.state compiler.cfg.liveness
compiler.cfg.registers heaps help.markup help.syntax math ; compiler.cfg.registers heaps help.markup help.syntax math sequences ;
IN: compiler.cfg.linear-scan.assignment IN: compiler.cfg.linear-scan.assignment
HELP: add-pending HELP: add-pending
@ -21,6 +21,10 @@ HELP: assign-registers-in-block
{ $values { "bb" basic-block } } { $values { "bb" basic-block } }
{ $description "Assigns registers and also inserts " { $link ##reload } " and " { $link ##spill } " instructions." } ; { $description "Assigns registers and also inserts " { $link ##reload } " and " { $link ##spill } " instructions." } ;
HELP: assign-registers
{ $values { "cfg" cfg } { "live-intervals" sequence } }
{ $description "Uses the live intervals in the sequence to assign physical registers to all instructions in the cfg. The live intervals must first have had their physical registers assigned by " { $link allocate-registers } "." } ;
HELP: assign-registers-in-insn HELP: assign-registers-in-insn
{ $values { "insn" insn } } { $values { "insn" insn } }
{ $description "Assigns physical registers and spill slots for the virtual registers used by the instruction." } ; { $description "Assigns physical registers and spill slots for the virtual registers used by the instruction." } ;

View File

@ -18,6 +18,14 @@ IN: compiler.cfg.linear-scan.live-intervals.tests
[ number-instructions ] [ cfg>sync-points ] bi [ number-instructions ] [ cfg>sync-points ] bi
] unit-test ] unit-test
! find-use
{
f T{ vreg-use { n 25 } }
} [
25 T{ live-interval-state { uses V{ } } } find-use
25 T{ live-interval-state { uses V{ T{ vreg-use { n 25 } } } } } find-use
] unit-test
! intervals-intersect? ! intervals-intersect?
{ t f f } [ { t f f } [
{ { 4 20 } } <live-interval-for-ranges> { { 4 20 } } <live-interval-for-ranges>

View File

@ -35,7 +35,7 @@ TUPLE: live-interval-state
: (find-use) ( insn# live-interval -- vreg-use ) : (find-use) ( insn# live-interval -- vreg-use )
uses>> [ n>> <=> ] with search nip ; uses>> [ n>> <=> ] with search nip ;
:: find-use ( insn# live-interval -- vreg-use ) :: find-use ( insn# live-interval -- vreg-use/f )
insn# live-interval (find-use) insn# live-interval (find-use)
dup [ dup n>> insn# = [ drop f ] unless ] when ; dup [ dup n>> insn# = [ drop f ] unless ] when ;

View File

@ -43,7 +43,7 @@ HELP: live-ins
{ $see-also compute-live-sets } ; { $see-also compute-live-sets } ;
HELP: live-outs HELP: live-outs
{ $var-description "Hash that maps from basic blocks to sets of vregs that are live after execution leaves the block." } ; { $var-description "Hash that maps from basic blocks to sets of vregs that are live after execution leaves the block. The data is computed by " { $link compute-live-sets } } ;
HELP: lookup-base-pointer HELP: lookup-base-pointer
{ $values { "vreg" "vreg" } { "vreg/f" { $maybe "vreg" } } } { $values { "vreg" "vreg" } { "vreg/f" { $maybe "vreg" } } }

View File

@ -1,6 +1,9 @@
USING: compiler.codegen.relocation help.markup help.syntax math ; USING: compiler.codegen.relocation help.markup help.syntax math vm ;
IN: compiler.constants IN: compiler.constants
HELP: context-callstack-save-offset
{ $description "Offset in bytes in the " { $link context } " struct to where the c callstack is saved." } ;
HELP: rt-cards-offset HELP: rt-cards-offset
{ $description "Relocation offset type for the cards table." } { $description "Relocation offset type for the cards table." }
{ $see-also rel-cards-offset } ; { $see-also rel-cards-offset } ;

View File

@ -11,6 +11,10 @@ HELP: output-value-infos
{ $description "Computes what the output value infos for a #call node should be." } { $description "Computes what the output value infos for a #call node should be." }
{ $see-also value-info-state } ; { $see-also value-info-state } ;
HELP: propagate-predicate
{ $values { "#call" #call } { "word" word } { "infos" sequence } }
{ $description "We need to force the caller word to recompile when the class is redefined, since now we're making assumptions but the class definition itself." } ;
ARTICLE: "compiler.tree.propagation.simple" ARTICLE: "compiler.tree.propagation.simple"
"Propagation for straight-line code" "Propagation for straight-line code"
"Propagation for straight-line code" ; "Propagation for straight-line code" ;

View File

@ -112,3 +112,43 @@ cpu x86.64? [
full-interval-and-bignum-literal setup-value-infos full-interval-and-bignum-literal setup-value-infos
V{ 0 1 } V{ 2 } \ mod call-outputs-quot-of-word V{ 0 1 } V{ 2 } \ mod call-outputs-quot-of-word
] unit-test ] unit-test
! (fold-call)
{
{
T{ value-info-state
{ class fixnum }
{ interval
T{ interval { from { 5 t } } { to { 5 t } } }
}
{ literal 5 }
{ literal? t }
}
}
} [
{ 2 3 "hello" } [ <literal-info> ] map setup-value-infos
{ 0 1 } { 2 } \ + <#call> dup word>> (fold-call)
] unit-test
{
{
T{ value-info-state
{ class object }
{ interval full-interval }
}
}
} [
{ 2 "hello" } [ <literal-info> ] map setup-value-infos { 0 1 } { 2 } \ +
<#call> (fold-call2)
] unit-test
! foldable-call?
{ t f f t } [
{ 2 3 "hello" } [ <literal-info> ] map setup-value-infos
{ 0 1 } { 2 } \ + <#call> foldable-call?
{ 0 2 } { 2 } \ + <#call> foldable-call?
number <class-info> 1array setup-value-infos
{ 0 } { 1 } \ >fixnum <#call> foldable-call?
"mamma mia" <literal-info> 1array setup-value-infos
{ 0 } { 1 } \ >fixnum <#call> foldable-call?
] unit-test