[MLton] modifying flatten.fun to always flatten

Lukasz S Ziarek lziarek@cs.purdue.edu
Tue, 20 Jan 2004 10:18:58 -0500 (EST)

I ran into acouple problems adopting the first approach, so I have
implimented the second approach. It seems to be doing what I need it to do
and the compiler fixpoints. I would like to know if there is a way to
print the ssa tree to a file before and after the flatten pass. Bassically
I just want to double check I am correctly flattening all tupples.

For any who are curious, the change was acomplished via this code:

    fun flattenALL(Statement.T {var, ty, exp}) =
             case exp of
                  Tuple xs => Option.app
	                (var, fn var =>
                              setVarInfo(var, {rep=Rep.new(),
                                               tuple = ref (SOME xs)}))
                | _ =>  Option.app
	                (var, fn var =>
                              setVarInfo(var, {rep= let val r = Rep.new()
                                             in Rep.tuplize r; r
                                        tuple = ref NONE}))
      val _ = List.foreach(functions, fn f =>
	            (f, fn b as Block.T {label, args, statements, transfer} =>
                                let val _ = Vector.foreach(statements, fn s =>
				in fn () => ()
      val _ = Vector.foreach(globals, flattenALL)

The only slight problem I ran into with this approach was the fact that I
needed to run my flattenALL function on the globals and as such
doitStatement needed to be modified to no longer setVarInfo. As of now I
have not detected any potential problems from PrimApps. It seems like the
flatten all saga is very much closer to completion, still need to add a
boolean to allow for a user defined flattening scheme.