void RemovePredecessor(BasicBlock bb) { if (Predecessors == null) { return; } if (Predecessors.Contains(bb)) Predecessors.Remove(bb); }
/// <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); }
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); }
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); }
/// <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; }
public NaiveRegisterPacker(BasicBlock bb, DefaultRegisterPacker derp) { BasicBlock = bb; Derp = derp; }
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); }