next up previous
Next: Analysis Up: But Mom, I don't Previous: The Problem

Recasting the Problem in a Direct-Style IR

We consider a simple direct-style IR:

\begin{displaymath}
\begin{array}{lcl}
e & ::= & l:t\\
t & ::= & x\\
& \vert ...
...2\\
& \vert & f\mbox{\tt (}\vec{x}\mbox{\tt )}\\
\end{array}\end{displaymath}

Translating the applyf function into this IR yields:

fun applyf (f, n) =
  fun lp_i i = 
    let bi = i < n in
    if bi
      then fun lp_j j = 
             let bj = j < n in
             if bj 
               then let foo = f (i, j) in
                    let j' = j + 1
                    in lp_j j'
               else () in
           let bar = lp_j = 0 in
           let i' = i + 1 in
           lp_i i'
      else () in
  lp_i 0

But, that's a little verbose for an example, so we'll work with the following:

fun applyf (f, n) =
  fun lp_i i = 
    if i < n
      then fun lp_j j = 
             if j < n 
               then let foo = f (i, j) in
                    lp_j (j + 1)
               else () in
           let bar = lp_j = 0 in
           lp_i (i + 1)
      else () in
  lp_i 0

Note that we once again have a non-tail call to lp_j requiring it to be in a separate cluster.



Matthew Fluet 2002-02-22