Lean C Compiler
Lean C Compiler
C compiler
◆ Accept a C program
◆ Emit:
– a custom interpreter
– postfix bytecodes
◆ Suits ROM, Java, optimizing
linkers?
trees as ASCII
"ADDI(..., CNSTI[1])"
tree patterns
trees as C initializer
"ADDI(*,CNSTI[*])"
instruction-set generator
interpreter and
interpretive code
class FromLCC {
public static int _main() {
int pc = 0;
M.sp -= 16;
while(true) switch (pc) {
...
i=0 case 3: M.putint((M.sp+4), 0);
case 6: M.putint(((M.getint(
rows[i]=1 (M.sp+4))<<2)+_rows), 1);
case 7: M.putint((M.sp+4),
i++ (M.getint((M.sp+4))+1));
if (M.getint((M.sp+4)) < 8) {
if(i<8)goto case 6 pc=6; continue; }; ...
}