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

Side by Side Diff: src/compiler/s390/code-generator-s390.cc

Issue 1916143002: S390X: [turbofan] Word32 loads should be unsigned. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove previous patchset Created 4 years, 8 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
« no previous file with comments | « no previous file | src/compiler/s390/instruction-codes-s390.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler/code-generator-impl.h" 8 #include "src/compiler/code-generator-impl.h"
9 #include "src/compiler/gap-resolver.h" 9 #include "src/compiler/gap-resolver.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return le; 230 return le;
231 case kSignedGreaterThan: 231 case kSignedGreaterThan:
232 case kUnsignedGreaterThan: 232 case kUnsignedGreaterThan:
233 return gt; 233 return gt;
234 case kOverflow: 234 case kOverflow:
235 // Overflow checked for AddP/SubP only. 235 // Overflow checked for AddP/SubP only.
236 switch (op) { 236 switch (op) {
237 #if V8_TARGET_ARCH_S390X 237 #if V8_TARGET_ARCH_S390X
238 case kS390_Add: 238 case kS390_Add:
239 case kS390_Sub: 239 case kS390_Sub:
240 return lt;
241 #endif 240 #endif
242 case kS390_AddWithOverflow32: 241 case kS390_AddWithOverflow32:
243 case kS390_SubWithOverflow32: 242 case kS390_SubWithOverflow32:
244 #if V8_TARGET_ARCH_S390X
245 return ne;
246 #else
247 return lt; 243 return lt;
248 #endif
249 default: 244 default:
250 break; 245 break;
251 } 246 }
252 break; 247 break;
253 case kNotOverflow: 248 case kNotOverflow:
254 switch (op) { 249 switch (op) {
255 #if V8_TARGET_ARCH_S390X 250 #if V8_TARGET_ARCH_S390X
256 case kS390_Add: 251 case kS390_Add:
257 case kS390_Sub: 252 case kS390_Sub:
258 return ge;
259 #endif 253 #endif
260 case kS390_AddWithOverflow32: 254 case kS390_AddWithOverflow32:
261 case kS390_SubWithOverflow32: 255 case kS390_SubWithOverflow32:
262 #if V8_TARGET_ARCH_S390X
263 return eq;
264 #else
265 return ge; 256 return ge;
266 #endif
267 default: 257 default:
268 break; 258 break;
269 } 259 }
270 break; 260 break;
271 default: 261 default:
272 break; 262 break;
273 } 263 }
274 UNREACHABLE(); 264 UNREACHABLE();
275 return kNoCondition; 265 return kNoCondition;
276 } 266 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 if (HasRegisterInput(instr, 1)) { \ 316 if (HasRegisterInput(instr, 1)) { \
327 __ SubAndCheckForOverflow(i.OutputRegister(), i.InputRegister(0), \ 317 __ SubAndCheckForOverflow(i.OutputRegister(), i.InputRegister(0), \
328 i.InputRegister(1), kScratchReg, r0); \ 318 i.InputRegister(1), kScratchReg, r0); \
329 } else { \ 319 } else { \
330 __ AddAndCheckForOverflow(i.OutputRegister(), i.InputRegister(0), \ 320 __ AddAndCheckForOverflow(i.OutputRegister(), i.InputRegister(0), \
331 -i.InputInt32(1), kScratchReg, r0); \ 321 -i.InputInt32(1), kScratchReg, r0); \
332 } \ 322 } \
333 } while (0) 323 } while (0)
334 324
335 #if V8_TARGET_ARCH_S390X 325 #if V8_TARGET_ARCH_S390X
336 #define ASSEMBLE_ADD_WITH_OVERFLOW32() \ 326 #define ASSEMBLE_ADD_WITH_OVERFLOW32() \
337 do { \ 327 do { \
338 ASSEMBLE_BINOP(AddP, AddP); \ 328 ASSEMBLE_ADD_WITH_OVERFLOW(); \
339 __ TestIfInt32(i.OutputRegister(), r0); \ 329 __ LoadAndTestP_ExtendSrc(kScratchReg, kScratchReg); \
340 } while (0) 330 } while (0)
341 331
342 #define ASSEMBLE_SUB_WITH_OVERFLOW32() \ 332 #define ASSEMBLE_SUB_WITH_OVERFLOW32() \
343 do { \ 333 do { \
344 ASSEMBLE_BINOP(SubP, SubP); \ 334 ASSEMBLE_SUB_WITH_OVERFLOW(); \
345 __ TestIfInt32(i.OutputRegister(), r0); \ 335 __ LoadAndTestP_ExtendSrc(kScratchReg, kScratchReg); \
346 } while (0) 336 } while (0)
347 #else 337 #else
348 #define ASSEMBLE_ADD_WITH_OVERFLOW32 ASSEMBLE_ADD_WITH_OVERFLOW 338 #define ASSEMBLE_ADD_WITH_OVERFLOW32 ASSEMBLE_ADD_WITH_OVERFLOW
349 #define ASSEMBLE_SUB_WITH_OVERFLOW32 ASSEMBLE_SUB_WITH_OVERFLOW 339 #define ASSEMBLE_SUB_WITH_OVERFLOW32 ASSEMBLE_SUB_WITH_OVERFLOW
350 #endif 340 #endif
351 341
352 #define ASSEMBLE_COMPARE(cmp_instr, cmpl_instr) \ 342 #define ASSEMBLE_COMPARE(cmp_instr, cmpl_instr) \
353 do { \ 343 do { \
354 if (HasRegisterInput(instr, 1)) { \ 344 if (HasRegisterInput(instr, 1)) { \
355 if (i.CompareLogical()) { \ 345 if (i.CompareLogical()) { \
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 445
456 #define ASSEMBLE_STORE_INTEGER(asm_instr) \ 446 #define ASSEMBLE_STORE_INTEGER(asm_instr) \
457 do { \ 447 do { \
458 size_t index = 0; \ 448 size_t index = 0; \
459 AddressingMode mode = kMode_None; \ 449 AddressingMode mode = kMode_None; \
460 MemOperand operand = i.MemoryOperand(&mode, &index); \ 450 MemOperand operand = i.MemoryOperand(&mode, &index); \
461 Register value = i.InputRegister(index); \ 451 Register value = i.InputRegister(index); \
462 __ asm_instr(value, operand); \ 452 __ asm_instr(value, operand); \
463 } while (0) 453 } while (0)
464 454
465 // TODO(mbrandy): fix paths that produce garbage in offset's upper 32-bits.
466 #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr, width) \ 455 #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr, width) \
467 do { \ 456 do { \
468 DoubleRegister result = i.OutputDoubleRegister(); \ 457 DoubleRegister result = i.OutputDoubleRegister(); \
469 size_t index = 0; \ 458 size_t index = 0; \
470 AddressingMode mode = kMode_None; \ 459 AddressingMode mode = kMode_None; \
471 MemOperand operand = i.MemoryOperand(&mode, index); \ 460 MemOperand operand = i.MemoryOperand(&mode, index); \
472 Register offset = operand.rb(); \ 461 Register offset = operand.rb(); \
473 __ lgfr(offset, offset); \
474 if (HasRegisterInput(instr, 2)) { \ 462 if (HasRegisterInput(instr, 2)) { \
475 __ CmpLogical32(offset, i.InputRegister(2)); \ 463 __ CmpLogical32(offset, i.InputRegister(2)); \
476 } else { \ 464 } else { \
477 __ CmpLogical32(offset, i.InputImmediate(2)); \ 465 __ CmpLogical32(offset, i.InputImmediate(2)); \
478 } \ 466 } \
479 auto ool = new (zone()) OutOfLineLoadNAN##width(this, result); \ 467 auto ool = new (zone()) OutOfLineLoadNAN##width(this, result); \
480 __ bge(ool->entry()); \ 468 __ bge(ool->entry()); \
481 __ asm_instr(result, operand); \ 469 __ asm_instr(result, operand); \
482 __ bind(ool->exit()); \ 470 __ bind(ool->exit()); \
483 } while (0) 471 } while (0)
484 472
485 // TODO(mbrandy): fix paths that produce garbage in offset's upper 32-bits.
486 #define ASSEMBLE_CHECKED_LOAD_INTEGER(asm_instr) \ 473 #define ASSEMBLE_CHECKED_LOAD_INTEGER(asm_instr) \
487 do { \ 474 do { \
488 Register result = i.OutputRegister(); \ 475 Register result = i.OutputRegister(); \
489 size_t index = 0; \ 476 size_t index = 0; \
490 AddressingMode mode = kMode_None; \ 477 AddressingMode mode = kMode_None; \
491 MemOperand operand = i.MemoryOperand(&mode, index); \ 478 MemOperand operand = i.MemoryOperand(&mode, index); \
492 Register offset = operand.rb(); \ 479 Register offset = operand.rb(); \
493 __ lgfr(offset, offset); \
494 if (HasRegisterInput(instr, 2)) { \ 480 if (HasRegisterInput(instr, 2)) { \
495 __ CmpLogical32(offset, i.InputRegister(2)); \ 481 __ CmpLogical32(offset, i.InputRegister(2)); \
496 } else { \ 482 } else { \
497 __ CmpLogical32(offset, i.InputImmediate(2)); \ 483 __ CmpLogical32(offset, i.InputImmediate(2)); \
498 } \ 484 } \
499 auto ool = new (zone()) OutOfLineLoadZero(this, result); \ 485 auto ool = new (zone()) OutOfLineLoadZero(this, result); \
500 __ bge(ool->entry()); \ 486 __ bge(ool->entry()); \
501 __ asm_instr(result, operand); \ 487 __ asm_instr(result, operand); \
502 __ bind(ool->exit()); \ 488 __ bind(ool->exit()); \
503 } while (0) 489 } while (0)
504 490
505 // TODO(mbrandy): fix paths that produce garbage in offset's upper 32-bits.
506 #define ASSEMBLE_CHECKED_STORE_FLOAT32() \ 491 #define ASSEMBLE_CHECKED_STORE_FLOAT32() \
507 do { \ 492 do { \
508 Label done; \ 493 Label done; \
509 size_t index = 0; \ 494 size_t index = 0; \
510 AddressingMode mode = kMode_None; \ 495 AddressingMode mode = kMode_None; \
511 MemOperand operand = i.MemoryOperand(&mode, index); \ 496 MemOperand operand = i.MemoryOperand(&mode, index); \
512 Register offset = operand.rb(); \ 497 Register offset = operand.rb(); \
513 __ lgfr(offset, offset); \
514 if (HasRegisterInput(instr, 2)) { \ 498 if (HasRegisterInput(instr, 2)) { \
515 __ CmpLogical32(offset, i.InputRegister(2)); \ 499 __ CmpLogical32(offset, i.InputRegister(2)); \
516 } else { \ 500 } else { \
517 __ CmpLogical32(offset, i.InputImmediate(2)); \ 501 __ CmpLogical32(offset, i.InputImmediate(2)); \
518 } \ 502 } \
519 __ bge(&done); \ 503 __ bge(&done); \
520 DoubleRegister value = i.InputDoubleRegister(3); \ 504 DoubleRegister value = i.InputDoubleRegister(3); \
521 __ StoreFloat32(value, operand); \ 505 __ StoreFloat32(value, operand); \
522 __ bind(&done); \ 506 __ bind(&done); \
523 } while (0) 507 } while (0)
524 508
525 // TODO(mbrandy): fix paths that produce garbage in offset's upper 32-bits.
526 #define ASSEMBLE_CHECKED_STORE_DOUBLE() \ 509 #define ASSEMBLE_CHECKED_STORE_DOUBLE() \
527 do { \ 510 do { \
528 Label done; \ 511 Label done; \
529 size_t index = 0; \ 512 size_t index = 0; \
530 AddressingMode mode = kMode_None; \ 513 AddressingMode mode = kMode_None; \
531 MemOperand operand = i.MemoryOperand(&mode, index); \ 514 MemOperand operand = i.MemoryOperand(&mode, index); \
532 DCHECK_EQ(kMode_MRR, mode); \ 515 DCHECK_EQ(kMode_MRR, mode); \
533 Register offset = operand.rb(); \ 516 Register offset = operand.rb(); \
534 __ lgfr(offset, offset); \
535 if (HasRegisterInput(instr, 2)) { \ 517 if (HasRegisterInput(instr, 2)) { \
536 __ CmpLogical32(offset, i.InputRegister(2)); \ 518 __ CmpLogical32(offset, i.InputRegister(2)); \
537 } else { \ 519 } else { \
538 __ CmpLogical32(offset, i.InputImmediate(2)); \ 520 __ CmpLogical32(offset, i.InputImmediate(2)); \
539 } \ 521 } \
540 __ bge(&done); \ 522 __ bge(&done); \
541 DoubleRegister value = i.InputDoubleRegister(3); \ 523 DoubleRegister value = i.InputDoubleRegister(3); \
542 __ StoreDouble(value, operand); \ 524 __ StoreDouble(value, operand); \
543 __ bind(&done); \ 525 __ bind(&done); \
544 } while (0) 526 } while (0)
545 527
546 // TODO(mbrandy): fix paths that produce garbage in offset's upper 32-bits.
547 #define ASSEMBLE_CHECKED_STORE_INTEGER(asm_instr) \ 528 #define ASSEMBLE_CHECKED_STORE_INTEGER(asm_instr) \
548 do { \ 529 do { \
549 Label done; \ 530 Label done; \
550 size_t index = 0; \ 531 size_t index = 0; \
551 AddressingMode mode = kMode_None; \ 532 AddressingMode mode = kMode_None; \
552 MemOperand operand = i.MemoryOperand(&mode, index); \ 533 MemOperand operand = i.MemoryOperand(&mode, index); \
553 Register offset = operand.rb(); \ 534 Register offset = operand.rb(); \
554 __ lgfr(offset, offset); \
555 if (HasRegisterInput(instr, 2)) { \ 535 if (HasRegisterInput(instr, 2)) { \
556 __ CmpLogical32(offset, i.InputRegister(2)); \ 536 __ CmpLogical32(offset, i.InputRegister(2)); \
557 } else { \ 537 } else { \
558 __ CmpLogical32(offset, i.InputImmediate(2)); \ 538 __ CmpLogical32(offset, i.InputImmediate(2)); \
559 } \ 539 } \
560 __ bge(&done); \ 540 __ bge(&done); \
561 Register value = i.InputRegister(3); \ 541 Register value = i.InputRegister(3); \
562 __ asm_instr(value, operand); \ 542 __ asm_instr(value, operand); \
563 __ bind(&done); \ 543 __ bind(&done); \
564 } while (0) 544 } while (0)
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 #endif 1543 #endif
1564 case kS390_LoadWordU8: 1544 case kS390_LoadWordU8:
1565 ASSEMBLE_LOAD_INTEGER(LoadlB); 1545 ASSEMBLE_LOAD_INTEGER(LoadlB);
1566 break; 1546 break;
1567 case kS390_LoadWordU16: 1547 case kS390_LoadWordU16:
1568 ASSEMBLE_LOAD_INTEGER(LoadLogicalHalfWordP); 1548 ASSEMBLE_LOAD_INTEGER(LoadLogicalHalfWordP);
1569 break; 1549 break;
1570 case kS390_LoadWordS16: 1550 case kS390_LoadWordS16:
1571 ASSEMBLE_LOAD_INTEGER(LoadHalfWordP); 1551 ASSEMBLE_LOAD_INTEGER(LoadHalfWordP);
1572 break; 1552 break;
1553 case kS390_LoadWordU32:
1554 ASSEMBLE_LOAD_INTEGER(LoadlW);
1555 break;
1573 case kS390_LoadWordS32: 1556 case kS390_LoadWordS32:
1574 ASSEMBLE_LOAD_INTEGER(LoadW); 1557 ASSEMBLE_LOAD_INTEGER(LoadW);
1575 break; 1558 break;
1576 #if V8_TARGET_ARCH_S390X 1559 #if V8_TARGET_ARCH_S390X
1577 case kS390_LoadWord64: 1560 case kS390_LoadWord64:
1578 ASSEMBLE_LOAD_INTEGER(lg); 1561 ASSEMBLE_LOAD_INTEGER(lg);
1579 break; 1562 break;
1580 #endif 1563 #endif
1581 case kS390_LoadFloat32: 1564 case kS390_LoadFloat32:
1582 ASSEMBLE_LOAD_FLOAT(LoadFloat32); 1565 ASSEMBLE_LOAD_FLOAT(LoadFloat32);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 case kCheckedLoadUint8: 1598 case kCheckedLoadUint8:
1616 ASSEMBLE_CHECKED_LOAD_INTEGER(LoadlB); 1599 ASSEMBLE_CHECKED_LOAD_INTEGER(LoadlB);
1617 break; 1600 break;
1618 case kCheckedLoadInt16: 1601 case kCheckedLoadInt16:
1619 ASSEMBLE_CHECKED_LOAD_INTEGER(LoadHalfWordP); 1602 ASSEMBLE_CHECKED_LOAD_INTEGER(LoadHalfWordP);
1620 break; 1603 break;
1621 case kCheckedLoadUint16: 1604 case kCheckedLoadUint16:
1622 ASSEMBLE_CHECKED_LOAD_INTEGER(LoadLogicalHalfWordP); 1605 ASSEMBLE_CHECKED_LOAD_INTEGER(LoadLogicalHalfWordP);
1623 break; 1606 break;
1624 case kCheckedLoadWord32: 1607 case kCheckedLoadWord32:
1625 ASSEMBLE_CHECKED_LOAD_INTEGER(LoadW); 1608 ASSEMBLE_CHECKED_LOAD_INTEGER(LoadlW);
1626 break; 1609 break;
1627 case kCheckedLoadWord64: 1610 case kCheckedLoadWord64:
1628 #if V8_TARGET_ARCH_S390X 1611 #if V8_TARGET_ARCH_S390X
1629 ASSEMBLE_CHECKED_LOAD_INTEGER(LoadP); 1612 ASSEMBLE_CHECKED_LOAD_INTEGER(LoadP);
1630 #else 1613 #else
1631 UNREACHABLE(); 1614 UNREACHABLE();
1632 #endif 1615 #endif
1633 break; 1616 break;
1634 case kCheckedLoadFloat32: 1617 case kCheckedLoadFloat32:
1635 ASSEMBLE_CHECKED_LOAD_FLOAT(LoadFloat32, 32); 1618 ASSEMBLE_CHECKED_LOAD_FLOAT(LoadFloat32, 32);
(...skipping 29 matching lines...) Expand all
1665 case kAtomicLoadUint8: 1648 case kAtomicLoadUint8:
1666 __ LoadlB(i.OutputRegister(), i.MemoryOperand()); 1649 __ LoadlB(i.OutputRegister(), i.MemoryOperand());
1667 break; 1650 break;
1668 case kAtomicLoadInt16: 1651 case kAtomicLoadInt16:
1669 __ LoadHalfWordP(i.OutputRegister(), i.MemoryOperand()); 1652 __ LoadHalfWordP(i.OutputRegister(), i.MemoryOperand());
1670 break; 1653 break;
1671 case kAtomicLoadUint16: 1654 case kAtomicLoadUint16:
1672 __ LoadLogicalHalfWordP(i.OutputRegister(), i.MemoryOperand()); 1655 __ LoadLogicalHalfWordP(i.OutputRegister(), i.MemoryOperand());
1673 break; 1656 break;
1674 case kAtomicLoadWord32: 1657 case kAtomicLoadWord32:
1675 __ Load(i.OutputRegister(), i.MemoryOperand()); 1658 __ LoadlW(i.OutputRegister(), i.MemoryOperand());
1676 break; 1659 break;
1677 default: 1660 default:
1678 UNREACHABLE(); 1661 UNREACHABLE();
1679 break; 1662 break;
1680 } 1663 }
1681 } // NOLINT(readability/fn_size) 1664 } // NOLINT(readability/fn_size)
1682 1665
1683 // Assembles branches after an instruction. 1666 // Assembles branches after an instruction.
1684 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { 1667 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) {
1685 S390OperandConverter i(this, instr); 1668 S390OperandConverter i(this, instr);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 UNREACHABLE(); 1750 UNREACHABLE();
1768 break; 1751 break;
1769 } 1752 }
1770 __ bind(&done); 1753 __ bind(&done);
1771 } 1754 }
1772 1755
1773 void CodeGenerator::AssembleArchLookupSwitch(Instruction* instr) { 1756 void CodeGenerator::AssembleArchLookupSwitch(Instruction* instr) {
1774 S390OperandConverter i(this, instr); 1757 S390OperandConverter i(this, instr);
1775 Register input = i.InputRegister(0); 1758 Register input = i.InputRegister(0);
1776 for (size_t index = 2; index < instr->InputCount(); index += 2) { 1759 for (size_t index = 2; index < instr->InputCount(); index += 2) {
1777 __ CmpP(input, Operand(i.InputInt32(index + 0))); 1760 __ Cmp32(input, Operand(i.InputInt32(index + 0)));
1778 __ beq(GetLabel(i.InputRpo(index + 1))); 1761 __ beq(GetLabel(i.InputRpo(index + 1)));
1779 } 1762 }
1780 AssembleArchJump(i.InputRpo(1)); 1763 AssembleArchJump(i.InputRpo(1));
1781 } 1764 }
1782 1765
1783 void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { 1766 void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) {
1784 S390OperandConverter i(this, instr); 1767 S390OperandConverter i(this, instr);
1785 Register input = i.InputRegister(0); 1768 Register input = i.InputRegister(0);
1786 int32_t const case_count = static_cast<int32_t>(instr->InputCount() - 2); 1769 int32_t const case_count = static_cast<int32_t>(instr->InputCount() - 2);
1787 Label** cases = zone()->NewArray<Label*>(case_count); 1770 Label** cases = zone()->NewArray<Label*>(case_count);
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 padding_size -= 2; 2112 padding_size -= 2;
2130 } 2113 }
2131 } 2114 }
2132 } 2115 }
2133 2116
2134 #undef __ 2117 #undef __
2135 2118
2136 } // namespace compiler 2119 } // namespace compiler
2137 } // namespace internal 2120 } // namespace internal
2138 } // namespace v8 2121 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/s390/instruction-codes-s390.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698