[clang] [PowerPC] Make "ca" aliased to "xer" (PR #77557)
Kai Luo via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 9 21:59:27 PST 2024
https://github.com/bzEq created https://github.com/llvm/llvm-project/pull/77557
`ca` is not accepted in clobber list of inline assembly right now. Make `ca` aliased to `xer`, so it can be accepted in clobber list.
Fixes #77549.
>From e1caee46dc81e59b8eab0379e200ca2a709801c3 Mon Sep 17 00:00:00 2001
From: Kai Luo <lkail at cn.ibm.com>
Date: Wed, 10 Jan 2024 05:29:22 +0000
Subject: [PATCH 1/2] Alias
---
clang/lib/Basic/Targets/PPC.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 045c273f03c7a0..fa86d93b141180 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -803,7 +803,7 @@ const TargetInfo::GCCRegAlias PPCTargetInfo::GCCRegAliases[] = {
{{"fr22"}, "f22"}, {{"fr23"}, "f23"}, {{"fr24"}, "f24"},
{{"fr25"}, "f25"}, {{"fr26"}, "f26"}, {{"fr27"}, "f27"},
{{"fr28"}, "f28"}, {{"fr29"}, "f29"}, {{"fr30"}, "f30"},
- {{"fr31"}, "f31"}, {{"cc"}, "cr0"},
+ {{"fr31"}, "f31"}, {{"cc"}, "cr0"}, {{"ca"}, "xer"},
};
ArrayRef<TargetInfo::GCCRegAlias> PPCTargetInfo::getGCCRegAliases() const {
>From aaee97fb9f7bef5ff4e3f845fa29d45e9c7a83b0 Mon Sep 17 00:00:00 2001
From: Kai Luo <lkail at cn.ibm.com>
Date: Wed, 10 Jan 2024 05:56:27 +0000
Subject: [PATCH 2/2] CA aliasing to XER
---
clang/lib/Basic/Targets/PPC.cpp | 3 +++
clang/test/CodeGen/ppc-register-names.c | 14 ++++++++++++++
2 files changed, 17 insertions(+)
create mode 100644 clang/test/CodeGen/ppc-register-names.c
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index fa86d93b141180..abf685f8883971 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -782,6 +782,9 @@ ArrayRef<const char *> PPCTargetInfo::getGCCRegNames() const {
const TargetInfo::GCCRegAlias PPCTargetInfo::GCCRegAliases[] = {
// While some of these aliases do map to different registers
// they still share the same register name.
+ // Strictly speaking, "ca" is a subregister of "xer". However
+ // currently we don't model other bit fields of "xer", so treat
+ // "ca" aliasing to "xer".
{{"0"}, "r0"}, {{"1", "sp"}, "r1"}, {{"2"}, "r2"},
{{"3"}, "r3"}, {{"4"}, "r4"}, {{"5"}, "r5"},
{{"6"}, "r6"}, {{"7"}, "r7"}, {{"8"}, "r8"},
diff --git a/clang/test/CodeGen/ppc-register-names.c b/clang/test/CodeGen/ppc-register-names.c
new file mode 100644
index 00000000000000..209488c2e5f1ae
--- /dev/null
+++ b/clang/test/CodeGen/ppc-register-names.c
@@ -0,0 +1,14 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang -target powerpc64le -c %s -mllvm -stop-after=finalize-isel -o - | \
+// RUN: FileCheck %s
+// RUN: %clang -target powerpc64 -c %s -mllvm -stop-after=finalize-isel -o - | \
+// RUN: FileCheck %s
+
+void test_function(void) {
+ asm volatile("":::"ca");
+ asm volatile("":::"xer");
+ // CHECK: call void asm sideeffect "", "~{xer}"()
+ // CHECK: call void asm sideeffect "", "~{xer}"()
+ // CHECK: INLINEASM &"", {{.*}} implicit-def early-clobber $xer
+ // CHECK: INLINEASM &"", {{.*}} implicit-def early-clobber $xer
+}
More information about the cfe-commits
mailing list