RISC-V: Add 'Sstc' extension and its CSRs
authorTsukasa OI <research_trasio@irq.a4lg.com>
Fri, 24 Jun 2022 02:51:56 +0000 (11:51 +0900)
committerNelson Chu <nelson.chu@sifive.com>
Tue, 28 Jun 2022 01:08:42 +0000 (09:08 +0800)
This commit adds "stimecmp / vstimecmp" Extension (Sstc) and its CSRs.

bfd/ChangeLog:

* elfxx-riscv.c (riscv_supported_std_s_ext): Add 'Sstc'
extension to valid 'S' extension list.

gas/ChangeLog:

* config/tc-riscv.c (enum riscv_csr_class): Add CSR classes for
'Sstc' extension. (riscv_csr_address): Add handling for new CSR
classes.
* testsuite/gas/riscv/csr-dw-regnums.s: Add new CSRs.
* testsuite/gas/riscv/csr-dw-regnums.d: Likewise.
* testsuite/gas/riscv/csr.s: Add new CSRs.
* testsuite/gas/riscv/csr-version-1p9p1.d: Likewise.
* testsuite/gas/riscv/csr-version-1p9p1.l: Likewise.
* testsuite/gas/riscv/csr-version-1p10.d: Likewise.
* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
* testsuite/gas/riscv/csr-version-1p12.l: Likewise.

include/ChangeLog:

* opcode/riscv-opc.h (CSR_STIMECMP, CSR_STIMECMPH,
CSR_VSTIMECMP, CSR_VSTIMECMPH): New CSR macros.

14 files changed:
bfd/elfxx-riscv.c
gas/config/tc-riscv.c
gas/testsuite/gas/riscv/csr-dw-regnums.d
gas/testsuite/gas/riscv/csr-dw-regnums.s
gas/testsuite/gas/riscv/csr-version-1p10.d
gas/testsuite/gas/riscv/csr-version-1p10.l
gas/testsuite/gas/riscv/csr-version-1p11.d
gas/testsuite/gas/riscv/csr-version-1p11.l
gas/testsuite/gas/riscv/csr-version-1p12.d
gas/testsuite/gas/riscv/csr-version-1p12.l
gas/testsuite/gas/riscv/csr-version-1p9p1.d
gas/testsuite/gas/riscv/csr-version-1p9p1.l
gas/testsuite/gas/riscv/csr.s
include/opcode/riscv-opc.h

index 855501c8eeb7f3422d2be8a0cc78759873e2fdd6..bf7dc20e8928700df756003ca230caac3f122be7 100644 (file)
@@ -1233,6 +1233,7 @@ static struct riscv_supported_ext riscv_supported_std_s_ext[] =
 {
   {"smstateen",                ISA_SPEC_CLASS_DRAFT,           1, 0, 0 },
   {"sscofpmf",         ISA_SPEC_CLASS_DRAFT,           1, 0, 0 },
+  {"sstc",             ISA_SPEC_CLASS_DRAFT,           1, 0, 0 },
   {"svinval",          ISA_SPEC_CLASS_DRAFT,           1, 0, 0 },
   {NULL, 0, 0, 0, 0}
 };
index 2f6180ea51e58739e0366c70bf947d92faaca485..a0e8456a0d10b586c3965a2997cb3cf7bdb2648c 100644 (file)
@@ -74,6 +74,10 @@ enum riscv_csr_class
   CSR_CLASS_SMSTATEEN_AND_H_32,        /* Smstateen RV32 only (with H) */
   CSR_CLASS_SSCOFPMF,          /* Sscofpmf only */
   CSR_CLASS_SSCOFPMF_32,       /* Sscofpmf RV32 only */
+  CSR_CLASS_SSTC,              /* Sstc only */
+  CSR_CLASS_SSTC_AND_H,                /* Sstc only (with H) */
+  CSR_CLASS_SSTC_32,           /* Sstc RV32 only */
+  CSR_CLASS_SSTC_AND_H_32,     /* Sstc RV32 only (with H) */
 };
 
 /* This structure holds all restricted conditions for a CSR.  */
@@ -949,6 +953,16 @@ riscv_csr_address (const char *csr_name,
     case CSR_CLASS_SSCOFPMF:
       extension = "sscofpmf";
       break;
+    case CSR_CLASS_SSTC:
+    case CSR_CLASS_SSTC_AND_H:
+    case CSR_CLASS_SSTC_32:
+    case CSR_CLASS_SSTC_AND_H_32:
+      is_rv32_only = (csr_class == CSR_CLASS_SSTC_32
+                     || csr_class == CSR_CLASS_SSTC_AND_H_32);
+      is_h_required = (csr_class == CSR_CLASS_SSTC_AND_H
+                     || csr_class == CSR_CLASS_SSTC_AND_H_32);
+      extension = "sstc";
+      break;
     case CSR_CLASS_DEBUG:
       break;
     default:
index 2f353293faa41182e5e2255f5f857d849e9fdfd9..b4b3806a085c247102436d96b3327661569024b2 100644 (file)
@@ -363,6 +363,10 @@ Contents of the .* section:
   DW_CFA_offset_extended_sf: r5949 \(mhpmevent29h\) at cfa\+7412
   DW_CFA_offset_extended_sf: r5950 \(mhpmevent30h\) at cfa\+7416
   DW_CFA_offset_extended_sf: r5951 \(mhpmevent31h\) at cfa\+7420
+  DW_CFA_offset_extended_sf: r4429 \(stimecmp\) at cfa\+1332
+  DW_CFA_offset_extended_sf: r4445 \(stimecmph\) at cfa\+1396
+  DW_CFA_offset_extended_sf: r4685 \(vstimecmp\) at cfa\+2356
+  DW_CFA_offset_extended_sf: r4701 \(vstimecmph\) at cfa\+2420
   DW_CFA_offset_extended_sf: r4163 \(utval\) at cfa\+268
   DW_CFA_offset_extended_sf: r4419 \(stval\) at cfa\+1292
   DW_CFA_offset_extended_sf: r4480 \(satp\) at cfa\+1536
index caac321c6e2a35e4e8cf073ffd4447a691f9f4fc..6cfa415ebc2d1221706713fb9388ec6a328c6871 100644 (file)
@@ -359,6 +359,11 @@ _start:
        .cfi_offset mhpmevent29h, 7412
        .cfi_offset mhpmevent30h, 7416
        .cfi_offset mhpmevent31h, 7420
+       # Sstc extension
+       .cfi_offset stimecmp, 1332
+       .cfi_offset stimecmph, 1396
+       .cfi_offset vstimecmp, 2356
+       .cfi_offset vstimecmph, 2420
        # dropped
        .cfi_offset ubadaddr, 268       # aliases
        .cfi_offset sbadaddr, 1292      # aliases
index 90cc5dd3a1eca484f49abeacc5d2a6d7692ab15f..bd8b10302e3fded1ad0e0d9298470cbc160381c5 100644 (file)
@@ -701,6 +701,14 @@ Disassembly of section .text:
 [      ]+[0-9a-f]+:[   ]+73e59073[     ]+csrw[         ]+mhpmevent30h,a1
 [      ]+[0-9a-f]+:[   ]+73f02573[     ]+csrr[         ]+a0,mhpmevent31h
 [      ]+[0-9a-f]+:[   ]+73f59073[     ]+csrw[         ]+mhpmevent31h,a1
+[      ]+[0-9a-f]+:[   ]+14d02573[     ]+csrr[         ]+a0,stimecmp
+[      ]+[0-9a-f]+:[   ]+14d59073[     ]+csrw[         ]+stimecmp,a1
+[      ]+[0-9a-f]+:[   ]+15d02573[     ]+csrr[         ]+a0,stimecmph
+[      ]+[0-9a-f]+:[   ]+15d59073[     ]+csrw[         ]+stimecmph,a1
+[      ]+[0-9a-f]+:[   ]+24d02573[     ]+csrr[         ]+a0,vstimecmp
+[      ]+[0-9a-f]+:[   ]+24d59073[     ]+csrw[         ]+vstimecmp,a1
+[      ]+[0-9a-f]+:[   ]+25d02573[     ]+csrr[         ]+a0,vstimecmph
+[      ]+[0-9a-f]+:[   ]+25d59073[     ]+csrw[         ]+vstimecmph,a1
 [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,utval
 [      ]+[0-9a-f]+:[   ]+04359073[     ]+csrw[         ]+utval,a1
 [      ]+[0-9a-f]+:[   ]+14302573[     ]+csrr[         ]+a0,stval
index e4144b6477a19b6bb38d6aaa55aa3f24e30c2871..b778453b556395ee0b40f19e8548b5784498426c 100644 (file)
 .*Warning: invalid CSR `mhpmevent31h', needs `sscofpmf' extension
 .*Warning: invalid CSR `mhpmevent31h', needs rv32i extension
 .*Warning: invalid CSR `mhpmevent31h', needs `sscofpmf' extension
+.*Warning: invalid CSR `stimecmp', needs `sstc' extension
+.*Warning: invalid CSR `stimecmp', needs `sstc' extension
+.*Warning: invalid CSR `stimecmph', needs rv32i extension
+.*Warning: invalid CSR `stimecmph', needs `sstc' extension
+.*Warning: invalid CSR `stimecmph', needs rv32i extension
+.*Warning: invalid CSR `stimecmph', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmp', needs `h' extension
+.*Warning: invalid CSR `vstimecmp', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmp', needs `h' extension
+.*Warning: invalid CSR `vstimecmp', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmph', needs rv32i extension
+.*Warning: invalid CSR `vstimecmph', needs `h' extension
+.*Warning: invalid CSR `vstimecmph', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmph', needs rv32i extension
+.*Warning: invalid CSR `vstimecmph', needs `h' extension
+.*Warning: invalid CSR `vstimecmph', needs `sstc' extension
 .*Warning: invalid CSR `ubadaddr' for the privileged spec `1.10'
 .*Warning: invalid CSR `ubadaddr' for the privileged spec `1.10'
 .*Warning: invalid CSR `sbadaddr' for the privileged spec `1.10'
index a85875acf08b605ce29627151449f184fa16b2d2..5d6333884f1a549731bae7ab9f8292004cb24720 100644 (file)
@@ -701,6 +701,14 @@ Disassembly of section .text:
 [      ]+[0-9a-f]+:[   ]+73e59073[     ]+csrw[         ]+mhpmevent30h,a1
 [      ]+[0-9a-f]+:[   ]+73f02573[     ]+csrr[         ]+a0,mhpmevent31h
 [      ]+[0-9a-f]+:[   ]+73f59073[     ]+csrw[         ]+mhpmevent31h,a1
+[      ]+[0-9a-f]+:[   ]+14d02573[     ]+csrr[         ]+a0,stimecmp
+[      ]+[0-9a-f]+:[   ]+14d59073[     ]+csrw[         ]+stimecmp,a1
+[      ]+[0-9a-f]+:[   ]+15d02573[     ]+csrr[         ]+a0,stimecmph
+[      ]+[0-9a-f]+:[   ]+15d59073[     ]+csrw[         ]+stimecmph,a1
+[      ]+[0-9a-f]+:[   ]+24d02573[     ]+csrr[         ]+a0,vstimecmp
+[      ]+[0-9a-f]+:[   ]+24d59073[     ]+csrw[         ]+vstimecmp,a1
+[      ]+[0-9a-f]+:[   ]+25d02573[     ]+csrr[         ]+a0,vstimecmph
+[      ]+[0-9a-f]+:[   ]+25d59073[     ]+csrw[         ]+vstimecmph,a1
 [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,utval
 [      ]+[0-9a-f]+:[   ]+04359073[     ]+csrw[         ]+utval,a1
 [      ]+[0-9a-f]+:[   ]+14302573[     ]+csrr[         ]+a0,stval
index f4a57f2c409405cccbf230d44b84337579e03a69..78bae817470ed066febd83a2c152cc794e4c5018 100644 (file)
 .*Warning: invalid CSR `mhpmevent31h', needs `sscofpmf' extension
 .*Warning: invalid CSR `mhpmevent31h', needs rv32i extension
 .*Warning: invalid CSR `mhpmevent31h', needs `sscofpmf' extension
+.*Warning: invalid CSR `stimecmp', needs `sstc' extension
+.*Warning: invalid CSR `stimecmp', needs `sstc' extension
+.*Warning: invalid CSR `stimecmph', needs rv32i extension
+.*Warning: invalid CSR `stimecmph', needs `sstc' extension
+.*Warning: invalid CSR `stimecmph', needs rv32i extension
+.*Warning: invalid CSR `stimecmph', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmp', needs `h' extension
+.*Warning: invalid CSR `vstimecmp', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmp', needs `h' extension
+.*Warning: invalid CSR `vstimecmp', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmph', needs rv32i extension
+.*Warning: invalid CSR `vstimecmph', needs `h' extension
+.*Warning: invalid CSR `vstimecmph', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmph', needs rv32i extension
+.*Warning: invalid CSR `vstimecmph', needs `h' extension
+.*Warning: invalid CSR `vstimecmph', needs `sstc' extension
 .*Warning: invalid CSR `ubadaddr' for the privileged spec `1.11'
 .*Warning: invalid CSR `ubadaddr' for the privileged spec `1.11'
 .*Warning: invalid CSR `sbadaddr' for the privileged spec `1.11'
index 60f19bff8749b9d50809134b72d8498cfa8f50be..728e647c55231a48995b09b406a344e5c48c2dd0 100644 (file)
@@ -701,6 +701,14 @@ Disassembly of section .text:
 [      ]+[0-9a-f]+:[   ]+73e59073[     ]+csrw[         ]+mhpmevent30h,a1
 [      ]+[0-9a-f]+:[   ]+73f02573[     ]+csrr[         ]+a0,mhpmevent31h
 [      ]+[0-9a-f]+:[   ]+73f59073[     ]+csrw[         ]+mhpmevent31h,a1
+[      ]+[0-9a-f]+:[   ]+14d02573[     ]+csrr[         ]+a0,stimecmp
+[      ]+[0-9a-f]+:[   ]+14d59073[     ]+csrw[         ]+stimecmp,a1
+[      ]+[0-9a-f]+:[   ]+15d02573[     ]+csrr[         ]+a0,stimecmph
+[      ]+[0-9a-f]+:[   ]+15d59073[     ]+csrw[         ]+stimecmph,a1
+[      ]+[0-9a-f]+:[   ]+24d02573[     ]+csrr[         ]+a0,vstimecmp
+[      ]+[0-9a-f]+:[   ]+24d59073[     ]+csrw[         ]+vstimecmp,a1
+[      ]+[0-9a-f]+:[   ]+25d02573[     ]+csrr[         ]+a0,vstimecmph
+[      ]+[0-9a-f]+:[   ]+25d59073[     ]+csrw[         ]+vstimecmph,a1
 [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,0x43
 [      ]+[0-9a-f]+:[   ]+04359073[     ]+csrw[         ]+0x43,a1
 [      ]+[0-9a-f]+:[   ]+14302573[     ]+csrr[         ]+a0,stval
index 37522fadbf4d8999be042711bdfcaa0278760fcd..cb026bb55e0c058754365eb199f8559ed4b10fd1 100644 (file)
 .*Warning: invalid CSR `mhpmevent31h', needs `sscofpmf' extension
 .*Warning: invalid CSR `mhpmevent31h', needs rv32i extension
 .*Warning: invalid CSR `mhpmevent31h', needs `sscofpmf' extension
+.*Warning: invalid CSR `stimecmp', needs `sstc' extension
+.*Warning: invalid CSR `stimecmp', needs `sstc' extension
+.*Warning: invalid CSR `stimecmph', needs rv32i extension
+.*Warning: invalid CSR `stimecmph', needs `sstc' extension
+.*Warning: invalid CSR `stimecmph', needs rv32i extension
+.*Warning: invalid CSR `stimecmph', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmp', needs `h' extension
+.*Warning: invalid CSR `vstimecmp', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmp', needs `h' extension
+.*Warning: invalid CSR `vstimecmp', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmph', needs rv32i extension
+.*Warning: invalid CSR `vstimecmph', needs `h' extension
+.*Warning: invalid CSR `vstimecmph', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmph', needs rv32i extension
+.*Warning: invalid CSR `vstimecmph', needs `h' extension
+.*Warning: invalid CSR `vstimecmph', needs `sstc' extension
 .*Warning: invalid CSR `ubadaddr' for the privileged spec `1.12'
 .*Warning: invalid CSR `ubadaddr' for the privileged spec `1.12'
 .*Warning: invalid CSR `sbadaddr' for the privileged spec `1.12'
index e9eb8c031fb44a78f96d56637d9621a257147545..a34b99f4632946452c57301edd2c117135a4231a 100644 (file)
@@ -701,6 +701,14 @@ Disassembly of section .text:
 [      ]+[0-9a-f]+:[   ]+73e59073[     ]+csrw[         ]+mhpmevent30h,a1
 [      ]+[0-9a-f]+:[   ]+73f02573[     ]+csrr[         ]+a0,mhpmevent31h
 [      ]+[0-9a-f]+:[   ]+73f59073[     ]+csrw[         ]+mhpmevent31h,a1
+[      ]+[0-9a-f]+:[   ]+14d02573[     ]+csrr[         ]+a0,stimecmp
+[      ]+[0-9a-f]+:[   ]+14d59073[     ]+csrw[         ]+stimecmp,a1
+[      ]+[0-9a-f]+:[   ]+15d02573[     ]+csrr[         ]+a0,stimecmph
+[      ]+[0-9a-f]+:[   ]+15d59073[     ]+csrw[         ]+stimecmph,a1
+[      ]+[0-9a-f]+:[   ]+24d02573[     ]+csrr[         ]+a0,vstimecmp
+[      ]+[0-9a-f]+:[   ]+24d59073[     ]+csrw[         ]+vstimecmp,a1
+[      ]+[0-9a-f]+:[   ]+25d02573[     ]+csrr[         ]+a0,vstimecmph
+[      ]+[0-9a-f]+:[   ]+25d59073[     ]+csrw[         ]+vstimecmph,a1
 [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,ubadaddr
 [      ]+[0-9a-f]+:[   ]+04359073[     ]+csrw[         ]+ubadaddr,a1
 [      ]+[0-9a-f]+:[   ]+14302573[     ]+csrr[         ]+a0,sbadaddr
index 893f8c8ba5625a8d1a21a154a81357d12d7c93c9..4fac40fb589973319287890e37382b65fbb76f22 100644 (file)
 .*Warning: invalid CSR `mhpmevent31h', needs `sscofpmf' extension
 .*Warning: invalid CSR `mhpmevent31h', needs rv32i extension
 .*Warning: invalid CSR `mhpmevent31h', needs `sscofpmf' extension
+.*Warning: invalid CSR `stimecmp', needs `sstc' extension
+.*Warning: invalid CSR `stimecmp', needs `sstc' extension
+.*Warning: invalid CSR `stimecmph', needs rv32i extension
+.*Warning: invalid CSR `stimecmph', needs `sstc' extension
+.*Warning: invalid CSR `stimecmph', needs rv32i extension
+.*Warning: invalid CSR `stimecmph', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmp', needs `h' extension
+.*Warning: invalid CSR `vstimecmp', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmp', needs `h' extension
+.*Warning: invalid CSR `vstimecmp', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmph', needs rv32i extension
+.*Warning: invalid CSR `vstimecmph', needs `h' extension
+.*Warning: invalid CSR `vstimecmph', needs `sstc' extension
+.*Warning: invalid CSR `vstimecmph', needs rv32i extension
+.*Warning: invalid CSR `vstimecmph', needs `h' extension
+.*Warning: invalid CSR `vstimecmph', needs `sstc' extension
 .*Warning: invalid CSR `utval' for the privileged spec `1.9.1'
 .*Warning: invalid CSR `utval' for the privileged spec `1.9.1'
 .*Warning: invalid CSR `fflags', needs `f' extension
index 2a723123f1bbcdcf3743f48f478fa228d47ffc6a..128aeb83a04df448ea2cdd303a6bd7c4ac19bfa7 100644 (file)
        csr mhpmevent30h
        csr mhpmevent31h
 
+       # Sstc extension
+       csr stimecmp
+       csr stimecmph
+       csr vstimecmp
+       csr vstimecmph
+
        # Supported in previous priv spec, but dropped now
 
        csr ubadaddr            # 0x043 in 1.9.1, but the value is utval since 1.10
index 8546a6e7172839e2c8b719abfcbd9e8eda0c31eb..88b8d7ff5951357d4995bcd7ba80d8025b7abfa6 100644 (file)
 #define CSR_MHPMEVENT29H 0x73d
 #define CSR_MHPMEVENT30H 0x73e
 #define CSR_MHPMEVENT31H 0x73f
+/* Sstc extension */
+#define CSR_STIMECMP 0x14d
+#define CSR_STIMECMPH 0x15d
+#define CSR_VSTIMECMP 0x24d
+#define CSR_VSTIMECMPH 0x25d
 /* Unprivileged Floating-Point CSR addresses.  */
 #define CSR_FFLAGS 0x1
 #define CSR_FRM 0x2
@@ -3201,6 +3206,11 @@ DECLARE_CSR(mhpmevent28h, CSR_MHPMEVENT28H, CSR_CLASS_SSCOFPMF_32, PRIV_SPEC_CLA
 DECLARE_CSR(mhpmevent29h, CSR_MHPMEVENT29H, CSR_CLASS_SSCOFPMF_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 DECLARE_CSR(mhpmevent30h, CSR_MHPMEVENT30H, CSR_CLASS_SSCOFPMF_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 DECLARE_CSR(mhpmevent31h, CSR_MHPMEVENT31H, CSR_CLASS_SSCOFPMF_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+/* Sstc extension */
+DECLARE_CSR(stimecmp, CSR_STIMECMP, CSR_CLASS_SSTC, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(stimecmph, CSR_STIMECMPH, CSR_CLASS_SSTC_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(vstimecmp, CSR_VSTIMECMP, CSR_CLASS_SSTC_AND_H, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(vstimecmph, CSR_VSTIMECMPH, CSR_CLASS_SSTC_AND_H_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 /* Dropped CSRs.  */
 DECLARE_CSR(mbase, CSR_MBASE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR(mbound, CSR_MBOUND, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_1P10)