From e75a0a085d5556ca3c6245d58fb5f33bc6eb0b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Fri, 25 May 2018 23:21:29 +0300 Subject: [PATCH] Update documentation --- README.md | 1 + ir.md | 6 ++++++ optimizations.md | 12 +++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 52c5688..e737860 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Gir supports following optimizations: * Turn runs of +- or <> into one command * Turn [-] or [+] into one command * Add offsets to commands that modify tape, to reduce moving tape head +* Turn multiply loops into one command TODO ---- diff --git a/ir.md b/ir.md index 0c84c5b..3933648 100644 --- a/ir.md +++ b/ir.md @@ -95,6 +95,12 @@ property | value type | `clear` offset | The location of the cell relative to current tape position +### multiply +property | value +---------|------ +type | `multiply` +changes | Map of offsets to the number that should be added to those cells multiplies by the current cell + Flattened --------- diff --git a/optimizations.md b/optimizations.md index 28d4a77..ecd9292 100644 --- a/optimizations.md +++ b/optimizations.md @@ -1,4 +1,4 @@ -Gir has four optimization passes. +Gir has five optimization passes. joinAdjacentOps --------------- @@ -39,6 +39,16 @@ current tape head location the operations are performed. It also adds an body ends at the same cell where it began, which is useful for performing further optimizations. +transformMultiplyLoops +---------------------- +* *consumed*: commands with offsets +* *unknown commands*: passed through unmodified +* *acts on*: balanced `loop`s that only have adds and where adds at offset 0 are together 1 or -1 +* *other known commands*: `loop` (recurses) + +`transformMultiplyLoops` changes loops of the form `[>+>++<<-]` into a +single `multiply` command. + flattenLoops ------------ * *consumes*: commands with offsets