TC-X Code to Write
Tip
Information on IA-32 assembly instructions may be found in the Intel® 64 and IA-32 Architectures Software Developer Manuals, or in this much shorter IA32 Instruction List form.
The documentation of the GNU Assembler (GAS) is also a recommended reading.
- src/target/ia32/gas-matcher.cc
target::ia32::GasMatcher
is the functor used for instruction selection pattern-matching.- src/target/ia32/gas-assembly.cc
GasAssembly::cjump_build
translates conditional branch instructions (branch if equal, if lower than, etc.) into IA-32 assembly.- Runtime
You have to complete the implementation of the runtime in
src/target/ia32/runtime-gnu-linux.s
:- strcmp
- streq
Warning
Strings are implemented as 4 bytes to encode the length, and then a 0-terminated C-like string. You should rely on the initial encoded length, which is always present for compliance.
See the example below on how the string data is represented (
l0
):hello-world-ia32.tigprint("Hello Tiger!")
tc --target-ia32 --inst-display hello-world-ia32.tig | head -n 6$ tc --target-ia32 --inst-display hello-world-ia32.tig | head -n 6 /** Tiger final assembler ouput. */ .section .rodata l0: .long 12 .asciz "Hello Tiger!" $ echo $? 0
String data representation (assuming little endian) Address (
l0
+)0x00
0x01
0x02
0x03
0x04
0x05
…
0x10
Value
0x00
0x00
0x00
0x0c
'H'
'e'
…
'\0'
- src/target/ia32/gas-codegen.cc (Optional)
Completing the
Codegen::rewrite_program
routine will be needed during register allocation only, see TC-9, Register Allocation.