[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Jitter: new stack primitive (or micro-primitive): quake
From: |
Luca Saiu |
Subject: |
Re: Jitter: new stack primitive (or micro-primitive): quake |
Date: |
Wed, 27 Nov 2019 20:08:05 +0100 |
User-agent: |
Gnus (Gnus v5.13), GNU Emacs 27.0.50, x86_64-pc-linux-gnu |
Hello José.
On 2019-11-27 at 10:09 +0100, Jose E. Marchesi wrote:
> Nice name for the instruction :)
>
> I updated the jitter submodule reference to the tag v0.9.204 and added a
> quake instruction to the PVM, along with a rewrite rule for rot;swap ->
> quake.
I have looked at your manually written instructions, and saw several
opportunities for simplification. It is true that you can achieve
exactly the same performance with rewrite rules (another is
swap;over -> tuck
), but to me the main motivation is readability; I find some of the
stack juggling in Poke quite difficult to follow. I am bothered by
dup rot dup rot
, for example.
If you are not against this kind of change I will prepare a patch, but
please do not accept it just to please me: you should retain full
control over the esthetics in Poke.
This is from my notes file:
--8<---------------cut here---------------start------------->8---
Stack optimizations in Poke
===========================
Compliment José about GCD. When he showed it to me in Frankfurt I did
not fully appreciate how clever it was.
Still, GCD can be optimized. The unconditional branch to a conditional
branch is ugly -- even if almost certainly not performance-critical.
%
.macro addo @base_type #unit
I think the second swap is useless.
%
Replace
nrot swap
by
reverse 3
Simpler, more intuitive, and faster. (it occurs once in .macro ais @etype)
%
Replace
rot swap
by
quake
It occurs several times.
%
Replace
rot drop
by
slide [TO IMPLEMENT: ( a b c -- b c ). POSSIBLY WITH A DEPTH ARGUMENT. ]
It also occurs several times.
%
Replace
dup rot dup rot 12 insns
( a b -- b a a b )
by
( a b ) tuck ( b a b ) over swap ( b a a b ) 11 insns; but "over swap"
stinks.
or
( a b ) tuck ( b a b ) bulge ( b a a b ) 7 insns estimated: I have to
implement bulge
or
( a b ) swap over over swap ( b a a b ) 14 insns; slower and only
marginally
easier to understand
%
Replace
over swap
( a b -- a a b )
with a new operation:
bulge
( a b -- a a b ) [ TO IMPLEMENT. If slide has an argument this can be the
same operation. ]
(I want to keep the name "swell" or "pump" for a different micro-primitive,
with effect ( a b -- a ? b ), "?" meaning unspecified.)
%
In src/pkl-gen.pks, .function array_valmapper
Replace
swap drop
by
nip
.
The rest of src/pkl-gen.pks looks fine.
--8<---------------cut here---------------end--------------->8---
Regards,
--
Luca Saiu
* My personal web site: http://ageinghacker.net
* GNU epsilon: http://www.gnu.org/software/epsilon
* Jitter: http://ageinghacker.net/projects/jitter
I support everyone's freedom of mocking any opinion or belief, no
matter how deeply held, with open disrespect and the same unrelented
enthusiasm of a toddler who has just learned the word "poo".
signature.asc
Description: PGP signature