Skip to content

Commit

Permalink
Add names for cext instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Linda-Njau committed Aug 14, 2024
1 parent d726e29 commit ac4dcf4
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion model/riscv_insts_cext.sail
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

/* ****************************************************************** */
$[name "no operation (compressed)"]
union clause ast = C_NOP : unit

mapping clause encdec_compressed = C_NOP() if extension("C")
Expand All @@ -25,7 +26,7 @@ function clause execute C_NOP() = RETIRE_SUCCESS
mapping clause assembly = C_NOP() <-> "c.nop"

/* ****************************************************************** */

$[name "add zero_extend non-zero immediate scaled by 4 to stack pointer (compressed)"]
union clause ast = C_ADDI4SPN : (cregidx, bits(8))

mapping clause encdec_compressed = C_ADDI4SPN(rd, nz96 @ nz54 @ nz3 @ nz2)
Expand All @@ -45,6 +46,7 @@ mapping clause assembly = C_ADDI4SPN(rdc, nzimm)
if nzimm != 0b00000000

/* ****************************************************************** */
$[name "load word (compressed)"]
union clause ast = C_LW : (bits(5), cregidx, cregidx)

mapping clause encdec_compressed = C_LW(ui6 @ ui53 @ ui2, rs1, rd) if extension("C")
Expand All @@ -61,6 +63,7 @@ mapping clause assembly = C_LW(uimm, rsc, rdc)
<-> "c.lw" ^ spc() ^ creg_name(rdc) ^ sep() ^ creg_name(rsc) ^ sep() ^ hex_bits_7(uimm @ 0b00)

/* ****************************************************************** */
$[name "load double-word (compressed)"]
union clause ast = C_LD : (bits(5), cregidx, cregidx)

mapping clause encdec_compressed = C_LD(ui76 @ ui53, rs1, rd)
Expand All @@ -81,6 +84,7 @@ mapping clause assembly = C_LD(uimm, rsc, rdc)
if sizeof(xlen) == 64

/* ****************************************************************** */
$[name "store word (compressed)"]
union clause ast = C_SW : (bits(5), cregidx, cregidx)

mapping clause encdec_compressed = C_SW(ui6 @ ui53 @ ui2, rs1, rs2) if extension("C")
Expand All @@ -97,6 +101,7 @@ mapping clause assembly = C_SW(uimm, rsc1, rsc2)
<-> "c.sw" ^ spc() ^ creg_name(rsc1) ^ sep() ^ creg_name(rsc2) ^ sep() ^ hex_bits_7(uimm @ 0b00)

/* ****************************************************************** */
$[name "store double-word (compressed)"]
union clause ast = C_SD : (bits(5), cregidx, cregidx)

mapping clause encdec_compressed = C_SD(ui76 @ ui53, rs1, rs2)
Expand All @@ -117,6 +122,7 @@ mapping clause assembly = C_SD(uimm, rsc1, rsc2)
if sizeof(xlen) == 64

/* ****************************************************************** */
$[name "add immediate (compressed)"]
union clause ast = C_ADDI : (bits(6), regidx)

mapping clause encdec_compressed = C_ADDI(nzi5 @ nzi40, rsd)
Expand All @@ -135,6 +141,7 @@ mapping clause assembly = C_ADDI(nzi, rsd)
if nzi != 0b000000 & rsd != zreg

/* ****************************************************************** */
$[name "jump and link (compressed)"]
union clause ast = C_JAL : (bits(11))

mapping clause encdec_compressed = C_JAL(i11 @ i10 @ i98 @ i7 @ i6 @ i5 @ i4 @ i31)
Expand All @@ -151,6 +158,7 @@ mapping clause assembly = C_JAL(imm)
if sizeof(xlen) == 32

/* ****************************************************************** */
$[name "add immediate word (compressed)"]
union clause ast = C_ADDIW : (bits(6), regidx)

mapping clause encdec_compressed = C_ADDIW(imm5 @ imm40, rsd)
Expand All @@ -167,6 +175,7 @@ mapping clause assembly = C_ADDIW(imm, rsd)
if sizeof(xlen) == 64

/* ****************************************************************** */
$[name "load immediate (compressed)"]
union clause ast = C_LI : (bits(6), regidx)

mapping clause encdec_compressed = C_LI(imm5 @ imm40, rd)
Expand All @@ -185,6 +194,7 @@ mapping clause assembly = C_LI(imm, rd)
if rd != zreg

/* ****************************************************************** */
$[name "add non-zero sign-extended immediate scaled by 16 to stack pointer(compressed)"]
union clause ast = C_ADDI16SP : (bits(6))

mapping clause encdec_compressed = C_ADDI16SP(nzi9 @ nzi87 @ nzi6 @ nzi5 @ nzi4)
Expand All @@ -203,6 +213,7 @@ mapping clause assembly = C_ADDI16SP(imm)
if imm != 0b000000

/* ****************************************************************** */
$[name "load upper immediate (compressed)"]
union clause ast = C_LUI : (bits(6), regidx)

mapping clause encdec_compressed = C_LUI(imm17 @ imm1612, rd)
Expand All @@ -221,6 +232,7 @@ mapping clause assembly = C_LUI(imm, rd)
if rd != zreg & rd != sp & imm != 0b000000

/* ****************************************************************** */
$[name "shift immediate (compressed)"]
union clause ast = C_SRLI : (bits(6), cregidx)

mapping clause encdec_compressed = C_SRLI(nzui5 @ nzui40, rsd)
Expand All @@ -239,6 +251,7 @@ mapping clause assembly = C_SRLI(shamt, rsd)
if shamt != 0b000000

/* ****************************************************************** */
$[name "shift immediate (compressed)"]
union clause ast = C_SRAI : (bits(6), cregidx)

mapping clause encdec_compressed = C_SRAI(nzui5 @ nzui40, rsd)
Expand All @@ -257,6 +270,7 @@ mapping clause assembly = C_SRAI(shamt, rsd)
if shamt != 0b000000

/* ****************************************************************** */
$[name "AND immediate (compressed)"]
union clause ast = C_ANDI : (bits(6), cregidx)

mapping clause encdec_compressed = C_ANDI(i5 @ i40, rsd) if extension("C")
Expand All @@ -271,6 +285,7 @@ mapping clause assembly = C_ANDI(imm, rsd)
<-> "c.andi" ^ spc() ^ creg_name(rsd) ^ sep() ^ hex_bits_signed_6(imm)

/* ****************************************************************** */
$[name "subtract (compressed)"]
union clause ast = C_SUB : (cregidx, cregidx)

mapping clause encdec_compressed = C_SUB(rsd, rs2) if extension("C")
Expand All @@ -286,6 +301,7 @@ mapping clause assembly = C_SUB(rsd, rs2)
<-> "c.sub" ^ spc() ^ creg_name(rsd) ^ sep() ^ creg_name(rs2)

/* ****************************************************************** */
$[name "exclusive OR (compressed)"]
union clause ast = C_XOR : (cregidx, cregidx)

mapping clause encdec_compressed = C_XOR(rsd, rs2) if extension("C")
Expand All @@ -301,6 +317,7 @@ mapping clause assembly = C_XOR(rsd, rs2)
<-> "c.xor" ^ spc() ^ creg_name(rsd) ^ sep() ^ creg_name(rs2)

/* ****************************************************************** */
$[name "OR (compressed)"]
union clause ast = C_OR : (cregidx, cregidx)

mapping clause encdec_compressed = C_OR(rsd, rs2) if extension("C")
Expand All @@ -316,6 +333,7 @@ mapping clause assembly = C_OR(rsd, rs2)
<-> "c.or" ^ spc() ^ creg_name(rsd) ^ sep() ^ creg_name(rs2)

/* ****************************************************************** */
$[name "AND (compressed)"]
union clause ast = C_AND : (cregidx, cregidx)

mapping clause encdec_compressed = C_AND(rsd, rs2) if extension("C")
Expand All @@ -331,6 +349,7 @@ mapping clause assembly = C_AND(rsd, rs2)
<-> "c.and" ^ spc() ^ creg_name(rsd) ^ sep() ^ creg_name(rs2)

/* ****************************************************************** */
$[name "subtract word (compressed)"]
union clause ast = C_SUBW : (cregidx, cregidx)

mapping clause encdec_compressed = C_SUBW(rsd, rs2)
Expand All @@ -350,6 +369,7 @@ mapping clause assembly = C_SUBW(rsd, rs2)
if sizeof(xlen) == 64

/* ****************************************************************** */
$[name "add word (compressed)"]
union clause ast = C_ADDW : (cregidx, cregidx)

mapping clause encdec_compressed = C_ADDW(rsd, rs2)
Expand All @@ -369,6 +389,7 @@ mapping clause assembly = C_ADDW(rsd, rs2)
if sizeof(xlen) == 64

/* ****************************************************************** */
$[name "jump (compressed)"]
union clause ast = C_J : (bits(11))

mapping clause encdec_compressed = C_J(i11 @ i10 @ i98 @ i7 @ i6 @ i5 @ i4 @ i31) if extension("C")
Expand All @@ -381,6 +402,7 @@ mapping clause assembly = C_J(imm)
<-> "c.j" ^ spc() ^ hex_bits_signed_11(imm)

/* ****************************************************************** */
$[name "branch if equal zero (compressed)"]
union clause ast = C_BEQZ : (bits(8), cregidx)

mapping clause encdec_compressed = C_BEQZ(i8 @ i76 @ i5 @ i43 @ i21, rs) if extension("C")
Expand All @@ -393,6 +415,7 @@ mapping clause assembly = C_BEQZ(imm, rs)
<-> "c.beqz" ^ spc() ^ creg_name(rs) ^ sep() ^ hex_bits_signed_8(imm)

/* ****************************************************************** */
$[name "branch if contain non-zero (compressed)"]
union clause ast = C_BNEZ : (bits(8), cregidx)

mapping clause encdec_compressed = C_BNEZ(i8 @ i76 @ i5 @ i43 @ i21, rs) if extension("C")
Expand All @@ -405,6 +428,7 @@ mapping clause assembly = C_BNEZ(imm, rs)
<-> "c.bnez" ^ spc() ^ creg_name(rs) ^ sep() ^ hex_bits_signed_8(imm)

/* ****************************************************************** */
$[name "shift immediate (compressed)"]
union clause ast = C_SLLI : (bits(6), regidx)

mapping clause encdec_compressed = C_SLLI(nzui5 @ nzui40, rsd)
Expand All @@ -421,6 +445,7 @@ mapping clause assembly = C_SLLI(shamt, rsd)
if shamt != 0b000000 & rsd != zreg

/* ****************************************************************** */
$[name "load word to stack pointer (compressed)"]
union clause ast = C_LWSP : (bits(6), regidx)

mapping clause encdec_compressed = C_LWSP(ui76 @ ui5 @ ui42, rd)
Expand All @@ -439,6 +464,7 @@ mapping clause assembly = C_LWSP(uimm, rd)
if rd != zreg

/* ****************************************************************** */
$[name "load double-word to stack pointer (compressed)"]
union clause ast = C_LDSP : (bits(6), regidx)

mapping clause encdec_compressed = C_LDSP(ui86 @ ui5 @ ui43, rd)
Expand All @@ -457,6 +483,7 @@ mapping clause assembly = C_LDSP(uimm, rd)
if rd != zreg & sizeof(xlen) == 64

/* ****************************************************************** */
$[name "store word to stack pointer (compressed)"]
union clause ast = C_SWSP : (bits(6), regidx)

mapping clause encdec_compressed = C_SWSP(ui76 @ ui52, rs2)
Expand All @@ -473,6 +500,7 @@ mapping clause assembly = C_SWSP(uimm, rs2)
<-> "c.swsp" ^ spc() ^ reg_name(rs2) ^ sep() ^ hex_bits_6(uimm)

/* ****************************************************************** */
$[name "store double-word to stack pointer (compressed)"]
union clause ast = C_SDSP : (bits(6), regidx)

mapping clause encdec_compressed = C_SDSP(ui86 @ ui53, rs2)
Expand All @@ -491,6 +519,7 @@ mapping clause assembly = C_SDSP(uimm, rs2)
if sizeof(xlen) == 64

/* ****************************************************************** */
$[name "jump register (compressed)"]
union clause ast = C_JR : (regidx)

mapping clause encdec_compressed = C_JR(rs1)
Expand All @@ -507,6 +536,7 @@ mapping clause assembly = C_JR(rs1)
if rs1 != zreg

/* ****************************************************************** */
$[name "jump and link register (compressed)"]
union clause ast = C_JALR : (regidx)

mapping clause encdec_compressed = C_JALR(rs1)
Expand All @@ -523,6 +553,7 @@ mapping clause assembly = C_JALR(rs1)
if rs1 != zreg

/* ****************************************************************** */
$[name "move (compressed)"]
union clause ast = C_MV : (regidx, regidx)

mapping clause encdec_compressed = C_MV(rd, rs2)
Expand All @@ -539,6 +570,7 @@ mapping clause assembly = C_MV(rd, rs2)
if rd != zreg & rs2 != zreg

/* ****************************************************************** */
$[name "environment breakpoint (compressed)"]
union clause ast = C_EBREAK : unit

mapping clause encdec_compressed = C_EBREAK() if extension("C")
Expand All @@ -550,6 +582,7 @@ function clause execute C_EBREAK() =
mapping clause assembly = C_EBREAK() <-> "c.ebreak"

/* ****************************************************************** */
$[name "add (compressed)"]
union clause ast = C_ADD : (regidx, regidx)

mapping clause encdec_compressed = C_ADD(rsd, rs2)
Expand Down

0 comments on commit ac4dcf4

Please sign in to comment.