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] Change gcc register name from a7 to sp. #87095

Merged
merged 3 commits into from
Apr 2, 2024

Conversation

tclin914
Copy link
Contributor

In M68kRegisterInfo.td, register SP is defined with name sp and alternate name a7.

Fixes: #78620

In M68kRegisterInfo.td, register SP is defined with name x7 and alternate name a7.

Fixes: llvm#78620
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" backend:m68k labels Mar 29, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 29, 2024

@llvm/pr-subscribers-backend-m68k

@llvm/pr-subscribers-clang

Author: Jim Lin (tclin914)

Changes

In M68kRegisterInfo.td, register SP is defined with name sp and alternate name a7.

Fixes: #78620


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

1 Files Affected:

  • (modified) clang/lib/Basic/Targets/M68k.cpp (+1-1)
diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp
index 1b7e0a7f32c9be..9e6b59f1e42a8d 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -127,7 +127,7 @@ bool M68kTargetInfo::hasFeature(StringRef Feature) const {
 
 const char *const M68kTargetInfo::GCCRegNames[] = {
     "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
-    "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
+    "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
     "pc"};
 
 ArrayRef<const char *> M68kTargetInfo::getGCCRegNames() const {

Copy link

github-actions bot commented Mar 29, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff d3bc9cc99b3d45e1fb8d65a57e308e899439fe26 c91fb8eacd5a156185df0b94819f02d671f9ed66 -- clang/test/CodeGen/M68k/inline-asm-gcc-regs.c clang/lib/Basic/Targets/M68k.cpp clang/lib/Basic/Targets/M68k.h
View the diff from clang-format here.
diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp
index 8b8bf97d6f..d018984224 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -126,9 +126,8 @@ bool M68kTargetInfo::hasFeature(StringRef Feature) const {
 }
 
 const char *const M68kTargetInfo::GCCRegNames[] = {
-    "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
-    "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
-    "pc"};
+    "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a0",
+    "a1", "a2", "a3", "a4", "a5", "a6", "sp", "pc"};
 
 ArrayRef<const char *> M68kTargetInfo::getGCCRegNames() const {
   return llvm::ArrayRef(GCCRegNames);

@mshockwave
Copy link
Member

Is it possible use TargetInfo::getGCCRegAliases to model the aliasing between a7 and sp?
Also, could you add a simple test?

Testcase is copied from
clang/test/CodeGen/LoongArch/inline-asm-gcc-regs.c.
@tclin914
Copy link
Contributor Author

tclin914 commented Apr 1, 2024

Is it possible use TargetInfo::getGCCRegAliases to model the aliasing between a7 and sp? Also, could you add a simple test?

Implement getGCCRegAliases and add testcase.

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.

Thank you! LGTM

@tclin914 tclin914 merged commit 4f0b5d5 into llvm:main Apr 2, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:m68k clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[M68k] error: unknown register name 'sp' in asm when trying to build Linux kernel
3 participants