Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(679)

Side by Side Diff: test/compiler-unittests/arm/instruction-selector-arm-unittest.cc

Issue 484953003: Revert "[arm] Shorter test names for parameterized tests." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/compiler-unittests/change-lowering-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "test/compiler-unittests/instruction-selector-unittest.h" 5 #include "test/compiler-unittests/instruction-selector-unittest.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace compiler { 9 namespace compiler {
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 1073741855, 1073741861, 1073741884, 1157627904, 1476395008, 111 1073741855, 1073741861, 1073741884, 1157627904, 1476395008,
112 1476395010, 1610612741, 2030043136, 2080374785, 2097152000}; 112 1476395010, 1610612741, 2030043136, 2080374785, 2097152000};
113 113
114 } // namespace 114 } // namespace
115 115
116 116
117 // ----------------------------------------------------------------------------- 117 // -----------------------------------------------------------------------------
118 // Data processing instructions. 118 // Data processing instructions.
119 119
120 120
121 namespace { 121 typedef InstructionSelectorTestWithParam<DPI> InstructionSelectorDPITest;
122
123 class DPITest : public InstructionSelectorTestWithParam<DPI> {};
124 122
125 123
126 TEST_P(DPITest, Parameters) { 124 TEST_P(InstructionSelectorDPITest, Parameters) {
127 const DPI dpi = GetParam(); 125 const DPI dpi = GetParam();
128 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 126 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
129 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1))); 127 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)));
130 Stream s = m.Build(); 128 Stream s = m.Build();
131 ASSERT_EQ(1U, s.size()); 129 ASSERT_EQ(1U, s.size());
132 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); 130 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode());
133 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 131 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
134 EXPECT_EQ(2U, s[0]->InputCount()); 132 EXPECT_EQ(2U, s[0]->InputCount());
135 EXPECT_EQ(1U, s[0]->OutputCount()); 133 EXPECT_EQ(1U, s[0]->OutputCount());
136 } 134 }
137 135
138 136
139 TEST_P(DPITest, Immediate) { 137 TEST_P(InstructionSelectorDPITest, Immediate) {
140 const DPI dpi = GetParam(); 138 const DPI dpi = GetParam();
141 TRACED_FOREACH(int32_t, imm, kImmediates) { 139 TRACED_FOREACH(int32_t, imm, kImmediates) {
142 StreamBuilder m(this, kMachInt32, kMachInt32); 140 StreamBuilder m(this, kMachInt32, kMachInt32);
143 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); 141 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)));
144 Stream s = m.Build(); 142 Stream s = m.Build();
145 ASSERT_EQ(1U, s.size()); 143 ASSERT_EQ(1U, s.size());
146 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); 144 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode());
147 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 145 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
148 ASSERT_EQ(2U, s[0]->InputCount()); 146 ASSERT_EQ(2U, s[0]->InputCount());
149 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 147 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
150 EXPECT_EQ(1U, s[0]->OutputCount()); 148 EXPECT_EQ(1U, s[0]->OutputCount());
151 } 149 }
152 TRACED_FOREACH(int32_t, imm, kImmediates) { 150 TRACED_FOREACH(int32_t, imm, kImmediates) {
153 StreamBuilder m(this, kMachInt32, kMachInt32); 151 StreamBuilder m(this, kMachInt32, kMachInt32);
154 m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0))); 152 m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)));
155 Stream s = m.Build(); 153 Stream s = m.Build();
156 ASSERT_EQ(1U, s.size()); 154 ASSERT_EQ(1U, s.size());
157 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); 155 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode());
158 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 156 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
159 ASSERT_EQ(2U, s[0]->InputCount()); 157 ASSERT_EQ(2U, s[0]->InputCount());
160 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 158 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
161 EXPECT_EQ(1U, s[0]->OutputCount()); 159 EXPECT_EQ(1U, s[0]->OutputCount());
162 } 160 }
163 } 161 }
164 162
165 163
166 TEST_P(DPITest, ShiftByParameter) { 164 TEST_P(InstructionSelectorDPITest, ShiftByParameter) {
167 const DPI dpi = GetParam(); 165 const DPI dpi = GetParam();
168 TRACED_FOREACH(Shift, shift, kShifts) { 166 TRACED_FOREACH(Shift, shift, kShifts) {
169 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 167 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
170 m.Return((m.*dpi.constructor)( 168 m.Return((m.*dpi.constructor)(
171 m.Parameter(0), 169 m.Parameter(0),
172 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); 170 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))));
173 Stream s = m.Build(); 171 Stream s = m.Build();
174 ASSERT_EQ(1U, s.size()); 172 ASSERT_EQ(1U, s.size());
175 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); 173 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode());
176 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 174 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
177 EXPECT_EQ(3U, s[0]->InputCount()); 175 EXPECT_EQ(3U, s[0]->InputCount());
178 EXPECT_EQ(1U, s[0]->OutputCount()); 176 EXPECT_EQ(1U, s[0]->OutputCount());
179 } 177 }
180 TRACED_FOREACH(Shift, shift, kShifts) { 178 TRACED_FOREACH(Shift, shift, kShifts) {
181 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 179 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
182 m.Return((m.*dpi.constructor)( 180 m.Return((m.*dpi.constructor)(
183 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), 181 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)),
184 m.Parameter(2))); 182 m.Parameter(2)));
185 Stream s = m.Build(); 183 Stream s = m.Build();
186 ASSERT_EQ(1U, s.size()); 184 ASSERT_EQ(1U, s.size());
187 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); 185 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode());
188 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 186 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
189 EXPECT_EQ(3U, s[0]->InputCount()); 187 EXPECT_EQ(3U, s[0]->InputCount());
190 EXPECT_EQ(1U, s[0]->OutputCount()); 188 EXPECT_EQ(1U, s[0]->OutputCount());
191 } 189 }
192 } 190 }
193 191
194 192
195 TEST_P(DPITest, ShiftByImmediate) { 193 TEST_P(InstructionSelectorDPITest, ShiftByImmediate) {
196 const DPI dpi = GetParam(); 194 const DPI dpi = GetParam();
197 TRACED_FOREACH(Shift, shift, kShifts) { 195 TRACED_FOREACH(Shift, shift, kShifts) {
198 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 196 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
199 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 197 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
200 m.Return((m.*dpi.constructor)( 198 m.Return((m.*dpi.constructor)(
201 m.Parameter(0), 199 m.Parameter(0),
202 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); 200 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm))));
203 Stream s = m.Build(); 201 Stream s = m.Build();
204 ASSERT_EQ(1U, s.size()); 202 ASSERT_EQ(1U, s.size());
205 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); 203 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode());
(...skipping 14 matching lines...) Expand all
220 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); 218 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode());
221 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 219 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
222 ASSERT_EQ(3U, s[0]->InputCount()); 220 ASSERT_EQ(3U, s[0]->InputCount());
223 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); 221 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
224 EXPECT_EQ(1U, s[0]->OutputCount()); 222 EXPECT_EQ(1U, s[0]->OutputCount());
225 } 223 }
226 } 224 }
227 } 225 }
228 226
229 227
230 TEST_P(DPITest, BranchWithParameters) { 228 TEST_P(InstructionSelectorDPITest, BranchWithParameters) {
231 const DPI dpi = GetParam(); 229 const DPI dpi = GetParam();
232 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 230 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
233 MLabel a, b; 231 MLabel a, b;
234 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), &a, &b); 232 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), &a, &b);
235 m.Bind(&a); 233 m.Bind(&a);
236 m.Return(m.Int32Constant(1)); 234 m.Return(m.Int32Constant(1));
237 m.Bind(&b); 235 m.Bind(&b);
238 m.Return(m.Int32Constant(0)); 236 m.Return(m.Int32Constant(0));
239 Stream s = m.Build(); 237 Stream s = m.Build();
240 ASSERT_EQ(1U, s.size()); 238 ASSERT_EQ(1U, s.size());
241 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 239 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
242 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 240 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
243 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 241 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
244 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 242 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
245 } 243 }
246 244
247 245
248 TEST_P(DPITest, BranchWithImmediate) { 246 TEST_P(InstructionSelectorDPITest, BranchWithImmediate) {
249 const DPI dpi = GetParam(); 247 const DPI dpi = GetParam();
250 TRACED_FOREACH(int32_t, imm, kImmediates) { 248 TRACED_FOREACH(int32_t, imm, kImmediates) {
251 StreamBuilder m(this, kMachInt32, kMachInt32); 249 StreamBuilder m(this, kMachInt32, kMachInt32);
252 MLabel a, b; 250 MLabel a, b;
253 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), &a, 251 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), &a,
254 &b); 252 &b);
255 m.Bind(&a); 253 m.Bind(&a);
256 m.Return(m.Int32Constant(1)); 254 m.Return(m.Int32Constant(1));
257 m.Bind(&b); 255 m.Bind(&b);
258 m.Return(m.Int32Constant(0)); 256 m.Return(m.Int32Constant(0));
(...skipping 16 matching lines...) Expand all
275 Stream s = m.Build(); 273 Stream s = m.Build();
276 ASSERT_EQ(1U, s.size()); 274 ASSERT_EQ(1U, s.size());
277 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 275 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
278 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 276 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
279 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 277 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
280 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 278 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
281 } 279 }
282 } 280 }
283 281
284 282
285 TEST_P(DPITest, BranchWithShiftByParameter) { 283 TEST_P(InstructionSelectorDPITest, BranchWithShiftByParameter) {
286 const DPI dpi = GetParam(); 284 const DPI dpi = GetParam();
287 TRACED_FOREACH(Shift, shift, kShifts) { 285 TRACED_FOREACH(Shift, shift, kShifts) {
288 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 286 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
289 MLabel a, b; 287 MLabel a, b;
290 m.Branch((m.*dpi.constructor)( 288 m.Branch((m.*dpi.constructor)(
291 m.Parameter(0), 289 m.Parameter(0),
292 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))), 290 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))),
293 &a, &b); 291 &a, &b);
294 m.Bind(&a); 292 m.Bind(&a);
295 m.Return(m.Int32Constant(1)); 293 m.Return(m.Int32Constant(1));
(...skipping 20 matching lines...) Expand all
316 Stream s = m.Build(); 314 Stream s = m.Build();
317 ASSERT_EQ(1U, s.size()); 315 ASSERT_EQ(1U, s.size());
318 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 316 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
319 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 317 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
320 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 318 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
321 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 319 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
322 } 320 }
323 } 321 }
324 322
325 323
326 TEST_P(DPITest, BranchWithShiftByImmediate) { 324 TEST_P(InstructionSelectorDPITest, BranchWithShiftByImmediate) {
327 const DPI dpi = GetParam(); 325 const DPI dpi = GetParam();
328 TRACED_FOREACH(Shift, shift, kShifts) { 326 TRACED_FOREACH(Shift, shift, kShifts) {
329 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 327 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
330 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 328 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
331 MLabel a, b; 329 MLabel a, b;
332 m.Branch((m.*dpi.constructor)(m.Parameter(0), 330 m.Branch((m.*dpi.constructor)(m.Parameter(0),
333 (m.*shift.constructor)( 331 (m.*shift.constructor)(
334 m.Parameter(1), m.Int32Constant(imm))), 332 m.Parameter(1), m.Int32Constant(imm))),
335 &a, &b); 333 &a, &b);
336 m.Bind(&a); 334 m.Bind(&a);
(...skipping 28 matching lines...) Expand all
365 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 363 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
366 ASSERT_EQ(5U, s[0]->InputCount()); 364 ASSERT_EQ(5U, s[0]->InputCount());
367 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); 365 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
368 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 366 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
369 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 367 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
370 } 368 }
371 } 369 }
372 } 370 }
373 371
374 372
375 TEST_P(DPITest, BranchIfZeroWithParameters) { 373 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithParameters) {
376 const DPI dpi = GetParam(); 374 const DPI dpi = GetParam();
377 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 375 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
378 MLabel a, b; 376 MLabel a, b;
379 m.Branch(m.Word32Equal((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), 377 m.Branch(m.Word32Equal((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)),
380 m.Int32Constant(0)), 378 m.Int32Constant(0)),
381 &a, &b); 379 &a, &b);
382 m.Bind(&a); 380 m.Bind(&a);
383 m.Return(m.Int32Constant(1)); 381 m.Return(m.Int32Constant(1));
384 m.Bind(&b); 382 m.Bind(&b);
385 m.Return(m.Int32Constant(0)); 383 m.Return(m.Int32Constant(0));
386 Stream s = m.Build(); 384 Stream s = m.Build();
387 ASSERT_EQ(1U, s.size()); 385 ASSERT_EQ(1U, s.size());
388 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 386 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
389 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 387 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
390 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 388 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
391 EXPECT_EQ(kEqual, s[0]->flags_condition()); 389 EXPECT_EQ(kEqual, s[0]->flags_condition());
392 } 390 }
393 391
394 392
395 TEST_P(DPITest, BranchIfNotZeroWithParameters) { 393 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithParameters) {
396 const DPI dpi = GetParam(); 394 const DPI dpi = GetParam();
397 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 395 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
398 MLabel a, b; 396 MLabel a, b;
399 m.Branch( 397 m.Branch(
400 m.Word32NotEqual((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), 398 m.Word32NotEqual((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)),
401 m.Int32Constant(0)), 399 m.Int32Constant(0)),
402 &a, &b); 400 &a, &b);
403 m.Bind(&a); 401 m.Bind(&a);
404 m.Return(m.Int32Constant(1)); 402 m.Return(m.Int32Constant(1));
405 m.Bind(&b); 403 m.Bind(&b);
406 m.Return(m.Int32Constant(0)); 404 m.Return(m.Int32Constant(0));
407 Stream s = m.Build(); 405 Stream s = m.Build();
408 ASSERT_EQ(1U, s.size()); 406 ASSERT_EQ(1U, s.size());
409 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 407 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
410 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 408 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
411 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 409 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
412 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 410 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
413 } 411 }
414 412
415 413
416 TEST_P(DPITest, BranchIfZeroWithImmediate) { 414 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithImmediate) {
417 const DPI dpi = GetParam(); 415 const DPI dpi = GetParam();
418 TRACED_FOREACH(int32_t, imm, kImmediates) { 416 TRACED_FOREACH(int32_t, imm, kImmediates) {
419 StreamBuilder m(this, kMachInt32, kMachInt32); 417 StreamBuilder m(this, kMachInt32, kMachInt32);
420 MLabel a, b; 418 MLabel a, b;
421 m.Branch(m.Word32Equal( 419 m.Branch(m.Word32Equal(
422 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), 420 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)),
423 m.Int32Constant(0)), 421 m.Int32Constant(0)),
424 &a, &b); 422 &a, &b);
425 m.Bind(&a); 423 m.Bind(&a);
426 m.Return(m.Int32Constant(1)); 424 m.Return(m.Int32Constant(1));
(...skipping 20 matching lines...) Expand all
447 Stream s = m.Build(); 445 Stream s = m.Build();
448 ASSERT_EQ(1U, s.size()); 446 ASSERT_EQ(1U, s.size());
449 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 447 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
450 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 448 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
451 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 449 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
452 EXPECT_EQ(kEqual, s[0]->flags_condition()); 450 EXPECT_EQ(kEqual, s[0]->flags_condition());
453 } 451 }
454 } 452 }
455 453
456 454
457 TEST_P(DPITest, BranchIfNotZeroWithImmediate) { 455 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithImmediate) {
458 const DPI dpi = GetParam(); 456 const DPI dpi = GetParam();
459 TRACED_FOREACH(int32_t, imm, kImmediates) { 457 TRACED_FOREACH(int32_t, imm, kImmediates) {
460 StreamBuilder m(this, kMachInt32, kMachInt32); 458 StreamBuilder m(this, kMachInt32, kMachInt32);
461 MLabel a, b; 459 MLabel a, b;
462 m.Branch(m.Word32NotEqual( 460 m.Branch(m.Word32NotEqual(
463 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), 461 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)),
464 m.Int32Constant(0)), 462 m.Int32Constant(0)),
465 &a, &b); 463 &a, &b);
466 m.Bind(&a); 464 m.Bind(&a);
467 m.Return(m.Int32Constant(1)); 465 m.Return(m.Int32Constant(1));
(...skipping 19 matching lines...) Expand all
487 m.Return(m.Int32Constant(0)); 485 m.Return(m.Int32Constant(0));
488 Stream s = m.Build(); 486 Stream s = m.Build();
489 ASSERT_EQ(1U, s.size()); 487 ASSERT_EQ(1U, s.size());
490 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 488 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
491 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 489 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
492 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 490 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
493 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 491 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
494 } 492 }
495 } 493 }
496 494
497 } // namespace
498 495
499 496 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorDPITest,
500 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, DPITest,
501 ::testing::ValuesIn(kDPIs)); 497 ::testing::ValuesIn(kDPIs));
502 498
503 499
504 // ----------------------------------------------------------------------------- 500 // -----------------------------------------------------------------------------
505 // Data processing instructions with overflow. 501 // Data processing instructions with overflow.
506 502
507 503
508 namespace { 504 typedef InstructionSelectorTestWithParam<ODPI> InstructionSelectorODPITest;
509
510 class ODPITest : public InstructionSelectorTestWithParam<ODPI> {};
511 505
512 506
513 TEST_P(ODPITest, OvfWithParameters) { 507 TEST_P(InstructionSelectorODPITest, OvfWithParameters) {
514 const ODPI odpi = GetParam(); 508 const ODPI odpi = GetParam();
515 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 509 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
516 m.Return( 510 m.Return(
517 m.Projection(1, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); 511 m.Projection(1, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1))));
518 Stream s = m.Build(); 512 Stream s = m.Build();
519 ASSERT_EQ(1U, s.size()); 513 ASSERT_EQ(1U, s.size());
520 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 514 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
521 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 515 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
522 EXPECT_EQ(2U, s[0]->InputCount()); 516 EXPECT_EQ(2U, s[0]->InputCount());
523 EXPECT_LE(1U, s[0]->OutputCount()); 517 EXPECT_LE(1U, s[0]->OutputCount());
524 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 518 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
525 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 519 EXPECT_EQ(kOverflow, s[0]->flags_condition());
526 } 520 }
527 521
528 522
529 TEST_P(ODPITest, OvfWithImmediate) { 523 TEST_P(InstructionSelectorODPITest, OvfWithImmediate) {
530 const ODPI odpi = GetParam(); 524 const ODPI odpi = GetParam();
531 TRACED_FOREACH(int32_t, imm, kImmediates) { 525 TRACED_FOREACH(int32_t, imm, kImmediates) {
532 StreamBuilder m(this, kMachInt32, kMachInt32); 526 StreamBuilder m(this, kMachInt32, kMachInt32);
533 m.Return(m.Projection( 527 m.Return(m.Projection(
534 1, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); 528 1, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm))));
535 Stream s = m.Build(); 529 Stream s = m.Build();
536 ASSERT_EQ(1U, s.size()); 530 ASSERT_EQ(1U, s.size());
537 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 531 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
538 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 532 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
539 ASSERT_EQ(2U, s[0]->InputCount()); 533 ASSERT_EQ(2U, s[0]->InputCount());
(...skipping 12 matching lines...) Expand all
552 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 546 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
553 ASSERT_EQ(2U, s[0]->InputCount()); 547 ASSERT_EQ(2U, s[0]->InputCount());
554 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 548 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
555 EXPECT_LE(1U, s[0]->OutputCount()); 549 EXPECT_LE(1U, s[0]->OutputCount());
556 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 550 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
557 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 551 EXPECT_EQ(kOverflow, s[0]->flags_condition());
558 } 552 }
559 } 553 }
560 554
561 555
562 TEST_P(ODPITest, OvfWithShiftByParameter) { 556 TEST_P(InstructionSelectorODPITest, OvfWithShiftByParameter) {
563 const ODPI odpi = GetParam(); 557 const ODPI odpi = GetParam();
564 TRACED_FOREACH(Shift, shift, kShifts) { 558 TRACED_FOREACH(Shift, shift, kShifts) {
565 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 559 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
566 m.Return(m.Projection( 560 m.Return(m.Projection(
567 1, (m.*odpi.constructor)( 561 1, (m.*odpi.constructor)(
568 m.Parameter(0), 562 m.Parameter(0),
569 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))))); 563 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))));
570 Stream s = m.Build(); 564 Stream s = m.Build();
571 ASSERT_EQ(1U, s.size()); 565 ASSERT_EQ(1U, s.size());
572 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 566 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
(...skipping 14 matching lines...) Expand all
587 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); 581 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode());
588 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 582 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
589 EXPECT_EQ(3U, s[0]->InputCount()); 583 EXPECT_EQ(3U, s[0]->InputCount());
590 EXPECT_LE(1U, s[0]->OutputCount()); 584 EXPECT_LE(1U, s[0]->OutputCount());
591 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 585 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
592 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 586 EXPECT_EQ(kOverflow, s[0]->flags_condition());
593 } 587 }
594 } 588 }
595 589
596 590
597 TEST_P(ODPITest, OvfWithShiftByImmediate) { 591 TEST_P(InstructionSelectorODPITest, OvfWithShiftByImmediate) {
598 const ODPI odpi = GetParam(); 592 const ODPI odpi = GetParam();
599 TRACED_FOREACH(Shift, shift, kShifts) { 593 TRACED_FOREACH(Shift, shift, kShifts) {
600 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 594 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
601 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 595 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
602 m.Return(m.Projection( 596 m.Return(m.Projection(
603 1, (m.*odpi.constructor)(m.Parameter(0), 597 1, (m.*odpi.constructor)(m.Parameter(0),
604 (m.*shift.constructor)( 598 (m.*shift.constructor)(
605 m.Parameter(1), m.Int32Constant(imm))))); 599 m.Parameter(1), m.Int32Constant(imm)))));
606 Stream s = m.Build(); 600 Stream s = m.Build();
607 ASSERT_EQ(1U, s.size()); 601 ASSERT_EQ(1U, s.size());
(...skipping 20 matching lines...) Expand all
628 ASSERT_EQ(3U, s[0]->InputCount()); 622 ASSERT_EQ(3U, s[0]->InputCount());
629 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); 623 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
630 EXPECT_LE(1U, s[0]->OutputCount()); 624 EXPECT_LE(1U, s[0]->OutputCount());
631 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 625 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
632 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 626 EXPECT_EQ(kOverflow, s[0]->flags_condition());
633 } 627 }
634 } 628 }
635 } 629 }
636 630
637 631
638 TEST_P(ODPITest, ValWithParameters) { 632 TEST_P(InstructionSelectorODPITest, ValWithParameters) {
639 const ODPI odpi = GetParam(); 633 const ODPI odpi = GetParam();
640 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 634 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
641 m.Return( 635 m.Return(
642 m.Projection(0, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); 636 m.Projection(0, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1))));
643 Stream s = m.Build(); 637 Stream s = m.Build();
644 ASSERT_EQ(1U, s.size()); 638 ASSERT_EQ(1U, s.size());
645 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 639 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
646 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 640 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
647 EXPECT_EQ(2U, s[0]->InputCount()); 641 EXPECT_EQ(2U, s[0]->InputCount());
648 EXPECT_LE(1U, s[0]->OutputCount()); 642 EXPECT_LE(1U, s[0]->OutputCount());
649 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); 643 EXPECT_EQ(kFlags_none, s[0]->flags_mode());
650 } 644 }
651 645
652 646
653 TEST_P(ODPITest, ValWithImmediate) { 647 TEST_P(InstructionSelectorODPITest, ValWithImmediate) {
654 const ODPI odpi = GetParam(); 648 const ODPI odpi = GetParam();
655 TRACED_FOREACH(int32_t, imm, kImmediates) { 649 TRACED_FOREACH(int32_t, imm, kImmediates) {
656 StreamBuilder m(this, kMachInt32, kMachInt32); 650 StreamBuilder m(this, kMachInt32, kMachInt32);
657 m.Return(m.Projection( 651 m.Return(m.Projection(
658 0, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); 652 0, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm))));
659 Stream s = m.Build(); 653 Stream s = m.Build();
660 ASSERT_EQ(1U, s.size()); 654 ASSERT_EQ(1U, s.size());
661 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 655 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
662 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 656 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
663 ASSERT_EQ(2U, s[0]->InputCount()); 657 ASSERT_EQ(2U, s[0]->InputCount());
(...skipping 10 matching lines...) Expand all
674 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); 668 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode());
675 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 669 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
676 ASSERT_EQ(2U, s[0]->InputCount()); 670 ASSERT_EQ(2U, s[0]->InputCount());
677 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 671 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
678 EXPECT_LE(1U, s[0]->OutputCount()); 672 EXPECT_LE(1U, s[0]->OutputCount());
679 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); 673 EXPECT_EQ(kFlags_none, s[0]->flags_mode());
680 } 674 }
681 } 675 }
682 676
683 677
684 TEST_P(ODPITest, ValWithShiftByParameter) { 678 TEST_P(InstructionSelectorODPITest, ValWithShiftByParameter) {
685 const ODPI odpi = GetParam(); 679 const ODPI odpi = GetParam();
686 TRACED_FOREACH(Shift, shift, kShifts) { 680 TRACED_FOREACH(Shift, shift, kShifts) {
687 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 681 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
688 m.Return(m.Projection( 682 m.Return(m.Projection(
689 0, (m.*odpi.constructor)( 683 0, (m.*odpi.constructor)(
690 m.Parameter(0), 684 m.Parameter(0),
691 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))))); 685 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))));
692 Stream s = m.Build(); 686 Stream s = m.Build();
693 ASSERT_EQ(1U, s.size()); 687 ASSERT_EQ(1U, s.size());
694 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 688 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
(...skipping 12 matching lines...) Expand all
707 ASSERT_EQ(1U, s.size()); 701 ASSERT_EQ(1U, s.size());
708 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); 702 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode());
709 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 703 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
710 EXPECT_EQ(3U, s[0]->InputCount()); 704 EXPECT_EQ(3U, s[0]->InputCount());
711 EXPECT_LE(1U, s[0]->OutputCount()); 705 EXPECT_LE(1U, s[0]->OutputCount());
712 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); 706 EXPECT_EQ(kFlags_none, s[0]->flags_mode());
713 } 707 }
714 } 708 }
715 709
716 710
717 TEST_P(ODPITest, ValWithShiftByImmediate) { 711 TEST_P(InstructionSelectorODPITest, ValWithShiftByImmediate) {
718 const ODPI odpi = GetParam(); 712 const ODPI odpi = GetParam();
719 TRACED_FOREACH(Shift, shift, kShifts) { 713 TRACED_FOREACH(Shift, shift, kShifts) {
720 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 714 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
721 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 715 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
722 m.Return(m.Projection( 716 m.Return(m.Projection(
723 0, (m.*odpi.constructor)(m.Parameter(0), 717 0, (m.*odpi.constructor)(m.Parameter(0),
724 (m.*shift.constructor)( 718 (m.*shift.constructor)(
725 m.Parameter(1), m.Int32Constant(imm))))); 719 m.Parameter(1), m.Int32Constant(imm)))));
726 Stream s = m.Build(); 720 Stream s = m.Build();
727 ASSERT_EQ(1U, s.size()); 721 ASSERT_EQ(1U, s.size());
(...skipping 18 matching lines...) Expand all
746 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 740 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
747 ASSERT_EQ(3U, s[0]->InputCount()); 741 ASSERT_EQ(3U, s[0]->InputCount());
748 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); 742 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
749 EXPECT_LE(1U, s[0]->OutputCount()); 743 EXPECT_LE(1U, s[0]->OutputCount());
750 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); 744 EXPECT_EQ(kFlags_none, s[0]->flags_mode());
751 } 745 }
752 } 746 }
753 } 747 }
754 748
755 749
756 TEST_P(ODPITest, BothWithParameters) { 750 TEST_P(InstructionSelectorODPITest, BothWithParameters) {
757 const ODPI odpi = GetParam(); 751 const ODPI odpi = GetParam();
758 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 752 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
759 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); 753 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1));
760 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); 754 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n)));
761 Stream s = m.Build(); 755 Stream s = m.Build();
762 ASSERT_LE(1U, s.size()); 756 ASSERT_LE(1U, s.size());
763 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 757 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
764 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 758 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
765 EXPECT_EQ(2U, s[0]->InputCount()); 759 EXPECT_EQ(2U, s[0]->InputCount());
766 EXPECT_EQ(2U, s[0]->OutputCount()); 760 EXPECT_EQ(2U, s[0]->OutputCount());
767 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 761 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
768 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 762 EXPECT_EQ(kOverflow, s[0]->flags_condition());
769 } 763 }
770 764
771 765
772 TEST_P(ODPITest, BothWithImmediate) { 766 TEST_P(InstructionSelectorODPITest, BothWithImmediate) {
773 const ODPI odpi = GetParam(); 767 const ODPI odpi = GetParam();
774 TRACED_FOREACH(int32_t, imm, kImmediates) { 768 TRACED_FOREACH(int32_t, imm, kImmediates) {
775 StreamBuilder m(this, kMachInt32, kMachInt32); 769 StreamBuilder m(this, kMachInt32, kMachInt32);
776 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); 770 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm));
777 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); 771 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n)));
778 Stream s = m.Build(); 772 Stream s = m.Build();
779 ASSERT_LE(1U, s.size()); 773 ASSERT_LE(1U, s.size());
780 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 774 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
781 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 775 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
782 ASSERT_EQ(2U, s[0]->InputCount()); 776 ASSERT_EQ(2U, s[0]->InputCount());
(...skipping 12 matching lines...) Expand all
795 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 789 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
796 ASSERT_EQ(2U, s[0]->InputCount()); 790 ASSERT_EQ(2U, s[0]->InputCount());
797 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 791 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
798 EXPECT_EQ(2U, s[0]->OutputCount()); 792 EXPECT_EQ(2U, s[0]->OutputCount());
799 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 793 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
800 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 794 EXPECT_EQ(kOverflow, s[0]->flags_condition());
801 } 795 }
802 } 796 }
803 797
804 798
805 TEST_P(ODPITest, BothWithShiftByParameter) { 799 TEST_P(InstructionSelectorODPITest, BothWithShiftByParameter) {
806 const ODPI odpi = GetParam(); 800 const ODPI odpi = GetParam();
807 TRACED_FOREACH(Shift, shift, kShifts) { 801 TRACED_FOREACH(Shift, shift, kShifts) {
808 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 802 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
809 Node* n = (m.*odpi.constructor)( 803 Node* n = (m.*odpi.constructor)(
810 m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))); 804 m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)));
811 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); 805 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n)));
812 Stream s = m.Build(); 806 Stream s = m.Build();
813 ASSERT_LE(1U, s.size()); 807 ASSERT_LE(1U, s.size());
814 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 808 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
815 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 809 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
(...skipping 12 matching lines...) Expand all
828 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); 822 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode());
829 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 823 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
830 EXPECT_EQ(3U, s[0]->InputCount()); 824 EXPECT_EQ(3U, s[0]->InputCount());
831 EXPECT_EQ(2U, s[0]->OutputCount()); 825 EXPECT_EQ(2U, s[0]->OutputCount());
832 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 826 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
833 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 827 EXPECT_EQ(kOverflow, s[0]->flags_condition());
834 } 828 }
835 } 829 }
836 830
837 831
838 TEST_P(ODPITest, BothWithShiftByImmediate) { 832 TEST_P(InstructionSelectorODPITest, BothWithShiftByImmediate) {
839 const ODPI odpi = GetParam(); 833 const ODPI odpi = GetParam();
840 TRACED_FOREACH(Shift, shift, kShifts) { 834 TRACED_FOREACH(Shift, shift, kShifts) {
841 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 835 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
842 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 836 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
843 Node* n = (m.*odpi.constructor)( 837 Node* n = (m.*odpi.constructor)(
844 m.Parameter(0), 838 m.Parameter(0),
845 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm))); 839 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)));
846 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); 840 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n)));
847 Stream s = m.Build(); 841 Stream s = m.Build();
848 ASSERT_LE(1U, s.size()); 842 ASSERT_LE(1U, s.size());
(...skipping 20 matching lines...) Expand all
869 ASSERT_EQ(3U, s[0]->InputCount()); 863 ASSERT_EQ(3U, s[0]->InputCount());
870 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); 864 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
871 EXPECT_EQ(2U, s[0]->OutputCount()); 865 EXPECT_EQ(2U, s[0]->OutputCount());
872 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 866 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
873 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 867 EXPECT_EQ(kOverflow, s[0]->flags_condition());
874 } 868 }
875 } 869 }
876 } 870 }
877 871
878 872
879 TEST_P(ODPITest, BranchWithParameters) { 873 TEST_P(InstructionSelectorODPITest, BranchWithParameters) {
880 const ODPI odpi = GetParam(); 874 const ODPI odpi = GetParam();
881 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 875 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
882 MLabel a, b; 876 MLabel a, b;
883 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); 877 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1));
884 m.Branch(m.Projection(1, n), &a, &b); 878 m.Branch(m.Projection(1, n), &a, &b);
885 m.Bind(&a); 879 m.Bind(&a);
886 m.Return(m.Int32Constant(0)); 880 m.Return(m.Int32Constant(0));
887 m.Bind(&b); 881 m.Bind(&b);
888 m.Return(m.Projection(0, n)); 882 m.Return(m.Projection(0, n));
889 Stream s = m.Build(); 883 Stream s = m.Build();
890 ASSERT_EQ(1U, s.size()); 884 ASSERT_EQ(1U, s.size());
891 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 885 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
892 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 886 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
893 EXPECT_EQ(4U, s[0]->InputCount()); 887 EXPECT_EQ(4U, s[0]->InputCount());
894 EXPECT_EQ(1U, s[0]->OutputCount()); 888 EXPECT_EQ(1U, s[0]->OutputCount());
895 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 889 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
896 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 890 EXPECT_EQ(kOverflow, s[0]->flags_condition());
897 } 891 }
898 892
899 893
900 TEST_P(ODPITest, BranchWithImmediate) { 894 TEST_P(InstructionSelectorODPITest, BranchWithImmediate) {
901 const ODPI odpi = GetParam(); 895 const ODPI odpi = GetParam();
902 TRACED_FOREACH(int32_t, imm, kImmediates) { 896 TRACED_FOREACH(int32_t, imm, kImmediates) {
903 StreamBuilder m(this, kMachInt32, kMachInt32); 897 StreamBuilder m(this, kMachInt32, kMachInt32);
904 MLabel a, b; 898 MLabel a, b;
905 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); 899 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm));
906 m.Branch(m.Projection(1, n), &a, &b); 900 m.Branch(m.Projection(1, n), &a, &b);
907 m.Bind(&a); 901 m.Bind(&a);
908 m.Return(m.Int32Constant(0)); 902 m.Return(m.Int32Constant(0));
909 m.Bind(&b); 903 m.Bind(&b);
910 m.Return(m.Projection(0, n)); 904 m.Return(m.Projection(0, n));
(...skipping 22 matching lines...) Expand all
933 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 927 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
934 ASSERT_EQ(4U, s[0]->InputCount()); 928 ASSERT_EQ(4U, s[0]->InputCount());
935 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 929 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
936 EXPECT_EQ(1U, s[0]->OutputCount()); 930 EXPECT_EQ(1U, s[0]->OutputCount());
937 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 931 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
938 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 932 EXPECT_EQ(kOverflow, s[0]->flags_condition());
939 } 933 }
940 } 934 }
941 935
942 936
943 TEST_P(ODPITest, BranchIfZeroWithParameters) { 937 TEST_P(InstructionSelectorODPITest, BranchIfZeroWithParameters) {
944 const ODPI odpi = GetParam(); 938 const ODPI odpi = GetParam();
945 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 939 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
946 MLabel a, b; 940 MLabel a, b;
947 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); 941 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1));
948 m.Branch(m.Word32Equal(m.Projection(1, n), m.Int32Constant(0)), &a, &b); 942 m.Branch(m.Word32Equal(m.Projection(1, n), m.Int32Constant(0)), &a, &b);
949 m.Bind(&a); 943 m.Bind(&a);
950 m.Return(m.Projection(0, n)); 944 m.Return(m.Projection(0, n));
951 m.Bind(&b); 945 m.Bind(&b);
952 m.Return(m.Int32Constant(0)); 946 m.Return(m.Int32Constant(0));
953 Stream s = m.Build(); 947 Stream s = m.Build();
954 ASSERT_EQ(1U, s.size()); 948 ASSERT_EQ(1U, s.size());
955 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 949 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
956 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 950 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
957 EXPECT_EQ(4U, s[0]->InputCount()); 951 EXPECT_EQ(4U, s[0]->InputCount());
958 EXPECT_EQ(1U, s[0]->OutputCount()); 952 EXPECT_EQ(1U, s[0]->OutputCount());
959 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 953 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
960 EXPECT_EQ(kNotOverflow, s[0]->flags_condition()); 954 EXPECT_EQ(kNotOverflow, s[0]->flags_condition());
961 } 955 }
962 956
963 957
964 TEST_P(ODPITest, BranchIfNotZeroWithParameters) { 958 TEST_P(InstructionSelectorODPITest, BranchIfNotZeroWithParameters) {
965 const ODPI odpi = GetParam(); 959 const ODPI odpi = GetParam();
966 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 960 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
967 MLabel a, b; 961 MLabel a, b;
968 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); 962 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1));
969 m.Branch(m.Word32NotEqual(m.Projection(1, n), m.Int32Constant(0)), &a, &b); 963 m.Branch(m.Word32NotEqual(m.Projection(1, n), m.Int32Constant(0)), &a, &b);
970 m.Bind(&a); 964 m.Bind(&a);
971 m.Return(m.Projection(0, n)); 965 m.Return(m.Projection(0, n));
972 m.Bind(&b); 966 m.Bind(&b);
973 m.Return(m.Int32Constant(0)); 967 m.Return(m.Int32Constant(0));
974 Stream s = m.Build(); 968 Stream s = m.Build();
975 ASSERT_EQ(1U, s.size()); 969 ASSERT_EQ(1U, s.size());
976 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 970 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
977 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 971 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
978 EXPECT_EQ(4U, s[0]->InputCount()); 972 EXPECT_EQ(4U, s[0]->InputCount());
979 EXPECT_EQ(1U, s[0]->OutputCount()); 973 EXPECT_EQ(1U, s[0]->OutputCount());
980 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 974 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
981 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 975 EXPECT_EQ(kOverflow, s[0]->flags_condition());
982 } 976 }
983 977
984 978
985 } // namespace 979 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorODPITest,
986
987 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, ODPITest,
988 ::testing::ValuesIn(kODPIs)); 980 ::testing::ValuesIn(kODPIs));
989 981
990 982
991 // ----------------------------------------------------------------------------- 983 // -----------------------------------------------------------------------------
992 // Shifts. 984 // Shifts.
993 985
994 986
995 namespace { 987 typedef InstructionSelectorTestWithParam<Shift> InstructionSelectorShiftTest;
996
997 class ShiftTest : public InstructionSelectorTestWithParam<Shift> {};
998 988
999 989
1000 TEST_P(ShiftTest, Parameters) { 990 TEST_P(InstructionSelectorShiftTest, Parameters) {
1001 const Shift shift = GetParam(); 991 const Shift shift = GetParam();
1002 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 992 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1003 m.Return((m.*shift.constructor)(m.Parameter(0), m.Parameter(1))); 993 m.Return((m.*shift.constructor)(m.Parameter(0), m.Parameter(1)));
1004 Stream s = m.Build(); 994 Stream s = m.Build();
1005 ASSERT_EQ(1U, s.size()); 995 ASSERT_EQ(1U, s.size());
1006 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); 996 EXPECT_EQ(kArmMov, s[0]->arch_opcode());
1007 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 997 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
1008 EXPECT_EQ(2U, s[0]->InputCount()); 998 EXPECT_EQ(2U, s[0]->InputCount());
1009 EXPECT_EQ(1U, s[0]->OutputCount()); 999 EXPECT_EQ(1U, s[0]->OutputCount());
1010 } 1000 }
1011 1001
1012 1002
1013 TEST_P(ShiftTest, Immediate) { 1003 TEST_P(InstructionSelectorShiftTest, Immediate) {
1014 const Shift shift = GetParam(); 1004 const Shift shift = GetParam();
1015 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 1005 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
1016 StreamBuilder m(this, kMachInt32, kMachInt32); 1006 StreamBuilder m(this, kMachInt32, kMachInt32);
1017 m.Return((m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm))); 1007 m.Return((m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)));
1018 Stream s = m.Build(); 1008 Stream s = m.Build();
1019 ASSERT_EQ(1U, s.size()); 1009 ASSERT_EQ(1U, s.size());
1020 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); 1010 EXPECT_EQ(kArmMov, s[0]->arch_opcode());
1021 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 1011 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
1022 ASSERT_EQ(2U, s[0]->InputCount()); 1012 ASSERT_EQ(2U, s[0]->InputCount());
1023 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 1013 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
1024 EXPECT_EQ(1U, s[0]->OutputCount()); 1014 EXPECT_EQ(1U, s[0]->OutputCount());
1025 } 1015 }
1026 } 1016 }
1027 1017
1028 1018
1029 TEST_P(ShiftTest, Word32EqualWithParameter) { 1019 TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameter) {
1030 const Shift shift = GetParam(); 1020 const Shift shift = GetParam();
1031 { 1021 {
1032 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 1022 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
1033 m.Return( 1023 m.Return(
1034 m.Word32Equal(m.Parameter(0), 1024 m.Word32Equal(m.Parameter(0),
1035 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); 1025 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))));
1036 Stream s = m.Build(); 1026 Stream s = m.Build();
1037 ASSERT_EQ(1U, s.size()); 1027 ASSERT_EQ(1U, s.size());
1038 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); 1028 EXPECT_EQ(kArmCmp, s[0]->arch_opcode());
1039 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 1029 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
(...skipping 12 matching lines...) Expand all
1052 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); 1042 EXPECT_EQ(kArmCmp, s[0]->arch_opcode());
1053 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 1043 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
1054 EXPECT_EQ(3U, s[0]->InputCount()); 1044 EXPECT_EQ(3U, s[0]->InputCount());
1055 EXPECT_EQ(1U, s[0]->OutputCount()); 1045 EXPECT_EQ(1U, s[0]->OutputCount());
1056 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 1046 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
1057 EXPECT_EQ(kEqual, s[0]->flags_condition()); 1047 EXPECT_EQ(kEqual, s[0]->flags_condition());
1058 } 1048 }
1059 } 1049 }
1060 1050
1061 1051
1062 TEST_P(ShiftTest, Word32EqualWithParameterAndImmediate) { 1052 TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameterAndImmediate) {
1063 const Shift shift = GetParam(); 1053 const Shift shift = GetParam();
1064 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 1054 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
1065 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 1055 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1066 m.Return(m.Word32Equal( 1056 m.Return(m.Word32Equal(
1067 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), 1057 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)),
1068 m.Parameter(0))); 1058 m.Parameter(0)));
1069 Stream s = m.Build(); 1059 Stream s = m.Build();
1070 ASSERT_EQ(1U, s.size()); 1060 ASSERT_EQ(1U, s.size());
1071 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); 1061 EXPECT_EQ(kArmCmp, s[0]->arch_opcode());
1072 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 1062 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
(...skipping 14 matching lines...) Expand all
1087 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 1077 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
1088 ASSERT_EQ(3U, s[0]->InputCount()); 1078 ASSERT_EQ(3U, s[0]->InputCount());
1089 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); 1079 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
1090 EXPECT_EQ(1U, s[0]->OutputCount()); 1080 EXPECT_EQ(1U, s[0]->OutputCount());
1091 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 1081 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
1092 EXPECT_EQ(kEqual, s[0]->flags_condition()); 1082 EXPECT_EQ(kEqual, s[0]->flags_condition());
1093 } 1083 }
1094 } 1084 }
1095 1085
1096 1086
1097 TEST_P(ShiftTest, Word32EqualToZeroWithParameters) { 1087 TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithParameters) {
1098 const Shift shift = GetParam(); 1088 const Shift shift = GetParam();
1099 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 1089 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1100 m.Return( 1090 m.Return(
1101 m.Word32Equal(m.Int32Constant(0), 1091 m.Word32Equal(m.Int32Constant(0),
1102 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)))); 1092 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1))));
1103 Stream s = m.Build(); 1093 Stream s = m.Build();
1104 ASSERT_EQ(1U, s.size()); 1094 ASSERT_EQ(1U, s.size());
1105 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); 1095 EXPECT_EQ(kArmMov, s[0]->arch_opcode());
1106 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 1096 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
1107 EXPECT_EQ(2U, s[0]->InputCount()); 1097 EXPECT_EQ(2U, s[0]->InputCount());
1108 EXPECT_EQ(2U, s[0]->OutputCount()); 1098 EXPECT_EQ(2U, s[0]->OutputCount());
1109 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 1099 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
1110 EXPECT_EQ(kEqual, s[0]->flags_condition()); 1100 EXPECT_EQ(kEqual, s[0]->flags_condition());
1111 } 1101 }
1112 1102
1113 1103
1114 TEST_P(ShiftTest, Word32EqualToZeroWithImmediate) { 1104 TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithImmediate) {
1115 const Shift shift = GetParam(); 1105 const Shift shift = GetParam();
1116 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 1106 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
1117 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 1107 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1118 m.Return(m.Word32Equal( 1108 m.Return(m.Word32Equal(
1119 m.Int32Constant(0), 1109 m.Int32Constant(0),
1120 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)))); 1110 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm))));
1121 Stream s = m.Build(); 1111 Stream s = m.Build();
1122 ASSERT_EQ(1U, s.size()); 1112 ASSERT_EQ(1U, s.size());
1123 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); 1113 EXPECT_EQ(kArmMov, s[0]->arch_opcode());
1124 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 1114 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
1125 ASSERT_EQ(2U, s[0]->InputCount()); 1115 ASSERT_EQ(2U, s[0]->InputCount());
1126 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 1116 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
1127 EXPECT_EQ(2U, s[0]->OutputCount()); 1117 EXPECT_EQ(2U, s[0]->OutputCount());
1128 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 1118 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
1129 EXPECT_EQ(kEqual, s[0]->flags_condition()); 1119 EXPECT_EQ(kEqual, s[0]->flags_condition());
1130 } 1120 }
1131 } 1121 }
1132 1122
1133 1123
1134 TEST_P(ShiftTest, Word32NotWithParameters) { 1124 TEST_P(InstructionSelectorShiftTest, Word32NotWithParameters) {
1135 const Shift shift = GetParam(); 1125 const Shift shift = GetParam();
1136 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 1126 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1137 m.Return(m.Word32Not((m.*shift.constructor)(m.Parameter(0), m.Parameter(1)))); 1127 m.Return(m.Word32Not((m.*shift.constructor)(m.Parameter(0), m.Parameter(1))));
1138 Stream s = m.Build(); 1128 Stream s = m.Build();
1139 ASSERT_EQ(1U, s.size()); 1129 ASSERT_EQ(1U, s.size());
1140 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); 1130 EXPECT_EQ(kArmMvn, s[0]->arch_opcode());
1141 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 1131 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
1142 EXPECT_EQ(2U, s[0]->InputCount()); 1132 EXPECT_EQ(2U, s[0]->InputCount());
1143 EXPECT_EQ(1U, s[0]->OutputCount()); 1133 EXPECT_EQ(1U, s[0]->OutputCount());
1144 } 1134 }
1145 1135
1146 1136
1147 TEST_P(ShiftTest, Word32NotWithImmediate) { 1137 TEST_P(InstructionSelectorShiftTest, Word32NotWithImmediate) {
1148 const Shift shift = GetParam(); 1138 const Shift shift = GetParam();
1149 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 1139 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
1150 StreamBuilder m(this, kMachInt32, kMachInt32); 1140 StreamBuilder m(this, kMachInt32, kMachInt32);
1151 m.Return(m.Word32Not( 1141 m.Return(m.Word32Not(
1152 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)))); 1142 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm))));
1153 Stream s = m.Build(); 1143 Stream s = m.Build();
1154 ASSERT_EQ(1U, s.size()); 1144 ASSERT_EQ(1U, s.size());
1155 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); 1145 EXPECT_EQ(kArmMvn, s[0]->arch_opcode());
1156 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 1146 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
1157 ASSERT_EQ(2U, s[0]->InputCount()); 1147 ASSERT_EQ(2U, s[0]->InputCount());
1158 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 1148 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
1159 EXPECT_EQ(1U, s[0]->OutputCount()); 1149 EXPECT_EQ(1U, s[0]->OutputCount());
1160 } 1150 }
1161 } 1151 }
1162 1152
1163 1153
1164 TEST_P(ShiftTest, Word32AndWithWord32NotWithParameters) { 1154 TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithParameters) {
1165 const Shift shift = GetParam(); 1155 const Shift shift = GetParam();
1166 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 1156 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
1167 m.Return(m.Word32And(m.Parameter(0), m.Word32Not((m.*shift.constructor)( 1157 m.Return(m.Word32And(m.Parameter(0), m.Word32Not((m.*shift.constructor)(
1168 m.Parameter(1), m.Parameter(2))))); 1158 m.Parameter(1), m.Parameter(2)))));
1169 Stream s = m.Build(); 1159 Stream s = m.Build();
1170 ASSERT_EQ(1U, s.size()); 1160 ASSERT_EQ(1U, s.size());
1171 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); 1161 EXPECT_EQ(kArmBic, s[0]->arch_opcode());
1172 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 1162 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
1173 EXPECT_EQ(3U, s[0]->InputCount()); 1163 EXPECT_EQ(3U, s[0]->InputCount());
1174 EXPECT_EQ(1U, s[0]->OutputCount()); 1164 EXPECT_EQ(1U, s[0]->OutputCount());
1175 } 1165 }
1176 1166
1177 1167
1178 TEST_P(ShiftTest, Word32AndWithWord32NotWithImmediate) { 1168 TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithImmediate) {
1179 const Shift shift = GetParam(); 1169 const Shift shift = GetParam();
1180 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 1170 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
1181 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 1171 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1182 m.Return(m.Word32And(m.Parameter(0), 1172 m.Return(m.Word32And(m.Parameter(0),
1183 m.Word32Not((m.*shift.constructor)( 1173 m.Word32Not((m.*shift.constructor)(
1184 m.Parameter(1), m.Int32Constant(imm))))); 1174 m.Parameter(1), m.Int32Constant(imm)))));
1185 Stream s = m.Build(); 1175 Stream s = m.Build();
1186 ASSERT_EQ(1U, s.size()); 1176 ASSERT_EQ(1U, s.size());
1187 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); 1177 EXPECT_EQ(kArmBic, s[0]->arch_opcode());
1188 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 1178 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
1189 ASSERT_EQ(3U, s[0]->InputCount()); 1179 ASSERT_EQ(3U, s[0]->InputCount());
1190 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); 1180 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
1191 EXPECT_EQ(1U, s[0]->OutputCount()); 1181 EXPECT_EQ(1U, s[0]->OutputCount());
1192 } 1182 }
1193 } 1183 }
1194 1184
1195 1185
1196 } // namespace 1186 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorShiftTest,
1197
1198
1199 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, ShiftTest,
1200 ::testing::ValuesIn(kShifts)); 1187 ::testing::ValuesIn(kShifts));
1201 1188
1202 1189
1203 // ----------------------------------------------------------------------------- 1190 // -----------------------------------------------------------------------------
1204 // Miscellaneous. 1191 // Miscellaneous.
1205 1192
1206 1193
1207 TEST_F(InstructionSelectorTest, Int32AddWithInt32Mul) { 1194 TEST_F(InstructionSelectorTest, Int32AddWithInt32Mul) {
1208 { 1195 {
1209 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 1196 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 ASSERT_EQ(3U, s[0]->InputCount()); 1741 ASSERT_EQ(3U, s[0]->InputCount());
1755 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); 1742 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1)));
1756 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); 1743 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2)));
1757 } 1744 }
1758 } 1745 }
1759 } 1746 }
1760 1747
1761 } // namespace compiler 1748 } // namespace compiler
1762 } // namespace internal 1749 } // namespace internal
1763 } // namespace v8 1750 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/compiler-unittests/change-lowering-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698