TC-7 Code to Write

Tip

Information on MIPS R2000 assembly instructions may be found in SPIM manual.

You can run the MIPS using Nolimips.

Relevant pages:

For the src/taget/mips folder you will find more information on this part in the book (Modern Compiler Implementation), in the chapter “9. Instruction Selection”.

Codegen

src/target/mips/spim-matcher.cc is the functor used for instruction selection pattern-matching.

src/target/mips/spim-assembly.cc

SpimAssembly::move_build builds a move instruction using MIPS R2000 standard instruction set.

SpimAssembly::binop_inst, SpimAssembly::binop_build build arithmetic binary operations (addition, multiplication, etc.) using MIPS R2000 standard instruction set.

SpimAssembly::load_build, SpimAssembly::store_build build a load (respectively a store) instruction using MIPS R2000 standard instruction set. Here, the indirect addressing mode is used.

SpimAssembly::cjump_build translates conditional branch instructions (branch if equal, if lower than, etc.) into MIPS R2000 assembly.

Runtime

You have to complete the implementation of the runtime in src/target/mips/runtime.s:

strcmp
streq
print_int
substring
concat
src/target/mips/spim-codegen.cc

Completing the Codegen::rewrite_program routine will be needed during register allocation only, see TC-9, Register Allocation.