13
13
#include " MipsInstrInfo.h"
14
14
#include " RegisterAliasing.h"
15
15
#include " TestBase.h"
16
+ #include " Uops.h"
16
17
17
18
#include < unordered_set>
18
19
@@ -22,6 +23,7 @@ namespace {
22
23
23
24
using testing::AnyOf;
24
25
using testing::ElementsAre;
26
+ using testing::HasSubstr;
25
27
using testing::SizeIs;
26
28
27
29
MATCHER (IsInvalid, " " ) { return !arg.isValid (); }
@@ -49,6 +51,8 @@ class SnippetGeneratorTest : public MipsSnippetGeneratorTest {
49
51
using LatencySnippetGeneratorTest =
50
52
SnippetGeneratorTest<LatencySnippetGenerator>;
51
53
54
+ using UopsSnippetGeneratorTest = SnippetGeneratorTest<UopsSnippetGenerator>;
55
+
52
56
TEST_F (LatencySnippetGeneratorTest, ImplicitSelfDependencyThroughExplicitRegs) {
53
57
// - ADD
54
58
// - Op0 Explicit Def RegClass(GPR32)
@@ -57,6 +61,7 @@ TEST_F(LatencySnippetGeneratorTest, ImplicitSelfDependencyThroughExplicitRegs) {
57
61
// - Var0 [Op0]
58
62
// - Var1 [Op1]
59
63
// - Var2 [Op2]
64
+ // - hasAliasingRegisters
60
65
const unsigned Opcode = Mips::ADD;
61
66
const auto CodeTemplates = checkAndGetCodeTemplates (Opcode);
62
67
ASSERT_THAT (CodeTemplates, SizeIs (1 ));
@@ -81,6 +86,7 @@ TEST_F(LatencySnippetGeneratorTest,
81
86
// - Var0 [Op0]
82
87
// - Var1 [Op1]
83
88
// - Var2 [Op2]
89
+ // - hasAliasingRegisters
84
90
randomGenerator ().seed (0 ); // Initialize seed.
85
91
const Instruction &Instr = State.getIC ().getInstr (Mips::XOR);
86
92
auto AllRegisters = State.getRATC ().emptyRegisters ();
@@ -90,6 +96,31 @@ TEST_F(LatencySnippetGeneratorTest,
90
96
consumeError (std::move (Error));
91
97
}
92
98
99
+ TEST_F (UopsSnippetGeneratorTest, MemoryUse) {
100
+ // LB reads from memory.
101
+ // - LB
102
+ // - Op0 Explicit Def RegClass(GPR32)
103
+ // - Op1 Explicit Use Memory RegClass(MSA128F16)
104
+ // - Op2 Explicit Use Memory
105
+ // - Var0 [Op0]
106
+ // - Var1 [Op1]
107
+ // - Var2 [Op2]
108
+ // - hasMemoryOperands
109
+ const unsigned Opcode = Mips::LB;
110
+ const auto CodeTemplates = checkAndGetCodeTemplates (Opcode);
111
+ ASSERT_THAT (CodeTemplates, SizeIs (1 ));
112
+ const auto &CT = CodeTemplates[0 ];
113
+ EXPECT_THAT (CT.Info , HasSubstr (" instruction is parallel, repeating a random one." ));
114
+ EXPECT_THAT (CT.Execution , ExecutionMode::UNKNOWN);
115
+ ASSERT_THAT (CT.Instructions ,
116
+ SizeIs (UopsSnippetGenerator::kMinNumDifferentAddresses ));
117
+ const InstructionTemplate &IT = CT.Instructions [0 ];
118
+ EXPECT_THAT (IT.getOpcode (), Opcode);
119
+ ASSERT_THAT (IT.getVariableValues (), SizeIs (3 ));
120
+ EXPECT_EQ (IT.getVariableValues ()[0 ].getReg (), 0u );
121
+ EXPECT_EQ (IT.getVariableValues ()[2 ].getImm (), 0 );
122
+ }
123
+
93
124
} // namespace
94
125
} // namespace exegesis
95
126
} // namespace llvm
0 commit comments