RISC-V: Add T-Head Int vendor extension
authorChristoph Müllner <christoph.muellner@vrull.eu>
Sun, 13 Nov 2022 15:59:21 +0000 (16:59 +0100)
committerNelson Chu <nelson@rivosinc.com>
Thu, 17 Nov 2022 08:43:55 +0000 (16:43 +0800)
This patch adds the XTheadInt extension, which provides interrupt
stack management instructions.

The XTheadFmv extension is documented in the RISC-V toolchain
contentions:
  https://github.com/riscv-non-isa/riscv-toolchain-conventions

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
bfd/elfxx-riscv.c
gas/NEWS
gas/doc/c-riscv.texi
gas/testsuite/gas/riscv/x-thead-int.d [new file with mode: 0644]
gas/testsuite/gas/riscv/x-thead-int.s [new file with mode: 0644]
include/opcode/riscv-opc.h
include/opcode/riscv.h
opcodes/riscv-opc.c

index a1e42064ee07d5ac3c9516ddc584092efc22d8bc..cfec9a6996c92e088016180716e9096be62ea9bc 100644 (file)
@@ -1240,6 +1240,7 @@ static struct riscv_supported_ext riscv_supported_vendor_x_ext[] =
   {"xtheadcondmov",    ISA_SPEC_CLASS_DRAFT,   1, 0, 0 },
   {"xtheadfmemidx",    ISA_SPEC_CLASS_DRAFT,   1, 0, 0 },
   {"xtheadfmv",                ISA_SPEC_CLASS_DRAFT,   1, 0, 0 },
+  {"xtheadint",                ISA_SPEC_CLASS_DRAFT,   1, 0, 0 },
   {"xtheadmac",                ISA_SPEC_CLASS_DRAFT,   1, 0, 0 },
   {"xtheadmemidx",     ISA_SPEC_CLASS_DRAFT,   1, 0, 0 },
   {"xtheadmempair",    ISA_SPEC_CLASS_DRAFT,   1, 0, 0 },
@@ -2422,6 +2423,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
       return riscv_subset_supports (rps, "xtheadfmemidx");
     case INSN_CLASS_XTHEADFMV:
       return riscv_subset_supports (rps, "xtheadfmv");
+    case INSN_CLASS_XTHEADINT:
+      return riscv_subset_supports (rps, "xtheadint");
     case INSN_CLASS_XTHEADMAC:
       return riscv_subset_supports (rps, "xtheadmac");
     case INSN_CLASS_XTHEADMEMIDX:
@@ -2578,6 +2581,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
       return "xtheadfmemidx";
     case INSN_CLASS_XTHEADFMV:
       return "xtheadfmv";
+    case INSN_CLASS_XTHEADINT:
+      return "xtheadint";
     case INSN_CLASS_XTHEADMAC:
       return "xtheadmac";
     case INSN_CLASS_XTHEADMEMIDX:
index ff0a25ddd9b7273f31490dbd4d4367be7abec28d..8ddd38a258393b505ec4659585ff46b5cd42916d 100644 (file)
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -26,7 +26,7 @@
   for --enable-compressed-debug-sections.
 
 * Add support for various T-Head extensions (XTheadBa, XTheadBb, XTheadBs,
-  XTheadCmo, XTheadCondMov, XTheadFMemIdx, XTheadFmv, XTheadMemIdx,
+  XTheadCmo, XTheadCondMov, XTheadFMemIdx, XTheadFmv, XTheadInt, XTheadMemIdx,
   XTheadMemPair, XTheadMac, and XTheadSync) from version 2.0 of the T-Head
   ISA manual, which are implemented in the Allwinner D1.
 
index f2a69d8b950d271cb210c33ca8cd2d13b8a05de4..d61e8e47fa4135d16d54d7fae7c1e9e644f88669 100644 (file)
@@ -739,6 +739,11 @@ The XTheadFmv extension provides access to the upper 32 bits of a doulbe-precisi
 
 It is documented in @url{https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.1.0/xthead-2022-11-07-2.1.0.pdf}.
 
+@item XTheadInt
+The XTheadInt extension provides access to ISR stack management instructions.
+
+It is documented in @url{https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.1.0/xthead-2022-11-07-2.1.0.pdf}.
+
 @item XTheadMac
 The XTheadMac extension provides multiply-accumulate instructions.
 
diff --git a/gas/testsuite/gas/riscv/x-thead-int.d b/gas/testsuite/gas/riscv/x-thead-int.d
new file mode 100644 (file)
index 0000000..23a82a2
--- /dev/null
@@ -0,0 +1,11 @@
+#as: -march=rv32i_xtheadint
+#source: x-thead-int.s
+#objdump: -dr
+
+.*:[   ]+file format .*
+
+Disassembly of section .text:
+
+0+000 <target>:
+[      ]+[0-9a-f]+:[   ]+0040000b[     ]+th.ipush
+[      ]+[0-9a-f]+:[   ]+0050000b[     ]+th.ipop
diff --git a/gas/testsuite/gas/riscv/x-thead-int.s b/gas/testsuite/gas/riscv/x-thead-int.s
new file mode 100644 (file)
index 0000000..23d8674
--- /dev/null
@@ -0,0 +1,3 @@
+target:
+       th.ipush
+       th.ipop
index d7d9dbc83f6f9cb5bc4f98a7bee6fb8fb98a3c30..f36b06dcd6bd4363d2dc9dd198218c7bd3ad4f9c 100644 (file)
 #define MASK_TH_FMV_HW_X 0xfff0707f
 #define MATCH_TH_FMV_X_HW 0x5000100b
 #define MASK_TH_FMV_X_HW 0xfff0707f
+/* Vendor-specific (T-Head) XTheadInt instructions. */
+#define MATCH_TH_IPOP 0x0050000b
+#define MASK_TH_IPOP 0xffffffff
+#define MATCH_TH_IPUSH 0x0040000b
+#define MASK_TH_IPUSH 0xffffffff
 /* Vendor-specific (T-Head) XTheadMac instructions.  */
 #define MATCH_TH_MULA 0x2000100b
 #define MASK_TH_MULA 0xfe00707f
@@ -3130,6 +3135,9 @@ DECLARE_INSN(th_fsurw, MATCH_TH_FSURW, MASK_TH_FSURW)
 /* Vendor-specific (T-Head) XTheadFmv instructions. */
 DECLARE_INSN(th_fmv_hw_x, MATCH_TH_FMV_HW_X, MASK_TH_FMV_HW_X)
 DECLARE_INSN(th_fmv_x_hw, MATCH_TH_FMV_X_HW, MASK_TH_FMV_X_HW)
+/* Vendor-specific (T-Head) XTheadInt instructions. */
+DECLARE_INSN(th_ipop, MATCH_TH_IPOP, MASK_TH_IPOP)
+DECLARE_INSN(th_ipush, MATCH_TH_IPUSH, MASK_TH_IPUSH)
 /* Vendor-specific (T-Head) XTheadMac instructions.  */
 DECLARE_INSN(th_mula, MATCH_TH_MULA, MASK_TH_MULA)
 DECLARE_INSN(th_mulah, MATCH_TH_MULAH, MASK_TH_MULAH)
index f90cf97ceb24aa7bf046fa059553069e32b3b78b..c3cbde600cb090dae76ec02a06825e0f26f7ca5a 100644 (file)
@@ -417,6 +417,7 @@ enum riscv_insn_class
   INSN_CLASS_XTHEADCONDMOV,
   INSN_CLASS_XTHEADFMEMIDX,
   INSN_CLASS_XTHEADFMV,
+  INSN_CLASS_XTHEADINT,
   INSN_CLASS_XTHEADMAC,
   INSN_CLASS_XTHEADMEMIDX,
   INSN_CLASS_XTHEADMEMPAIR,
index dfd508b0e71c9763a4131ec204089313e30ad052..0e691544f9bcd319806e1f97f0d91ed5ac5ea65c 100644 (file)
@@ -1935,6 +1935,10 @@ const struct riscv_opcode riscv_opcodes[] =
 {"th.fmv.hw.x", 32, INSN_CLASS_XTHEADFMV, "d,S", MATCH_TH_FMV_HW_X,  MASK_TH_FMV_HW_X,  match_opcode, 0},
 {"th.fmv.x.hw", 32, INSN_CLASS_XTHEADFMV, "d,S", MATCH_TH_FMV_X_HW,  MASK_TH_FMV_X_HW,  match_opcode, 0},
 
+/* Vendor-specific (T-Head) XTheadInt instructions.  */
+{"th.ipop",  0, INSN_CLASS_XTHEADINT, "", MATCH_TH_IPOP,  MASK_TH_IPOP,  match_opcode, 0},
+{"th.ipush", 0, INSN_CLASS_XTHEADINT, "", MATCH_TH_IPUSH, MASK_TH_IPUSH, match_opcode, 0},
+
 /* Vendor-specific (T-Head) XTheadMemIdx instructions.  */
 {"th.ldia",  64, INSN_CLASS_XTHEADMEMIDX, "d,(s),Xs5@20,Xu2@25", MATCH_TH_LDIA,  MASK_TH_LDIA,  match_th_load_inc, 0},
 {"th.ldib",  64, INSN_CLASS_XTHEADMEMIDX, "d,(s),Xs5@20,Xu2@25", MATCH_TH_LDIB,  MASK_TH_LDIB,  match_th_load_inc, 0},