Temp_map F_TempMap() { static Temp_map m = NULL; if (!m) { m = Temp_empty(); Temp_enter(m, F_FP(), "fp"); Temp_enter(m, F_SP(), "sp"); Temp_enter(m, F_RV(), "rv"); Temp_enter(m, F_ZERO(), "zf"); Temp_tempList args = F_ARGS(); Temp_tempList callee = F_CALLEE(); Temp_tempList caller = F_CALLER(); string buf[10]; for (int i=0; args; args = args->tail, i++) { sprintf(buf, "args%d", i); Temp_enter(m, args, ""); } for (int i=0; callee; callee = callee->tail, i++) { sprintf(buf, "callee%d", i); Temp_enter(m, args, ""); } for (int i=0; caller; caller = caller->tail, i++) { sprintf(buf, "caller%d", i); Temp_enter(m, args, ""); } } return Temp_layerMap(m, Temp_name()); }
static Temp_tempList F_make_calle_saves(void) { Temp_temp rbx = Temp_newtemp(), r12 = Temp_newtemp(), r13 = Temp_newtemp(), r14 = Temp_newtemp(), r15 = Temp_newtemp(); F_add_to_map("rbx", rbx); F_add_to_map("r12", r12); F_add_to_map("r13", r13); F_add_to_map("r14", r14); F_add_to_map("r15", r15); return TL(F_SP(), TL(F_FP(), TL(rbx, TL(r12, TL(r13, TL(r14, TL(r15, NULL))))))); }
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)); }