diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-01-18 21:31:30 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-01-18 21:31:30 -0800 |
commit | 040ac1066fae0f2041e4b508174518598639bae2 (patch) | |
tree | 674f7f1beaff5a6bdf45d2acf8cc466a846f4fd7 /match.h | |
parent | a91aff6dfa0d97c4130a3a7c630466b8ec2e247b (diff) | |
download | txr-040ac1066fae0f2041e4b508174518598639bae2.tar.gz txr-040ac1066fae0f2041e4b508174518598639bae2.tar.bz2 txr-040ac1066fae0f2041e4b508174518598639bae2.zip |
compiler: improve code for and/or.
Squeeze the constant and unreachable cases out of (and ...)
and (or ...) forms, producing a more streamlined translation.
This is the first appearance of structural pattern matching in
the compiler!
* share/txr/stdlib/compiler.tl (compiler compile): Handle and
using new expand-and function, which translates it to if
forms. Handle or via the renamed method comp-or.
(compiler comp-and-or): Renamed to comp-or, since it handles
only or. All the switching between or/and is eliminated.
The or form is first reduced using simplify-or.
We retain this function because one case in cond relies on or;
or is a useful primitive because (or a b) evaluates a only
once; whereas (if a a b) requires common-subexpression
elimination to generate the same code as (or a b).
(true-const-p, expand-and, flatten-or, reduce-or,
simplify-or): New functions.
Diffstat (limited to 'match.h')
0 files changed, 0 insertions, 0 deletions