1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
llvm-mirror/unittests/ADT/EnumeratedArrayTest.cpp
bmahjour d3fb929e1b [DDG] Data Dependence Graph - Pi Block
Summary:
    This patch adds Pi Blocks to the DDG. A pi-block represents a group of DDG
    nodes that are part of a strongly-connected component of the graph.
    Replacing all the SCCs with pi-blocks results in an acyclic representation
    of the DDG. For example if we have:
       {a -> b}, {b -> c, d}, {c -> a}
    the cycle a -> b -> c -> a is abstracted into a pi-block "p" as follows:
       {p -> d} with "p" containing: {a -> b}, {b -> c}, {c -> a}
    In this implementation the edges between nodes that are part of the pi-block
    are preserved. The crossing edges (edges where one end of the edge is in the
    set of nodes belonging to an SCC and the other end is outside that set) are
    replaced with corresponding edges to/from the pi-block node instead.

    Authored By: bmahjour

    Reviewer: Meinersbur, fhahn, myhsu, xtian, dmgreen, kbarton, jdoerfert

    Reviewed By: Meinersbur

    Subscribers: ychen, arphaman, simoll, a.elovikov, mgorny, hiraditya, jfb, wuzish, llvm-commits, jsji, Whitney, etiotto, ppc-slack

    Tag: #llvm

    Differential Revision: https://reviews.llvm.org/D68827
2019-11-08 15:46:08 -05:00

52 lines
1.5 KiB
C++

//===- llvm/unittest/ADT/EnumeratedArrayTest.cpp ----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// EnumeratedArray unit tests.
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/EnumeratedArray.h"
#include "gtest/gtest.h"
namespace llvm {
//===--------------------------------------------------------------------===//
// Test initialization and use of operator[] for both read and write.
//===--------------------------------------------------------------------===//
TEST(EnumeratedArray, InitAndIndex) {
enum class Colors { Red, Blue, Green, Last = Green };
EnumeratedArray<float, Colors, Colors::Last, size_t> Array1;
Array1[Colors::Red] = 1.0;
Array1[Colors::Blue] = 2.0;
Array1[Colors::Green] = 3.0;
EXPECT_EQ(Array1[Colors::Red], 1.0);
EXPECT_EQ(Array1[Colors::Blue], 2.0);
EXPECT_EQ(Array1[Colors::Green], 3.0);
EnumeratedArray<bool, Colors> Array2(true);
EXPECT_TRUE(Array2[Colors::Red]);
EXPECT_TRUE(Array2[Colors::Blue]);
EXPECT_TRUE(Array2[Colors::Green]);
Array2[Colors::Red] = true;
Array2[Colors::Blue] = false;
Array2[Colors::Green] = true;
EXPECT_TRUE(Array2[Colors::Red]);
EXPECT_FALSE(Array2[Colors::Blue]);
EXPECT_TRUE(Array2[Colors::Green]);
}
} // namespace llvm