Exemplo n.º 1
0
            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);
            }
Exemplo n.º 2
0
 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");
         }
     }
 }
Exemplo n.º 3
0
            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());
            }
Exemplo n.º 4
0
 public abstract string String(Temp.Label label, string values);
Exemplo n.º 5
0
 public abstract Frame NewFrame(Temp.Label name, BoolList formals);
Exemplo n.º 6
0
 public Label(Temp.Label label)
 {
     Lab = label;
 }
Exemplo n.º 7
0
 public BasicBlocks(Tree.StmList stms)
 {
     Done = new Temp.Label();
     MakeBlocks(stms);
 }
Exemplo n.º 8
0
 public Label(Temp.Label label)
 {
     Lab = label;
 }
Exemplo n.º 9
0
 public BasicBlocks(Tree.StmList stms)
 {
     Done = new Temp.Label();
     MakeBlocks(stms);
 }
Exemplo n.º 10
0
 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");
     }
 }