Skip to content

Commit c661c4f

Browse files
author
Chen Zheng
authored
[AIX] recognize vsr in inline asm for AIX (#68476)
Extend `PPCTargetInfo::getGCCAddlRegNames()` to aix as well. The definition should be common between Linux PPC and AIX PPC.
1 parent b48450c commit c661c4f

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

clang/lib/Basic/Targets/PPC.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
753753
}
754754
}
755755

756+
// Make sure that registers are added in the correct array index which should be
757+
// the DWARF number for PPC registers.
756758
const char *const PPCTargetInfo::GCCRegNames[] = {
757759
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8",
758760
"r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
@@ -807,6 +809,7 @@ ArrayRef<TargetInfo::GCCRegAlias> PPCTargetInfo::getGCCRegAliases() const {
807809
// PPC ELFABIv2 DWARF Definition "Table 2.26. Mappings of Common Registers".
808810
// vs0 ~ vs31 is mapping to 32 - 63,
809811
// vs32 ~ vs63 is mapping to 77 - 108.
812+
// And this mapping applies to all OSes which run on powerpc.
810813
const TargetInfo::AddlRegName GCCAddlRegNames[] = {
811814
// Table of additional register names to use in user input.
812815
{{"vs0"}, 32}, {{"vs1"}, 33}, {{"vs2"}, 34}, {{"vs3"}, 35},
@@ -828,10 +831,7 @@ const TargetInfo::AddlRegName GCCAddlRegNames[] = {
828831
};
829832

830833
ArrayRef<TargetInfo::AddlRegName> PPCTargetInfo::getGCCAddlRegNames() const {
831-
if (ABI == "elfv2")
832-
return llvm::ArrayRef(GCCAddlRegNames);
833-
else
834-
return TargetInfo::getGCCAddlRegNames();
834+
return llvm::ArrayRef(GCCAddlRegNames);
835835
}
836836

837837
static constexpr llvm::StringLiteral ValidCPUNames[] = {

clang/test/CodeGen/PowerPC/inline-asm-matching-ppc-vsx.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22

33
// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -target-feature +vsx \
44
// RUN: -target-cpu pwr9 -emit-llvm %s -o - | FileCheck %s
5+
// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -target-feature +vsx \
6+
// RUN: -target-cpu pwr9 -emit-llvm %s -o - | FileCheck %s
7+
// RUN: %clang_cc1 -triple powerpc64-ibm-aix -target-feature +vsx \
8+
// RUN: -target-cpu pwr9 -emit-llvm %s -o - | FileCheck %s
9+
// RUN: %clang_cc1 -triple powerpc-ibm-aix -target-feature +vsx \
10+
// RUN: -target-cpu pwr9 -emit-llvm %s -o - | FileCheck %s
511

612
// This case is to test VSX register support in the clobbers list for inline asm.
713
void testVSX (void) {
814
unsigned int a = 0;
915
unsigned int *dbell=&a;
1016
int d;
1117
__asm__ __volatile__ (
12-
"lxvw4x %%vs32, 0, %2\n\t"
13-
"stxvw4x %%vs32, 0, %1"
18+
"lxvw4x 32, 0, %2\n\t"
19+
"stxvw4x 32, 0, %1"
1420
: "=m"(*(volatile unsigned int*)(dbell))
1521
: "r" (dbell), "r" (&d)
1622
: "vs32"
1723
);
1824
}
1925

20-
// CHECK: call void asm sideeffect "lxvw4x %vs32, 0, $2\0A\09stxvw4x %vs32, 0, $1", "=*m,r,r,~{vs32}"
26+
// CHECK: call void asm sideeffect "lxvw4x 32, 0, $2\0A\09stxvw4x 32, 0, $1", "=*m,r,r,~{vs32}"

0 commit comments

Comments
 (0)