Next: , Previous: , Up: TC-8   [Contents][Index]


4.17.2 TC-8 Samples

First consider simple examples, without any branching:

10 + 20 * 30

File 4.72: tens.tig

$ tc -I tens.tig
# == Final assembler ouput. == #
# Routine: _main
tc_main:
# Allocate frame
        move    $x13, $ra
        move    $x5, $s0
        move    $x6, $s1
        move    $x7, $s2
        move    $x8, $s3
        move    $x9, $s4
        move    $x10, $s5
        move    $x11, $s6
        move    $x12, $s7
l0:
        li      $x1, 10
        li      $x2, 20
        mul     $x3, $x2, 30
        add     $x4, $x1, $x3
l1:
        move    $s0, $x5
        move    $s1, $x6
        move    $s2, $x7
        move    $s3, $x8
        move    $s4, $x9
        move    $s5, $x10
        move    $s6, $x11
        move    $s7, $x12
        move    $ra, $x13
# Deallocate frame
        jr      $ra

Example 4.119: tc -I tens.tig

$ tc -FVN tens.tig

Example 4.120: tc -FVN tens.tig

assignments.ext/tens.main._main.flow

File 4.73: tens.main._main.flow.gv

assignments.ext/tens.main._main.liveness

File 4.74: tens.main._main.liveness.gv

assignments.ext/tens.main._main.interference

File 4.75: tens.main._main.interference.gv

But as you can see, the result is quite hairy, and unreadable, especially for interference graphs:

To circumvent this problem, use --callee-save to limit the number of such registers:

100 + 200 * 300

File 4.76: hundreds.tig

$ tc --callee-save=0 -VN hundreds.tig

Example 4.121: tc --callee-save=0 -VN hundreds.tig

assignments.ext/hundreds.main._main.liveness

File 4.77: hundreds.main._main.liveness.gv

assignments.ext/hundreds.main._main.interference

File 4.78: hundreds.main._main.interference.gv


Branching is of course a most interesting feature to exercise:

1 | 2 | 3

File 4.79: ors.tig

$ tc --callee-save=0 -I ors.tig
# == Final assembler ouput. == #
# Routine: _main
tc_main:
# Allocate frame
        move    $x4, $ra
l5:
        li      $x1, 1
        bne     $x1, 0, l3
l4:
        li      $x2, 2
        bne     $x2, 0, l0
l1:
l2:
        j       l6
l0:
        j       l2
l3:
        li      $x3, 1
        bne     $x3, 0, l0
l7:
        j       l1
l6:
        move    $ra, $x4
# Deallocate frame
        jr      $ra

Example 4.122: tc --callee-save=0 -I ors.tig

$ tc -FVN ors.tig

Example 4.123: tc -FVN ors.tig

assignments.ext/ors.main._main.flow

File 4.80: ors.main._main.flow.gv

assignments.ext/ors.main._main.liveness

File 4.81: ors.main._main.liveness.gv

assignments.ext/ors.main._main.interference

File 4.82: ors.main._main.interference.gv


Next: , Previous: , Up: TC-8   [Contents][Index]