Esempio n. 1
0
F_access F_allocLocal(F_frame f, bool escape) {
  int offset = 0;
  F_accessList tail;
  for (F_accessList locals = f->locals; locals; locals = locals->tail)
    if (locals->head->kind == inFrame) offset -= F_wordSize;

  F_access l = (escape) ? InFrame(offset) : InReg(Temp_newtemp());
  f->locals = F_AccessList(l, f->locals);
  return l;
}
Esempio n. 2
0
F_frame F_newFrame(Temp_label label, U_boolList escape) {
  F_frame f = (F_frame)checked_malloc(sizeof(*f));
  f->label = label;
  int offset = 0;
  int reg = 0;

  F_accessList h = F_AccessList(NULL, NULL), p = h;
  for (; escape; escape = escape->tail) {
    if (escape->head == TRUE || reg >= regNum) {
      p->tail = F_AccessList(InFrame(offset += F_wordSize), NULL);
    } else {
      p->tail = F_AccessList(InReg(Temp_newtemp()), NULL);
    }
    p = p->tail;
  }
  f->formals = h->tail; free(h);
  return f;
}
Esempio n. 3
0
static F_accessList makeFormalAccessList(F_frame f, U_boolList formals)
{
	U_boolList fmls;
	F_accessList headList = NULL, tailList = NULL;
	int i = 1;
	for (fmls = formals; fmls; fmls = fmls->tail) {
		F_access access = NULL;
		if (i <= F_K && !fmls->head) {
			access = InReg(Temp_newtemp());
			i++;
		} else {
			/* Add 1 for return address space. */
			access = InFrame((1 + i) * F_WORD_SIZE);
		}
		if (headList) {
			tailList->tail = F_AccessList(access, NULL);
			tailList = tailList->tail;
		} else {
			headList = F_AccessList(access, NULL);
			tailList = headList;
		}
	}
	return headList;
}
Esempio n. 4
0
F_access F_allocLocal(F_frame f, bool escape)
{
	f->local_count++;
	if (escape) return InFrame(F_WORD_SIZE * (- f->local_count));
	return InReg(Temp_newtemp());
}