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

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

Issue 436593002: [turbofan] Add Int32AddWithOverflow machine operator. (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
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 <list> 5 #include <list>
6 6
7 #include "test/cctest/compiler/instruction-selector-tester.h" 7 #include "test/cctest/compiler/instruction-selector-tester.h"
8 #include "test/cctest/compiler/value-helper.h" 8 #include "test/cctest/compiler/value-helper.h"
9 9
10 using namespace v8::internal; 10 using namespace v8::internal;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 CHECK_EQ(1, m.code.size()); 218 CHECK_EQ(1, m.code.size());
219 CHECK_EQ(dpi.reverse_arch_opcode, m.code[0]->arch_opcode()); 219 CHECK_EQ(dpi.reverse_arch_opcode, m.code[0]->arch_opcode());
220 CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); 220 CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode());
221 } 221 }
222 } 222 }
223 } 223 }
224 } 224 }
225 } 225 }
226 226
227 227
228 TEST(InstructionSelectorInt32AddWithOverflowP) {
229 {
230 InstructionSelectorTester m;
231 m.Return(m.Projection(
232 1, m.Int32AddWithOverflow(m.Parameter(0), m.Parameter(1))));
233 m.SelectInstructions();
234 CHECK_EQ(1, m.code.size());
235 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
236 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode());
237 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
238 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
239 CHECK_EQ(2, m.code[0]->InputCount());
240 CHECK_EQ(1, m.code[0]->OutputCount());
241 }
242 {
243 InstructionSelectorTester m;
244 m.Return(m.Projection(
245 0, m.Int32AddWithOverflow(m.Parameter(0), m.Parameter(1))));
246 m.SelectInstructions();
247 CHECK_EQ(1, m.code.size());
248 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
249 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode());
250 CHECK_EQ(kFlags_none, m.code[0]->flags_mode());
251 CHECK_EQ(2, m.code[0]->InputCount());
252 CHECK_EQ(1, m.code[0]->OutputCount());
253 }
254 {
255 InstructionSelectorTester m;
256 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Parameter(1));
257 m.Return(m.Word32Equal(m.Projection(0, add), m.Projection(1, add)));
258 m.SelectInstructions();
259 CHECK_LE(1, m.code.size());
260 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
261 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode());
262 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
263 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
264 CHECK_EQ(2, m.code[0]->InputCount());
265 CHECK_EQ(2, m.code[0]->OutputCount());
266 }
267 }
268
269
270 TEST(InstructionSelectorInt32AddWithOverflowImm) {
271 Immediates immediates;
272 for (Immediates::const_iterator i = immediates.begin(); i != immediates.end();
273 ++i) {
274 int32_t imm = *i;
275 {
276 InstructionSelectorTester m;
277 m.Return(m.Projection(
278 1, m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(imm))));
279 m.SelectInstructions();
280 CHECK_EQ(1, m.code.size());
281 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
282 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
283 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
284 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
285 CHECK_EQ(2, m.code[0]->InputCount());
286 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
287 CHECK_EQ(1, m.code[0]->OutputCount());
288 }
289 {
290 InstructionSelectorTester m;
291 m.Return(m.Projection(
292 1, m.Int32AddWithOverflow(m.Int32Constant(imm), m.Parameter(0))));
293 m.SelectInstructions();
294 CHECK_EQ(1, m.code.size());
295 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
296 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
297 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
298 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
299 CHECK_EQ(2, m.code[0]->InputCount());
300 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
301 CHECK_EQ(1, m.code[0]->OutputCount());
302 }
303 {
304 InstructionSelectorTester m;
305 m.Return(m.Projection(
306 0, m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(imm))));
307 m.SelectInstructions();
308 CHECK_EQ(1, m.code.size());
309 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
310 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
311 CHECK_EQ(kFlags_none, m.code[0]->flags_mode());
312 CHECK_EQ(2, m.code[0]->InputCount());
313 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
314 CHECK_EQ(1, m.code[0]->OutputCount());
315 }
316 {
317 InstructionSelectorTester m;
318 m.Return(m.Projection(
319 0, m.Int32AddWithOverflow(m.Int32Constant(imm), m.Parameter(0))));
320 m.SelectInstructions();
321 CHECK_EQ(1, m.code.size());
322 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
323 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
324 CHECK_EQ(kFlags_none, m.code[0]->flags_mode());
325 CHECK_EQ(2, m.code[0]->InputCount());
326 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
327 CHECK_EQ(1, m.code[0]->OutputCount());
328 }
329 {
330 InstructionSelectorTester m;
331 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(imm));
332 m.Return(m.Word32Equal(m.Projection(0, add), m.Projection(1, add)));
333 m.SelectInstructions();
334 CHECK_LE(1, m.code.size());
335 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
336 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
337 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
338 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
339 CHECK_EQ(2, m.code[0]->InputCount());
340 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
341 CHECK_EQ(2, m.code[0]->OutputCount());
342 }
343 {
344 InstructionSelectorTester m;
345 Node* add = m.Int32AddWithOverflow(m.Int32Constant(imm), m.Parameter(0));
346 m.Return(m.Word32Equal(m.Projection(0, add), m.Projection(1, add)));
347 m.SelectInstructions();
348 CHECK_LE(1, m.code.size());
349 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
350 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
351 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
352 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
353 CHECK_EQ(2, m.code[0]->InputCount());
354 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
355 CHECK_EQ(2, m.code[0]->OutputCount());
356 }
357 }
358 }
359
360
228 TEST(InstructionSelectorWord32AndAndWord32XorWithMinus1P) { 361 TEST(InstructionSelectorWord32AndAndWord32XorWithMinus1P) {
229 { 362 {
230 InstructionSelectorTester m; 363 InstructionSelectorTester m;
231 m.Return(m.Word32And(m.Parameter(0), 364 m.Return(m.Word32And(m.Parameter(0),
232 m.Word32Xor(m.Int32Constant(-1), m.Parameter(1)))); 365 m.Word32Xor(m.Int32Constant(-1), m.Parameter(1))));
233 m.SelectInstructions(); 366 m.SelectInstructions();
234 CHECK_EQ(1, m.code.size()); 367 CHECK_EQ(1, m.code.size());
235 CHECK_EQ(kArmBic, m.code[0]->arch_opcode()); 368 CHECK_EQ(kArmBic, m.code[0]->arch_opcode());
236 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); 369 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode());
237 } 370 }
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 m.Return(m.Int32Constant(0)); 1435 m.Return(m.Int32Constant(0));
1303 m.SelectInstructions(); 1436 m.SelectInstructions();
1304 CHECK_EQ(1, m.code.size()); 1437 CHECK_EQ(1, m.code.size());
1305 CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); 1438 CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode());
1306 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); 1439 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode());
1307 CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); 1440 CHECK_EQ(kFlags_branch, m.code[0]->flags_mode());
1308 CHECK_EQ(kEqual, m.code[0]->flags_condition()); 1441 CHECK_EQ(kEqual, m.code[0]->flags_condition());
1309 } 1442 }
1310 } 1443 }
1311 } 1444 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698