[PATCH] D101733: [M68k][AsmParser] Fix invalid register name parsing logics

Ricky Taylor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 2 16:23:25 PDT 2021


ricky26 accepted this revision.
ricky26 added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp:483
   // Parse simple general-purpose registers.
-  if (RegisterNameLower.size() == 2) {
+  if (RegisterNameLower.size() >= 2) {
     static unsigned RegistersByIndex[] = {
----------------
myhsu wrote:
> ricky26 wrote:
> > It might be simpler to pull out CCR for now. Otherwise this will cause some invalid register names to be parsed as valid `%a0q` for example would be parsed as A0 (the third character would be ignored).
> > 
> > A better solution might be to remove this check and in the switch cases check the name length.
> > 
> > I recognise this is due to my error!
> Good point. Will do.
> Although when we're going to support register with size suffix (e.g. `%a0.l`) we still need to handle more general cases (because AsmLexer will lex "a0.l" as a single identifier albeit there is a `AsmToken::Dot` token) but I think it's trivial to change.
Agreed. I expected some changes to the register name parsing to be necessary. 😄 


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

https://reviews.llvm.org/D101733



More information about the llvm-commits mailing list