Skip to content

cmd/internal/obj/riscv: add assembly support of Zfa extension - #76996

Open
lxq015 wants to merge 7 commits into
golang:masterfrom
lxq015:zfa_asm
Open

lxq015 wants to merge 7 commits into
golang:masterfrom
lxq015:zfa_asm

Conversation

@lxq015

@lxq015 lxq015 commented Dec 26, 2025 •

Copy link
Copy Markdown
Contributor

This patch adds the assembly support of Zfa extension, which is defined
in chapter 26 of RISC-V ISA manual.

Zfa adds several additional floating-point instructions and is mandatory
in RVA23 profile.

Follow-up to CL 631575

Co-authored-by: wangpengcheng.pp@bytedance.com

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 5169a81) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/732700.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Pengcheng Wang:

Patch Set 2:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Xueqi Luo:

Patch Set 3:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Xueqi Luo:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Boyao Wang:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: ef6f524) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/732700.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Xueqi Luo:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Meng Zhuo:

Patch Set 4: Code-Review+2 Commit-Queue+1

(4 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 4:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2026-06-22T08:46:13Z","revision":"b250ea9b19d714f92475bcf42d4c1cbc67798194"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Meng Zhuo:

Patch Set 4: -Commit-Queue

(Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_7530>)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 4:

This CL has failed the run. Reason:

Tryjob golang/try/x_tools-gotip-linux-amd64 has failed with summary (view all results):


Error: Failed to run "fetch \"golang.org/x/tools/gopls\" dependencies": exit status 1

Additional links for debugging:


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 4: LUCI-TryBot-Result-1


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: faa5743) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/732700.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Julian Zhu:

Patch Set 5: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 5:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2026-09-28T09:49:16Z","revision":"52a3228f86c43d2e173e5566a79bfedeb5d924a4"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Julian Zhu:

Patch Set 5: -Commit-Queue

(Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_61713>)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 5:

This CL has failed the run. Reason:

Tryjob golang/try/gotip-linux-arm64_debian13 has failed with summary (view all results):


To reproduce, try gomote repro 8669425104989874593.

Additional links for debugging:


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 5: LUCI-TryBot-Result-1


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Julian Zhu:

Patch Set 5:

(4 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

…ouble

The single fimmMapping keyed by float64 served both FLIS (single-precision
immediate) and FLID (double-precision immediate), which made progedit and
the encoder disagree: progedit looked up float64(f32) (the operand rounded
to float32 then widened back) while the encoder looked up the original
float64 operand. A double like 1.0000000000000002 rounds to 1.0 as float32
and would pass progedit's check but fail the encoder's, producing an
"unknown floating point immediate" error.

Split the map into flisMapping (float32 keys) and flidMapping (float64
keys), and check each instruction in its own domain: FLIS keys on the
float32 value, FLID on the float64 value. Also check NaN on float32
directly (f32 != f32) since math.IsNaN only accepts float64.
flidMapping[1] was copied from flisMapping and held the single-precision
minimum positive normal (2^-126, 1.1754943508222875e-38). Per the RISC-V
Zfa spec, entry 1 (the minimum positive normal value) has a numerically
different value for double-precision, so flidMapping[1] must be the
double-precision minimum positive normal 2^-1022
(2.2250738585072014e-308).

Update the corresponding FLID test line in riscv64.s to use the double
value; its encoding (index 1) is unchanged.
The Zfa fround/froundnx instructions take an explicit rounding mode in the
rm field (bits 14:12), but AFROUNDS/AFROUNDNXS/AFROUNDD/AFROUNDNXD were
only given rFFEncoding, which hardcoded funct3 to 0 (RNE) with no way to
select another rounding mode.

Wire them into the existing rounding-mode suffix mechanism used by fcvt:
ParseSuffix now accepts .RNE/.RTZ/.RDN/.RUP/.RMM on the fround instructions
and stores the mode in Scond, and instructionsForProg writes it into
funct3, defaulting to RNE when no suffix is given (preserving the previous
encoding for suffix-free fround).

Add end-to-end tests for all four fround instructions across all five
rounding modes.
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: c661ca4) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/732700.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Xueqi Luo:

Patch Set 6:

(5 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/732700.
After addressing review feedback, remember to publish your drafts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants