Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[M68k] allow 16-bit registers for MOVE to/from CCR #107591

Closed
wants to merge 1 commit into from

Conversation

TechnoElf
Copy link
Contributor

Fixes #106210.

Copy link

github-actions bot commented Sep 6, 2024

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Sep 6, 2024

@llvm/pr-subscribers-backend-m68k

Author: Janis Heims (TechnoElf)

Changes

Fixes #106210.


Full diff: https://github.com/llvm/llvm-project/pull/107591.diff

1 Files Affected:

  • (modified) llvm/lib/Target/M68k/M68kInstrInfo.cpp (+12-6)
diff --git a/llvm/lib/Target/M68k/M68kInstrInfo.cpp b/llvm/lib/Target/M68k/M68kInstrInfo.cpp
index 23c5c76a47479b..8704d64ca17a36 100644
--- a/llvm/lib/Target/M68k/M68kInstrInfo.cpp
+++ b/llvm/lib/Target/M68k/M68kInstrInfo.cpp
@@ -709,13 +709,19 @@ void M68kInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
   bool ToSR = DstReg == M68k::SR;
 
   if (FromCCR) {
-    assert(M68k::DR8RegClass.contains(DstReg) &&
-           "Need DR8 register to copy CCR");
-    Opc = M68k::MOV8dc;
+    if (M68k::DR8RegClass.contains(DstReg))
+      Opc = M68k::MOV8dc;
+    else if (M68k::DR16RegClass.contains(DstReg))
+      Opc = M68k::MOV16dc;
+    else
+      llvm_unreachable("Invalid register for MOVE from CCR");
   } else if (ToCCR) {
-    assert(M68k::DR8RegClass.contains(SrcReg) &&
-           "Need DR8 register to copy CCR");
-    Opc = M68k::MOV8cd;
+    if (M68k::DR8RegClass.contains(SrcReg))
+      Opc = M68k::MOV8cd;
+    else if (M68k::DR16RegClass.contains(SrcReg))
+      Opc = M68k::MOV16cd;
+    else
+      llvm_unreachable("Invalid register for MOVE to CCR");
   } else if (FromSR || ToSR)
     llvm_unreachable("Cannot emit SR copy instruction");
 

@TechnoElf
Copy link
Contributor Author

Ping @0x59616e

@0x59616e 0x59616e assigned 0x59616e and unassigned 0x59616e Oct 4, 2024
@0x59616e 0x59616e self-requested a review October 4, 2024 13:44
Copy link
Member

@mshockwave mshockwave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! Could you add some tests?

assert(M68k::DR8RegClass.contains(DstReg) &&
"Need DR8 register to copy CCR");
Opc = M68k::MOV8dc;
if (M68k::DR8RegClass.contains(DstReg))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TechnoElf
Copy link
Contributor Author

Should I close this PR as #114714 already implements the requested changes?

@mshockwave
Copy link
Member

Should I close this PR as #114714 already implements the requested changes?

Feel free to do that!

@TechnoElf TechnoElf closed this Nov 11, 2024
mshockwave pushed a commit that referenced this pull request Nov 27, 2024
Builds on @TechnoElf 's CCR MOV pr
#107591 and adds some tests.

Fixes #106210.

---------

Co-authored-by: TechnoElf <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[M68k] incorrect assertion on move from CC register to data register
4 participants