Skip to content

Commit 8235c92

Browse files
committed
Re-try getSupportedLibcallImpl
1 parent 9f9497c commit 8235c92

File tree

2 files changed

+26
-36
lines changed

2 files changed

+26
-36
lines changed

llvm/lib/Target/AArch64/Utils/AArch64SMEAttributes.cpp

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -76,44 +76,34 @@ SMEAttrs::SMEAttrs(const AttributeList &Attrs) {
7676

7777
void SMEAttrs::addKnownFunctionAttrs(StringRef FuncName,
7878
const TargetLowering &TLI) {
79-
// If the function name does not start with a _ or #_ is not a builtin.
80-
if (!FuncName.starts_with('_') && !FuncName.starts_with("#_"))
79+
RTLIB::LibcallImpl Impl = TLI.getSupportedLibcallImpl(FuncName);
80+
if (Impl == RTLIB::Unsupported)
8181
return;
82-
83-
struct SMERoutineAttr {
84-
RTLIB::Libcall LC{RTLIB::UNKNOWN_LIBCALL};
85-
unsigned Attrs{SMEAttrs::Normal};
86-
};
87-
88-
static constexpr unsigned SMCompatiableABIRoutine =
89-
SMEAttrs::SM_Compatible | SMEAttrs::SME_ABI_Routine;
90-
static constexpr unsigned SMCompatiableABIRoutineInZA =
91-
SMCompatiableABIRoutine | encodeZAState(StateValue::In);
92-
93-
// Table of SME routine -> Known attributes.
94-
static constexpr SMERoutineAttr SMERoutineAttrs[]{
95-
{RTLIB::SMEABI_SME_STATE, SMCompatiableABIRoutine},
96-
{RTLIB::SMEABI_TPIDR2_SAVE, SMCompatiableABIRoutine},
97-
{RTLIB::SMEABI_GET_CURRENT_VG, SMCompatiableABIRoutine},
98-
{RTLIB::SMEABI_SME_STATE_SIZE, SMCompatiableABIRoutine},
99-
{RTLIB::SMEABI_SME_SAVE, SMCompatiableABIRoutine},
100-
{RTLIB::SMEABI_SME_RESTORE, SMCompatiableABIRoutine},
101-
{RTLIB::SMEABI_ZA_DISABLE, SMCompatiableABIRoutineInZA},
102-
{RTLIB::SMEABI_TPIDR2_RESTORE, SMCompatiableABIRoutineInZA},
103-
{RTLIB::SC_MEMCPY, SMEAttrs::SM_Compatible},
104-
{RTLIB::SC_MEMMOVE, SMEAttrs::SM_Compatible},
105-
{RTLIB::SC_MEMSET, SMEAttrs::SM_Compatible},
106-
{RTLIB::SC_MEMCHR, SMEAttrs::SM_Compatible},
107-
};
108-
10982
unsigned KnownAttrs = SMEAttrs::Normal;
110-
for (auto [LC, Attrs] : SMERoutineAttrs) {
111-
if (TLI.getLibcallName(LC) == FuncName) {
112-
KnownAttrs = Attrs;
113-
break;
114-
}
83+
RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
84+
switch (LC) {
85+
case RTLIB::SMEABI_SME_STATE:
86+
case RTLIB::SMEABI_TPIDR2_SAVE:
87+
case RTLIB::SMEABI_GET_CURRENT_VG:
88+
case RTLIB::SMEABI_SME_STATE_SIZE:
89+
case RTLIB::SMEABI_SME_SAVE:
90+
case RTLIB::SMEABI_SME_RESTORE:
91+
KnownAttrs |= SMEAttrs::SM_Compatible | SMEAttrs::SME_ABI_Routine;
92+
break;
93+
case RTLIB::SMEABI_ZA_DISABLE:
94+
case RTLIB::SMEABI_TPIDR2_RESTORE:
95+
KnownAttrs |= SMEAttrs::SM_Compatible | encodeZAState(StateValue::In) |
96+
SMEAttrs::SME_ABI_Routine;
97+
break;
98+
case RTLIB::SC_MEMCPY:
99+
case RTLIB::SC_MEMMOVE:
100+
case RTLIB::SC_MEMSET:
101+
case RTLIB::SC_MEMCHR:
102+
KnownAttrs |= SMEAttrs::SM_Compatible;
103+
break;
104+
default:
105+
break;
115106
}
116-
117107
set(KnownAttrs);
118108
}
119109

llvm/lib/Target/AArch64/Utils/AArch64SMEAttributes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class SMEAttrs {
9292
static StateValue decodeZAState(unsigned Bitmask) {
9393
return static_cast<StateValue>((Bitmask & ZA_Mask) >> ZA_Shift);
9494
}
95-
static constexpr unsigned encodeZAState(StateValue S) {
95+
static unsigned encodeZAState(StateValue S) {
9696
return static_cast<unsigned>(S) << ZA_Shift;
9797
}
9898

0 commit comments

Comments
 (0)