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

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

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

Powered by Google App Engine
This is Rietveld 408576698