Skip to content

Commit

Permalink
Expand "j_s symb" to "jump symb, x31" assembly pseudo-instruction
Browse files Browse the repository at this point in the history
As suggested by Léo Gourdin in #437.

The previous expansion as a plain "j" instruction fails when the jump
offset is too large to be represented (issue #436).

Fixes: #436
Closes: #437
  • Loading branch information
xavierleroy committed Jun 24, 2022
1 parent 44a668f commit a34adc8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Usability:
trigger only if parameters were declared.)
- Check (and warn if requested) for arguments of struct/union types passed
to a variable-argument function.

Bug fixes:
- RISC-V: fixed an error in the modeling of float32 <-> float64 conversions
when the argument is a NaN (#428).
Expand All @@ -29,6 +29,8 @@ Bug fixes:
in correct but different allocations.)
- Hardened the configure script against Cygwin installations that produce
\r\n for end-of-lines (#434).
- RISC-V: tail calls to far-away functions were causing link-time errors
(#436, #437).

Coq development:
- Updated the Flocq library to version 4.1.
Expand Down
2 changes: 1 addition & 1 deletion riscV/Asm.v
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ Definition exec_instr (f: function) (i: instruction) (rs: regset) (m: mem) : out
| Pj_l l =>
goto_label f l rs m
| Pj_s s sg =>
Next (rs#PC <- (Genv.symbol_address ge s Ptrofs.zero)) m
Next (rs#PC <- (Genv.symbol_address ge s Ptrofs.zero) #X31 <- Vundef) m
| Pj_r r sg =>
Next (rs#PC <- (rs#r)) m
| Pjal_s s sg =>
Expand Down
1 change: 1 addition & 0 deletions riscV/Asmgenproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ Local Transparent destroyed_by_op.
(* match states *)
econstructor; eauto.
apply agree_set_other; auto with asmgen.
apply agree_set_other; auto with asmgen.
Simpl. unfold Genv.symbol_address. rewrite symbols_preserved. rewrite H. auto.

- (* Mbuiltin *)
Expand Down
4 changes: 1 addition & 3 deletions riscV/TargetPrinter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,10 @@ module Target : TARGET =
fprintf oc " sra %a, %a, %a\n" ireg rd ireg0 rs1 ireg0 rs2

(* Unconditional jumps. Links are always to X1/RA. *)
(* TODO: fix up arguments for calls to variadics, to move *)
(* floating point arguments to integer registers. How? *)
| Pj_l(l) ->
fprintf oc " j %a\n" print_label l
| Pj_s(s, sg) ->
fprintf oc " j %a\n" symbol s
fprintf oc " jump %a, x31\n" symbol s
| Pj_r(r, sg) ->
fprintf oc " jr %a\n" ireg r
| Pjal_s(s, sg) ->
Expand Down

0 comments on commit a34adc8

Please sign in to comment.