| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "test/cctest/compiler/instruction-selector-tester.h" | |
| 6 #include "test/cctest/compiler/value-helper.h" | |
| 7 | |
| 8 using namespace v8::internal; | |
| 9 using namespace v8::internal::compiler; | |
| 10 | |
| 11 TEST(InstructionSelectorInt32AddP) { | |
| 12 InstructionSelectorTester m; | |
| 13 m.Return(m.Int32Add(m.Parameter(0), m.Parameter(1))); | |
| 14 m.SelectInstructions(); | |
| 15 CHECK_EQ(1, m.code.size()); | |
| 16 CHECK_EQ(kIA32Add, m.code[0]->arch_opcode()); | |
| 17 } | |
| 18 | |
| 19 | |
| 20 TEST(InstructionSelectorInt32AddImm) { | |
| 21 FOR_INT32_INPUTS(i) { | |
| 22 int32_t imm = *i; | |
| 23 { | |
| 24 InstructionSelectorTester m; | |
| 25 m.Return(m.Int32Add(m.Parameter(0), m.Int32Constant(imm))); | |
| 26 m.SelectInstructions(); | |
| 27 CHECK_EQ(1, m.code.size()); | |
| 28 CHECK_EQ(kIA32Add, m.code[0]->arch_opcode()); | |
| 29 CHECK_EQ(2, m.code[0]->InputCount()); | |
| 30 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); | |
| 31 } | |
| 32 { | |
| 33 InstructionSelectorTester m; | |
| 34 m.Return(m.Int32Add(m.Int32Constant(imm), m.Parameter(0))); | |
| 35 m.SelectInstructions(); | |
| 36 CHECK_EQ(1, m.code.size()); | |
| 37 CHECK_EQ(kIA32Add, m.code[0]->arch_opcode()); | |
| 38 CHECK_EQ(2, m.code[0]->InputCount()); | |
| 39 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); | |
| 40 } | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 | |
| 45 TEST(InstructionSelectorInt32SubP) { | |
| 46 InstructionSelectorTester m; | |
| 47 m.Return(m.Int32Sub(m.Parameter(0), m.Parameter(1))); | |
| 48 m.SelectInstructions(); | |
| 49 CHECK_EQ(1, m.code.size()); | |
| 50 CHECK_EQ(kIA32Sub, m.code[0]->arch_opcode()); | |
| 51 CHECK_EQ(1, m.code[0]->OutputCount()); | |
| 52 } | |
| 53 | |
| 54 | |
| 55 TEST(InstructionSelectorInt32SubImm) { | |
| 56 FOR_INT32_INPUTS(i) { | |
| 57 int32_t imm = *i; | |
| 58 InstructionSelectorTester m; | |
| 59 m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(imm))); | |
| 60 m.SelectInstructions(); | |
| 61 CHECK_EQ(1, m.code.size()); | |
| 62 CHECK_EQ(kIA32Sub, m.code[0]->arch_opcode()); | |
| 63 CHECK_EQ(2, m.code[0]->InputCount()); | |
| 64 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); | |
| 65 } | |
| 66 } | |
| OLD | NEW |