OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Declares a Simulator for ARM instructions if we are not generating a native | 5 // Declares a Simulator for ARM instructions if we are not generating a native |
6 // ARM binary. This Simulator allows us to run and debug ARM code generation on | 6 // ARM binary. This Simulator allows us to run and debug ARM code generation on |
7 // regular desktop machines. | 7 // regular desktop machines. |
8 // Dart calls into generated code by "calling" the InvokeDartCode stub, | 8 // Dart calls into generated code by "calling" the InvokeDartCode stub, |
9 // which will start execution in the Simulator or forwards to the real entry | 9 // which will start execution in the Simulator or forwards to the real entry |
10 // on a ARM HW platform. | 10 // on a ARM HW platform. |
11 | 11 |
12 #ifndef VM_SIMULATOR_ARM_H_ | 12 #ifndef VM_SIMULATOR_ARM_H_ |
13 #define VM_SIMULATOR_ARM_H_ | 13 #define VM_SIMULATOR_ARM_H_ |
14 | 14 |
15 #ifndef VM_SIMULATOR_H_ | 15 #ifndef VM_SIMULATOR_H_ |
16 #error Do not include simulator_arm.h directly; use simulator.h. | 16 #error Do not include simulator_arm.h directly; use simulator.h. |
17 #endif | 17 #endif |
18 | 18 |
19 #include "vm/constants_arm.h" | 19 #include "vm/constants_arm.h" |
20 #include "vm/object.h" | 20 #include "vm/object.h" |
21 | 21 |
22 namespace dart { | 22 namespace dart { |
23 | 23 |
24 class Isolate; | 24 class Isolate; |
25 class SimulatorSetjmpBuffer; | 25 class SimulatorSetjmpBuffer; |
26 | 26 |
| 27 typedef struct { |
| 28 union { |
| 29 uint32_t u; |
| 30 float f; |
| 31 } data_[4]; |
| 32 } simd_value_t; |
| 33 |
27 class Simulator { | 34 class Simulator { |
28 public: | 35 public: |
29 static const uword kSimulatorStackUnderflowSize = 64; | 36 static const uword kSimulatorStackUnderflowSize = 64; |
30 | 37 |
31 Simulator(); | 38 Simulator(); |
32 ~Simulator(); | 39 ~Simulator(); |
33 | 40 |
34 // The currently executing Simulator instance, which is associated to the | 41 // The currently executing Simulator instance, which is associated to the |
35 // current isolate | 42 // current isolate |
36 static Simulator* Current(); | 43 static Simulator* Current(); |
37 | 44 |
38 // Accessors for register state. Reading the pc value adheres to the ARM | 45 // Accessors for register state. Reading the pc value adheres to the ARM |
39 // architecture specification and is off by 8 from the currently executing | 46 // architecture specification and is off by 8 from the currently executing |
40 // instruction. | 47 // instruction. |
41 void set_register(Register reg, int32_t value); | 48 void set_register(Register reg, int32_t value); |
42 int32_t get_register(Register reg) const; | 49 int32_t get_register(Register reg) const; |
43 | 50 |
44 // Special case of set_register and get_register to access the raw PC value. | 51 // Special case of set_register and get_register to access the raw PC value. |
45 void set_pc(int32_t value); | 52 void set_pc(int32_t value); |
46 int32_t get_pc() const; | 53 int32_t get_pc() const; |
47 | 54 |
48 // Accessors for VFP register state. | 55 // Accessors for VFP register state. |
49 void set_sregister(SRegister reg, float value); | 56 void set_sregister(SRegister reg, float value); |
50 float get_sregister(SRegister reg) const; | 57 float get_sregister(SRegister reg) const; |
51 void set_dregister(DRegister reg, double value); | 58 void set_dregister(DRegister reg, double value); |
52 double get_dregister(DRegister reg) const; | 59 double get_dregister(DRegister reg) const; |
| 60 void set_qregister(QRegister reg, simd_value_t value); |
| 61 simd_value_t get_qregister(QRegister reg) const; |
53 | 62 |
54 // When moving integer (rather than floating point) values to/from | 63 // When moving integer (rather than floating point) values to/from |
55 // the FPU registers, use the _bits calls to avoid gcc taking liberties with | 64 // the FPU registers, use the _bits calls to avoid gcc taking liberties with |
56 // integers that map to such things as NaN floating point values. | 65 // integers that map to such things as NaN floating point values. |
57 void set_sregister_bits(SRegister reg, int32_t value); | 66 void set_sregister_bits(SRegister reg, int32_t value); |
58 int32_t get_sregister_bits(SRegister reg) const; | 67 int32_t get_sregister_bits(SRegister reg) const; |
59 void set_dregister_bits(DRegister reg, int64_t value); | 68 void set_dregister_bits(DRegister reg, int64_t value); |
60 int64_t get_dregister_bits(DRegister reg) const; | 69 int64_t get_dregister_bits(DRegister reg) const; |
61 | 70 |
62 // Accessor to the internal simulator stack top. | 71 // Accessor to the internal simulator stack top. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 static const uword kEndSimulatingPC = -2; | 128 static const uword kEndSimulatingPC = -2; |
120 | 129 |
121 // CPU state. | 130 // CPU state. |
122 int32_t registers_[kNumberOfCpuRegisters]; | 131 int32_t registers_[kNumberOfCpuRegisters]; |
123 bool n_flag_; | 132 bool n_flag_; |
124 bool z_flag_; | 133 bool z_flag_; |
125 bool c_flag_; | 134 bool c_flag_; |
126 bool v_flag_; | 135 bool v_flag_; |
127 | 136 |
128 // VFP state. | 137 // VFP state. |
129 union { // S and D register banks are overlapping. | 138 union { // S, D, and Q register banks are overlapping. |
130 int32_t sregisters_[kNumberOfSRegisters]; | 139 int32_t sregisters_[kNumberOfSRegisters]; |
131 int64_t dregisters_[kNumberOfDRegisters]; | 140 int64_t dregisters_[kNumberOfDRegisters]; |
| 141 simd_value_t qregisters_[kNumberOfQRegisters]; |
132 }; | 142 }; |
133 bool fp_n_flag_; | 143 bool fp_n_flag_; |
134 bool fp_z_flag_; | 144 bool fp_z_flag_; |
135 bool fp_c_flag_; | 145 bool fp_c_flag_; |
136 bool fp_v_flag_; | 146 bool fp_v_flag_; |
137 | 147 |
138 // Simulator support. | 148 // Simulator support. |
139 char* stack_; | 149 char* stack_; |
140 bool pc_modified_; | 150 bool pc_modified_; |
141 int icount_; | 151 int icount_; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 static bool HasExclusiveAccessAndOpen(uword addr); | 241 static bool HasExclusiveAccessAndOpen(uword addr); |
232 | 242 |
233 // Executing is handled based on the instruction type. | 243 // Executing is handled based on the instruction type. |
234 void DecodeType01(Instr* instr); // Both type 0 and type 1 rolled into one. | 244 void DecodeType01(Instr* instr); // Both type 0 and type 1 rolled into one. |
235 void DecodeType2(Instr* instr); | 245 void DecodeType2(Instr* instr); |
236 void DecodeType3(Instr* instr); | 246 void DecodeType3(Instr* instr); |
237 void DecodeType4(Instr* instr); | 247 void DecodeType4(Instr* instr); |
238 void DecodeType5(Instr* instr); | 248 void DecodeType5(Instr* instr); |
239 void DecodeType6(Instr* instr); | 249 void DecodeType6(Instr* instr); |
240 void DecodeType7(Instr* instr); | 250 void DecodeType7(Instr* instr); |
| 251 void DecodeSIMDDataProcessing(Instr* instr); |
241 | 252 |
242 // Executes one instruction. | 253 // Executes one instruction. |
243 void InstructionDecode(Instr* instr); | 254 void InstructionDecode(Instr* instr); |
244 | 255 |
245 // Executes ARM instructions until the PC reaches kEndSimulatingPC. | 256 // Executes ARM instructions until the PC reaches kEndSimulatingPC. |
246 void Execute(); | 257 void Execute(); |
247 | 258 |
248 // Longjmp support for exceptions. | 259 // Longjmp support for exceptions. |
249 SimulatorSetjmpBuffer* last_setjmp_buffer() { | 260 SimulatorSetjmpBuffer* last_setjmp_buffer() { |
250 return last_setjmp_buffer_; | 261 return last_setjmp_buffer_; |
251 } | 262 } |
252 void set_last_setjmp_buffer(SimulatorSetjmpBuffer* buffer) { | 263 void set_last_setjmp_buffer(SimulatorSetjmpBuffer* buffer) { |
253 last_setjmp_buffer_ = buffer; | 264 last_setjmp_buffer_ = buffer; |
254 } | 265 } |
255 | 266 |
256 friend class SimulatorDebugger; | 267 friend class SimulatorDebugger; |
257 friend class SimulatorSetjmpBuffer; | 268 friend class SimulatorSetjmpBuffer; |
258 DISALLOW_COPY_AND_ASSIGN(Simulator); | 269 DISALLOW_COPY_AND_ASSIGN(Simulator); |
259 }; | 270 }; |
260 | 271 |
261 } // namespace dart | 272 } // namespace dart |
262 | 273 |
263 #endif // VM_SIMULATOR_ARM_H_ | 274 #endif // VM_SIMULATOR_ARM_H_ |
OLD | NEW |