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/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/ppc/frames-ppc.h" | 9 #include "src/ppc/frames-ppc.h" |
10 | 10 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 198 } |
199 | 199 |
200 | 200 |
201 void InstructionSelector::VisitStore(Node* node) { | 201 void InstructionSelector::VisitStore(Node* node) { |
202 PPCOperandGenerator g(this); | 202 PPCOperandGenerator g(this); |
203 Node* base = node->InputAt(0); | 203 Node* base = node->InputAt(0); |
204 Node* offset = node->InputAt(1); | 204 Node* offset = node->InputAt(1); |
205 Node* value = node->InputAt(2); | 205 Node* value = node->InputAt(2); |
206 | 206 |
207 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); | 207 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); |
| 208 WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); |
208 MachineType rep = RepresentationOf(store_rep.machine_type()); | 209 MachineType rep = RepresentationOf(store_rep.machine_type()); |
209 if (store_rep.write_barrier_kind() == kFullWriteBarrier) { | 210 |
210 DCHECK(rep == kRepTagged); | 211 // TODO(ppc): I guess this could be done in a better way. |
211 // TODO(dcarney): refactor RecordWrite function to take temp registers | 212 if (write_barrier_kind != kNoWriteBarrier) { |
212 // and pass them here instead of using fixed regs | 213 DCHECK_EQ(kRepTagged, rep); |
213 // TODO(dcarney): handle immediate indices. | 214 InstructionOperand inputs[3]; |
214 InstructionOperand temps[] = {g.TempRegister(r8), g.TempRegister(r9)}; | 215 size_t input_count = 0; |
215 Emit(kPPC_StoreWriteBarrier, g.NoOutput(), g.UseFixed(base, r7), | 216 inputs[input_count++] = g.UseUniqueRegister(base); |
216 g.UseFixed(offset, r8), g.UseFixed(value, r9), arraysize(temps), | 217 inputs[input_count++] = g.UseUniqueRegister(offset); |
217 temps); | 218 inputs[input_count++] = (write_barrier_kind == kMapWriteBarrier) |
218 return; | 219 ? g.UseRegister(value) |
219 } | 220 : g.UseUniqueRegister(value); |
220 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind()); | 221 RecordWriteMode record_write_mode = RecordWriteMode::kValueIsAny; |
221 ArchOpcode opcode; | 222 switch (write_barrier_kind) { |
222 ImmediateMode mode = kInt16Imm; | 223 case kNoWriteBarrier: |
223 switch (rep) { | 224 UNREACHABLE(); |
224 case kRepFloat32: | 225 break; |
225 opcode = kPPC_StoreFloat32; | 226 case kMapWriteBarrier: |
226 break; | 227 record_write_mode = RecordWriteMode::kValueIsMap; |
227 case kRepFloat64: | 228 break; |
228 opcode = kPPC_StoreDouble; | 229 case kPointerWriteBarrier: |
229 break; | 230 record_write_mode = RecordWriteMode::kValueIsPointer; |
230 case kRepBit: // Fall through. | 231 break; |
231 case kRepWord8: | 232 case kFullWriteBarrier: |
232 opcode = kPPC_StoreWord8; | 233 record_write_mode = RecordWriteMode::kValueIsAny; |
233 break; | 234 break; |
234 case kRepWord16: | 235 } |
235 opcode = kPPC_StoreWord16; | 236 InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()}; |
236 break; | 237 size_t const temp_count = arraysize(temps); |
| 238 InstructionCode code = kArchStoreWithWriteBarrier; |
| 239 code |= MiscField::encode(static_cast<int>(record_write_mode)); |
| 240 Emit(code, 0, nullptr, input_count, inputs, temp_count, temps); |
| 241 } else { |
| 242 ArchOpcode opcode; |
| 243 ImmediateMode mode = kInt16Imm; |
| 244 switch (rep) { |
| 245 case kRepFloat32: |
| 246 opcode = kPPC_StoreFloat32; |
| 247 break; |
| 248 case kRepFloat64: |
| 249 opcode = kPPC_StoreDouble; |
| 250 break; |
| 251 case kRepBit: // Fall through. |
| 252 case kRepWord8: |
| 253 opcode = kPPC_StoreWord8; |
| 254 break; |
| 255 case kRepWord16: |
| 256 opcode = kPPC_StoreWord16; |
| 257 break; |
237 #if !V8_TARGET_ARCH_PPC64 | 258 #if !V8_TARGET_ARCH_PPC64 |
238 case kRepTagged: // Fall through. | 259 case kRepTagged: // Fall through. |
239 #endif | 260 #endif |
240 case kRepWord32: | 261 case kRepWord32: |
241 opcode = kPPC_StoreWord32; | 262 opcode = kPPC_StoreWord32; |
242 break; | 263 break; |
243 #if V8_TARGET_ARCH_PPC64 | 264 #if V8_TARGET_ARCH_PPC64 |
244 case kRepTagged: // Fall through. | 265 case kRepTagged: // Fall through. |
245 case kRepWord64: | 266 case kRepWord64: |
246 opcode = kPPC_StoreWord64; | 267 opcode = kPPC_StoreWord64; |
247 mode = kInt16Imm_4ByteAligned; | 268 mode = kInt16Imm_4ByteAligned; |
248 break; | 269 break; |
249 #endif | 270 #endif |
250 default: | 271 default: |
251 UNREACHABLE(); | 272 UNREACHABLE(); |
252 return; | 273 return; |
253 } | 274 } |
254 if (g.CanBeImmediate(offset, mode)) { | 275 if (g.CanBeImmediate(offset, mode)) { |
255 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), | 276 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), |
256 g.UseRegister(base), g.UseImmediate(offset), g.UseRegister(value)); | 277 g.UseRegister(base), g.UseImmediate(offset), g.UseRegister(value)); |
257 } else if (g.CanBeImmediate(base, mode)) { | 278 } else if (g.CanBeImmediate(base, mode)) { |
258 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), | 279 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), |
259 g.UseRegister(offset), g.UseImmediate(base), g.UseRegister(value)); | 280 g.UseRegister(offset), g.UseImmediate(base), g.UseRegister(value)); |
260 } else { | 281 } else { |
261 Emit(opcode | AddressingModeField::encode(kMode_MRR), g.NoOutput(), | 282 Emit(opcode | AddressingModeField::encode(kMode_MRR), g.NoOutput(), |
262 g.UseRegister(base), g.UseRegister(offset), g.UseRegister(value)); | 283 g.UseRegister(base), g.UseRegister(offset), g.UseRegister(value)); |
| 284 } |
263 } | 285 } |
264 } | 286 } |
265 | 287 |
266 | 288 |
267 void InstructionSelector::VisitCheckedLoad(Node* node) { | 289 void InstructionSelector::VisitCheckedLoad(Node* node) { |
268 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); | 290 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); |
269 MachineType typ = TypeOf(OpParameter<MachineType>(node)); | 291 MachineType typ = TypeOf(OpParameter<MachineType>(node)); |
270 PPCOperandGenerator g(this); | 292 PPCOperandGenerator g(this); |
271 Node* const base = node->InputAt(0); | 293 Node* const base = node->InputAt(0); |
272 Node* const offset = node->InputAt(1); | 294 Node* const offset = node->InputAt(1); |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 return MachineOperatorBuilder::kFloat64RoundDown | | 1611 return MachineOperatorBuilder::kFloat64RoundDown | |
1590 MachineOperatorBuilder::kFloat64RoundTruncate | | 1612 MachineOperatorBuilder::kFloat64RoundTruncate | |
1591 MachineOperatorBuilder::kFloat64RoundTiesAway | | 1613 MachineOperatorBuilder::kFloat64RoundTiesAway | |
1592 MachineOperatorBuilder::kWord32Popcnt; | 1614 MachineOperatorBuilder::kWord32Popcnt; |
1593 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f. | 1615 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f. |
1594 } | 1616 } |
1595 | 1617 |
1596 } // namespace compiler | 1618 } // namespace compiler |
1597 } // namespace internal | 1619 } // namespace internal |
1598 } // namespace v8 | 1620 } // namespace v8 |
OLD | NEW |