[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:28:19 PDT 2021
myhsu updated this revision to Diff 342287.
myhsu marked an inline comment as done.
myhsu added a comment.
Handle CCR register's name as special case
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101733/new/
https://reviews.llvm.org/D101733
Files:
llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp
llvm/test/CodeGen/M68k/Encoding/Data/Classes/MxMoveCCR.mir
llvm/test/MC/M68k/Data/Classes/MxMoveCCR.s
Index: llvm/test/MC/M68k/Data/Classes/MxMoveCCR.s
===================================================================
--- /dev/null
+++ 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
+
Index: llvm/test/CodeGen/M68k/Encoding/Data/Classes/MxMoveCCR.mir
===================================================================
--- 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
-
-...
Index: llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp
===================================================================
--- llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp
+++ llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp
@@ -479,6 +479,12 @@
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 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101733.342287.patch
Type: text/x-patch
Size: 3281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210502/4cefba0a/attachment.bin>
More information about the llvm-commits
mailing list