Namespace codegen
, delivered for T7.
The instruction selection per se split into a generic part, and a target specific (MIPS and IA32) part. Voir src/codegen/mips, and src/codegen/ia32.
The abstract class
codegen::Assembly
which is the interface for elementary assembly instructions generation.
The abstract class
codegen::Codegen
which is the interface for all our back ends.
Converting
translate::Fragment
s intoassem::Fragment
s.
Command line interface.
This is the Tiger runtime, written in C, based on Andrew Appel's runtime.c. The actual runtime.s file for MIPS was written by hand, but the ia32 was a compiled version of this file. It should be noted that:
- Strings
- Strings are implemented as 4 bytes to encode the length, and then a 0-terminated a` la C string. The length part is due to conformance to the Tiger Reference Manual, which specifies that 0 is a regular character that can be part of the strings, but it is nevertheless terminated by 0 to be compliant with SPIM/Mipsy's
- Special Strings
- There are some special strings: 0 and 1 character long strings are all implemented via a singleton. That is to say there is only one allocated string "", a single "1" etc. These singletons are allocated by
main
. It is essential to preserve this invariant/convention in the whole runtime.strcmp
vs.stringEqual
- I don't know how Appel wants to support "bar" < "foo" since he doesn't provide
strcmp
. We do. But note that anyway his implementation of "foo" != "fooo" is more efficient than ours, since he can decide just be looking at the lengths. That could be improved in the future...main
- The runtime has some initializations to make, such as strings singletons, and then calls the compiled program. This is why the runtime provides
main
, and callst_main
, which is the “main” that your compiler should provide.