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

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

Issue 552653003: [turbofan] Fix the node matchers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address nit. Created 6 years, 3 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/typer.cc ('k') | src/unique.h » ('j') | 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-impl.h" 5 #include "src/compiler/instruction-selector-impl.h"
6 #include "src/compiler/node-matchers.h" 6 #include "src/compiler/node-matchers.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 namespace compiler { 10 namespace compiler {
(...skipping 27 matching lines...) Expand all
38 38
39 bool CanBeImmediate64(Node* node) { 39 bool CanBeImmediate64(Node* node) {
40 switch (node->opcode()) { 40 switch (node->opcode()) {
41 case IrOpcode::kInt32Constant: 41 case IrOpcode::kInt32Constant:
42 return true; 42 return true;
43 case IrOpcode::kNumberConstant: 43 case IrOpcode::kNumberConstant:
44 return true; 44 return true;
45 case IrOpcode::kHeapConstant: { 45 case IrOpcode::kHeapConstant: {
46 // Constants in new space cannot be used as immediates in V8 because 46 // Constants in new space cannot be used as immediates in V8 because
47 // the GC does not scan code objects when collecting the new generation. 47 // the GC does not scan code objects when collecting the new generation.
48 Handle<HeapObject> value = ValueOf<Handle<HeapObject> >(node->op()); 48 Unique<HeapObject> value = OpParameter<Unique<HeapObject> >(node);
49 return !isolate()->heap()->InNewSpace(*value); 49 return !isolate()->heap()->InNewSpace(*value.handle());
50 } 50 }
51 default: 51 default:
52 return false; 52 return false;
53 } 53 }
54 } 54 }
55 }; 55 };
56 56
57 57
58 void InstructionSelector::VisitLoad(Node* node) { 58 void InstructionSelector::VisitLoad(Node* node) {
59 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); 59 MachineType rep = RepresentationOf(OpParameter<MachineType>(node));
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 void InstructionSelector::VisitWord32Or(Node* node) { 236 void InstructionSelector::VisitWord32Or(Node* node) {
237 VisitBinop(this, node, kX64Or32); 237 VisitBinop(this, node, kX64Or32);
238 } 238 }
239 239
240 240
241 void InstructionSelector::VisitWord64Or(Node* node) { 241 void InstructionSelector::VisitWord64Or(Node* node) {
242 VisitBinop(this, node, kX64Or); 242 VisitBinop(this, node, kX64Or);
243 } 243 }
244 244
245 245
246 template <typename T> 246 void InstructionSelector::VisitWord32Xor(Node* node) {
247 static void VisitXor(InstructionSelector* selector, Node* node, 247 X64OperandGenerator g(this);
248 ArchOpcode xor_opcode, ArchOpcode not_opcode) { 248 Uint32BinopMatcher m(node);
249 X64OperandGenerator g(selector);
250 BinopMatcher<IntMatcher<T>, IntMatcher<T> > m(node);
251 if (m.right().Is(-1)) { 249 if (m.right().Is(-1)) {
252 selector->Emit(not_opcode, g.DefineSameAsFirst(node), 250 Emit(kX64Not32, g.DefineSameAsFirst(node), g.Use(m.left().node()));
253 g.Use(m.left().node()));
254 } else { 251 } else {
255 VisitBinop(selector, node, xor_opcode); 252 VisitBinop(this, node, kX64Xor32);
256 } 253 }
257 } 254 }
258 255
259 256
260 void InstructionSelector::VisitWord32Xor(Node* node) { 257 void InstructionSelector::VisitWord64Xor(Node* node) {
261 VisitXor<int32_t>(this, node, kX64Xor32, kX64Not32); 258 X64OperandGenerator g(this);
259 Uint64BinopMatcher m(node);
260 if (m.right().Is(-1)) {
261 Emit(kX64Not, g.DefineSameAsFirst(node), g.Use(m.left().node()));
262 } else {
263 VisitBinop(this, node, kX64Xor);
264 }
262 } 265 }
263 266
264 267
265 void InstructionSelector::VisitWord64Xor(Node* node) {
266 VisitXor<int64_t>(this, node, kX64Xor, kX64Not);
267 }
268
269
270 // Shared routine for multiple 32-bit shift operations. 268 // Shared routine for multiple 32-bit shift operations.
271 // TODO(bmeurer): Merge this with VisitWord64Shift using template magic? 269 // TODO(bmeurer): Merge this with VisitWord64Shift using template magic?
272 static void VisitWord32Shift(InstructionSelector* selector, Node* node, 270 static void VisitWord32Shift(InstructionSelector* selector, Node* node,
273 ArchOpcode opcode) { 271 ArchOpcode opcode) {
274 X64OperandGenerator g(selector); 272 X64OperandGenerator g(selector);
275 Node* left = node->InputAt(0); 273 Node* left = node->InputAt(0);
276 Node* right = node->InputAt(1); 274 Node* right = node->InputAt(1);
277 275
278 // TODO(turbofan): assembler only supports some addressing modes for shifts. 276 // TODO(turbofan): assembler only supports some addressing modes for shifts.
279 if (g.CanBeImmediate(right)) { 277 if (g.CanBeImmediate(right)) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 void InstructionSelector::VisitInt32Add(Node* node) { 360 void InstructionSelector::VisitInt32Add(Node* node) {
363 VisitBinop(this, node, kX64Add32); 361 VisitBinop(this, node, kX64Add32);
364 } 362 }
365 363
366 364
367 void InstructionSelector::VisitInt64Add(Node* node) { 365 void InstructionSelector::VisitInt64Add(Node* node) {
368 VisitBinop(this, node, kX64Add); 366 VisitBinop(this, node, kX64Add);
369 } 367 }
370 368
371 369
372 template <typename T> 370 void InstructionSelector::VisitInt32Sub(Node* node) {
373 static void VisitSub(InstructionSelector* selector, Node* node, 371 X64OperandGenerator g(this);
374 ArchOpcode sub_opcode, ArchOpcode neg_opcode) { 372 Int32BinopMatcher m(node);
375 X64OperandGenerator g(selector);
376 BinopMatcher<IntMatcher<T>, IntMatcher<T> > m(node);
377 if (m.left().Is(0)) { 373 if (m.left().Is(0)) {
378 selector->Emit(neg_opcode, g.DefineSameAsFirst(node), 374 Emit(kX64Neg32, g.DefineSameAsFirst(node), g.Use(m.right().node()));
379 g.Use(m.right().node()));
380 } else { 375 } else {
381 VisitBinop(selector, node, sub_opcode); 376 VisitBinop(this, node, kX64Sub32);
382 } 377 }
383 } 378 }
384 379
385 380
386 void InstructionSelector::VisitInt32Sub(Node* node) { 381 void InstructionSelector::VisitInt64Sub(Node* node) {
387 VisitSub<int32_t>(this, node, kX64Sub32, kX64Neg32); 382 X64OperandGenerator g(this);
383 Int64BinopMatcher m(node);
384 if (m.left().Is(0)) {
385 Emit(kX64Neg, g.DefineSameAsFirst(node), g.Use(m.right().node()));
386 } else {
387 VisitBinop(this, node, kX64Sub);
388 }
388 } 389 }
389 390
390 391
391 void InstructionSelector::VisitInt64Sub(Node* node) {
392 VisitSub<int64_t>(this, node, kX64Sub, kX64Neg);
393 }
394
395
396 static void VisitMul(InstructionSelector* selector, Node* node, 392 static void VisitMul(InstructionSelector* selector, Node* node,
397 ArchOpcode opcode) { 393 ArchOpcode opcode) {
398 X64OperandGenerator g(selector); 394 X64OperandGenerator g(selector);
399 Node* left = node->InputAt(0); 395 Node* left = node->InputAt(0);
400 Node* right = node->InputAt(1); 396 Node* right = node->InputAt(1);
401 if (g.CanBeImmediate(right)) { 397 if (g.CanBeImmediate(right)) {
402 selector->Emit(opcode, g.DefineAsRegister(node), g.Use(left), 398 selector->Emit(opcode, g.DefineAsRegister(node), g.Use(left),
403 g.UseImmediate(right)); 399 g.UseImmediate(right));
404 } else if (g.CanBeImmediate(left)) { 400 } else if (g.CanBeImmediate(left)) {
405 selector->Emit(opcode, g.DefineAsRegister(node), g.Use(right), 401 selector->Emit(opcode, g.DefineAsRegister(node), g.Use(right),
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 DCHECK(deoptimization == NULL && continuation == NULL); 722 DCHECK(deoptimization == NULL && continuation == NULL);
727 Emit(kArchDrop | 723 Emit(kArchDrop |
728 MiscField::encode(static_cast<int>(buffer.pushed_nodes.size())), 724 MiscField::encode(static_cast<int>(buffer.pushed_nodes.size())),
729 NULL); 725 NULL);
730 } 726 }
731 } 727 }
732 728
733 } // namespace compiler 729 } // namespace compiler
734 } // namespace internal 730 } // namespace internal
735 } // namespace v8 731 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/typer.cc ('k') | src/unique.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698