This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] add support for zbkx subextension in MC layer.
ClosedPublic

Authored by SForeKeeper on Jan 21 2022, 6:33 AM.

Details

Summary

This patch adds support for zbkx extension from K extension(v1.0.0) in MC layer.
Instructions with same functionality and same encoding is defined in the bitmanip extension.
It defines {Xperm8, Xperm4} as instruction aliases for xperm.* in Zbp extension. When Zbkx is enabled while Zbp is not, xperm.h will not be available. When Zbkx and Zbp are both enabled, the instructions will be decoded in Zbp format.

D94999 this is the patch that introduces xperm.* instructions.

Diff Detail

Event Timeline

SForeKeeper created this revision.Jan 21 2022, 6:33 AM
SForeKeeper requested review of this revision.Jan 21 2022, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 21 2022, 6:33 AM
SForeKeeper retitled this revision from [RISCV][RFC] add support for zbkx subextension. to [RISCV][RFC] add support for zbkx subextension in MC layer..Jan 21 2022, 6:35 AM
SForeKeeper edited the summary of this revision. (Show Details)
SForeKeeper edited the summary of this revision. (Show Details)Jan 21 2022, 6:38 AM

Update comments in tablegen file.

Fixes faulty commit that removes previous commit.

Fixes incorrect update.

Please upload patches with full context using -U99999 as described here https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface

llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
432 ↗(On Diff #401991)

"Float in Integer"?

llvm/lib/Target/RISCV/RISCVInstrInfoZk.td
9 ↗(On Diff #401991)

This should be Zk not K. But since I think these should be in Zb. It doesn't really matter.

19 ↗(On Diff #401991)

This extension name starts with Zb so I think it should be in RISCVInstrInfoZb.

llvm/test/MC/RISCV/rv32zbkx-valid.s
13

How do these get disassembled when Zbkx and Zbp are both enabled?

Revision Contents look weired. Does this patch upload by git diff -U99999?
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface

llvm/lib/Target/RISCV/RISCVInstrInfoZk.td
9 ↗(On Diff #401991)

agree, i also think it should be put to Zb

VincentWu added inline comments.Jan 21 2022, 6:21 PM
llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
18

it will be better to organize it in the same order as RISCVSchedRocket.td

Please upload patches with full context using -U99999 as described here https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface

Understood, will apply in next update. Since there are xperm.* instructions in RISCVInstrInfoZb.td, should them be removal since Zbp doesn't exist anymore?

SForeKeeper edited the summary of this revision. (Show Details)

Now xperm8 and xperm4 are aliases for xperm.* instructions in Zbp extension. They will be decoded to xperm8 and xperm4 when both extensions are enabled.

SForeKeeper edited the summary of this revision. (Show Details)Jan 22 2022, 7:04 AM
craig.topper added inline comments.Jan 22 2022, 10:43 AM
llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
747

I'd rename the instructions in Zbp to xperm4 and xperm8 and add xperm.n and xperm.b aliases for Zbp. If Zbp gets picked up in the future, the instructions will likely be renamed to match Zbkx.

llvm/test/MC/RISCV/attribute-arch.s
165

Blank line before to keep consistency.

SForeKeeper marked 2 inline comments as done.

Changed instrucions' name from xperm.* to xperm8 and xperm4 and use xperm.* as instruction aliases.
Now when both are enabled they would be decoded in Zbp format.

SForeKeeper edited the summary of this revision. (Show Details)Jan 22 2022, 5:10 PM
craig.topper added inline comments.Jan 23 2022, 11:58 AM
llvm/lib/Target/RISCV/RISCV.td
204

Replace 'B' with 'Zb'. I have a patch to fix the existing locations here D117822

llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
15–20

Please add Zbkx to the header. I just pushed a commit to add a spot for Zbk* extensions.

747

I wouldn't speculate on whether Zbp will be ratified or not. Just say Zbp is unratified and that it would likely adopt the already ratified Zbkx names.

Please remove [RFC] from the title.

SForeKeeper marked an inline comment as done.
SForeKeeper retitled this revision from [RISCV][RFC] add support for zbkx subextension in MC layer. to [RISCV] add support for zbkx subextension in MC layer..

Fix comments.

This revision is now accepted and ready to land.Jan 23 2022, 10:47 PM
VincentWu added inline comments.Jan 23 2022, 10:54 PM
llvm/lib/Target/RISCV/RISCV.td
166

you may need rebase again and include zbxk into subTargeteature list of FeatureStdExtZks & FeatureStdExtZkn which is added in https://reviews.llvm.org/D98136.

llvm/test/CodeGen/RISCV/attributes.ll
133

same here

llvm/test/MC/RISCV/attribute-arch.s
135

again

VincentWu added inline comments.Jan 23 2022, 10:56 PM
llvm/lib/Target/RISCV/RISCV.td
166

*zbkx

Rebase and add Zbkx in Zks, Zkn.

This revision was landed with ongoing or failed builds.Jan 24 2022, 4:39 AM
This revision was automatically updated to reflect the committed changes.