Next: src/target/mips, Previous: src/assem, Up: Project Layout [Contents][Index]
Namespace target
, delivered for TC-7. Some data on
the back end.
Description of a CPU: everything about its registers, and its word size.
Description of a target (language): its CPU, its assembly
(target::Assembly
), and it translator (target::Codegen
).
The abstract class target::Assembly
, the interface for
elementary assembly instructions generation.
The abstract class target::Codegen
, the interface for all our
back ends.
The instruction selection per se split into a generic part, and a target specific (MIPS, IA-32 and ARM) part. See src/target/mips, src/target/ia32 and src/target/arm.
Converting tree::Fragment
s into assem::Fragment
s.
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 IA-32 was a compiled version of this file. It should be noted that:
Strings are implemented as 4 bytes to encode the length, and then a
0-terminated à 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/Nolimips’ print
syscall. This might change in the future.
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
We don’t know how Appel wants to support ‘"bar" < "foo"’ since he
doesn’t provide strcmp
. We do. His implementation of equality
is more efficient than ours though, 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 calls tc_main
, which is the
“main” that your compiler should provide.
Next: src/target/mips, Previous: src/assem, Up: Project Layout [Contents][Index]