| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" |
| 8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 return false; | 76 return false; |
| 77 } | 77 } |
| 78 | 78 |
| 79 AddressingMode GenerateMemoryOperandInputs(Node* index, int scale_exponent, | 79 AddressingMode GenerateMemoryOperandInputs(Node* index, int scale_exponent, |
| 80 Node* base, Node* displacement, | 80 Node* base, Node* displacement, |
| 81 DisplacementMode displacement_mode, | 81 DisplacementMode displacement_mode, |
| 82 InstructionOperand inputs[], | 82 InstructionOperand inputs[], |
| 83 size_t* input_count) { | 83 size_t* input_count) { |
| 84 AddressingMode mode = kMode_MRI; | 84 AddressingMode mode = kMode_MRI; |
| 85 if (base != nullptr && (index != nullptr || displacement != nullptr)) { |
| 86 if (base->opcode() == IrOpcode::kInt32Constant && |
| 87 OpParameter<int32_t>(base) == 0) { |
| 88 base = nullptr; |
| 89 } else if (base->opcode() == IrOpcode::kInt64Constant && |
| 90 OpParameter<int64_t>(base) == 0) { |
| 91 base = nullptr; |
| 92 } |
| 93 } |
| 85 if (base != nullptr) { | 94 if (base != nullptr) { |
| 86 inputs[(*input_count)++] = UseRegister(base); | 95 inputs[(*input_count)++] = UseRegister(base); |
| 87 if (index != nullptr) { | 96 if (index != nullptr) { |
| 88 DCHECK(scale_exponent >= 0 && scale_exponent <= 3); | 97 DCHECK(scale_exponent >= 0 && scale_exponent <= 3); |
| 89 inputs[(*input_count)++] = UseRegister(index); | 98 inputs[(*input_count)++] = UseRegister(index); |
| 90 if (displacement != nullptr) { | 99 if (displacement != nullptr) { |
| 91 inputs[(*input_count)++] = displacement_mode | 100 inputs[(*input_count)++] = displacement_mode |
| 92 ? UseNegatedImmediate(displacement) | 101 ? UseNegatedImmediate(displacement) |
| 93 : UseImmediate(displacement); | 102 : UseImmediate(displacement); |
| 94 static const AddressingMode kMRnI_modes[] = {kMode_MR1I, kMode_MR2I, | 103 static const AddressingMode kMRnI_modes[] = {kMode_MR1I, kMode_MR2I, |
| 95 kMode_MR4I, kMode_MR8I}; | 104 kMode_MR4I, kMode_MR8I}; |
| 96 mode = kMRnI_modes[scale_exponent]; | 105 mode = kMRnI_modes[scale_exponent]; |
| 97 } else { | 106 } else { |
| 98 static const AddressingMode kMRn_modes[] = {kMode_MR1, kMode_MR2, | 107 static const AddressingMode kMRn_modes[] = {kMode_MR1, kMode_MR2, |
| 99 kMode_MR4, kMode_MR8}; | 108 kMode_MR4, kMode_MR8}; |
| 100 mode = kMRn_modes[scale_exponent]; | 109 mode = kMRn_modes[scale_exponent]; |
| 101 } | 110 } |
| 102 } else { | 111 } else { |
| 103 if (displacement == nullptr) { | 112 if (displacement == nullptr) { |
| 104 mode = kMode_MR; | 113 mode = kMode_MR; |
| 105 } else { | 114 } else { |
| 106 inputs[(*input_count)++] = displacement_mode == kNegativeDisplacement | 115 inputs[(*input_count)++] = displacement_mode == kNegativeDisplacement |
| 107 ? UseNegatedImmediate(displacement) | 116 ? UseNegatedImmediate(displacement) |
| 108 : UseImmediate(displacement); | 117 : UseImmediate(displacement); |
| 109 mode = kMode_MRI; | 118 mode = kMode_MRI; |
| 110 } | 119 } |
| 111 } | 120 } |
| 112 } else { | 121 } else { |
| 113 DCHECK_NOT_NULL(index); | |
| 114 DCHECK(scale_exponent >= 0 && scale_exponent <= 3); | 122 DCHECK(scale_exponent >= 0 && scale_exponent <= 3); |
| 115 inputs[(*input_count)++] = UseRegister(index); | |
| 116 if (displacement != nullptr) { | 123 if (displacement != nullptr) { |
| 117 inputs[(*input_count)++] = displacement_mode == kNegativeDisplacement | 124 if (index == nullptr) { |
| 118 ? UseNegatedImmediate(displacement) | 125 inputs[(*input_count)++] = UseRegister(displacement); |
| 119 : UseImmediate(displacement); | 126 mode = kMode_MR; |
| 120 static const AddressingMode kMnI_modes[] = {kMode_MRI, kMode_M2I, | 127 } else { |
| 121 kMode_M4I, kMode_M8I}; | 128 inputs[(*input_count)++] = UseRegister(index); |
| 122 mode = kMnI_modes[scale_exponent]; | 129 inputs[(*input_count)++] = displacement_mode == kNegativeDisplacement |
| 130 ? UseNegatedImmediate(displacement) |
| 131 : UseImmediate(displacement); |
| 132 static const AddressingMode kMnI_modes[] = {kMode_MRI, kMode_M2I, |
| 133 kMode_M4I, kMode_M8I}; |
| 134 mode = kMnI_modes[scale_exponent]; |
| 135 } |
| 123 } else { | 136 } else { |
| 137 inputs[(*input_count)++] = UseRegister(index); |
| 124 static const AddressingMode kMn_modes[] = {kMode_MR, kMode_MR1, | 138 static const AddressingMode kMn_modes[] = {kMode_MR, kMode_MR1, |
| 125 kMode_M4, kMode_M8}; | 139 kMode_M4, kMode_M8}; |
| 126 mode = kMn_modes[scale_exponent]; | 140 mode = kMn_modes[scale_exponent]; |
| 127 if (mode == kMode_MR1) { | 141 if (mode == kMode_MR1) { |
| 128 // [%r1 + %r1*1] has a smaller encoding than [%r1*2+0] | 142 // [%r1 + %r1*1] has a smaller encoding than [%r1*2+0] |
| 129 inputs[(*input_count)++] = UseRegister(index); | 143 inputs[(*input_count)++] = UseRegister(index); |
| 130 } | 144 } |
| 131 } | 145 } |
| 132 } | 146 } |
| 133 return mode; | 147 return mode; |
| (...skipping 2333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2467 // static | 2481 // static |
| 2468 MachineOperatorBuilder::AlignmentRequirements | 2482 MachineOperatorBuilder::AlignmentRequirements |
| 2469 InstructionSelector::AlignmentRequirements() { | 2483 InstructionSelector::AlignmentRequirements() { |
| 2470 return MachineOperatorBuilder::AlignmentRequirements:: | 2484 return MachineOperatorBuilder::AlignmentRequirements:: |
| 2471 FullUnalignedAccessSupport(); | 2485 FullUnalignedAccessSupport(); |
| 2472 } | 2486 } |
| 2473 | 2487 |
| 2474 } // namespace compiler | 2488 } // namespace compiler |
| 2475 } // namespace internal | 2489 } // namespace internal |
| 2476 } // namespace v8 | 2490 } // namespace v8 |
| OLD | NEW |