Skip to content

Commit

Permalink
Fix branch-misses on Raspberry Pi 3B
Browse files Browse the repository at this point in the history
According to "Arm Cortex-A53 MPCore Processor Technical Reference
Manual", the data-processing instructions using the PC as a
destination register is not predicted. Replace the `MOV pc, ...`
with `BLX` or `POP` instruction.

Ref: #93
  • Loading branch information
vacantron committed Dec 16, 2023
1 parent 9408e2b commit 074aaf5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/arm-codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
emit(__movt(__AL, __r8, ph2_ir->src1 + 4));
emit(__add_r(__AL, __sp, __sp, __r8));
emit(__lw(__AL, __lr, __sp, -4));
emit(__mov_r(__AL, __pc, __lr));
emit(__blx(__AL, __lr));
return;
case OP_add:
emit(__add_r(__AL, rd, rn, rm));
Expand Down

0 comments on commit 074aaf5

Please sign in to comment.