1 //===-- SchedClassResolutionTest.cpp ----------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "SchedClassResolution.h"
15 #include "llvm/Support/TargetRegistry.h"
16 #include "llvm/Support/TargetSelect.h"
17 #include "gmock/gmock.h"
18 #include "gtest/gtest.h"
25 using testing::UnorderedElementsAre
;
27 class SchedClassResolutionTest
: public X86TestBase
{
29 SchedClassResolutionTest() : STI(State
.getSubtargetInfo()) {
30 // Compute the ProxResIdx of ports uses in tests.
31 const auto &SM
= STI
.getSchedModel();
32 for (unsigned I
= 0, E
= SM
.getNumProcResourceKinds(); I
< E
; ++I
) {
33 const std::string Name
= SM
.getProcResource(I
)->Name
;
34 if (Name
== "HWPort0") {
36 } else if (Name
== "HWPort1") {
38 } else if (Name
== "HWPort5") {
40 } else if (Name
== "HWPort6") {
42 } else if (Name
== "HWPort05") {
44 } else if (Name
== "HWPort0156") {
53 EXPECT_NE(P0156Idx
, 0);
57 const MCSubtargetInfo
&STI
;
63 uint16_t P0156Idx
= 0;
66 TEST_F(SchedClassResolutionTest
, ComputeIdealizedProcResPressure_2P0
) {
68 computeIdealizedProcResPressure(STI
.getSchedModel(), {{P0Idx
, 2}});
69 EXPECT_THAT(Pressure
, UnorderedElementsAre(Pair(P0Idx
, 2.0)));
72 TEST_F(SchedClassResolutionTest
, ComputeIdealizedProcResPressure_2P05
) {
74 computeIdealizedProcResPressure(STI
.getSchedModel(), {{P05Idx
, 2}});
76 UnorderedElementsAre(Pair(P0Idx
, 1.0), Pair(P5Idx
, 1.0)));
79 TEST_F(SchedClassResolutionTest
, ComputeIdealizedProcResPressure_2P05_2P0156
) {
80 const auto Pressure
= computeIdealizedProcResPressure(
81 STI
.getSchedModel(), {{P05Idx
, 2}, {P0156Idx
, 2}});
83 UnorderedElementsAre(Pair(P0Idx
, 1.0), Pair(P1Idx
, 1.0),
84 Pair(P5Idx
, 1.0), Pair(P6Idx
, 1.0)));
87 TEST_F(SchedClassResolutionTest
,
88 ComputeIdealizedProcResPressure_1P1_1P05_2P0156
) {
89 const auto Pressure
= computeIdealizedProcResPressure(
90 STI
.getSchedModel(), {{P1Idx
, 1}, {P05Idx
, 1}, {P0156Idx
, 2}});
92 UnorderedElementsAre(Pair(P0Idx
, 1.0), Pair(P1Idx
, 1.0),
93 Pair(P5Idx
, 1.0), Pair(P6Idx
, 1.0)));
97 } // namespace exegesis