public override Frame.Frame NewFrame(Temp.Label name, BoolList formals) { MipsFrame ret = new MipsFrame(); ret.Name = name; AccessList ptr = null; int count = 0; for (BoolList f = formals; f != null; f = f.Tail) { Access a; if (count < 4 && !f.Head) { a = ret.AllocLocal(false); } else { a = ret.AllocLocal(true); } if (ret.Formals == null) { ptr = ret.Formals = new AccessList(a, null); } else { ptr = ptr.Tail = new AccessList(a, null); } } AllFrames.Add(ret); return(ret); }
void Trace(Tree.StmList l) { for (; ;) { Tree.LABEL lab = (Tree.LABEL)l.Head; Table.Remove(lab.Label); Tree.StmList last = GetLast(l); Tree.Stm s = last.Tail.Head; if (s is Tree.JUMP) { Tree.JUMP j = (Tree.JUMP)s; Tree.StmList target = (Tree.StmList)Table[j.Targets.Head]; if (j.Targets.Tail == null && target != null) { last.Tail = target; l = target; } else { last.Tail.Tail = GetNext(); return; } } else if (s is Tree.CJUMP) { Tree.CJUMP j = (Tree.CJUMP)s; Tree.StmList t = (Tree.StmList)Table[j.IfTrue]; Tree.StmList f = (Tree.StmList)Table[j.IfFalse]; if (f != null) { last.Tail.Tail = f; l = f; } else if (t != null) { last.Tail.Head = new Tree.CJUMP(Tree.CJUMP.NotRel(j.Relop), j.Left, j.Right, j.IfFalse, j.IfTrue); last.Tail.Tail = t; l = t; } else { Temp.Label ff = new Temp.Label(); last.Tail.Head = new Tree.CJUMP(j.Relop, j.Left, j.Right, j.IfTrue, ff); last.Tail.Tail = new Tree.StmList(new Tree.LABEL(ff), new Tree.StmList(new Tree.JUMP(j.IfFalse), GetNext())); return; } } else { throw new FatalError("Bad basic block in TraceSchedule"); } } }
public override string String(Temp.Label label, string value) { StringBuilder sb = new StringBuilder(); sb.AppendLine(".data"); sb.AppendLine(label.ToString() + ":"); sb.Append("\t.asciiz \""); sb.AppendLine(Unescape(value) + "\""); return(sb.ToString()); }
public abstract string String(Temp.Label label, string values);
public abstract Frame NewFrame(Temp.Label name, BoolList formals);
public Label(Temp.Label label) { Lab = label; }
public BasicBlocks(Tree.StmList stms) { Done = new Temp.Label(); MakeBlocks(stms); }
void Trace(Tree.StmList l) { for (; ; ) { Tree.LABEL lab = (Tree.LABEL)l.Head; Table.Remove(lab.Label); Tree.StmList last = GetLast(l); Tree.Stm s = last.Tail.Head; if (s is Tree.JUMP) { Tree.JUMP j = (Tree.JUMP)s; Tree.StmList target = (Tree.StmList)Table[j.Targets.Head]; if (j.Targets.Tail == null && target != null) { last.Tail = target; l = target; } else { last.Tail.Tail = GetNext(); return; } } else if (s is Tree.CJUMP) { Tree.CJUMP j = (Tree.CJUMP)s; Tree.StmList t = (Tree.StmList)Table[j.IfTrue]; Tree.StmList f = (Tree.StmList)Table[j.IfFalse]; if (f != null) { last.Tail.Tail = f; l = f; } else if (t != null) { last.Tail.Head = new Tree.CJUMP(Tree.CJUMP.NotRel(j.Relop), j.Left, j.Right, j.IfFalse, j.IfTrue); last.Tail.Tail = t; l = t; } else { Temp.Label ff = new Temp.Label(); last.Tail.Head = new Tree.CJUMP(j.Relop, j.Left, j.Right, j.IfTrue, ff); last.Tail.Tail = new Tree.StmList(new Tree.LABEL(ff), new Tree.StmList(new Tree.JUMP(j.IfFalse), GetNext())); return; } } else throw new FatalError("Bad basic block in TraceSchedule"); } }