Ejemplo n.º 1
0
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());
}
Ejemplo n.º 2
0
void show_instr(void * i) 
{
	AS_instr instr = (AS_instr) i;
	assert(F_tempMap);
	assert(instr);

	/*switch (instr->kind) {
		case I_OPER: puts(instr->u.OPER.assem); break;
		case I_LABEL: puts(instr->u.LABEL.assem); break;
		case I_MOVE: puts(instr->u.MOVE.assem); break;
		default: assert("Invalid SHOW INSTR");
	}*/

    AS_print(stdout, instr, Temp_layerMap(F_tempMap, Temp_name()));
}
Ejemplo n.º 3
0
/* print the assembly language instructions to filename.s */
static void doProc(FILE *out, F_frame frame, T_stm body)
{
    T_stmList stmList;
    AS_instrList iList;

    stmList = C_linearize(body);
    stmList = C_traceSchedule(C_basicBlocks(stmList));
//    printStmList(stdout, stmList);
    print_graph_Stm_List(out, stmList);

    iList  = F_codegen(frame, stmList);

    fprintf(stdout, "BEGIN %s\n", Temp_labelstring(frame->name));
    AS_printInstrList (stdout, iList, Temp_layerMap(f_map,Temp_name()));
    fprintf(stdout, "END %s\n\n", Temp_labelstring(frame->name));
}
Ejemplo n.º 4
0
static void doProc(FILE *out, F_frame frame, T_stm body)
{
	//printStm(body);
	AS_proc proc;
	T_stmList stmList;
	AS_instrList iList;
	stmList = C_linearize(body);
	stmList = C_traceSchedule(C_basicBlocks(stmList));
	//printStmList(stdout, stmList);
	iList  = codegen(frame, stmList); /* 9 */
	G_graph g = FG_AssemFlowGraph(iList);
	//G_show(stdout, G_nodes(g), show_instr);
	//show_graph(g);
	struct L_graph lg = L_liveness(g);
	show_graph(lg.graph);
	fprintf(out, "BEGIN %s\n", Temp_labelstring(F_name(frame)));
	AS_printInstrList (out, iList, Temp_layerMap(F_tempMap,Temp_name()));
	fprintf(out, "END %s\n\n", Temp_labelstring(F_name(frame)));
}
Ejemplo n.º 5
0
Temp_map Temp_layerMap(Temp_map over, Temp_map under) {
  if (over==NULL)
      return under;
  else return newMap(over->tab, Temp_layerMap(over->under, under));
}