OLD | NEW |
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/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/arm64/macro-assembler-arm64.h" | 8 #include "src/arm64/macro-assembler-arm64.h" |
9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler/code-generator-impl.h" | 10 #include "src/compiler/code-generator-impl.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 Operand InputOperand64(size_t index) { return InputOperand(index); } | 92 Operand InputOperand64(size_t index) { return InputOperand(index); } |
93 | 93 |
94 Operand InputOperand32(size_t index) { | 94 Operand InputOperand32(size_t index) { |
95 return ToOperand32(instr_->InputAt(index)); | 95 return ToOperand32(instr_->InputAt(index)); |
96 } | 96 } |
97 | 97 |
98 Register OutputRegister64() { return OutputRegister(); } | 98 Register OutputRegister64() { return OutputRegister(); } |
99 | 99 |
100 Register OutputRegister32() { return ToRegister(instr_->Output()).W(); } | 100 Register OutputRegister32() { return ToRegister(instr_->Output()).W(); } |
101 | 101 |
102 Register TempRegister32() { return ToRegister(instr_->TempAt(0)).W(); } | 102 Register TempRegister32(size_t index) { |
| 103 return ToRegister(instr_->TempAt(index)).W(); |
| 104 } |
103 | 105 |
104 Operand InputOperand2_32(size_t index) { | 106 Operand InputOperand2_32(size_t index) { |
105 switch (AddressingModeField::decode(instr_->opcode())) { | 107 switch (AddressingModeField::decode(instr_->opcode())) { |
106 case kMode_None: | 108 case kMode_None: |
107 return InputOperand32(index); | 109 return InputOperand32(index); |
108 case kMode_Operand2_R_LSL_I: | 110 case kMode_Operand2_R_LSL_I: |
109 return Operand(InputRegister32(index), LSL, InputInt5(index + 1)); | 111 return Operand(InputRegister32(index), LSL, InputInt5(index + 1)); |
110 case kMode_Operand2_R_LSR_I: | 112 case kMode_Operand2_R_LSR_I: |
111 return Operand(InputRegister32(index), LSR, InputInt5(index + 1)); | 113 return Operand(InputRegister32(index), LSR, InputInt5(index + 1)); |
112 case kMode_Operand2_R_ASR_I: | 114 case kMode_Operand2_R_ASR_I: |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 MemOperand(i.InputRegister(0), i.InputRegister(1))); \ | 530 MemOperand(i.InputRegister(0), i.InputRegister(1))); \ |
529 __ Dmb(InnerShareable, BarrierAll); \ | 531 __ Dmb(InnerShareable, BarrierAll); \ |
530 } while (0) | 532 } while (0) |
531 | 533 |
532 #define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(load_instr, store_instr) \ | 534 #define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(load_instr, store_instr) \ |
533 do { \ | 535 do { \ |
534 Label exchange; \ | 536 Label exchange; \ |
535 __ bind(&exchange); \ | 537 __ bind(&exchange); \ |
536 __ Add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ | 538 __ Add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ |
537 __ load_instr(i.OutputRegister32(), i.TempRegister(0)); \ | 539 __ load_instr(i.OutputRegister32(), i.TempRegister(0)); \ |
538 __ store_instr(i.TempRegister32(), i.InputRegister32(2), \ | 540 __ store_instr(i.TempRegister32(0), i.InputRegister32(2), \ |
539 i.TempRegister(0)); \ | 541 i.TempRegister(0)); \ |
540 __ cbnz(i.TempRegister32(), &exchange); \ | 542 __ cbnz(i.TempRegister32(0), &exchange); \ |
| 543 } while (0) |
| 544 |
| 545 #define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(load_instr, store_instr, \ |
| 546 mask) \ |
| 547 do { \ |
| 548 Label compareExchange; \ |
| 549 Label exit; \ |
| 550 __ bind(&compareExchange); \ |
| 551 __ Add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ |
| 552 __ load_instr(i.OutputRegister32(), i.TempRegister(0)); \ |
| 553 __ eor(i.TempRegister32(1), i.OutputRegister32(), i.InputRegister32(2)); \ |
| 554 __ And(i.TempRegister32(1), i.TempRegister32(1), Operand(mask)); \ |
| 555 __ cbnz(i.TempRegister32(1), &exit); \ |
| 556 __ store_instr(i.TempRegister32(0), i.InputRegister32(3), \ |
| 557 i.TempRegister(0)); \ |
| 558 __ cbnz(i.TempRegister32(0), &compareExchange); \ |
| 559 __ bind(&exit); \ |
541 } while (0) | 560 } while (0) |
542 | 561 |
543 #define ASSEMBLE_IEEE754_BINOP(name) \ | 562 #define ASSEMBLE_IEEE754_BINOP(name) \ |
544 do { \ | 563 do { \ |
545 FrameScope scope(masm(), StackFrame::MANUAL); \ | 564 FrameScope scope(masm(), StackFrame::MANUAL); \ |
546 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ | 565 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ |
547 0, 2); \ | 566 0, 2); \ |
548 } while (0) | 567 } while (0) |
549 | 568 |
550 #define ASSEMBLE_IEEE754_UNOP(name) \ | 569 #define ASSEMBLE_IEEE754_UNOP(name) \ |
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrh, stlxrh); | 1675 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrh, stlxrh); |
1657 __ Sxth(i.OutputRegister(0), i.OutputRegister(0)); | 1676 __ Sxth(i.OutputRegister(0), i.OutputRegister(0)); |
1658 break; | 1677 break; |
1659 case kAtomicExchangeUint16: | 1678 case kAtomicExchangeUint16: |
1660 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrh, stlxrh); | 1679 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxrh, stlxrh); |
1661 __ Uxth(i.OutputRegister(0), i.OutputRegister(0)); | 1680 __ Uxth(i.OutputRegister(0), i.OutputRegister(0)); |
1662 break; | 1681 break; |
1663 case kAtomicExchangeWord32: | 1682 case kAtomicExchangeWord32: |
1664 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxr, stlxr); | 1683 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldaxr, stlxr); |
1665 break; | 1684 break; |
| 1685 case kAtomicCompareExchangeInt8: |
| 1686 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrb, stlxrb, 0x000000ff); |
| 1687 __ Sxtb(i.OutputRegister(0), i.OutputRegister(0)); |
| 1688 break; |
| 1689 case kAtomicCompareExchangeUint8: |
| 1690 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrb, stlxrb, 0x000000ff); |
| 1691 __ Uxtb(i.OutputRegister(0), i.OutputRegister(0)); |
| 1692 break; |
| 1693 case kAtomicCompareExchangeInt16: |
| 1694 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrh, stlxrh, 0x0000ffff); |
| 1695 __ Sxth(i.OutputRegister(0), i.OutputRegister(0)); |
| 1696 break; |
| 1697 case kAtomicCompareExchangeUint16: |
| 1698 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxrh, stlxrh, 0x0000ffff); |
| 1699 __ Uxth(i.OutputRegister(0), i.OutputRegister(0)); |
| 1700 break; |
| 1701 case kAtomicCompareExchangeWord32: |
| 1702 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldaxr, stlxr, 0xffffffff); |
| 1703 break; |
1666 } | 1704 } |
1667 return kSuccess; | 1705 return kSuccess; |
1668 } // NOLINT(readability/fn_size) | 1706 } // NOLINT(readability/fn_size) |
1669 | 1707 |
1670 | 1708 |
1671 // Assemble branches after this instruction. | 1709 // Assemble branches after this instruction. |
1672 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 1710 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
1673 Arm64OperandConverter i(this, instr); | 1711 Arm64OperandConverter i(this, instr); |
1674 Label* tlabel = branch->true_label; | 1712 Label* tlabel = branch->true_label; |
1675 Label* flabel = branch->false_label; | 1713 Label* flabel = branch->false_label; |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 padding_size -= kInstructionSize; | 2247 padding_size -= kInstructionSize; |
2210 } | 2248 } |
2211 } | 2249 } |
2212 } | 2250 } |
2213 | 2251 |
2214 #undef __ | 2252 #undef __ |
2215 | 2253 |
2216 } // namespace compiler | 2254 } // namespace compiler |
2217 } // namespace internal | 2255 } // namespace internal |
2218 } // namespace v8 | 2256 } // namespace v8 |
OLD | NEW |