Optimising parsed words
  Home FAQ Contact Sign in
comp.lang.forth only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.forth Profile…
 Up
Optimising parsed words         


Author: Alex McDonald
Date: Jul 12, 2007 14:35

I'm developing an optimiser for the new version of win32forth that
employs the method of simulating at compile time (using smart compile,)
the stack effects of basic blocks. Anton has several papers that discuss
this method (the RAFTS papers) and I believe VFX using a similar (the
same?) technique.

http://www.complang.tuwien.ac.at/papers/ertl&pirker96.ps.gz

I've grasped the idea of "before" and "after" stacks, and building a
data flow graph from the primitives, with the following fairly simple
classes of words;

Class 1. execute stack manipulation words that have no side effects
(such as modifying memory) such as DUP SWAP etc.
Class 2. don't execute, but add to the DFG by popping/pushing based on
the word's stack effects and point to the operands on the stack.
Class 3. terminate at other words and build a DFG for the basic block

The bit I can't get my noddle around are parsing words like TO and S" .
Here's the output from my intelligent compile, parse tree for TO

0 value y ok
: x 10 to y ;

outputs the tree for x of
Show full article (1.87Kb)
5 Comments
Re: Optimising parsed words         


Author: Elizabeth D Rather
Date: Jul 12, 2007 15:06

Alex McDonald wrote:
> I'm developing an optimiser for the new version of win32forth that
> employs the method of simulating at compile time (using smart compile,)
> the stack effects of basic blocks. Anton has several papers that discuss
> this method (the RAFTS papers) and I believe VFX using a similar (the
> same?) technique.
>
> http://www.complang.tuwien.ac.at/papers/ertl&pirker96.ps.gz
>
> I've grasped the idea of "before" and "after" stacks, and building a
> data flow graph from the primitives, with the following fairly simple
> classes of words;
>
> Class 1. execute stack manipulation words that have no side effects
> (such as modifying memory) such as DUP SWAP etc.
> Class 2. don't execute, but add to the DFG by popping/pushing based on
> the word's stack effects and point to the operands on the stack.
> Class 3. terminate at other words and build a DFG for the basic block
>
> The bit I can't get my noddle around are parsing words like TO and S" . ...
Show full article (2.67Kb)
no comments
Re: Optimising parsed words         


Author: Alex McDonald
Date: Jul 12, 2007 16:06

Elizabeth D Rather wrote:
> Alex McDonald wrote:
>> I'm developing an optimiser for the new version of win32forth that
>> employs the method of simulating at compile time (using smart
>> compile,) the stack effects of basic blocks. Anton has several papers
>> that discuss this method (the RAFTS papers) and I believe VFX using a
>> similar (the same?) technique.
>>
>> http://www.complang.tuwien.ac.at/papers/ertl&pirker96.ps.gz
>>
>> I've grasped the idea of "before" and "after" stacks, and building a
>> data flow graph from the primitives, with the following fairly simple
>> classes of words;
>>
>> Class 1. execute stack manipulation words that have no side effects
>> (such as modifying memory) such as DUP SWAP etc.
>> Class 2. don't execute, but add to the DFG by popping/pushing based on
>> the word's stack effects and point to the operands on the stack.
>> Class 3. terminate at other words and build a DFG for the basic block
>> ...
Show full article (3.35Kb)
no comments
Re: Optimising parsed words         


Author: Anton Ertl
Date: Jul 13, 2007 03:20

Alex McDonald rivadpm.com> writes:
>The trouble I'm having is that although [10 literal] [n literal] are
>both rooted in the DFG, the ! is not rooted, as it can only represent
>operations that have output stack operands, so ! doesn't have a way of
>connecting to the "after" data stack.
>
>Aha, I've just spotted a note in the paper above that says ! and other 0
>output stack effect words have to be kept on a separate list. It doesn't
>say how they're dealt with; I'll have to get some pencil and paper and
>experiment.

You just treat them as roots in the graph. The order in which your
process the various roots is (partially) determined by the dependences
through memory.

- anton
no comments
Re: Optimising parsed words         


Author: Anton Ertl
Date: Jul 13, 2007 04:32

Alex McDonald rivadpm.com> writes:
>I'm developing an optimiser for the new version of win32forth that
>employs the method of simulating at compile time (using smart compile,)
>the stack effects of basic blocks. Anton has several papers that discuss
>this method (the RAFTS papers) and I believe VFX using a similar (the
>same?) technique.
>
>http://www.complang.tuwien.ac.at/papers/ertl&pirker96.ps.gz

For the modern Intel/AMD CPUs I would probably leave the instruction
scheduling away for simplicity (the hardware performs scheduling, and
instruction scheduling tends to increase the register pressure). I
might be tempted to leave the graph away and generate code directly,
but that may cost quite a bit of performance (no instruction
selection, only register allocation); one could get a part of
instruction selection back through some variant of peephole
optimization.
Show full article (3.09Kb)
no comments
Re: Optimising parsed words         


Author: Alex McDonald
Date: Jul 13, 2007 07:48

Anton Ertl wrote:
> Alex McDonald rivadpm.com> writes:
>> I'm developing an optimiser for the new version of win32forth that
>> employs the method of simulating at compile time (using smart compile,)
>> the stack effects of basic blocks. Anton has several papers that discuss
>> this method (the RAFTS papers) and I believe VFX using a similar (the
>> same?) technique.
>>
>> http://www.complang.tuwien.ac.at/papers/ertl&pirker96.ps.gz
>
> For the modern Intel/AMD CPUs I would probably leave the instruction
> scheduling away for simplicity (the hardware performs scheduling, and
> instruction scheduling tends to increase the register pressure). I
> might be tempted to leave the graph away and generate code directly,
> but that may cost quite a bit of performance (no instruction
> selection...
Show full article (3.73Kb)
no comments