compiler IR/MR functions and closures

Timmy Douglas timmy+slate at cc.gatech.edu
Sun Aug 13 15:56:22 PDT 2006


I'm not sure who can answer this question, but maybe someone who knows
something about compilers might be able to give me a hint. I decided
to take a look at mobius/optimizer/* again, and I've gotten stuck,
pretty quickly.

Basically, I've been trying to run code like this (I got x+1 to work
instead of x itself... recorded two lines to my darcs):

[ | ir mr |
 ir: (Optimizer IR Generator new).
 ir generate:  ([ | :x |  x + 1] `quote).
 mr: (Optimizer MR Generator newArchitecture: ir module).
 lobby inform: ir module printString.
 mr generate: ir module.
 mr generate: (ir module closures at: 0). " <- problem here"

] do.


I marked the problem above. In that generate function, the mr
generator tries to find the closure in the list of it's registered
functions (which are registered? when I generate the ir module). The
problem is that the MR stage only holds functions but the IR stage (as
it is written) holds both functions and closures separately (so
closures aren't passed in between stages). I would like to have the
"mr generate: ir module." line do all the required preparation before
the IR->MR generation (but I don't really know what is going on here
or if that is what should be done...). The thing is, I'm not sure what
I should do with all the closures... or how they're supposed to be
moved from the IR generator to the MR one? help? why am I working on
this crap?



The following condition was signaled:
("Closure" parent: Nil. name: Nil. inputVariables: {"ExtensibleArray" ...}. outputVariables: {"ExtensibleArray" ...}.
    localVariables: {"Set" ...}. constants: {"Set" ...}. child: ("Continuation" ...).
    instantiations: {"Set"}. closures: {"Set"}) is not a key in {"Dictionary"}



g@(Optimizer MR Generator traits) generate: f@(Optimizer IR Function traits)
[| _0 _1 _2 _3 _4 | 
  g variables: g variables new.
  g continuations: g continuations new.
  g basicBlock: Nil.
  g function: (g functions at: f) `>> 
  " <---snip---> "
  g function
]

g functions at: f

g: ("Generator" module: ("Module" ...). functions: {"Dictionary"}. function: ("Function" ...).
    variables: {"Dictionary"}. continuations: {"Dictionary"}. basicBlock: Nil)
f: ("Closure" parent: Nil. name: Nil. inputVariables: {"ExtensibleArray" ...}. outputVariables: {"ExtensibleArray" ...}.
    localVariables: {"Set" ...}. constants: {"Set" ...}. child: ("Continuation" ...).
    instantiations: {"Set"}. closures: {"Set"})



More information about the Slate mailing list