Skip to content

Conversation

palmer-dabbelt
Copy link
Contributor

These larger SEWs aren't in the ratified V spec. Thanks to dzaima and sorear on IRC for pointing this one out.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented May 13, 2024

@llvm/pr-subscribers-mc

@llvm/pr-subscribers-backend-risc-v

Author: Palmer Dabbelt (palmer-dabbelt)

Changes

These larger SEWs aren't in the ratified V spec. Thanks to dzaima and sorear on IRC for pointing this one out.


Full diff: https://github.com/llvm/llvm-project/pull/92010.diff

2 Files Affected:

  • (modified) llvm/include/llvm/TargetParser/RISCVTargetParser.h (+1-1)
  • (modified) llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp (+1-1)
diff --git a/llvm/include/llvm/TargetParser/RISCVTargetParser.h b/llvm/include/llvm/TargetParser/RISCVTargetParser.h
index cdd19189f8dc7..5b1494efe7bdc 100644
--- a/llvm/include/llvm/TargetParser/RISCVTargetParser.h
+++ b/llvm/include/llvm/TargetParser/RISCVTargetParser.h
@@ -61,7 +61,7 @@ enum {
 namespace RISCVVType {
 // Is this a SEW value that can be encoded into the VTYPE format.
 inline static bool isValidSEW(unsigned SEW) {
-  return isPowerOf2_32(SEW) && SEW >= 8 && SEW <= 1024;
+  return isPowerOf2_32(SEW) && SEW >= 8 && SEW <= 64;
 }
 
 // Is this a LMUL value that can be encoded into the VTYPE format.
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 123b37442329f..6bdd038bd07e9 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2227,7 +2227,7 @@ bool RISCVAsmParser::generateVTypeError(SMLoc ErrorLoc) {
   return Error(
       ErrorLoc,
       "operand must be "
-      "e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]");
+      "e[8|16|32|64],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]");
 }
 
 ParseStatus RISCVAsmParser::parseMaskReg(OperandVector &Operands) {

@jrtc27
Copy link
Collaborator

jrtc27 commented May 13, 2024

66da87d is the commit that first introduced this check which was committed just after V 0.9 (haven't checked if it implemented 0.9 or stuck with 0.8), and up until 1.0 64 < SEW <= 1024 was reserved (see riscvarchive/riscv-v-spec@c32b714).

@topperc
Copy link
Collaborator

topperc commented May 13, 2024

Can you add tests to test/MC/RISCV/rvv/invalid.s? I see a test for e2048 in there. I guess we didn't have any tests for e128-e1024.

These larger SEWs aren't in the ratified V spec.  Thanks to dzaima and
sorear on IRC for pointing this one out.

Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
@llvmbot llvmbot added the llvm:mc Machine (object) code label May 13, 2024
@palmer-dabbelt
Copy link
Contributor Author

Can you add tests to test/MC/RISCV/rvv/invalid.s? I see a test for e2048 in there. I guess we didn't have any tests for e128-e1024.

Done. Also I fixed up the errors in those tests (I'm no building/testing this locally, I figured some CI would do it for me).

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

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

LGTM

@topperc
Copy link
Collaborator

topperc commented May 13, 2024

@palmer-dabbelt I assume you need someone to commit this?

@topperc topperc merged commit b04c07b into llvm:main May 14, 2024
Copy link

@palmer-dabbelt Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:RISC-V llvm:mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants