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.rpo compiler.cfg.stacks compiler.cfg.stacks.local
compiler.cfg.utilities compiler.test compiler.tree compiler.tree.builder
compiler.tree.optimizer fry hashtables io kernel kernel.private locals make math
math.partial-dispatch math.private namespaces prettyprint sbufs sequences
sequences.private slots.private strings strings.private tools.test vectors
words ;
compiler.tree.optimizer cpu.architecture fry hashtables io kernel kernel.private
locals make math math.partial-dispatch math.private namespaces prettyprint sbufs
sequences sequences.private slots.private strings strings.private tools.test
vectors words ;
FROM: alien.c-types => int ;
IN: compiler.cfg.builder.tests
@ -275,6 +275,26 @@ IN: compiler.cfg.builder.tests
replaces get
] 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 } [
V{ } 0 insns>block basic-block set init-cfg-test
V{ } 1 insns>block [ emit-loop-call ] V{ } make drop

View File

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

View File

@ -1,7 +1,7 @@
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.registers heaps help.markup help.syntax math ;
compiler.cfg.registers heaps help.markup help.syntax math sequences ;
IN: compiler.cfg.linear-scan.assignment
HELP: add-pending
@ -21,6 +21,10 @@ HELP: assign-registers-in-block
{ $values { "bb" basic-block } }
{ $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
{ $values { "insn" insn } }
{ $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
] 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?
{ t f f } [
{ { 4 20 } } <live-interval-for-ranges>

View File

@ -35,7 +35,7 @@ TUPLE: live-interval-state
: (find-use) ( insn# live-interval -- vreg-use )
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)
dup [ dup n>> insn# = [ drop f ] unless ] when ;

View File

@ -43,7 +43,7 @@ HELP: live-ins
{ $see-also compute-live-sets } ;
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
{ $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
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
{ $description "Relocation offset type for the cards table." }
{ $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." }
{ $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"
"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
V{ 0 1 } V{ 2 } \ mod call-outputs-quot-of-word
] 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