Skip to content

Commit

Permalink
Fix RVC instructions with missing zeroes
Browse files Browse the repository at this point in the history
A handful of compressed instructions seem to have zeroes missing
from their `*_raw` encoding format string.
This leads to incorrect encoding,
such as what was intended as a `c_srai64`
actually being encoded as a `c_addi`.
  • Loading branch information
elliotb-lowrisc authored and PeterRugg committed Apr 17, 2024
1 parent cc0c883 commit 8bd8432
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/RISCV/RV_C.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ c_addi16sp_raw = "011 nzimm[9] 00010 nzimm[
c_addi16sp nzimm = encode c_addi16sp_raw nzimm
c_lui_raw = "011 nzimm[17] rd_nz_n2[4:0] nzimm[16:12] 01"
c_lui rd_nz_n2 nzimm = encode c_lui_raw nzimm rd_nz_n2
c_srli64_raw = "100 0 00 rs1'_rd'[2:0] 0 01"
c_srli64_raw = "100 0 00 rs1'_rd'[2:0] 00000 01"
c_srli64 rs1'_rd' = encode c_srli64_raw rs1'_rd'
c_srli_raw = "100 nzuimm[5] 00 rs1'_rd'[2:0] nzuimm[4:0] 01"
c_srli rs1'_rd' nzuimm = encode c_srli_raw nzuimm rs1'_rd'
c_srai64_raw = "100 0 01 rs1'_rd'[2:0] 0 01"
c_srai64_raw = "100 0 01 rs1'_rd'[2:0] 00000 01"
c_srai64 rs1'_rd' = encode c_srai64_raw rs1'_rd'
c_srai_raw = "100 nzuimm[5] 01 rs1'_rd'[2:0] nzuimm[4:0] 01"
c_srai rs1'_rd' nzuimm = encode c_srai_raw nzuimm rs1'_rd'
Expand Down Expand Up @@ -175,7 +175,7 @@ c_beqz_raw = "110 imm[8] imm[4:3] rs1'[2
c_beqz rs1' imm = encode c_beqz_raw imm rs1'
c_bnez_raw = "111 imm[8] imm[4:3] rs1'[2:0] imm[7:6] imm[2:1] imm[5] 01"
c_bnez rs1' imm = encode c_bnez_raw imm rs1'
c_slli64_raw = "000 0 rs1_rd_nz[4:0] 0 10"
c_slli64_raw = "000 0 rs1_rd_nz[4:0] 00000 10"
c_slli64 rs1_rd_nz = encode c_slli64_raw rs1_rd_nz
c_slli_raw = "000 nzuimm[5] rs1_rd_nz[4:0] nzuimm[4:0] 10"
c_slli rs1_rd_nz nzuimm = encode c_slli_raw nzuimm rs1_rd_nz
Expand All @@ -189,13 +189,13 @@ c_flwsp_raw = "011 uimm[5] rd[4:
c_flwsp rd uimm = encode c_flwsp_raw uimm rd
c_ldsp_raw = "011 uimm[5] rd_nz[4:0] uimm[4:2] uimm[7:6] 10"
c_ldsp rd_nz uimm = encode c_ldsp_raw uimm rd_nz
c_jr_raw = "100 0 rs1_nz[4:0] 0 10"
c_jr_raw = "100 0 rs1_nz[4:0] 00000 10"
c_jr rs1_nz = encode c_jr_raw rs1_nz
c_mv_raw = "100 0 rd_nz[4:0] rs2_nz[4:0] 10"
c_mv rd_nz rs2_nz = encode c_mv_raw rd_nz rs2_nz
c_ebreak_raw = "100 1 0 0 10"
c_ebreak_raw = "100 1 00000 00000 10"
c_ebreak = encode c_ebreak_raw
c_jalr_raw = "100 1 rs1_nz[4:0] 0 10"
c_jalr_raw = "100 1 rs1_nz[4:0] 00000 10"
c_jalr rs1_nz = encode c_jalr_raw rs1_nz
c_add_raw = "100 1 rs1_rd_nz[4:0] rs2_nz[4:0] 10"
c_add rs1_rd_nz rs2_nz = encode c_add_raw rs1_rd_nz rs2_nz
Expand Down

0 comments on commit 8bd8432

Please sign in to comment.