Re: Is Assembler Language essential in compiler construction?
- From: Tim <tim.d.richards@xxxxxxxxx>
- Date: Wed, 11 Feb 2009 04:12:10 -0800 (PST)
Frankly, most university first courses on compilers don't spend much
time on the back end of compilers; there just isn't time. And the
assembly languages of most modern processors are just too complex. I
would like to see the Java virtual machine or some other used virtual
machine be the target language for a first course on compilers, if
that is not already too much information. Students would find this
more interesting and useful than a faked machine language and more
reasonable than a real assembly language.
I taught an undergraduate course on compiler construction where we
used JVM bytecode as the target instruction set. We then used the
Jasmin bytecode assembler to generate class files. Overall, I feel
that it was a great success. Because the JVM is at a higher level
(and concepts are similar to the Java language) and is stack oriented,
students were able to pick it up quickly. You can also apply register
allocation techniques to determine the minimal number of stack slots
required for local variables. Because most students do not go on to
do compiler work, the focus on the JVM allows them to get a better
understanding of the platform (JVM) they are working on---so it is a
win/win situation.
A slightly different option would be to compile to some intermediate
language used in a real compiler such that the students could use the
real compiler to finish the translation into machine code. This would
require a cooperative compiler with a reasonably simple intermediate
language.
This is also a great option. It is great if the compiler framework
allows optimizations to be coded up easily---this allows students to
get their hands dirty with high-level IR-oriented optimizations. LLVM
comes to mind.
The back end is where the real compiler work is done though, so a
second course, possibly at the graduate level, that dealt with
compiler back ends would be useful. Such a course could deal with
translating virtual machine code into real machine code. I recommend
compiling to a processor whose machine language is not too complex,
and is really used today, say for embedded applications.
I think a compiler book using these ideas would be very successful
especially if universities used it in their compiler courses. Wish I
had sufficient knowledge to write it but I only know front ends well.
The ideal scenario is probably one where the computer architecture,
programming language, and compiler construction courses worked
together to teach students a specific architecture assembly language,
how to deal with programming language theory (including lexing and
parsing), and programming language construction (focusing more on the
middle/back- end phases).
/Tim
.
- References:
- Is Assembler Language essential in compiler construction?
- From: marco . m . petersen
- Re: Is Assembler Language essential in compiler construction?
- From: Ralph Boland
- Is Assembler Language essential in compiler construction?
- Prev by Date: Re: Is Assembler Language essential in compiler construction?
- Next by Date: Re: Is Assembler Language essential in compiler construction?
- Previous by thread: Re: Is Assembler Language essential in compiler construction?
- Next by thread: Re: Is Assembler Language essential in compiler construction?
- Index(es):
Relevant Pages
|