From 1eac4afc8ba893e065b2072881718b029c1a1e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sat, 15 Nov 2014 07:22:28 +0100 Subject: [PATCH] compiler.cfg.linear-scan.allocation.state: sub docs and tests --- .../allocation/state/state-docs.factor | 19 +++++++++++++++++++ .../allocation/state/state-tests.factor | 14 ++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 basis/compiler/cfg/linear-scan/allocation/state/state-docs.factor create mode 100644 basis/compiler/cfg/linear-scan/allocation/state/state-tests.factor diff --git a/basis/compiler/cfg/linear-scan/allocation/state/state-docs.factor b/basis/compiler/cfg/linear-scan/allocation/state/state-docs.factor new file mode 100644 index 0000000000..9e54cd9078 --- /dev/null +++ b/basis/compiler/cfg/linear-scan/allocation/state/state-docs.factor @@ -0,0 +1,19 @@ +USING: assocs compiler.cfg compiler.cfg.instructions cpu.architecture +help.markup help.syntax math ; +IN: compiler.cfg.linear-scan.allocation.state + +HELP: init-allocator +{ $values { "registers" { $link assoc } " mapping from register class to available machine registers." } } +{ $description "Initializes the state for the register allocator." } +{ $see-also reg-class } ; + +HELP: next-spill-slot +{ $values { "size" "number of bytes required" } { "spill-slot" spill-slot } } +{ $description "Creates a new " { $link spill-slot } " of the given size and also allocates space in the " { $link cfg } " in the 'cfg' dynamic variable for it." } ; + +HELP: spill-slots +{ $var-description "Mapping from vregs to spill slots." } ; + +HELP: align-spill-area +{ $values { "align" integer } } +{ $description "This word is used to ensure that the alignment of the spill area in the " { $link cfg } " is equal to the largest " { $link spill-slot } "." } ; diff --git a/basis/compiler/cfg/linear-scan/allocation/state/state-tests.factor b/basis/compiler/cfg/linear-scan/allocation/state/state-tests.factor new file mode 100644 index 0000000000..8018a803c2 --- /dev/null +++ b/basis/compiler/cfg/linear-scan/allocation/state/state-tests.factor @@ -0,0 +1,14 @@ +USING: combinators.extras compiler.cfg compiler.cfg.instructions +compiler.cfg.linear-scan.allocation.state kernel namespaces tools.test ; +IN: compiler.cfg.linear-scan.allocation.state.tests + +{ + T{ spill-slot f 0 } + T{ spill-slot f 8 } + T{ cfg { spill-area-size 16 } } +} [ + H{ } clone spill-slots set + T{ cfg { spill-area-size 0 } } cfg set + [ 8 next-spill-slot ] twice + cfg get +] unit-test