public static HighRegion Read(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader) { uint numCfgNodes = reader.ReadUInt32(); if (numCfgNodes == 0) throw new Exception("Region has no CFG nodes"); HighCfgNodeHandle[] cfgNodes = new HighCfgNodeHandle[numCfgNodes]; for (uint i = 0; i < numCfgNodes; i++) cfgNodes[i] = new HighCfgNodeHandle(); for (uint i = 0; i < numCfgNodes; i++) cfgNodes[i].Value = HighCfgNode.Read(rpa, catalog, methodBody, cfgNodes, baseLocation, haveDebugInfo, reader); RegionPhiResolver phiResolver = new RegionPhiResolver(cfgNodes); for (uint i = 0; i < numCfgNodes; i++) { foreach (HighPhi phi in cfgNodes[i].Value.Phis) phi.Resolve(phiResolver); } HighCfgNodeHandle entryNode = cfgNodes[0]; if (entryNode.Value.Phis.Length != 0) throw new RpaLoadException("Region entry node has phis"); return new HighRegion(entryNode); }
public void Resolve(RegionPhiResolver phiResolver) { if (m_unresolvedCollection == null) throw new Exception("Phi collection has already been resolved"); m_links = m_unresolvedCollection.Resolve(phiResolver); m_unresolvedCollection = null; }
public HighPhiLink[] Resolve(RegionPhiResolver phiResolver) { List<HighPhiLink> phiLinks = new List<HighPhiLink>(); foreach (UnresolvedLink link in m_links) { HighCfgNodeHandle predecessor = phiResolver.LookupPredecessor(link.PredecessorIndex); HighSsaRegister reg; if (link.IsConstant) reg = link.ConstantReg; else reg = phiResolver.LookupReg(link.PredecessorIndex, link.LinkIndex); phiLinks.Add(new HighPhiLink(predecessor, reg)); } return phiLinks.ToArray(); }