One of my favorite routines in the C emitter related code (ir-hlc.bas):
Code: Select all
'':::::
private sub _emitSpillRegs _
( _
)
/' do nothing '/
end sub
Now that's the kind of code even I can understand. Eleven routines in the emitter start with the words /' do nothing '/.
This piece of code is nice too:
Code: Select all
#ifdef TARGET_X86
hWriteLine( "static inline " & rtype_str & " fb_" & fname & " ( " & ptype_str & !" value ) {\n" & _
!"\tvolatile " & rtype_str & !" result;\n" & _
!"\t__asm__ (\n" & _
!"\t\t\"fld" & ptype_suffix & !" %1;\"\n" & _
!"\t\t\"fistp" & rtype_suffix & !" %0;\"\n" & _
!"\t\t:\"=m\" (result)\n" & _
!"\t\t:\"m\" (value)\n" & _
!"\t);\n" & _
!"\treturn result;\n" & _
!"}", FALSE )
#else
#error !!!WRITEME!!!
#endif
Mind the !!!WRITEME!!!.
Someone said something about the kind of C code getting emitted. The part of the code starting with __asm__ looks like GCC code to me so it's not Ansci C and not C99 (it's GCC).
Another routine contains this statement:
Code: Select all
hWriteLine( "goto *" & hVregToStr( v1 ) )
Computed goto (goto *) is a GCC extension (it's not part of C99). But you will not hear me complaining (computed goto seems like a good idea).
By far my MOST favorite part of the C emitter thus far...
Code: Select all
'' HACK: reusing the accessed flag (that's used by variables only)
If there is one thing I love to find in source code it's hacks.
Source code without hacks is no good. Thus far only one piece of source code in the C emitter has been marked hack. That's a bit disappointing to me. The final version of the emitter should contain at least ten hacks :)
I hope v1ctor will be able to finish the C emitter.