spinoza1111wrote:
Start with some basic metrics. Count cycles and generated code.
a) Take the half dozen or so cases and hand code them up as
micro operations and
b) then separate all those micro operations that can be done at
compile time and those that must be done at run time
c) Map the micro operations on the instruction set you are using
and count cycles and bytes.
The most significant differences will be the base address of an
array is generally a constant that can often be optimized out
with instruction selection or compile time math.
Constant index references are generally a big win for arrays
in most execution environments
You really probably should have finished your book. Code
generation and optimization are about 90% of creating a
compiler. This stuff is pretty fundamental to that process.
Bullshit. If you don't understand parsing, the compiler is worthless.
And if you don't understand modern language design, the compiler is
even more worthless. Kernighan and Pike didn't understand modern
language design in 1970, because their mistakes in designing C
(aliasing, the preprocessor, the use of magic libraries, a broken
pseudo-for, pre-increment and post-increment not thought out in terms
of sequence, no strings, no characters properly understood, an integer
thought to have 16 bits in the original edition, braces used instead
of begin and end keywords at a time when braces weren't even available
on many keytops, two different ways of talking about arrays, etc)
became ... drum roll ... modern language design, rule one of which is
"please, don't EVER do another C".
Please, do not reinvent C
One such language was enough for me
One such language is enough for thee
One such language is enough for such as we
Are. Stay far
Away from C.
Oh say can you see
Any creeps who love C?
It's JUST a good way
Of hiding incompetency.
Old Basic was a better language and old Basic was a bad language. The
conclusion follows, directly.
Oh yes, and I did finish my book. It is available in stores and you
need to buy a copy. I'd send you a courtesy copy if you deserved one,
but you do not. It covers optimization and spends a whole chapter on
code generation for .Net, but the real meat is parsing since if you
screw up parsing there's not point in either code generation or
optimization, is there now?