Optimize a sequence of list ops.


method label_indices(op)

Figure out which arguments of an op are labels, and return an array of their indices.

method combineLabels(label1, label2, ...)

Creates a new label to represent a group of label objects. Also remembers what the original names are so a comment giving them can be generated later.

method optimize(ops...)

 1. Merge equivalent labels
 2. Jump threading: Replace goto X; ...; X: goto Y; with goto Y.
 3. Eliminate unreachable code.
 4. Eliminate jumps to the following address.
 5. Eliminate unused labels.

 1. I would like to optimize

     B1: sub x, 1
         goto S0
     B2: sub x, 1
         goto B1
     B3: sub x, 1
         goto B2


     B1: sub x, 1
         goto S0
     B2: sub x, 2
         goto S0
     B3: sub x, 3
         goto S0
since this commonly occurs in regex code, due to sequence of single-character matches (eg /a[bB]c/).

But perhaps this should be handled in the Tree -> List rewrite??