public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "juzhe.zhong@rivai.ai" <juzhe.zhong@rivai.ai>
To: cooper.joshua <cooper.joshua@linux.alibaba.com>,
	 gcc-patches <gcc-patches@gcc.gnu.org>
Cc: "Jim Wilson" <jim.wilson.gcc@gmail.com>,
	 palmer <palmer@dabbelt.com>,  andrew <andrew@sifive.com>,
	 philipp.tomsich <philipp.tomsich@vrull.eu>,
	 jeffreyalaw <jeffreyalaw@gmail.com>,
	 christoph.muellner <christoph.muellner@vrull.eu>,
	 cooper.joshua <cooper.joshua@linux.alibaba.com>,
	 jinma <jinma@linux.alibaba.com>,
	 cooper.qu <cooper.qu@linux.alibaba.com>
Subject: Re: [PATCH v4 4/6] RISC-V: Adds the prefix "th." for the instructions of XTheadVector.
Date: Mon, 25 Dec 2023 16:18:43 +0800	[thread overview]
Message-ID: <CAE97C0B1E1BC63A+2023122516184246064524@rivai.ai> (raw)
In-Reply-To: <20231225081431.873-1-cooper.joshua@linux.alibaba.com>

[-- Attachment #1: Type: text/plain, Size: 3960 bytes --]

OK.



juzhe.zhong@rivai.ai
 
From: Jun Sha (Joshua)
Date: 2023-12-25 16:14
To: gcc-patches
CC: jim.wilson.gcc; palmer; andrew; philipp.tomsich; jeffreyalaw; christoph.muellner; juzhe.zhong; Jun Sha (Joshua); Jin Ma; Xianmiao Qu
Subject: [PATCH v4 4/6] RISC-V: Adds the prefix "th." for the instructions of XTheadVector.
This patch adds th. prefix to all XTheadVector instructions by
implementing new assembly output functions. In this version, we 
follow Kito's suggestions and only check the prefix is 'v', so that 
no extra attribute is needed.
 
gcc/ChangeLog:
 
* config/riscv/riscv-protos.h (riscv_asm_output_opcode): 
New function to add assembler insn code prefix/suffix.
* config/riscv/riscv.cc (riscv_asm_output_opcode): Likewise.
* config/riscv/riscv.h (ASM_OUTPUT_OPCODE): Likewise.
 
Co-authored-by: Jin Ma <jinma@linux.alibaba.com>
Co-authored-by: Xianmiao Qu <cooper.qu@linux.alibaba.com>
Co-authored-by: Christoph Müllner <christoph.muellner@vrull.eu>
---
gcc/config/riscv/riscv-protos.h               |  1 +
gcc/config/riscv/riscv.cc                     | 19 +++++++++++++++++++
gcc/config/riscv/riscv.h                      |  4 ++++
.../riscv/rvv/xtheadvector/prefix.c           | 12 ++++++++++++
4 files changed, 36 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/xtheadvector/prefix.c
 
diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h
index 31049ef7523..5ea54b45703 100644
--- a/gcc/config/riscv/riscv-protos.h
+++ b/gcc/config/riscv/riscv-protos.h
@@ -102,6 +102,7 @@ struct riscv_address_info {
};
/* Routines implemented in riscv.cc.  */
+extern const char *riscv_asm_output_opcode (FILE *asm_out_file, const char *p);
extern enum riscv_symbol_type riscv_classify_symbolic_expression (rtx);
extern bool riscv_symbolic_constant_p (rtx, enum riscv_symbol_type *);
extern int riscv_float_const_rtx_index_for_fli (rtx);
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 0d1cbc5cb5f..30e6ced5f3f 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -5636,6 +5636,25 @@ riscv_get_v_regno_alignment (machine_mode mode)
   return lmul;
}
+/* Define ASM_OUTPUT_OPCODE to do anything special before
+   emitting an opcode.  */
+const char *
+riscv_asm_output_opcode (FILE *asm_out_file, const char *p)
+{
+  if (!TARGET_XTHEADVECTOR)
+    return p;
+
+  if (current_output_insn == NULL_RTX)
+    return p;
+
+  /* We need to add th. prefix to all the xtheadvector
+     insturctions here.*/
+  if (p[0] == 'v')
+    fputs ("th.", asm_out_file);
+
+  return p;
+}
+
/* Implement TARGET_PRINT_OPERAND.  The RISCV-specific operand codes are:
    'h' Print the high-part relocation associated with OP, after stripping
diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 6df9ec73c5e..c33361a254d 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -826,6 +826,10 @@ extern enum riscv_cc get_riscv_cc (const rtx use);
       asm_fprintf ((FILE), "%U%s", (NAME)); \
   } while (0)
+#undef ASM_OUTPUT_OPCODE
+#define ASM_OUTPUT_OPCODE(STREAM, PTR) \
+  (PTR) = riscv_asm_output_opcode(STREAM, PTR)
+
#define JUMP_TABLES_IN_TEXT_SECTION 0
#define CASE_VECTOR_MODE SImode
#define CASE_VECTOR_PC_RELATIVE (riscv_cmodel != CM_MEDLOW)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/xtheadvector/prefix.c b/gcc/testsuite/gcc.target/riscv/rvv/xtheadvector/prefix.c
new file mode 100644
index 00000000000..48867f4ddfb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/xtheadvector/prefix.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gc_xtheadvector -mabi=ilp32 -O0" } */
+
+#include "riscv_vector.h"
+
+vint32m1_t
+prefix (vint32m1_t vx, vint32m1_t vy, size_t vl)
+{
+  return __riscv_vadd_vv_i32m1 (vx, vy, vl);
+}
+
+/* { dg-final { scan-assembler {\mth\.v\M} } } */
-- 
2.17.1
 
 

  reply	other threads:[~2023-12-25  8:19 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-18  4:22 [PATCH v2 0/9] RISC-V: Support XTheadVector extensions Jun Sha (Joshua)
2023-11-18  4:26 ` [PATCH v2 1/9] RISC-V: minimal support for xtheadvector Jun Sha (Joshua)
2023-11-18 10:06   ` Kito Cheng
2023-11-18  4:28 ` [PATCH v2 2/9] RISC-V: Handle differences between xtheadvector and vector Jun Sha (Joshua)
2023-11-18 10:13   ` Kito Cheng
2023-11-18  4:29 ` [PATCH v2 3/9] RISC-V: Tests for overlapping RVV and XTheadVector instructions (Part1) Jun Sha (Joshua)
2023-11-18  4:32 ` [PATCH v2 4/9] RISC-V: Tests for overlapping RVV and XTheadVector instructions (Part2) Jun Sha (Joshua)
2023-11-18  4:34 ` [PATCH v2 5/9] RISC-V: Tests for overlapping RVV and XTheadVector instructions (Part3) Jun Sha (Joshua)
2023-11-18  4:35 ` [PATCH v2 6/9] RISC-V: Tests for overlapping RVV and XTheadVector instructions (Part4) Jun Sha (Joshua)
2023-11-18  4:37 ` [PATCH v2 8/9] RISC-V: Add support for xtheadvector-specific load/store intrinsics Jun Sha (Joshua)
2023-11-18  4:39 ` [PATCH v2 9/9] RISC-V: Disable fractional type intrinsics for the XTheadVector extension Jun Sha (Joshua)
2023-12-20 12:20 ` [PATCH v3 0/6] RISC-V: Support " Jun Sha (Joshua)
2023-12-20 12:25   ` [PATCH v3 1/6] RISC-V: Refactor riscv-vector-builtins-bases.cc Jun Sha (Joshua)
2023-12-20 18:14     ` Jeff Law
2023-12-27  2:46       ` 回复:[PATCH " joshua
2023-12-29  1:44       ` joshua
2023-12-20 12:27   ` [PATCH v3 2/6] RISC-V: Split csr_operand in predicates.md for vector patterns Jun Sha (Joshua)
2023-12-20 18:16     ` Jeff Law
2023-12-27  2:49       ` 回复:[PATCH " joshua
2023-12-28 15:50         ` Jeff Law
2023-12-20 12:30   ` [PATCH v3 3/6] RISC-V: Introduce XTheadVector as a subset of V1.0.0 Jun Sha (Joshua)
2023-12-20 12:32   ` [PATCH v3 4/6] RISC-V: Adds the prefix "th." for the instructions of XTheadVector Jun Sha (Joshua)
2023-12-20 18:22     ` Jeff Law
2023-12-20 22:48       ` 钟居哲
2023-12-21  4:41         ` Jeff Law
2023-12-21  9:43           ` Kito Cheng
2023-12-25  6:25     ` [PATCH v4 " Jun Sha (Joshua)
2023-12-25  6:37       ` juzhe.zhong
2023-12-25  7:08         ` 回复:[PATCH " joshua
2023-12-25  7:09           ` juzhe.zhong
2023-12-25  8:14       ` [PATCH " Jun Sha (Joshua)
2023-12-25  8:18         ` juzhe.zhong [this message]
2023-12-20 12:34   ` [PATCH v3 5/6] RISC-V: Handle differences between XTheadvector and Vector Jun Sha (Joshua)
2023-12-20 14:00     ` 钟居哲
2023-12-20 14:24       ` 回复:[PATCH " joshua
2023-12-20 14:27         ` 钟居哲
2023-12-20 14:41           ` 回复:回复:[PATCH " joshua
2023-12-20 14:48             ` 回复:[PATCH " 钟居哲
2023-12-20 14:55             ` 钟居哲
2023-12-20 15:21               ` 回复:回复:[PATCH " joshua
2023-12-20 15:29                 ` 回复:[PATCH " 钟居哲
2023-12-25  6:29     ` [PATCH v4 " Jun Sha (Joshua)
2023-12-29  1:46       ` Jun Sha (Joshua)
2023-12-29  1:58         ` juzhe.zhong
2023-12-29  2:09           ` 回复:[PATCH " joshua
2023-12-29  2:11             ` Re:[PATCH " joshua
2023-12-29  2:14             ` 回复:[PATCH " juzhe.zhong
2023-12-29  2:17               ` Re:[PATCH " joshua
2023-12-29  2:22                 ` juzhe.zhong
2023-12-29  2:25                   ` Re:Re:[PATCH " joshua
2023-12-29  2:25                     ` Re:[PATCH " juzhe.zhong
2023-12-29  2:30                       ` joshua
2023-12-29  2:31                         ` juzhe.zhong
2023-12-29  2:47                         ` juzhe.zhong
2023-12-20 12:36   ` [PATCH v3 6/6] RISC-V: Add support for xtheadvector-specific intrinsics Jun Sha (Joshua)
2023-12-25  6:31     ` [PATCH v4 " Jun Sha (Joshua)
2023-12-29  1:49       ` Jun Sha (Joshua)
2023-12-20 23:04   ` [PATCH v3 0/6] RISC-V: Support XTheadVector extension 钟居哲
2023-12-22  3:33     ` 回复:[PATCH " joshua
2023-12-22  8:07       ` juzhe.zhong
2023-12-22 10:29         ` 回复:回复:[PATCH " joshua
2023-12-22 10:31           ` 回复:[PATCH " juzhe.zhong
2023-12-23  3:37             ` 回复:回复:[PATCH " joshua
2023-12-23 22:52               ` 回复:[PATCH " 钟居哲
2023-12-22 17:21         ` Jeff Law
2023-12-20 23:08   ` [PATCH " 钟居哲
2023-12-21  3:28     ` Jeff Law
2023-12-21  3:30       ` juzhe.zhong
2023-12-21  4:04         ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAE97C0B1E1BC63A+2023122516184246064524@rivai.ai \
    --to=juzhe.zhong@rivai.ai \
    --cc=andrew@sifive.com \
    --cc=christoph.muellner@vrull.eu \
    --cc=cooper.joshua@linux.alibaba.com \
    --cc=cooper.qu@linux.alibaba.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=jim.wilson.gcc@gmail.com \
    --cc=jinma@linux.alibaba.com \
    --cc=palmer@dabbelt.com \
    --cc=philipp.tomsich@vrull.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).