static Temp_tempList F_special_registers(void) { static Temp_tempList spregs = NULL; if (!spregs) { spregs = Temp_TempList(F_SP(), Temp_TempList(F_FP(), Temp_TempList(F_RV(), NULL))); } return spregs; }
AS_instrList F_procEntryExit2(AS_instrList body) { static Temp_tempList returnSink = NULL; if (returnSink) returnSink = Temp_TempList( F_ZERO(), Temp_TempList( F_RA(), Temp_TempList( F_SP(), F_CALLEE()))); return AS_splice(body, AS_IOnstrList( AS_Oper("", NULL, returnSink, NULL), NULL)); }
int main(int argc, string *argv) { #if 0 Temp_temp a1 = Temp_namedtemp(1), a2 = Temp_namedtemp(2), a3 = Temp_namedtemp(3), a4 = Temp_namedtemp(4), a5 = Temp_namedtemp(5); Temp_tempList a = Temp_TempList(a1, Temp_TempList(a2, Temp_TempList(a3, NULL))), b = Temp_TempList(a2, Temp_TempList(a4, NULL)); printf("union: "); printTempList(unionn(a, b)); printf("except: "); printTempList(except(a,b)); #endif #if 1 A_exp absyn_root; S_table base_env, base_tenv; F_fragList frags; char outfile[100]; FILE *out = stdout; if (argc==2) { absyn_root = parse(argv[1]); if (!absyn_root) return 1; //pr_exp(stdout,absyn_root, 4); frags = SEM_transProg(absyn_root); if (anyErrors) return 1; /* don't continue */ /* convert the filename */ sprintf(outfile, "%s.s", argv[1]); out = fopen(outfile, "w"); for (;frags;frags=frags->tail) { if (frags->head->kind == F_procFrag) { //puts(Temp_labelstring(F_name(frags->head->u.proc.frame))); doProc(out, frags->head->u.proc.frame, frags->head->u.proc.body); } else if (frags->head->kind == F_stringFrag) { fprintf(out, "%s: %s\n",Temp_labelstring(frags->head->u.stringg.label), frags->head->u.stringg.str); } else assert(0); } fclose(out); return 0; } EM_error(0,"usage: tiger file.tig"); return 1; #endif }
Temp_tempList F_CALLER() { static Temp_tempList caller = NULL; if (caller) return caller; for (int i = 0; i < 2; ++i) { Temp_temp r = Temp_newtemp(); caller = Temp_TempList(r, caller); } return caller; }
Temp_tempList F_CALLEE() { static Temp_tempList callee = NULL; if (callee) return callee; for (int i = 0; i < 6; ++i) { Temp_temp r = Temp_newtemp(); callee = Temp_TempList(r, callee); } return callee; }
Temp_tempList F_ARGS() { static Temp_tempList argr = NULL; if (argr) return argr; for (int i = 0; i < 6; ++i) { Temp_temp r = Temp_newtemp(); argr = Temp_TempList(r, argr); } return argr; }