5#ifndef RUNTIME_VM_SIMULATOR_RISCV_H_
6#define RUNTIME_VM_SIMULATOR_RISCV_H_
8#ifndef RUNTIME_VM_SIMULATOR_H_
9#error Do not include simulator_riscv.h directly; use simulator.h.
19class SimulatorSetjmpBuffer;
37 PreservedRegisters preserved;
38 PrepareCall(&preserved);
48 PreservedRegisters preserved;
49 PrepareCall(&preserved);
56 PreservedRegisters preserved;
57 PrepareCall(&preserved);
65 PreservedRegisters preserved;
66 PrepareCall(&preserved);
70 return get_fregd(
FA0);
76 PreservedRegisters preserved;
77 PrepareCall(&preserved);
82 return get_fregd(
FA0);
85 PreservedRegisters preserved;
86 PrepareCall(&preserved);
90 return get_fregd(
FA0);
93 PreservedRegisters preserved;
94 PrepareCall(&preserved);
97 return get_fregd(
FA0);
101 PreservedRegisters preserved;
102 SavePreservedRegisters(&preserved);
106 return get_fregs(
FA0);
112 PreservedRegisters preserved;
113 PrepareCall(&preserved);
114 set_fregs(
FA0, arg0);
115 set_fregs(
FA1, arg1);
116 set_fregs(
FA2, arg2);
118 return get_fregs(
FA0);
121 PreservedRegisters preserved;
122 PrepareCall(&preserved);
124 set_fregs(
FA0, arg1);
126 return get_fregs(
FA0);
129 PreservedRegisters preserved;
130 PrepareCall(&preserved);
131 set_fregd(
FA0, arg0);
133 return get_fregs(
FA0);
145 bool fp_return =
false,
146 bool fp_args =
false);
185 struct PreservedRegisters {
189 void PrepareCall(PreservedRegisters* preserved);
190 void ClobberVolatileRegisters();
191 void SavePreservedRegisters(PreservedRegisters* preserved);
192 void CheckPreservedRegisters(PreservedRegisters* preserved);
193 void RunCall(intx_t
function, PreservedRegisters* preserved);
195 void Interpret(
Instr instr);
196 void Interpret(
CInstr instr);
197 void InterpretLUI(
Instr instr);
198 void InterpretAUIPC(
Instr instr);
199 void InterpretJAL(
Instr instr);
200 void InterpretJALR(
Instr instr);
201 void InterpretBRANCH(
Instr instr);
202 void InterpretLOAD(
Instr instr);
203 void InterpretSTORE(
Instr instr);
204 void InterpretOPIMM(
Instr instr);
205 void InterpretOPIMM32(
Instr instr);
206 void InterpretOP(
Instr instr);
207 void InterpretOP_0(
Instr instr);
208 void InterpretOP_SUB(
Instr instr);
209 void InterpretOP_MULDIV(
Instr instr);
210 void InterpretOP_SHADD(
Instr instr);
211 void InterpretOP_MINMAXCLMUL(
Instr instr);
212 void InterpretOP_ROTATE(
Instr instr);
213 void InterpretOP_BCLRBEXT(
Instr instr);
214 void InterpretOP32(
Instr instr);
215 void InterpretOP32_0(
Instr instr);
216 void InterpretOP32_SUB(
Instr instr);
217 void InterpretOP32_MULDIV(
Instr instr);
218 void InterpretOP32_SHADD(
Instr instr);
219 void InterpretOP32_ADDUW(
Instr instr);
220 void InterpretOP32_ROTATE(
Instr instr);
221 void InterpretMISCMEM(
Instr instr);
222 void InterpretSYSTEM(
Instr instr);
223 void InterpretECALL(
Instr instr);
224 void InterpretEBREAK(
Instr instr);
225 void InterpretEBREAK(
CInstr instr);
226 void InterpretAMO(
Instr instr);
227 void InterpretAMO8(
Instr instr);
228 void InterpretAMO16(
Instr instr);
229 void InterpretAMO32(
Instr instr);
230 void InterpretAMO64(
Instr instr);
231 template <
typename type>
232 void InterpretLR(
Instr instr);
233 template <
typename type>
234 void InterpretSC(
Instr instr);
235 template <
typename type>
236 void InterpretAMOSWAP(
Instr instr);
237 template <
typename type>
238 void InterpretAMOADD(
Instr instr);
239 template <
typename type>
240 void InterpretAMOXOR(
Instr instr);
241 template <
typename type>
242 void InterpretAMOAND(
Instr instr);
243 template <
typename type>
244 void InterpretAMOOR(
Instr instr);
245 template <
typename type>
246 void InterpretAMOMIN(
Instr instr);
247 template <
typename type>
248 void InterpretAMOMAX(
Instr instr);
249 template <
typename type>
250 void InterpretAMOMINU(
Instr instr);
251 template <
typename type>
252 void InterpretAMOMAXU(
Instr instr);
253 template <
typename type>
254 void InterpretLOADORDERED(
Instr instr);
255 template <
typename type>
256 void InterpretSTOREORDERED(
Instr instr);
257 void InterpretLOADFP(
Instr instr);
258 void InterpretSTOREFP(
Instr instr);
259 void InterpretFMADD(
Instr instr);
260 void InterpretFMSUB(
Instr instr);
261 void InterpretFNMADD(
Instr instr);
262 void InterpretFNMSUB(
Instr instr);
263 void InterpretOPFP(
Instr instr);
264 DART_NORETURN
void IllegalInstruction(
Instr instr);
265 DART_NORETURN
void IllegalInstruction(
CInstr instr);
267 template <
typename type>
269 template <
typename type>
272 intx_t CSRRead(uint16_t csr);
273 void CSRWrite(uint16_t csr, intx_t
value);
274 void CSRSet(uint16_t csr, intx_t mask);
275 void CSRClear(uint16_t csr, intx_t mask);
277 uintx_t get_xreg(
Register rs)
const {
return xregs_[rs]; }
284 double get_fregd(
FRegister rs)
const {
return fregs_[rs]; }
287 static constexpr uint64_t kNaNBox = 0xFFFFFFFF00000000;
290 uint64_t bits64 = bit_cast<uint64_t>(fregs_[rs]);
291 if ((bits64 & kNaNBox) != kNaNBox) {
294 return bit_cast<float>(0x7fc00000);
296 uint32_t bits32 =
static_cast<uint32_t
>(bits64);
297 return bit_cast<float>(bits32);
300 uint32_t bits32 = bit_cast<uint32_t>(
value);
301 uint64_t bits64 =
static_cast<uint64_t
>(bits32);
303 fregs_[rd] = bit_cast<double>(bits64);
308 static constexpr uword kBadLR = -1;
313 static constexpr uword kEndSimulatingPC = -2;
321 uintx_t reserved_address_;
322 uintx_t reserved_value_;
331 uword overflow_stack_limit_;
336 static bool IsIllegalAddress(
uword addr) {
return addr < 64 * 1024; }
340 void ExecuteNoTrace();
344 bool IsTracingExecution()
const;
349 last_setjmp_buffer_ =
buffer;
double CallD(intx_t function, double arg0, double arg1=0.0, double arg2=0.0)
double CallD(intx_t function, intx_t arg0, intx_t arg1=0)
double CallD(intx_t function, float arg0)
uintx_t get_register(Register rs) const
float CallF(intx_t function, float arg0, float arg1=0.0f, float arg2=0.0f)
static uword RedirectExternalReference(uword function, CallKind call_kind, int argument_count)
void JumpToFrame(uword pc, uword sp, uword fp, Thread *thread)
friend class SimulatorSetjmpBuffer
float CallF(intx_t function, double arg0)
static Simulator * Current()
uint64_t get_icount() const
intx_t CallI(intx_t function, double arg0, double arg1=0.0)
int64_t Call(intx_t entry, intx_t parameter0, intx_t parameter1, intx_t parameter2, intx_t parameter3, bool fp_return=false, bool fp_args=false)
uword overflow_stack_limit() const
intx_t CallX(intx_t function, intx_t arg0=0, intx_t arg1=0, intx_t arg2=0, intx_t arg3=0)
uword stack_limit() const
static constexpr uword kSimulatorStackUnderflowSize
float CallF(intx_t function, intx_t arg0, intx_t arg1=0)
intx_t CallI(intx_t function, float arg0, float arg1=0.0f)
float CallF(intx_t function, intx_t arg0, float arg1)
double CallD(intx_t function, intx_t arg0, double arg1)
static uword FunctionForRedirect(uword redirect)
Dart_NativeFunction function
const int kNumberOfFpuRegisters
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer