Skip to content

Commit

Permalink
Add Zawrs extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ved-rivos committed May 6, 2024
1 parent 7438d1e commit c5229c3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions disasm/disasm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,11 @@ void disassembler_t::add_instructions(const isa_parser_t* isa)
DEFINE_XAMO(amocas_h)
}

if (isa->extension_enabled(EXT_ZAWRS)) {
DEFINE_NOARG(wrs_sto);
DEFINE_NOARG(wrs_nto);
}

if (isa->extension_enabled(EXT_ZICFILP)) {
// lpad encodes as `auipc x0, label`, so it needs to be added before auipc
// for higher disassembling priority
Expand Down
10 changes: 8 additions & 2 deletions disasm/isa_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv)
extension_table[EXT_ZACAS] = true;
} else if (ext_str == "zabha") {
extension_table[EXT_ZABHA] = true;
} else if (ext_str == "zawrs") {
extension_table[EXT_ZAWRS] = true;
} else if (ext_str == "zmmul") {
extension_table[EXT_ZMMUL] = true;
} else if (ext_str == "zba") {
Expand Down Expand Up @@ -378,14 +380,18 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv)
bad_isa_string(str, "'Zcf/Zcd/Zcb/Zcmp/Zcmt' extensions require 'Zca' extension");
}

if (extension_table[EXT_ZACAS] && !extension_table['A'] && !extension_table[EXT_ZAAMO]) {
if (extension_table[EXT_ZACAS] && !extension_table[EXT_ZAAMO]) {
bad_isa_string(str, "'Zacas' extension requires either the 'A' or the 'Zaamo' extension");
}

if (extension_table[EXT_ZABHA] && !extension_table['A'] && !extension_table[EXT_ZAAMO]) {
if (extension_table[EXT_ZABHA] && !extension_table[EXT_ZAAMO]) {
bad_isa_string(str, "'Zabha' extension requires either the 'A' or the 'Zaamo' extension");
}

if (extension_table[EXT_ZAWRS] && !extension_table[EXT_ZALRSC]) {
bad_isa_string(str, "'Zabha' extension requires either the 'A' or the 'Zalrsc' extension");
}

// When SSE is 0, Zicfiss behavior is defined by Zicmop
if (extension_table[EXT_ZICFISS] && !extension_table[EXT_ZIMOP]) {
bad_isa_string(str, "'Zicfiss' extension requires 'Zimop' extension");
Expand Down
6 changes: 6 additions & 0 deletions riscv/insns/wrs_nto.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if (get_field(STATE.mstatus->read(), MSTATUS_TW)) {
require_privilege(PRV_M);
} else if (STATE.v) {
if (get_field(STATE.hstatus->read(), HSTATUS_VTW))
require_novirt();
}
1 change: 1 addition & 0 deletions riscv/insns/wrs_sto.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// WRS.STO stalls for a short duration
1 change: 1 addition & 0 deletions riscv/isa_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef enum {
EXT_ZALRSC,
EXT_ZACAS,
EXT_ZABHA,
EXT_ZAWRS,
EXT_INTERNAL_ZFH_MOVE,
EXT_SMCSRIND,
EXT_SSCSRIND,
Expand Down
5 changes: 5 additions & 0 deletions riscv/riscv.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,10 @@ riscv_insn_ext_zabha = \
amoxor_h \
amocas_h \

riscv_insn_ext_zawrs = \
wrs_sto \
wrs_nto \

riscv_insn_ext_zalasr = \
lb_aq \
lh_aq \
Expand Down Expand Up @@ -1099,6 +1103,7 @@ riscv_insn_list = \
$(riscv_insn_ext_q_zfa) \
$(riscv_insn_ext_zacas) \
$(riscv_insn_ext_zabha) \
$(riscv_insn_ext_zawrs) \
$(riscv_insn_ext_zalasr) \
$(riscv_insn_ext_zce) \
$(riscv_insn_ext_zfh) \
Expand Down

0 comments on commit c5229c3

Please sign in to comment.