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 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 InstructionOperand inputs[3]; | 1186 InstructionOperand inputs[3]; |
1187 AddressingMode mode = g.GetEffectiveAddressMemoryOperand( | 1187 AddressingMode mode = g.GetEffectiveAddressMemoryOperand( |
1188 node->InputAt(0), inputs, &input_count); | 1188 node->InputAt(0), inputs, &input_count); |
1189 opcode |= AddressingModeField::encode(mode); | 1189 opcode |= AddressingModeField::encode(mode); |
1190 Emit(opcode, 1, outputs, input_count, inputs); | 1190 Emit(opcode, 1, outputs, input_count, inputs); |
1191 } else { | 1191 } else { |
1192 Emit(kX64Movsxlq, g.DefineAsRegister(node), g.Use(node->InputAt(0))); | 1192 Emit(kX64Movsxlq, g.DefineAsRegister(node), g.Use(node->InputAt(0))); |
1193 } | 1193 } |
1194 } | 1194 } |
1195 | 1195 |
| 1196 namespace { |
1196 | 1197 |
1197 void InstructionSelector::VisitChangeUint32ToUint64(Node* node) { | 1198 bool ZeroExtendsWord32ToWord64(Node* node) { |
1198 X64OperandGenerator g(this); | 1199 switch (node->opcode()) { |
1199 Node* value = node->InputAt(0); | |
1200 switch (value->opcode()) { | |
1201 case IrOpcode::kWord32And: | 1200 case IrOpcode::kWord32And: |
1202 case IrOpcode::kWord32Or: | 1201 case IrOpcode::kWord32Or: |
1203 case IrOpcode::kWord32Xor: | 1202 case IrOpcode::kWord32Xor: |
1204 case IrOpcode::kWord32Shl: | 1203 case IrOpcode::kWord32Shl: |
1205 case IrOpcode::kWord32Shr: | 1204 case IrOpcode::kWord32Shr: |
1206 case IrOpcode::kWord32Sar: | 1205 case IrOpcode::kWord32Sar: |
1207 case IrOpcode::kWord32Ror: | 1206 case IrOpcode::kWord32Ror: |
1208 case IrOpcode::kWord32Equal: | 1207 case IrOpcode::kWord32Equal: |
1209 case IrOpcode::kInt32Add: | 1208 case IrOpcode::kInt32Add: |
1210 case IrOpcode::kInt32Sub: | 1209 case IrOpcode::kInt32Sub: |
1211 case IrOpcode::kInt32Mul: | 1210 case IrOpcode::kInt32Mul: |
1212 case IrOpcode::kInt32MulHigh: | 1211 case IrOpcode::kInt32MulHigh: |
1213 case IrOpcode::kInt32Div: | 1212 case IrOpcode::kInt32Div: |
1214 case IrOpcode::kInt32LessThan: | 1213 case IrOpcode::kInt32LessThan: |
1215 case IrOpcode::kInt32LessThanOrEqual: | 1214 case IrOpcode::kInt32LessThanOrEqual: |
1216 case IrOpcode::kInt32Mod: | 1215 case IrOpcode::kInt32Mod: |
1217 case IrOpcode::kUint32Div: | 1216 case IrOpcode::kUint32Div: |
1218 case IrOpcode::kUint32LessThan: | 1217 case IrOpcode::kUint32LessThan: |
1219 case IrOpcode::kUint32LessThanOrEqual: | 1218 case IrOpcode::kUint32LessThanOrEqual: |
1220 case IrOpcode::kUint32Mod: | 1219 case IrOpcode::kUint32Mod: |
1221 case IrOpcode::kUint32MulHigh: { | 1220 case IrOpcode::kUint32MulHigh: |
1222 // These 32-bit operations implicitly zero-extend to 64-bit on x64, so the | 1221 // These 32-bit operations implicitly zero-extend to 64-bit on x64, so the |
1223 // zero-extension is a no-op. | 1222 // zero-extension is a no-op. |
1224 Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value)); | 1223 return true; |
1225 return; | 1224 case IrOpcode::kProjection: { |
| 1225 Node* const value = node->InputAt(0); |
| 1226 switch (value->opcode()) { |
| 1227 case IrOpcode::kInt32AddWithOverflow: |
| 1228 case IrOpcode::kInt32SubWithOverflow: |
| 1229 case IrOpcode::kInt32MulWithOverflow: |
| 1230 return true; |
| 1231 default: |
| 1232 return false; |
| 1233 } |
1226 } | 1234 } |
1227 default: | 1235 default: |
1228 break; | 1236 return false; |
| 1237 } |
| 1238 } |
| 1239 |
| 1240 } // namespace |
| 1241 |
| 1242 void InstructionSelector::VisitChangeUint32ToUint64(Node* node) { |
| 1243 X64OperandGenerator g(this); |
| 1244 Node* value = node->InputAt(0); |
| 1245 if (ZeroExtendsWord32ToWord64(value)) { |
| 1246 // These 32-bit operations implicitly zero-extend to 64-bit on x64, so the |
| 1247 // zero-extension is a no-op. |
| 1248 Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value)); |
| 1249 return; |
1229 } | 1250 } |
1230 Emit(kX64Movl, g.DefineAsRegister(node), g.Use(value)); | 1251 Emit(kX64Movl, g.DefineAsRegister(node), g.Use(value)); |
1231 } | 1252 } |
1232 | 1253 |
1233 | 1254 |
1234 namespace { | 1255 namespace { |
1235 | 1256 |
1236 void VisitRO(InstructionSelector* selector, Node* node, | 1257 void VisitRO(InstructionSelector* selector, Node* node, |
1237 InstructionCode opcode) { | 1258 InstructionCode opcode) { |
1238 X64OperandGenerator g(selector); | 1259 X64OperandGenerator g(selector); |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2273 // static | 2294 // static |
2274 MachineOperatorBuilder::AlignmentRequirements | 2295 MachineOperatorBuilder::AlignmentRequirements |
2275 InstructionSelector::AlignmentRequirements() { | 2296 InstructionSelector::AlignmentRequirements() { |
2276 return MachineOperatorBuilder::AlignmentRequirements:: | 2297 return MachineOperatorBuilder::AlignmentRequirements:: |
2277 FullUnalignedAccessSupport(); | 2298 FullUnalignedAccessSupport(); |
2278 } | 2299 } |
2279 | 2300 |
2280 } // namespace compiler | 2301 } // namespace compiler |
2281 } // namespace internal | 2302 } // namespace internal |
2282 } // namespace v8 | 2303 } // namespace v8 |
OLD | NEW |