Exemple #1
0
    /*
     * Test Building Full Dominator Tree
     */
    private static void TestCalculatingDominanceFrontier(int index, SortedSet <int> expected)
    {
        // Build Dominator Tree
        IRGraph       cfg           = BuildSampleCFG();
        DominatorTree dominatorTree = new DominatorTree(cfg);

        SortedSet <IRBlock> result    = dominatorTree.GetDominanceFrontier(cfg.GetBlock(index));
        SortedSet <int>     intResult = ConvertToIndexSet(result);

        if (!intResult.SetEquals(expected))
        {
            throw new Exception("Dominance frontier for block " + index + " is " + ConvertSetToString(intResult) + " should be " + ConvertSetToString(expected));
        }
    }
Exemple #2
0
    /*
     * Test the dominance set
     */
    private static void TestDomaintes(int index, SortedSet <int> expected)
    {
        IRGraph cfg = BuildSampleCFG();

        SortedSet <IRBlock> V      = cfg.GetSetOfAllBlocks();
        SortedSet <IRBlock> VSansR = new SortedSet <IRBlock>();

        VSansR.UnionWith(V);
        VSansR.Remove(cfg.GetGraphHead());

        SortedSet <IRBlock> result    = DominatorTree.CalculateDominatesSet(cfg, V, VSansR, cfg.GetBlock(index));
        SortedSet <int>     intResult = ConvertToIndexSet(result);

        if (!intResult.SetEquals(expected))
        {
            throw new Exception("Dominates blocks for block " + index + " is " + ConvertSetToString(intResult) + " should be " + ConvertSetToString(expected));
        }
    }