Ejemplo n.º 1
0
 void RemovePredecessor(BasicBlock bb)
 {
     if (Predecessors == null)
     {
         return;
     }
     if (Predecessors.Contains(bb))
         Predecessors.Remove(bb);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a BasicBlock HEAD instruction to the graph (always a new BasicBlock)
 /// </summary>
 /// <param name="nInstruction"></param>
 /// <param name="ehinfo"></param>
 void HeadInstruction(int nInstruction, EHInfo ehinfo)
 {
     CurrentBasicBlock = new BasicBlock(this, BasicBlocks.Count, nInstruction, ehinfo);
     BasicBlocks.Add(CurrentBasicBlock);
 }
Ejemplo n.º 3
0
        void AddSuccessor(BasicBlock bb)
        {
            if (Successors == null)
                Successors = new List<BasicBlock>();

            if (bb == this)
                return;

            if (Successors.Contains(bb))
                return;

            Successors.Add(bb);
            if (bb!=null)
                bb.AddPredecessor(this);
        }
Ejemplo n.º 4
0
        void AddPredecessor(BasicBlock bb)
        {
            if (Predecessors == null)
            {
                Predecessors = new List<BasicBlock>();
                Predecessors.Add(bb);
                return;
            }

            if (bb == this)
                return;

            if (Predecessors.Contains(bb))
                return;

            Predecessors.Add(bb);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds a BasicBlock TAIL instruction to the graph (terminates the current BasicBlock after adding this instruction)
 /// </summary>
 /// <param name="nInstruction"></param>
 /// <param name="ehinfo"></param>
 void TailInstruction(int nInstruction, EHInfo ehinfo)
 {
     NormalInstruction(nInstruction, ehinfo);
     CurrentBasicBlock = null;
 }
Ejemplo n.º 6
0
 public NaiveRegisterPacker(BasicBlock bb, DefaultRegisterPacker derp)
 {
     BasicBlock = bb;
     Derp = derp;
 }
Ejemplo n.º 7
0
        void PackRegisters(BasicBlock bb)
        {
            NaiveRegisterPacker nrp = new NaiveRegisterPacker(bb,this);

            List<int> registerPastWrites = bb.GetRegisterPastWrites();
            List<int> registerFutureReads = bb.GetRegisterFutureReads();

            {
                List<int> listReserved = new List<int>();

                // listReserved is the intersection of RegisterPastWrites with RegisterReads OR RegisterFutureReads
                foreach (int n in registerPastWrites)
                {
                    if (bb.RegisterReads.Contains(n) || registerFutureReads.Contains(n))
                        listReserved.Add(n);
                }
                if (listReserved.Count>0)
                    nrp.HeadRegisters(listReserved, bb.Instructions);
            }

            nrp.ScanRanges(bb.Instructions);

            {
                List<int> listReserved = new List<int>();

                // listReserved is the intersection of RegisterFutureReads with RegisterWrites OR RegisterPastWrites
                foreach (int n in registerFutureReads)
                {
                    if (bb.RegisterWrites.Contains(n) || registerPastWrites.Contains(n))
                        listReserved.Add(n);
                }

                if (listReserved.Count > 0)
                    nrp.TailRegisters(listReserved, bb.Instructions);
            }

            nrp.Condense(bb.Instructions);
        }