Skip to content

Add support for Zhinxmin extension #753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ For booting operating system images, see the information under the
- F and D extensions for single and double-precision floating-point, v2.2
- Zfh and Zfhmin extensions for half-precision floating-point, v1.0
- Zfa extension for additional floating-point instructions, v1.0
- Zfinx, Zdinx, and Zhinx extensions for floating-point in integer registers, v1.0
- Zfinx, Zdinx, Zhinx, and Zhinxmin extensions for floating-point in integer registers, v1.0
- C extension for compressed instructions, v2.0
- Zca, Zcf, Zcd, and Zcb extensions for code size reduction, v1.0
- Zcmop extension for compressed May-Be-Operations, v1.0
Expand Down
3 changes: 3 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@
"Zhinx": {
"supported": false
},
"Zhinxmin": {
"supported": false
},
"Zvbb": {
"supported": true
},
Expand Down
3 changes: 3 additions & 0 deletions model/riscv_extensions.sail
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ function clause hartSupports(Ext_Zksh) = config extensions.Zksh.supported
// Floating-Point in Integer Registers (half precision)
enum clause extension = Ext_Zhinx
function clause hartSupports(Ext_Zhinx) = config extensions.Zhinx.supported
// Floating-Point in Integer Registers (minimal half precision)
enum clause extension = Ext_Zhinxmin
function clause hartSupports(Ext_Zhinxmin) = config extensions.Zhinxmin.supported

// Vector Basic Bit-manipulation
enum clause extension = Ext_Zvbb
Expand Down
3 changes: 2 additions & 1 deletion model/riscv_insts_zfh.sail
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/*=======================================================================================*/

function clause currentlyEnabled(Ext_Zhinx) = hartSupports(Ext_Zhinx) & currentlyEnabled(Ext_Zfinx)
function clause currentlyEnabled(Ext_Zhinxmin) = (hartSupports(Ext_Zhinxmin) & currentlyEnabled(Ext_Zfinx))| currentlyEnabled(Ext_Zhinx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function clause currentlyEnabled(Ext_Zhinxmin) = (hartSupports(Ext_Zhinxmin) & currentlyEnabled(Ext_Zfinx))| currentlyEnabled(Ext_Zhinx)
function clause currentlyEnabled(Ext_Zhinxmin) = (hartSupports(Ext_Zhinxmin) & currentlyEnabled(Ext_Zfinx))

I looked through the specification but couldn’t find anything indicating that Zhinx enables Zhinxmin.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same approach we took for Zfh and Zfhmin. Zhinx includes everything in Zhinxmin, so we gate the relevant instructions on Zhinxmin and enable Zhinxmin if Zhinx is enabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't know if this is a good approach to turn on extensions silently. Whats the advantage of enabling Zhinxmin automatically when Zhinx is active, given that Zhinx already includes all those instructions? Wouldn't it be cleaner to keep each extension's enabled status independent?

This may be confusing for the reader.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's been a lot of discussion surrounding these extensions where one implies another. See riscv/riscv-isa-manual#1121 and riscv/riscv-isa-manual#869 for a discussion about M/Zmmul. Right now, we do this for a number of other extensions (Zfhmin, Zmmul, possibly a few others), so I'd be in favor of keeping it consistent in this PR and we can open an issue to potentially change all of them later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, lets keep it and handle this in a separate PR.


/* **************************************************************** */
/* This file specifies the instructions in the Zfh extension */
Expand Down Expand Up @@ -167,7 +168,7 @@ function fle_H (v1, v2, is_quiet) = {
function haveHalfFPU() -> bool = currentlyEnabled(Ext_Zfh) | currentlyEnabled(Ext_Zhinx)
// Support for conversion of halves to/from single & double, but no actual
// calculations with halves.
function haveHalfMin() -> bool = haveHalfFPU() | currentlyEnabled(Ext_Zfhmin)
function haveHalfMin() -> bool = haveHalfFPU() | currentlyEnabled(Ext_Zfhmin) | currentlyEnabled(Ext_Zhinxmin)

/* ****************************************************************** */
/* Floating-point loads */
Expand Down
Loading