@@ -142,7 +142,9 @@ RVOP(
142
142
if (ir -> rd )
143
143
rv -> X [ir -> rd ] = pc + 4 ;
144
144
/* check instruction misaligned */
145
+ #if !RV32_HAS (EXT_C )
145
146
RV_EXC_MISALIGN_HANDLER (pc , insn , false, 0 );
147
+ #endif
146
148
struct rv_insn * taken = ir -> branch_taken ;
147
149
if (taken ) {
148
150
#if RV32_HAS (JIT )
@@ -213,7 +215,9 @@ RVOP(
213
215
if (ir -> rd )
214
216
rv -> X [ir -> rd ] = pc + 4 ;
215
217
/* check instruction misaligned */
218
+ #if !RV32_HAS (EXT_C )
216
219
RV_EXC_MISALIGN_HANDLER (pc , insn , false, 0 );
220
+ #endif
217
221
#if !RV32_HAS (JIT )
218
222
LOOKUP_OR_UPDATE_BRANCH_HISTORY_TABLE ();
219
223
#endif
@@ -238,51 +242,54 @@ RVOP(
238
242
(type) x cond (type) y
239
243
/* clang-format on */
240
244
241
- #define BRANCH_FUNC (type , cond ) \
242
- const uint32_t pc = PC; \
243
- if (BRANCH_COND(type, rv->X[ir->rs1], rv->X[ir->rs2], cond)) { \
244
- is_branch_taken = false; \
245
- struct rv_insn *untaken = ir->branch_untaken; \
246
- if (!untaken) \
247
- goto nextop; \
248
- IIF(RV32_HAS(JIT)) \
249
- ({ \
250
- block_t *block = cache_get(rv->block_cache, PC + 4); \
251
- if (!block) { \
252
- ir->branch_untaken = NULL; \
253
- goto nextop; \
254
- } \
255
- untaken = ir->branch_untaken = block->ir_head; \
256
- if (cache_hot(rv->block_cache, PC + 4)) \
257
- goto nextop; \
258
- }, ); \
259
- PC += 4; \
260
- last_pc = PC; \
261
- MUST_TAIL return untaken->impl(rv, untaken, cycle, PC); \
262
- } \
263
- is_branch_taken = true; \
264
- PC += ir->imm; \
265
- /* check instruction misaligned */ \
266
- RV_EXC_MISALIGN_HANDLER (pc , insn , false, 0 ); \
267
- struct rv_insn * taken = ir -> branch_taken ; \
268
- if (taken ) { \
269
- IIF (RV32_HAS (JIT )) \
270
- ({ \
271
- block_t * block = cache_get (rv -> block_cache , PC ); \
272
- if (!block ) { \
273
- ir -> branch_taken = NULL ; \
274
- goto end_insn ; \
275
- } \
276
- taken = ir -> branch_taken = block -> ir_head ; \
277
- if (cache_hot (rv -> block_cache , PC )) \
278
- goto end_insn ; \
279
- }, ); \
280
- last_pc = PC ; \
281
- MUST_TAIL return taken -> impl (rv , taken , cycle , PC ); \
282
- } \
283
- end_insn : \
284
- rv -> csr_cycle = cycle ; \
285
- rv -> PC = PC ; \
245
+ #define BRANCH_FUNC (type , cond ) \
246
+ IIF(RV32_HAS(EXT_C)) \
247
+ (, const uint32_t pc = \
248
+ PC;) if (BRANCH_COND(type, rv->X[ir->rs1], rv->X[ir->rs2], cond)) \
249
+ { \
250
+ is_branch_taken = false; \
251
+ struct rv_insn *untaken = ir->branch_untaken; \
252
+ if (!untaken) \
253
+ goto nextop; \
254
+ IIF(RV32_HAS(JIT)) \
255
+ ({ \
256
+ block_t *block = cache_get(rv->block_cache, PC + 4); \
257
+ if (!block) { \
258
+ ir->branch_untaken = NULL; \
259
+ goto nextop; \
260
+ } \
261
+ untaken = ir->branch_untaken = block->ir_head; \
262
+ if (cache_hot(rv->block_cache, PC + 4)) \
263
+ goto nextop; \
264
+ }, ); \
265
+ PC += 4; \
266
+ last_pc = PC; \
267
+ MUST_TAIL return untaken->impl(rv, untaken, cycle, PC); \
268
+ } \
269
+ is_branch_taken = true; \
270
+ PC += ir->imm; \
271
+ /* check instruction misaligned */ \
272
+ IIF (RV32_HAS (EXT_C )) \
273
+ (, RV_EXC_MISALIGN_HANDLER (pc , insn , false, 0 );) struct rv_insn * taken = \
274
+ ir -> branch_taken ; \
275
+ if (taken ) { \
276
+ IIF (RV32_HAS (JIT )) \
277
+ ({ \
278
+ block_t * block = cache_get (rv -> block_cache , PC ); \
279
+ if (!block ) { \
280
+ ir -> branch_taken = NULL ; \
281
+ goto end_insn ; \
282
+ } \
283
+ taken = ir -> branch_taken = block -> ir_head ; \
284
+ if (cache_hot (rv -> block_cache , PC )) \
285
+ goto end_insn ; \
286
+ }, ); \
287
+ last_pc = PC ; \
288
+ MUST_TAIL return taken -> impl (rv , taken , cycle , PC ); \
289
+ } \
290
+ end_insn : \
291
+ rv -> csr_cycle = cycle ; \
292
+ rv -> PC = PC ; \
286
293
return true;
287
294
288
295
/* In RV32I and RV64I, if the branch is taken, set pc = pc + offset, where
@@ -1815,7 +1822,6 @@ RVOP(
1815
1822
{
1816
1823
rv -> X [rv_reg_ra ] = PC + 2 ;
1817
1824
PC += ir -> imm ;
1818
- RV_EXC_MISALIGN_HANDLER (PC , insn , true, 0 );
1819
1825
struct rv_insn * taken = ir -> branch_taken ;
1820
1826
if (taken ) {
1821
1827
#if RV32_HAS (JIT )
@@ -1981,7 +1987,6 @@ RVOP(
1981
1987
cj ,
1982
1988
{
1983
1989
PC += ir -> imm ;
1984
- RV_EXC_MISALIGN_HANDLER (PC , insn , true, 0 );
1985
1990
struct rv_insn * taken = ir -> branch_taken ;
1986
1991
if (taken ) {
1987
1992
#if RV32_HAS (JIT )
@@ -2158,7 +2163,6 @@ RVOP(
2158
2163
clwsp ,
2159
2164
{
2160
2165
const uint32_t addr = rv -> X [rv_reg_sp ] + ir -> imm ;
2161
- RV_EXC_MISALIGN_HANDLER (3 , load , true, 1 );
2162
2166
rv -> X [ir -> rd ] = rv -> io .mem_read_w (addr );
2163
2167
},
2164
2168
GEN ({
@@ -2224,7 +2228,6 @@ RVOP(
2224
2228
const int32_t jump_to = rv -> X [ir -> rs1 ];
2225
2229
rv -> X [rv_reg_ra ] = PC + 2 ;
2226
2230
PC = jump_to ;
2227
- RV_EXC_MISALIGN_HANDLER (PC , insn , true, 0 );
2228
2231
#if !RV32_HAS (JIT )
2229
2232
LOOKUP_OR_UPDATE_BRANCH_HISTORY_TABLE ();
2230
2233
#endif
@@ -2262,7 +2265,6 @@ RVOP(
2262
2265
cswsp ,
2263
2266
{
2264
2267
const uint32_t addr = rv -> X [rv_reg_sp ] + ir -> imm ;
2265
- RV_EXC_MISALIGN_HANDLER (3 , store , true, 1 );
2266
2268
rv -> io .mem_write_w (addr , rv -> X [ir -> rs2 ]);
2267
2269
},
2268
2270
GEN ({
0 commit comments