[PATCH] D150049: [RISCV] Simplify matchRegisterNameHelper interface. NFC

Sergei Barannikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 7 23:55:38 PDT 2023


barannikov88 added a comment.

Just a few suggestions, not mandatory.



================
Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1445
+// failure, returns a non-valid MCRegister. If IsRVE, then registers x16-x31
+// will be // rejected.
+static MCRegister matchRegisterNameHelper(bool IsRVE, StringRef Name) {
----------------
Stray //


================
Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1447
+static MCRegister matchRegisterNameHelper(bool IsRVE, StringRef Name) {
+  MCRegister RegNo = MatchRegisterName(Name);
   // The 16-/32- and 64-bit FPRs have the same asm name. Check that the initial
----------------
Since you are refactoring this, RegNo could be renamed to Reg.



================
Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1455-1458
+  if (!RegNo.isValid())
     RegNo = MatchRegisterAltName(Name);
   if (IsRVE && RegNo >= RISCV::X16 && RegNo <= RISCV::X31)
+    RegNo = MCRegister();
----------------
Why change this? NoRegister was fine.



================
Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1475
   EndLoc = Tok.getEndLoc();
-  RegNo = 0;
   StringRef Name = getLexer().getTok().getIdentifier();
 
----------------



================
Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1478
+  RegNo = matchRegisterNameHelper(isRVE(), Name);
+  if (!RegNo.isValid())
     return MatchOperand_NoMatch;
----------------
Just `if (!RegNo)`?



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150049/new/

https://reviews.llvm.org/D150049



More information about the llvm-commits mailing list