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

Min-Yih Hsu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 2 15:21:28 PDT 2021


myhsu added inline comments.


================
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[] = {
----------------
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.


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

https://reviews.llvm.org/D101733



More information about the llvm-commits mailing list