[llvm] 5b3dd2a - [M68k][AsmParser] Fix invalid register name parsing logics
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Wed May 5 17:15:15 PDT 2021
Author: Min-Yih Hsu
Date: 2021-05-05T17:13:02-07:00
New Revision: 5b3dd2a49035445dcfdb09fb7e890b79adf6ab6f
URL: https://github.com/llvm/llvm-project/commit/5b3dd2a49035445dcfdb09fb7e890b79adf6ab6f
DIFF: https://github.com/llvm/llvm-project/commit/5b3dd2a49035445dcfdb09fb7e890b79adf6ab6f.diff
LOG: [M68k][AsmParser] Fix invalid register name parsing logics
Adjust sanity check in register parsing function to allow register
name with more than 2 characters (e.g. ccr).
Differential Revision: https://reviews.llvm.org/D101733
Added:
llvm/test/MC/M68k/Data/Classes/MxMoveCCR.s
Modified:
llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp
Removed:
llvm/test/CodeGen/M68k/Encoding/Data/Classes/MxMoveCCR.mir
################################################################################
diff --git a/llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp b/llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp
index 3f5da05db5e12..d8465f6d682b7 100644
--- a/llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp
+++ b/llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp
@@ -479,6 +479,12 @@ bool M68kAsmParser::parseRegisterName(unsigned &RegNo, SMLoc Loc,
StringRef RegisterName) {
auto RegisterNameLower = RegisterName.lower();
+ // CCR register
+ if (RegisterNameLower == "ccr") {
+ RegNo = M68k::CCR;
+ return true;
+ }
+
// Parse simple general-purpose registers.
if (RegisterNameLower.size() == 2) {
static unsigned RegistersByIndex[] = {
@@ -501,13 +507,6 @@ bool M68kAsmParser::parseRegisterName(unsigned &RegNo, SMLoc Loc,
break;
}
- case 'c':
- if (RegisterNameLower[1] == 'c' && RegisterNameLower[2] == 'r') {
- RegNo = M68k::CCR;
- return true;
- }
- break;
-
case 's':
if (RegisterNameLower[1] == 'p') {
RegNo = M68k::SP;
diff --git a/llvm/test/CodeGen/M68k/Encoding/Data/Classes/MxMoveCCR.mir b/llvm/test/CodeGen/M68k/Encoding/Data/Classes/MxMoveCCR.mir
deleted file mode 100644
index c276d3c5fa316..0000000000000
--- a/llvm/test/CodeGen/M68k/Encoding/Data/Classes/MxMoveCCR.mir
+++ /dev/null
@@ -1,34 +0,0 @@
-# RUN: llc %s -mtriple=m68k -start-after=prologepilog -O0 -filetype=obj -o - \
-# RUN: | extract-section .text \
-# RUN: | FileCheck %s -check-prefixes=MOV16CD,MOV16DC
-
-#------------------------------------------------------------------------------
-# MxMoveToCCR and MxMoveFromCCR load/store condition flag register
-#------------------------------------------------------------------------------
-
---- # To CCR
-# ---------------------------------------+-----------+-----------
-# F E D C B A 9 8 7 6 | 5 4 3 | 2 1 0
-# ---------------------------------------+-----------+-----------
-# 0 1 0 0 0 1 0 0 1 1 | MODE | REG
-# ---------------------------------------+-----------+-----------
-# MOV16CD: 0 1 0 0 0 1 0 0 . 1 1 0 0 0 0 0 1
-name: MxMoveToCCR
-body: |
- bb.0:
- $ccr = MOV16cd $wd1, implicit-def $ccr
-
-...
---- # From CCR
-# ---------------------------------------+-----------+-----------
-# F E D C B A 9 8 7 6 | 5 4 3 | 2 1 0
-# ---------------------------------------+-----------+-----------
-# 0 1 0 0 0 0 1 0 1 1 | MODE | REG
-# ---------------------------------------+-----------+-----------
-# MOV16DC-SAME: 0 1 0 0 0 0 1 0 . 1 1 0 0 0 0 0 1
-name: MxMoveFromCCR
-body: |
- bb.0:
- $wd1 = MOV16dc $ccr, implicit $ccr
-
-...
diff --git a/llvm/test/MC/M68k/Data/Classes/MxMoveCCR.s b/llvm/test/MC/M68k/Data/Classes/MxMoveCCR.s
new file mode 100644
index 0000000000000..f7f964a362af5
--- /dev/null
+++ b/llvm/test/MC/M68k/Data/Classes/MxMoveCCR.s
@@ -0,0 +1,16 @@
+; RUN: llvm-mc -triple=m68k -show-encoding %s | FileCheck %s
+ .text
+ .globl MxMoveToCCR
+; CHECK-LABEL: MxMoveToCCR:
+MxMoveToCCR:
+ ; CHECK: move.w %d1, %ccr
+ ; CHECK-SAME: encoding: [0x44,0xc1]
+ move.w %d1, %ccr
+
+ .globl MxMoveFromCCR
+; CHECK-LABEL: MxMoveFromCCR:
+MxMoveFromCCR:
+ ; CHECK: move.w %ccr, %d1
+ ; CHECK-SAME: encoding: [0x42,0xc1]
+ move.w %ccr, %d1
+
More information about the llvm-commits
mailing list