version 1.17, 2002/08/22 20:07:33
|
version 1.21, 2003/02/23 21:17:00
|
Line 85 Input File Format
|
Line 85 Input File Format
|
* Input File Grammar:: |
* Input File Grammar:: |
* Simple instructions:: |
* Simple instructions:: |
* Superinstructions:: |
* Superinstructions:: |
|
* Store Optimization:: |
* Register Machines:: How to define register VM instructions |
* Register Machines:: How to define register VM instructions |
|
|
Input File Grammar |
Input File Grammar |
Line 605 Most examples are taken from the example
|
Line 606 Most examples are taken from the example
|
* Input File Grammar:: |
* Input File Grammar:: |
* Simple instructions:: |
* Simple instructions:: |
* Superinstructions:: |
* Superinstructions:: |
|
* Store Optimization:: |
* Register Machines:: How to define register VM instructions |
* Register Machines:: How to define register VM instructions |
@end menu |
@end menu |
|
|
Line 707 text according to the following grammar;
|
Line 709 text according to the following grammar;
|
Forth you need for using Vmgen: |
Forth you need for using Vmgen: |
|
|
@example |
@example |
text: stack-decl|type-prefix-decl|stack-prefix-decl |
text: stack-decl|type-prefix-decl|stack-prefix-decl|set-flag |
|
|
stack-decl: 'stack ' ident ident ident |
stack-decl: 'stack ' ident ident ident |
type-prefix-decl: |
type-prefix-decl: |
's" ' string '" ' ('single'|'double') ident 'type-prefix' ident |
's" ' string '" ' ('single'|'double') ident 'type-prefix' ident |
stack-prefix-decl: ident 'stack-prefix' string |
stack-prefix-decl: ident 'stack-prefix' string |
|
set-flag: 'store-optimization' ('on'|'off') |
@end example |
@end example |
|
|
Note that the syntax of this code is not checked thoroughly (there are |
Note that the syntax of this code is not checked thoroughly (there are |
Line 732 are:
|
Line 735 are:
|
@findex single |
@findex single |
@findex double |
@findex double |
@findex stack-prefix |
@findex stack-prefix |
|
@findex store-optimization |
@example |
@example |
stack ( "name" "pointer" "type" -- ) |
stack ( "name" "pointer" "type" -- ) |
( name execution: -- stack ) |
( name execution: -- stack ) |
type-prefix ( addr u item-size stack "prefix" -- ) |
type-prefix ( addr u item-size stack "prefix" -- ) |
single ( -- item-size ) |
single ( -- item-size ) |
double ( -- item-size ) |
double ( -- item-size ) |
stack-prefix ( stack "prefix" -- ) |
stack-prefix ( stack "prefix" -- ) |
|
store-optimization ( -- addr ) |
@end example |
@end example |
|
|
An @var{item-size} takes three cells on the stack. |
An @var{item-size} takes three cells on the stack. |
Line 972 contents.
|
Line 977 contents.
|
|
|
|
|
@c -------------------------------------------------------------------- |
@c -------------------------------------------------------------------- |
@node Superinstructions, Register Machines, Simple instructions, Input File Format |
@node Superinstructions, Store Optimization, Simple instructions, Input File Format |
@section Superinstructions |
@section Superinstructions |
@cindex superinstructions, defining |
@cindex superinstructions, defining |
@cindex defining superinstructions |
@cindex defining superinstructions |
Line 1030 does not check these restrictions, they
|
Line 1035 does not check these restrictions, they
|
interpreter. |
interpreter. |
|
|
@c ------------------------------------------------------------------- |
@c ------------------------------------------------------------------- |
@node Register Machines, , Superinstructions, Input File Format |
@node Store Optimization, Register Machines, Superinstructions, Input File Format |
|
@section Store Optimization |
|
@cindex store optimization |
|
@cindex optimization, stack stores |
|
@cindex stack stores, optimization |
|
@cindex eliminating stack stores |
|
|
|
This minor optimization (0.6\%--0.8\% reduction in executed instructions |
|
for Gforth) puts additional requirements on the instruction descriptions |
|
and is therefore disabled by default. |
|
|
|
What does it do? Consider an instruction like |
|
|
|
@example |
|
dup ( n -- n n ) |
|
@end example |
|
|
|
For simplicity, also assume that we are not caching the top-of-stack in |
|
a register. Now, the C code for dup first loads @code{n} from the |
|
stack, and then stores it twice to the stack, one time to the address |
|
where it came from; that time is unnecessary, but gcc does not optimize |
|
it away, so vmgen can do it instead (if you turn on the store |
|
optimization). |
|
|
|
Vmgen uses the stack item's name to determine if the stack item contains |
|
the same value as it did at the start. Therefore, if you use the store |
|
optimization, you have to ensure that stack items that have the same |
|
name on input and output also have the same value, and are not changed |
|
in the C code you supply. I.e., the following code could fail if you |
|
turn on the store optimization: |
|
|
|
@example |
|
add1 ( n -- n ) |
|
n++; |
|
@end example |
|
|
|
Instead, you have to use different names, i.e.: |
|
|
|
@example |
|
add1 ( n1 -- n1 ) |
|
n2=n1+1; |
|
@end example |
|
|
|
To turn on the store optimization, write |
|
|
|
@example |
|
\E store-optimization on |
|
@end example |
|
|
|
at the start of the file. You can turn this optimization on or off |
|
between any two VM instruction descriptions. For turning it off again, |
|
you can use |
|
|
|
@example |
|
\E store-optimization off |
|
@end example |
|
|
|
@c ------------------------------------------------------------------- |
|
@node Register Machines, , Store Optimization, Input File Format |
@section Register Machines |
@section Register Machines |
@cindex Register VM |
@cindex Register VM |
@cindex Superinstructions for register VMs |
@cindex Superinstructions for register VMs |
Line 1100 You have used an instruction-stream pref
|
Line 1163 You have used an instruction-stream pref
|
side). |
side). |
|
|
@cindex @code{prefix for this combination must be defined earlier} error |
@cindex @code{prefix for this combination must be defined earlier} error |
@item the prefix for this combination must be defined earlier |
@item the prefix for this superinstruction must be defined earlier |
You have defined a superinstruction (e.g. @code{abc = a b c}) without |
You have defined a superinstruction (e.g. @code{abc = a b c}) without |
defining its direct prefix (e.g., @code{ab = a b}), |
defining its direct prefix (e.g., @code{ab = a b}), |
@xref{Superinstructions}. |
@xref{Superinstructions}. |
Line 1723 a major change, and it's ramifications a
|
Line 1786 a major change, and it's ramifications a
|
@chapter The future |
@chapter The future |
@cindex future ideas |
@cindex future ideas |
|
|
We have a number of ideas for future versions of Gforth. However, there |
We have a number of ideas for future versions of Vmgen. However, there |
are so many possible things to do that we would like some feedback from |
are so many possible things to do that we would like some feedback from |
you. What are you doing with Vmgen, what features are you missing, and |
you. What are you doing with Vmgen, what features are you missing, and |
why? |
why? |
Line 1746 please let us know.
|
Line 1809 please let us know.
|
@chapter Changes |
@chapter Changes |
@cindex Changes from old versions |
@cindex Changes from old versions |
|
|
Use-visible changes between 0.5.9-20010501 and 0.5.9-20020822: |
User-visible changes between 0.5.9-20020822 and 0.5.9-20020901: |
|
|
|
The store optimization is now disabled by default, but can be enabled by |
|
the user (@pxref{Store Optimization}). Documentation for this |
|
optimization is also new. |
|
|
|
User-visible changes between 0.5.9-20010501 and 0.5.9-20020822: |
|
|
There is now a manual (in info, HTML, Postscript, or plain text format). |
There is now a manual (in info, HTML, Postscript, or plain text format). |
|
|