Noeud « Previous »: T6 Canonicalization Samples, Noeud « Up »: T6 Samples



4.8.2.2 T6 Scheduling Samples

Once your eseq and call canonicalized, normalize cjumps: they must be followed by their “false” label. This goes in two steps:

  1. Split in basic blocks.

    A basic block is a sequence of code starting with a label, ending with a jump (conditional or not), and with no jumps, no labels inside.

  2. Build the traces.

    Now put all the basic blocks into a single sequence.


The following example highlights the need for new labels: at least one for the entry point, and one for the exit point:
     1 & 2
     File 113: 1-and-2.tig
     $ tc -L 1-and-2.tig
     /* == Low Level Intermediate representation. == */
     # Routine: Main
     label Main
     # Prologue
     # Body
     seq
         label l3
         cjump ne
             const 1
             const 0
             name l0
             name l1
         label l1
         label l2
         jump
             name l4
         label l0
         jump
             name l2
         label l4
     seq end
     # Epilogue
     label end
     Example 114: tc -L 1-and-2.tig

The following example contains many jumps. Compare the hir to the lir:
     while 10 | 20 do if 30 | 40 then break else break
     File 115: broken-while.tig
     $ tc -H broken-while.tig
     /* == High Level Intermediate representation. == */
     # Routine: Main
     label Main
     # Prologue
     # Body
     seq
         label l1
         seq
             cjump ne
                 const 10
                 const 0
                 name l8
                 name l9
             label l8
             cjump ne
                 const 1
                 const 0
                 name l2
                 name l0
             label l9
             cjump ne
                 const 20
                 const 0
                 name l2
                 name l0
         seq end
         label l2
         seq
             seq
                 cjump ne
                     const 30
                     const 0
                     name l6
                     name l7
                 label l6
                 cjump ne
                     const 1
                     const 0
                     name l3
                     name l4
                 label l7
                 cjump ne
                     const 40
                     const 0
                     name l3
                     name l4
             seq end
             label l3
             jump
                 name l0
             jump
                 name l5
             label l4
             jump
                 name l0
             label l5
         seq end
         jump
             name l1
         label l0
     seq end
     # Epilogue
     label end
     Example 116: tc -H broken-while.tig
     $ tc -L broken-while.tig
     /* == Low Level Intermediate representation. == */
     # Routine: Main
     label Main
     # Prologue
     # Body
     seq
         label l10
         label l1
         cjump ne
             const 10
             const 0
             name l8
             name l9
         label l9
         cjump ne
             const 20
             const 0
             name l2
             name l0
         label l0
         jump
             name l11
         label l2
         cjump ne
             const 30
             const 0
             name l6
             name l7
         label l7
         cjump ne
             const 40
             const 0
             name l3
             name l4
         label l4
         jump
             name l0
         label l3
         jump
             name l0
         label l6
         cjump ne
             const 1
             const 0
             name l3
             name l13
         label l13
         jump
             name l4
         label l8
         cjump ne
             const 1
             const 0
             name l2
             name l14
         label l14
         jump
             name l0
         label l11
     seq end
     # Epilogue
     label end
     Example 117: tc -L broken-while.tig