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

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

Issue 469743002: [turbofan] Refactor the InstructionSelector tests. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ARM64 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
(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 <list>
6
7 #include "test/cctest/compiler/instruction-selector-tester.h"
8
9 using namespace v8::internal;
10 using namespace v8::internal::compiler;
11
12 namespace {
13
14 struct DPI {
15 Operator* op;
16 ArchOpcode arch_opcode;
17 };
18
19
20 // ARM64 Logical instructions.
21 class LogicalInstructions V8_FINAL : public std::list<DPI>,
22 private HandleAndZoneScope {
23 public:
24 LogicalInstructions() {
25 MachineOperatorBuilder machine(main_zone());
26 DPI and32 = {machine.Word32And(), kArm64And32};
27 push_back(and32);
28 DPI and64 = {machine.Word64And(), kArm64And};
29 push_back(and64);
30 DPI or32 = {machine.Word32Or(), kArm64Or32};
31 push_back(or32);
32 DPI or64 = {machine.Word64Or(), kArm64Or};
33 push_back(or64);
34 DPI xor32 = {machine.Word32Xor(), kArm64Xor32};
35 push_back(xor32);
36 DPI xor64 = {machine.Word64Xor(), kArm64Xor};
37 push_back(xor64);
38 }
39 };
40
41
42 // ARM64 Arithmetic instructions.
43 class AddSubInstructions V8_FINAL : public std::list<DPI>,
44 private HandleAndZoneScope {
45 public:
46 AddSubInstructions() {
47 MachineOperatorBuilder machine(main_zone());
48 DPI add32 = {machine.Int32Add(), kArm64Add32};
49 push_back(add32);
50 DPI add64 = {machine.Int64Add(), kArm64Add};
51 push_back(add64);
52 DPI sub32 = {machine.Int32Sub(), kArm64Sub32};
53 push_back(sub32);
54 DPI sub64 = {machine.Int64Sub(), kArm64Sub};
55 push_back(sub64);
56 }
57 };
58
59
60 // ARM64 Add/Sub immediates.
61 class AddSubImmediates V8_FINAL : public std::list<int32_t> {
62 public:
63 AddSubImmediates() {
64 for (int32_t imm12 = 0; imm12 < 4096; ++imm12) {
65 CHECK(Assembler::IsImmAddSub(imm12));
66 CHECK(Assembler::IsImmAddSub(imm12 << 12));
67 push_back(imm12);
68 push_back(imm12 << 12);
69 }
70 }
71 };
72
73
74 // ARM64 Arithmetic instructions.
75 class MulDivInstructions V8_FINAL : public std::list<DPI>,
76 private HandleAndZoneScope {
77 public:
78 MulDivInstructions() {
79 MachineOperatorBuilder machine(main_zone());
80 DPI mul32 = {machine.Int32Mul(), kArm64Mul32};
81 push_back(mul32);
82 DPI mul64 = {machine.Int64Mul(), kArm64Mul};
83 push_back(mul64);
84 DPI sdiv32 = {machine.Int32Div(), kArm64Idiv32};
85 push_back(sdiv32);
86 DPI sdiv64 = {machine.Int64Div(), kArm64Idiv};
87 push_back(sdiv64);
88 DPI udiv32 = {machine.Int32UDiv(), kArm64Udiv32};
89 push_back(udiv32);
90 DPI udiv64 = {machine.Int64UDiv(), kArm64Udiv};
91 push_back(udiv64);
92 }
93 };
94
95 } // namespace
96
97
98 TEST(InstructionSelectorLogicalP) {
99 LogicalInstructions instructions;
100 for (LogicalInstructions::const_iterator i = instructions.begin();
101 i != instructions.end(); ++i) {
102 DPI dpi = *i;
103 InstructionSelectorTester m;
104 m.Return(m.NewNode(dpi.op, m.Parameter(0), m.Parameter(1)));
105 m.SelectInstructions();
106 CHECK_EQ(1, m.code.size());
107 CHECK_EQ(dpi.arch_opcode, m.code[0]->arch_opcode());
108 }
109 }
110
111
112 TEST(InstructionSelectorAddSubP) {
113 AddSubInstructions instructions;
114 for (AddSubInstructions::const_iterator i = instructions.begin();
115 i != instructions.end(); ++i) {
116 DPI dpi = *i;
117 InstructionSelectorTester m;
118 m.Return(m.NewNode(dpi.op, m.Parameter(0), m.Parameter(1)));
119 m.SelectInstructions();
120 CHECK_EQ(1, m.code.size());
121 CHECK_EQ(dpi.arch_opcode, m.code[0]->arch_opcode());
122 }
123 }
124
125
126 TEST(InstructionSelectorAddSubImm) {
127 AddSubInstructions instructions;
128 AddSubImmediates immediates;
129 for (AddSubInstructions::const_iterator i = instructions.begin();
130 i != instructions.end(); ++i) {
131 DPI dpi = *i;
132 for (AddSubImmediates::const_iterator j = immediates.begin();
133 j != immediates.end(); ++j) {
134 int32_t imm = *j;
135 InstructionSelectorTester m;
136 m.Return(m.NewNode(dpi.op, m.Parameter(0), m.Int32Constant(imm)));
137 m.SelectInstructions();
138 CHECK_EQ(1, m.code.size());
139 CHECK_EQ(dpi.arch_opcode, m.code[0]->arch_opcode());
140 CHECK(m.code[0]->InputAt(1)->IsImmediate());
141 }
142 }
143 }
144
145
146 TEST(InstructionSelectorMulDivP) {
147 MulDivInstructions instructions;
148 for (MulDivInstructions::const_iterator i = instructions.begin();
149 i != instructions.end(); ++i) {
150 DPI dpi = *i;
151 InstructionSelectorTester m;
152 m.Return(m.NewNode(dpi.op, m.Parameter(0), m.Parameter(1)));
153 m.SelectInstructions();
154 CHECK_EQ(1, m.code.size());
155 CHECK_EQ(dpi.arch_opcode, m.code[0]->arch_opcode());
156 }
157 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-instruction-selector-arm.cc ('k') | test/cctest/compiler/test-instruction-selector-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698