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/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace compiler { | 10 namespace compiler { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 // Shared routine for multiple binary operations. | 144 // Shared routine for multiple binary operations. |
145 static void VisitBinop(InstructionSelector* selector, Node* node, | 145 static void VisitBinop(InstructionSelector* selector, Node* node, |
146 ArchOpcode opcode, ImmediateMode operand_mode) { | 146 ArchOpcode opcode, ImmediateMode operand_mode) { |
147 FlagsContinuation cont; | 147 FlagsContinuation cont; |
148 VisitBinop(selector, node, opcode, operand_mode, &cont); | 148 VisitBinop(selector, node, opcode, operand_mode, &cont); |
149 } | 149 } |
150 | 150 |
151 | 151 |
152 void InstructionSelector::VisitLoad(Node* node) { | 152 void InstructionSelector::VisitLoad(Node* node) { |
153 MachineType rep = OpParameter<MachineType>(node); | 153 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); |
154 Arm64OperandGenerator g(this); | 154 Arm64OperandGenerator g(this); |
155 Node* base = node->InputAt(0); | 155 Node* base = node->InputAt(0); |
156 Node* index = node->InputAt(1); | 156 Node* index = node->InputAt(1); |
157 | 157 |
158 InstructionOperand* result = rep == kMachineFloat64 | 158 InstructionOperand* result = rep == rFloat64 ? g.DefineAsDoubleRegister(node) |
159 ? g.DefineAsDoubleRegister(node) | 159 : g.DefineAsRegister(node); |
160 : g.DefineAsRegister(node); | |
161 | 160 |
162 ArchOpcode opcode; | 161 ArchOpcode opcode; |
| 162 // TODO(titzer): signed/unsigned small loads |
163 switch (rep) { | 163 switch (rep) { |
164 case kMachineFloat64: | 164 case rFloat64: |
165 opcode = kArm64Float64Load; | 165 opcode = kArm64Float64Load; |
166 break; | 166 break; |
167 case kMachineWord8: | 167 case rBit: // Fall through. |
| 168 case rWord8: |
168 opcode = kArm64LoadWord8; | 169 opcode = kArm64LoadWord8; |
169 break; | 170 break; |
170 case kMachineWord16: | 171 case rWord16: |
171 opcode = kArm64LoadWord16; | 172 opcode = kArm64LoadWord16; |
172 break; | 173 break; |
173 case kMachineWord32: | 174 case rWord32: |
174 opcode = kArm64LoadWord32; | 175 opcode = kArm64LoadWord32; |
175 break; | 176 break; |
176 case kMachineTagged: // Fall through. | 177 case rTagged: // Fall through. |
177 case kMachineWord64: | 178 case rWord64: |
178 opcode = kArm64LoadWord64; | 179 opcode = kArm64LoadWord64; |
179 break; | 180 break; |
180 default: | 181 default: |
181 UNREACHABLE(); | 182 UNREACHABLE(); |
182 return; | 183 return; |
183 } | 184 } |
184 if (g.CanBeImmediate(index, kLoadStoreImm)) { | 185 if (g.CanBeImmediate(index, kLoadStoreImm)) { |
185 Emit(opcode | AddressingModeField::encode(kMode_MRI), result, | 186 Emit(opcode | AddressingModeField::encode(kMode_MRI), result, |
186 g.UseRegister(base), g.UseImmediate(index)); | 187 g.UseRegister(base), g.UseImmediate(index)); |
187 } else if (g.CanBeImmediate(base, kLoadStoreImm)) { | 188 } else if (g.CanBeImmediate(base, kLoadStoreImm)) { |
188 Emit(opcode | AddressingModeField::encode(kMode_MRI), result, | 189 Emit(opcode | AddressingModeField::encode(kMode_MRI), result, |
189 g.UseRegister(index), g.UseImmediate(base)); | 190 g.UseRegister(index), g.UseImmediate(base)); |
190 } else { | 191 } else { |
191 Emit(opcode | AddressingModeField::encode(kMode_MRR), result, | 192 Emit(opcode | AddressingModeField::encode(kMode_MRR), result, |
192 g.UseRegister(base), g.UseRegister(index)); | 193 g.UseRegister(base), g.UseRegister(index)); |
193 } | 194 } |
194 } | 195 } |
195 | 196 |
196 | 197 |
197 void InstructionSelector::VisitStore(Node* node) { | 198 void InstructionSelector::VisitStore(Node* node) { |
198 Arm64OperandGenerator g(this); | 199 Arm64OperandGenerator g(this); |
199 Node* base = node->InputAt(0); | 200 Node* base = node->InputAt(0); |
200 Node* index = node->InputAt(1); | 201 Node* index = node->InputAt(1); |
201 Node* value = node->InputAt(2); | 202 Node* value = node->InputAt(2); |
202 | 203 |
203 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); | 204 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); |
204 MachineType rep = store_rep.rep; | 205 MachineType rep = RepresentationOf(store_rep.machine_type); |
205 if (store_rep.write_barrier_kind == kFullWriteBarrier) { | 206 if (store_rep.write_barrier_kind == kFullWriteBarrier) { |
206 DCHECK(rep == kMachineTagged); | 207 DCHECK(rep == rTagged); |
207 // TODO(dcarney): refactor RecordWrite function to take temp registers | 208 // TODO(dcarney): refactor RecordWrite function to take temp registers |
208 // and pass them here instead of using fixed regs | 209 // and pass them here instead of using fixed regs |
209 // TODO(dcarney): handle immediate indices. | 210 // TODO(dcarney): handle immediate indices. |
210 InstructionOperand* temps[] = {g.TempRegister(x11), g.TempRegister(x12)}; | 211 InstructionOperand* temps[] = {g.TempRegister(x11), g.TempRegister(x12)}; |
211 Emit(kArm64StoreWriteBarrier, NULL, g.UseFixed(base, x10), | 212 Emit(kArm64StoreWriteBarrier, NULL, g.UseFixed(base, x10), |
212 g.UseFixed(index, x11), g.UseFixed(value, x12), ARRAY_SIZE(temps), | 213 g.UseFixed(index, x11), g.UseFixed(value, x12), ARRAY_SIZE(temps), |
213 temps); | 214 temps); |
214 return; | 215 return; |
215 } | 216 } |
216 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); | 217 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); |
217 InstructionOperand* val; | 218 InstructionOperand* val; |
218 if (rep == kMachineFloat64) { | 219 if (rep == rFloat64) { |
219 val = g.UseDoubleRegister(value); | 220 val = g.UseDoubleRegister(value); |
220 } else { | 221 } else { |
221 val = g.UseRegister(value); | 222 val = g.UseRegister(value); |
222 } | 223 } |
223 ArchOpcode opcode; | 224 ArchOpcode opcode; |
224 switch (rep) { | 225 switch (rep) { |
225 case kMachineFloat64: | 226 case rFloat64: |
226 opcode = kArm64Float64Store; | 227 opcode = kArm64Float64Store; |
227 break; | 228 break; |
228 case kMachineWord8: | 229 case rBit: // Fall through. |
| 230 case rWord8: |
229 opcode = kArm64StoreWord8; | 231 opcode = kArm64StoreWord8; |
230 break; | 232 break; |
231 case kMachineWord16: | 233 case rWord16: |
232 opcode = kArm64StoreWord16; | 234 opcode = kArm64StoreWord16; |
233 break; | 235 break; |
234 case kMachineWord32: | 236 case rWord32: |
235 opcode = kArm64StoreWord32; | 237 opcode = kArm64StoreWord32; |
236 break; | 238 break; |
237 case kMachineTagged: // Fall through. | 239 case rTagged: // Fall through. |
238 case kMachineWord64: | 240 case rWord64: |
239 opcode = kArm64StoreWord64; | 241 opcode = kArm64StoreWord64; |
240 break; | 242 break; |
241 default: | 243 default: |
242 UNREACHABLE(); | 244 UNREACHABLE(); |
243 return; | 245 return; |
244 } | 246 } |
245 if (g.CanBeImmediate(index, kLoadStoreImm)) { | 247 if (g.CanBeImmediate(index, kLoadStoreImm)) { |
246 Emit(opcode | AddressingModeField::encode(kMode_MRI), NULL, | 248 Emit(opcode | AddressingModeField::encode(kMode_MRI), NULL, |
247 g.UseRegister(base), g.UseImmediate(index), val); | 249 g.UseRegister(base), g.UseImmediate(index), val); |
248 } else if (g.CanBeImmediate(base, kLoadStoreImm)) { | 250 } else if (g.CanBeImmediate(base, kLoadStoreImm)) { |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 // Caller clean up of stack for C-style calls. | 660 // Caller clean up of stack for C-style calls. |
659 if (is_c_frame && aligned_push_count > 0) { | 661 if (is_c_frame && aligned_push_count > 0) { |
660 DCHECK(deoptimization == NULL && continuation == NULL); | 662 DCHECK(deoptimization == NULL && continuation == NULL); |
661 Emit(kArm64Drop | MiscField::encode(aligned_push_count), NULL); | 663 Emit(kArm64Drop | MiscField::encode(aligned_push_count), NULL); |
662 } | 664 } |
663 } | 665 } |
664 | 666 |
665 } // namespace compiler | 667 } // namespace compiler |
666 } // namespace internal | 668 } // namespace internal |
667 } // namespace v8 | 669 } // namespace v8 |
OLD | NEW |