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

Side by Side Diff: src/compiler/x64/instruction-selector-x64-unittest.cc

Issue 605693002: [turbofan] add new x64 addressing modes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: gcc fix Created 6 years, 2 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 | « src/compiler/x64/instruction-selector-x64.cc ('k') | 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 "src/compiler/instruction-selector-unittest.h" 5 #include "src/compiler/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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); 154 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode());
155 EXPECT_EQ(3U, s[0]->InputCount()); 155 EXPECT_EQ(3U, s[0]->InputCount());
156 EXPECT_EQ(0U, s[0]->OutputCount()); 156 EXPECT_EQ(0U, s[0]->OutputCount());
157 } 157 }
158 158
159 159
160 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, 160 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
161 InstructionSelectorMemoryAccessTest, 161 InstructionSelectorMemoryAccessTest,
162 ::testing::ValuesIn(kMemoryAccesses)); 162 ::testing::ValuesIn(kMemoryAccesses));
163 163
164 // -----------------------------------------------------------------------------
165 // AddressingMode for loads and stores.
166
167 class AddressingModeUnitTest : public InstructionSelectorTest {
168 public:
169 AddressingModeUnitTest() : m(NULL) { Reset(); }
170 ~AddressingModeUnitTest() { delete m; }
171
172 void Run(Node* base, Node* index, AddressingMode mode) {
173 Node* load = m->Load(kMachInt32, base, index);
174 m->Store(kMachInt32, base, index, load);
175 m->Return(m->Int32Constant(0));
176 Stream s = m->Build();
177 ASSERT_EQ(2U, s.size());
178 EXPECT_EQ(mode, s[0]->addressing_mode());
179 EXPECT_EQ(mode, s[1]->addressing_mode());
180 }
181
182 Node* zero;
183 Node* null_ptr;
184 Node* non_zero;
185 Node* base_reg; // opaque value to generate base as register
186 Node* index_reg; // opaque value to generate index as register
187 Node* scales[4];
188 StreamBuilder* m;
189
190 void Reset() {
191 delete m;
192 m = new StreamBuilder(this, kMachInt32, kMachInt32, kMachInt32);
193 zero = m->Int32Constant(0);
194 null_ptr = m->Int64Constant(0);
195 non_zero = m->Int32Constant(127);
196 base_reg = m->Parameter(0);
197 index_reg = m->Parameter(0);
198
199 scales[0] = m->Int32Constant(1);
200 scales[1] = m->Int32Constant(2);
201 scales[2] = m->Int32Constant(4);
202 scales[3] = m->Int32Constant(8);
203 }
204 };
205
206
207 TEST_F(AddressingModeUnitTest, AddressingMode_MR) {
208 Node* base = base_reg;
209 Node* index = zero;
210 Run(base, index, kMode_MR);
211 }
212
213
214 TEST_F(AddressingModeUnitTest, AddressingMode_MRI) {
215 Node* base = base_reg;
216 Node* index = non_zero;
217 Run(base, index, kMode_MRI);
218 }
219
220
221 TEST_F(AddressingModeUnitTest, AddressingMode_MR1) {
222 Node* base = base_reg;
223 Node* index = index_reg;
224 Run(base, index, kMode_MR1);
225 }
226
227
228 TEST_F(AddressingModeUnitTest, AddressingMode_MRN) {
229 AddressingMode expected[] = {kMode_MR1, kMode_MR2, kMode_MR4, kMode_MR8};
230 for (size_t i = 0; i < arraysize(scales); ++i) {
231 Reset();
232 Node* base = base_reg;
233 Node* index = m->Int32Mul(index_reg, scales[i]);
234 Run(base, index, expected[i]);
235 }
236 }
237
238
239 TEST_F(AddressingModeUnitTest, AddressingMode_MR1I) {
240 Node* base = base_reg;
241 Node* index = m->Int32Add(index_reg, non_zero);
242 Run(base, index, kMode_MR1I);
243 }
244
245
246 TEST_F(AddressingModeUnitTest, AddressingMode_MRNI) {
247 AddressingMode expected[] = {kMode_MR1I, kMode_MR2I, kMode_MR4I, kMode_MR8I};
248 for (size_t i = 0; i < arraysize(scales); ++i) {
249 Reset();
250 Node* base = base_reg;
251 Node* index = m->Int32Add(m->Int32Mul(index_reg, scales[i]), non_zero);
252 Run(base, index, expected[i]);
253 }
254 }
255
256
257 TEST_F(AddressingModeUnitTest, AddressingMode_M1) {
258 Node* base = null_ptr;
259 Node* index = index_reg;
260 Run(base, index, kMode_M1);
261 }
262
263
264 TEST_F(AddressingModeUnitTest, AddressingMode_MN) {
265 AddressingMode expected[] = {kMode_M1, kMode_M2, kMode_M4, kMode_M8};
266 for (size_t i = 0; i < arraysize(scales); ++i) {
267 Reset();
268 Node* base = null_ptr;
269 Node* index = m->Int32Mul(index_reg, scales[i]);
270 Run(base, index, expected[i]);
271 }
272 }
273
274
275 TEST_F(AddressingModeUnitTest, AddressingMode_M1I) {
276 Node* base = null_ptr;
277 Node* index = m->Int32Add(index_reg, non_zero);
278 Run(base, index, kMode_M1I);
279 }
280
281
282 TEST_F(AddressingModeUnitTest, AddressingMode_MNI) {
283 AddressingMode expected[] = {kMode_M1I, kMode_M2I, kMode_M4I, kMode_M8I};
284 for (size_t i = 0; i < arraysize(scales); ++i) {
285 Reset();
286 Node* base = null_ptr;
287 Node* index = m->Int32Add(m->Int32Mul(index_reg, scales[i]), non_zero);
288 Run(base, index, expected[i]);
289 }
290 }
291
164 } // namespace compiler 292 } // namespace compiler
165 } // namespace internal 293 } // namespace internal
166 } // namespace v8 294 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698