From: Chao Liu <chao.liu@yeah.net>
To: qemu-devel@nongnu.org
Cc: bmeng.cn@gmail.com, liwei1518@gmail.com,
peter.maydell@linaro.org, palmer@dabbelt.com,
alistair.francis@wdc.com, dbarboza@ventanamicro.com,
zhiwei_liu@linux.alibaba.com, Chao Liu <chao.liu@yeah.net>
Subject: [RFC PATCH v1 0/1] Add helper_print functions for printing intermediate results of complex instructions in RISC-V target
Date: Sun, 24 Nov 2024 01:23:37 +0800 [thread overview]
Message-ID: <cover.1732376265.git.chao.liu@yeah.net> (raw)
Hi all,
Recently, I have been working on functional simulation and verification of
an extended complex instruction set for an AI chip based on the RISC-V
architecture using QEMU.
Given the complexity of some instructions, I attempted to introduce a set of
helper functions that can print certain intermediate results of IR
corresponding to a single instruction, such as those from sparse matrix operations.
My implementation approach is as follows:
1. Encapsulate printf within helper functions (to avoid issues where the printf
address might exceed the ±2GB address space when called directly). Since helpers
do not support variadic arguments, I defined multiple helper_print functions with
a maximum of 7 parameters.
2. Designed a syntactic sugar using C macros and the concatenation operator ##
to encapsulate the aforementioned helper_print functions, which can support up
to 7 parameters.
However, I encountered some issues, such as having to set < #pragma GCC diagnostic
ignored "-Wformat-security"> for this piece of code, but I think there might be
some security risks involved.
Currently, these macros are temporarily added under target/risc-v, but I believe
they could be designed more generally to support more architectures.
During testing, I found that these interfaces work particularly well for debugging
simulations of complex instructions.
Therefore, I am sharing this patch with the mailing list in hopes that we can discuss
and come up with a friendlier and more universal solution. :)
Regards,
Chao
Chao Liu (1):
riscv: Add gen_helper_print() to debug IR
target/riscv/helper.h | 13 ++++++++++++
target/riscv/op_helper.c | 46 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
--
2.40.1
next reply other threads:[~2024-11-23 17:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-23 17:23 Chao Liu [this message]
2024-11-23 17:23 ` [RFC PATCH v1 1/1] riscv: Add helper_print() for printing intermediate results of IR Chao Liu
2024-11-23 18:35 ` [RFC PATCH v1 0/1] Add helper_print functions for printing intermediate results of complex instructions in RISC-V target Chao Liu
2024-11-23 19:08 ` Chao Liu
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=cover.1732376265.git.chao.liu@yeah.net \
--to=chao.liu@yeah.net \
--cc=alistair.francis@wdc.com \
--cc=bmeng.cn@gmail.com \
--cc=dbarboza@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.