See if this has any value, I thought it might. For a toy compiler I'm working on, I also started a trivial translator that does three address code -> Parrot assembler. While its currently a very simple script, I'm making it do named lexicals, named globals and register tracking. Then it'd be nice have very simple a very simple peep hole optimizer in it as well.
If you guys think it might be useful, even academically, somewhere in the tree let me know. I do think named lexicals/global handling would be nice in Parrot assembly. The benefit I could see to having a separate module to do 3address -> Parrot is it might give other compiler writers a head start and let us do a common optimizer. If people have different opinions on intermediate code generation, I'd like to hear them, since I've only done toy compilers in school which always used 3address or quadruples. -Melvin PS: If you do like the idea, here is a sample of what my compiler emits which I translate to Parrot. Please tell me where you see stupidity or weakness. The "emit" directive is a simple "here document" to emit unmodified code. The "reg" directive simply assigns a temporary to hold the named identifier in the basic block. Other than that its very similar to Parrot. # t.quad # _START: call __Main __END: end #DEFINE CLASS Hello __Main: # def method # declare local Str in register $0 reg $0 = Str Str = "Hello world!\n" # Build arg list arg Str call __System_Console_WriteLine ret #END CLASS emit<<EOF __System_Console_WriteLine: restore_s S0 print S0 ret EOF Translates to: # t.pasm # _START: bsr __Main __END: end #DEFINE CLASS Hello __Main: # declare local Str in register $0 # Assigning register S0 to lexical Str set S0, "Hello world!\n" # Build arg list save_s S0 bsr __System_Console_WriteLine ret #END CLASS __System_Console_WriteLine: restore_s S0 print S0 ret