@@ -76,44 +76,34 @@ SMEAttrs::SMEAttrs(const AttributeList &Attrs) {
7676
7777void 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
0 commit comments