diff options
author | Andrew Waterman <andrew@sifive.com> | 2021-06-02 00:40:10 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2021-06-02 00:40:10 -0700 |
commit | cb7805a9689e2d5de23b959b177940d1b8813bd2 (patch) | |
tree | b539e96afdd276167ccafc61760faee26767b3f2 | |
parent | 16308bc1a01b8f540cf3e95e9f30b96d92df01e0 (diff) | |
download | riscv-isa-sim-cb7805a9689e2d5de23b959b177940d1b8813bd2.zip riscv-isa-sim-cb7805a9689e2d5de23b959b177940d1b8813bd2.tar.gz riscv-isa-sim-cb7805a9689e2d5de23b959b177940d1b8813bd2.tar.bz2 |
Accept Zba, Zbb, Zbc, Zbs ISA strings
The B extension still implies the presence of Zba/Zbb/Zbc/Zbs.
46 files changed, 85 insertions, 45 deletions
diff --git a/riscv/insns/add_uw.h b/riscv/insns/add_uw.h index 4b4d9c6..5b25a36 100644 --- a/riscv/insns/add_uw.h +++ b/riscv/insns/add_uw.h @@ -1,3 +1,3 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBA); WRITE_RD(sext_xlen(zext32(RS1) + RS2)); diff --git a/riscv/insns/andn.h b/riscv/insns/andn.h index 4582aac..cb544cc 100644 --- a/riscv/insns/andn.h +++ b/riscv/insns/andn.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBB); WRITE_RD(RS1 & ~RS2); diff --git a/riscv/insns/bclr.h b/riscv/insns/bclr.h index f0b0e0a..589273e 100644 --- a/riscv/insns/bclr.h +++ b/riscv/insns/bclr.h @@ -1,3 +1,3 @@ -require_extension('B'); +require_extension(EXT_ZBS); int shamt = RS2 & (xlen-1); WRITE_RD(sext_xlen(RS1 & ~(1LL << shamt))); diff --git a/riscv/insns/bclri.h b/riscv/insns/bclri.h index 546dcaa..8df6a5f 100644 --- a/riscv/insns/bclri.h +++ b/riscv/insns/bclri.h @@ -1,3 +1,3 @@ -require_extension('B'); +require_extension(EXT_ZBS); int shamt = SHAMT & (xlen-1); WRITE_RD(sext_xlen(RS1 & ~(1LL << shamt))); diff --git a/riscv/insns/bext.h b/riscv/insns/bext.h index 7149a2a..24c80b0 100644 --- a/riscv/insns/bext.h +++ b/riscv/insns/bext.h @@ -1,3 +1,3 @@ -require_extension('B'); +require_extension(EXT_ZBS); int shamt = RS2 & (xlen-1); WRITE_RD(sext_xlen(1 & (RS1 >> shamt))); diff --git a/riscv/insns/bexti.h b/riscv/insns/bexti.h index c930cfb..31d2316 100644 --- a/riscv/insns/bexti.h +++ b/riscv/insns/bexti.h @@ -1,3 +1,3 @@ -require_extension('B'); +require_extension(EXT_ZBS); int shamt = SHAMT & (xlen-1); WRITE_RD(sext_xlen(1 & (RS1 >> shamt))); diff --git a/riscv/insns/binv.h b/riscv/insns/binv.h index 5892252..cef5b78 100644 --- a/riscv/insns/binv.h +++ b/riscv/insns/binv.h @@ -1,3 +1,3 @@ -require_extension('B'); +require_extension(EXT_ZBS); int shamt = RS2 & (xlen-1); WRITE_RD(sext_xlen(RS1 ^ (1LL << shamt))); diff --git a/riscv/insns/binvi.h b/riscv/insns/binvi.h index f67143c..3272d39 100644 --- a/riscv/insns/binvi.h +++ b/riscv/insns/binvi.h @@ -1,3 +1,3 @@ -require_extension('B'); +require_extension(EXT_ZBS); int shamt = SHAMT & (xlen-1); WRITE_RD(sext_xlen(RS1 ^ (1LL << shamt))); diff --git a/riscv/insns/bset.h b/riscv/insns/bset.h index 0e3f0fc..9009fb3 100644 --- a/riscv/insns/bset.h +++ b/riscv/insns/bset.h @@ -1,3 +1,3 @@ -require_extension('B'); +require_extension(EXT_ZBS); int shamt = RS2 & (xlen-1); WRITE_RD(sext_xlen(RS1 | (1LL << shamt))); diff --git a/riscv/insns/bseti.h b/riscv/insns/bseti.h index 44aa8bb..4952378 100644 --- a/riscv/insns/bseti.h +++ b/riscv/insns/bseti.h @@ -1,3 +1,3 @@ -require_extension('B'); +require_extension(EXT_ZBS); int shamt = SHAMT & (xlen-1); WRITE_RD(sext_xlen(RS1 | (1LL << shamt))); diff --git a/riscv/insns/clmul.h b/riscv/insns/clmul.h index 9601567..7299f69 100644 --- a/riscv/insns/clmul.h +++ b/riscv/insns/clmul.h @@ -1,4 +1,4 @@ -require_extension('B'); +require_extension(EXT_ZBC); reg_t a = zext_xlen(RS1), b = zext_xlen(RS2), x = 0; for (int i = 0; i < xlen; i++) if ((b >> i) & 1) diff --git a/riscv/insns/clmulh.h b/riscv/insns/clmulh.h index 68a50e3..dbc5ac9 100644 --- a/riscv/insns/clmulh.h +++ b/riscv/insns/clmulh.h @@ -1,4 +1,4 @@ -require_extension('B'); +require_extension(EXT_ZBC); reg_t a = zext_xlen(RS1), b = zext_xlen(RS2), x = 0; for (int i = 1; i < xlen; i++) if ((b >> i) & 1) diff --git a/riscv/insns/clmulr.h b/riscv/insns/clmulr.h index f07487e..ffa046d 100644 --- a/riscv/insns/clmulr.h +++ b/riscv/insns/clmulr.h @@ -1,4 +1,4 @@ -require_extension('B'); +require_extension(EXT_ZBC); reg_t a = zext_xlen(RS1), b = zext_xlen(RS2), x = 0; for (int i = 0; i < xlen; i++) if ((b >> i) & 1) diff --git a/riscv/insns/clz.h b/riscv/insns/clz.h index 6821b2d..d334e40 100644 --- a/riscv/insns/clz.h +++ b/riscv/insns/clz.h @@ -1,4 +1,4 @@ -require_extension('B'); +require_extension(EXT_ZBB); reg_t x = xlen; for (int i = 0; i < xlen; i++) if (1 & (RS1 >> (xlen-i-1))) { x = i; break; } diff --git a/riscv/insns/clzw.h b/riscv/insns/clzw.h index 6313554..46816e7 100644 --- a/riscv/insns/clzw.h +++ b/riscv/insns/clzw.h @@ -1,5 +1,5 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBB); reg_t x = 32; for (int i = 0; i < 32; i++) if (1 & (RS1 >> (31-i))) { x = i; break; } diff --git a/riscv/insns/cpop.h b/riscv/insns/cpop.h index 773e2e1..1f5c3ef 100644 --- a/riscv/insns/cpop.h +++ b/riscv/insns/cpop.h @@ -1,4 +1,4 @@ -require_extension('B'); +require_extension(EXT_ZBB); reg_t x = 0; for (int i = 0; i < xlen; i++) if (1 & (RS1 >> i)) x++; diff --git a/riscv/insns/cpopw.h b/riscv/insns/cpopw.h index 13e9ba0..4138398 100644 --- a/riscv/insns/cpopw.h +++ b/riscv/insns/cpopw.h @@ -1,5 +1,5 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBB); reg_t x = 0; for (int i = 0; i < 32; i++) if (1 & (RS1 >> i)) x++; diff --git a/riscv/insns/ctz.h b/riscv/insns/ctz.h index 889de0f..25d3723 100644 --- a/riscv/insns/ctz.h +++ b/riscv/insns/ctz.h @@ -1,4 +1,4 @@ -require_extension('B'); +require_extension(EXT_ZBB); reg_t x = xlen; for (int i = 0; i < xlen; i++) if (1 & (RS1 >> i)) { x = i; break; } diff --git a/riscv/insns/ctzw.h b/riscv/insns/ctzw.h index 59f58ad..aca46e9 100644 --- a/riscv/insns/ctzw.h +++ b/riscv/insns/ctzw.h @@ -1,5 +1,5 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBB); reg_t x = 32; for (int i = 0; i < 32; i++) if (1 & (RS1 >> i)) { x = i; break; } diff --git a/riscv/insns/gorci.h b/riscv/insns/gorci.h index c42142f..a7fc810 100644 --- a/riscv/insns/gorci.h +++ b/riscv/insns/gorci.h @@ -1,4 +1,9 @@ -require_extension('B'); +// Zbb contains orc.b but not general gorci +if (SHAMT == 7) + require_extension(EXT_ZBB); +else + require_extension('B'); + require(SHAMT < xlen); reg_t x = RS1; int shamt = SHAMT; diff --git a/riscv/insns/grevi.h b/riscv/insns/grevi.h index 68213c6..46d04dd 100644 --- a/riscv/insns/grevi.h +++ b/riscv/insns/grevi.h @@ -1,4 +1,9 @@ -require_extension('B'); +// Zbb contains rev8 but not general grevi +if (SHAMT == xlen - 8) + require_extension(EXT_ZBB); +else + require_extension('B'); + require(SHAMT < xlen); reg_t x = RS1; int shamt = SHAMT; diff --git a/riscv/insns/max.h b/riscv/insns/max.h index f57e722..09f29f5 100644 --- a/riscv/insns/max.h +++ b/riscv/insns/max.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBB); WRITE_RD(sext_xlen(sreg_t(RS1) > sreg_t(RS2) ? RS1 : RS2)); diff --git a/riscv/insns/maxu.h b/riscv/insns/maxu.h index e1ecdf4..05af492 100644 --- a/riscv/insns/maxu.h +++ b/riscv/insns/maxu.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBB); WRITE_RD(sext_xlen(RS1 > RS2 ? RS1 : RS2)); diff --git a/riscv/insns/min.h b/riscv/insns/min.h index 1b2fadb..174e312 100644 --- a/riscv/insns/min.h +++ b/riscv/insns/min.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBB); WRITE_RD(sext_xlen(sreg_t(RS1) < sreg_t(RS2) ? RS1 : RS2)); diff --git a/riscv/insns/minu.h b/riscv/insns/minu.h index fdf315e..7582c0d 100644 --- a/riscv/insns/minu.h +++ b/riscv/insns/minu.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBB); WRITE_RD(sext_xlen(RS1 < RS2 ? RS1 : RS2)); diff --git a/riscv/insns/orn.h b/riscv/insns/orn.h index 670926f..1421ff8 100644 --- a/riscv/insns/orn.h +++ b/riscv/insns/orn.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBB); WRITE_RD(RS1 | ~RS2); diff --git a/riscv/insns/pack.h b/riscv/insns/pack.h index 841f24d..cde3bd1 100644 --- a/riscv/insns/pack.h +++ b/riscv/insns/pack.h @@ -1,4 +1,9 @@ -require_extension('B'); +// RV32Zbb contains zext.h but not general pack +if (insn.rs2() == 0 && xlen == 32) + require_extension(EXT_ZBB); +else + require_extension('B'); + reg_t lo = zext_xlen(RS1 << (xlen/2)) >> (xlen/2); reg_t hi = zext_xlen(RS2 << (xlen/2)); WRITE_RD(sext_xlen(lo | hi)); diff --git a/riscv/insns/packw.h b/riscv/insns/packw.h index 23939f8..b2f335a 100644 --- a/riscv/insns/packw.h +++ b/riscv/insns/packw.h @@ -1,5 +1,10 @@ +// RV64Zbb contains zext.h but not general packw +if (insn.rs2() == 0) + require_extension(EXT_ZBB); +else + require_extension('B'); + require_rv64; -require_extension('B'); reg_t lo = zext32(RS1 << 16) >> 16; reg_t hi = zext32(RS2 << 16); WRITE_RD(sext32(lo | hi)); diff --git a/riscv/insns/rol.h b/riscv/insns/rol.h index 2b15c93..a86447d 100644 --- a/riscv/insns/rol.h +++ b/riscv/insns/rol.h @@ -1,4 +1,4 @@ -require_extension('B'); +require_extension(EXT_ZBB); int shamt = RS2 & (xlen-1); int rshamt = -shamt & (xlen-1); WRITE_RD(sext_xlen((RS1 << shamt) | (zext_xlen(RS1) >> rshamt))); diff --git a/riscv/insns/rolw.h b/riscv/insns/rolw.h index 6d66a50..f5d365b 100644 --- a/riscv/insns/rolw.h +++ b/riscv/insns/rolw.h @@ -1,5 +1,5 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBB); int shamt = RS2 & 31; int rshamt = -shamt & 31; WRITE_RD(sext32((RS1 << shamt) | (zext32(RS1) >> rshamt))); diff --git a/riscv/insns/ror.h b/riscv/insns/ror.h index 8788a12..925e144 100644 --- a/riscv/insns/ror.h +++ b/riscv/insns/ror.h @@ -1,4 +1,4 @@ -require_extension('B'); +require_extension(EXT_ZBB); int shamt = RS2 & (xlen-1); int rshamt = -shamt & (xlen-1); WRITE_RD(sext_xlen((RS1 << rshamt) | (zext_xlen(RS1) >> shamt))); diff --git a/riscv/insns/rori.h b/riscv/insns/rori.h index 72f1529..408ed50 100644 --- a/riscv/insns/rori.h +++ b/riscv/insns/rori.h @@ -1,4 +1,4 @@ -require_extension('B'); +require_extension(EXT_ZBB); require(SHAMT < xlen); int shamt = SHAMT & (xlen-1); int rshamt = -shamt & (xlen-1); diff --git a/riscv/insns/roriw.h b/riscv/insns/roriw.h index 817cfc8..35df883 100644 --- a/riscv/insns/roriw.h +++ b/riscv/insns/roriw.h @@ -1,5 +1,5 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBB); require(SHAMT < 32); int shamt = SHAMT & 31; int rshamt = -shamt & 31; diff --git a/riscv/insns/rorw.h b/riscv/insns/rorw.h index b42ab73..53e98b2 100644 --- a/riscv/insns/rorw.h +++ b/riscv/insns/rorw.h @@ -1,5 +1,5 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBB); int shamt = RS2 & 31; int rshamt = -shamt & 31; WRITE_RD(sext32((RS1 << rshamt) | (zext32(RS1) >> shamt))); diff --git a/riscv/insns/sext_b.h b/riscv/insns/sext_b.h index 566e6f8..5acde61 100644 --- a/riscv/insns/sext_b.h +++ b/riscv/insns/sext_b.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBB); WRITE_RD((sreg_t)(int8_t)(RS1)); diff --git a/riscv/insns/sext_h.h b/riscv/insns/sext_h.h index bd1fde2..e89a68d 100644 --- a/riscv/insns/sext_h.h +++ b/riscv/insns/sext_h.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBB); WRITE_RD((sreg_t)(int16_t)(RS1)); diff --git a/riscv/insns/sh1add.h b/riscv/insns/sh1add.h index f2805ab..6cbc360 100644 --- a/riscv/insns/sh1add.h +++ b/riscv/insns/sh1add.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBA); WRITE_RD(sext_xlen((RS1 << 1) + RS2)); diff --git a/riscv/insns/sh1add_uw.h b/riscv/insns/sh1add_uw.h index 7456958..1177002 100644 --- a/riscv/insns/sh1add_uw.h +++ b/riscv/insns/sh1add_uw.h @@ -1,3 +1,3 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBA); WRITE_RD(sext_xlen((zext32(RS1) << 1) + RS2)); diff --git a/riscv/insns/sh2add.h b/riscv/insns/sh2add.h index ff68d37..ea55e79 100644 --- a/riscv/insns/sh2add.h +++ b/riscv/insns/sh2add.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBA); WRITE_RD(sext_xlen((RS1 << 2) + RS2)); diff --git a/riscv/insns/sh2add_uw.h b/riscv/insns/sh2add_uw.h index 9948980..b51250d 100644 --- a/riscv/insns/sh2add_uw.h +++ b/riscv/insns/sh2add_uw.h @@ -1,3 +1,3 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBA); WRITE_RD(sext_xlen((zext32(RS1) << 2) + RS2)); diff --git a/riscv/insns/sh3add.h b/riscv/insns/sh3add.h index 631a0ce..de71f0f 100644 --- a/riscv/insns/sh3add.h +++ b/riscv/insns/sh3add.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBA); WRITE_RD(sext_xlen((RS1 << 3) + RS2)); diff --git a/riscv/insns/sh3add_uw.h b/riscv/insns/sh3add_uw.h index e41a65d..b618b85 100644 --- a/riscv/insns/sh3add_uw.h +++ b/riscv/insns/sh3add_uw.h @@ -1,3 +1,3 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBA); WRITE_RD(sext_xlen((zext32(RS1) << 3) + RS2)); diff --git a/riscv/insns/slli_uw.h b/riscv/insns/slli_uw.h index 99ac5f8..9cd48a9 100644 --- a/riscv/insns/slli_uw.h +++ b/riscv/insns/slli_uw.h @@ -1,3 +1,3 @@ require_rv64; -require_extension('B'); +require_extension(EXT_ZBA); WRITE_RD(sext_xlen(zext32(RS1) << SHAMT)); diff --git a/riscv/insns/xnor.h b/riscv/insns/xnor.h index b2fe95b..a7a89ba 100644 --- a/riscv/insns/xnor.h +++ b/riscv/insns/xnor.h @@ -1,2 +1,2 @@ -require_extension('B'); +require_extension(EXT_ZBB); WRITE_RD(RS1 ^ ~RS2); diff --git a/riscv/processor.cc b/riscv/processor.cc index 3e33efb..b62f98a 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -269,6 +269,14 @@ void processor_t::parse_isa_string(const char* str) auto ext_str = std::string(ext, end - ext); if (ext_str == "zfh") { extension_table[EXT_ZFH] = true; + } else if (ext_str == "zba") { + extension_table[EXT_ZBA] = true; + } else if (ext_str == "zbb") { + extension_table[EXT_ZBB] = true; + } else if (ext_str == "zbc") { + extension_table[EXT_ZBC] = true; + } else if (ext_str == "zbs") { + extension_table[EXT_ZBS] = true; } else { sprintf(error_msg, "unsupported extension '%s'", ext_str.c_str()); bad_isa_string(str, error_msg); @@ -283,6 +291,14 @@ void processor_t::parse_isa_string(const char* str) state.misa = max_isa; + if (supports_extension('B')) { + // B implies Zba, Zbb, Zbc, Zbs + extension_table[EXT_ZBA] = true; + extension_table[EXT_ZBB] = true; + extension_table[EXT_ZBC] = true; + extension_table[EXT_ZBS] = true; + } + if (!supports_extension('I')) bad_isa_string(str, "'I' extension is required"); diff --git a/riscv/processor.h b/riscv/processor.h index e3a8d60..346b252 100644 --- a/riscv/processor.h +++ b/riscv/processor.h @@ -243,7 +243,11 @@ typedef enum { typedef enum { // 65('A') ~ 90('Z') is reserved for standard isa in misa - EXT_ZFH = 0, + EXT_ZFH, + EXT_ZBA, + EXT_ZBB, + EXT_ZBC, + EXT_ZBS, } isa_extension_t; typedef enum { |