From 40a631f452726606e1d43b5d2744aa983949af78 Mon Sep 17 00:00:00 2001 From: Sander de Smalen Date: Fri, 19 Jan 2024 16:02:24 +0000 Subject: [Clang] Refactor diagnostics for SME builtins. (#78258) The arm_sme.td file was still using `IsSharedZA` and `IsPreservesZA`, which should be changed to match the new state attributes added in #76971. This patch adds `IsInZA`, `IsOutZA` and `IsInOutZA` as the state for the Clang builtins and fixes up the code in SemaChecking and SveEmitter to match. Note that the code is written in such a way that it can be easily extended with ZT0 state (to follow in a future patch). --- clang/utils/TableGen/SveEmitter.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'clang/utils') diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp index 99b7148..b67c8e5 100644 --- a/clang/utils/TableGen/SveEmitter.cpp +++ b/clang/utils/TableGen/SveEmitter.cpp @@ -1720,21 +1720,21 @@ void SVEEmitter::createBuiltinZAState(raw_ostream &OS) { for (auto *R : RV) createIntrinsic(R, Defs); - std::map> DefsZAState; - - uint64_t IsSharedZAFlag = getEnumValueForFlag("IsSharedZA"); + std::map> IntrinsicsPerState; for (auto &Def : Defs) { - bool HasZAState = Def->isFlagSet(IsSharedZAFlag); - DefsZAState[HasZAState].insert(Def->getMangledName()); + if (Def->isFlagSet(getEnumValueForFlag("IsInZA"))) + IntrinsicsPerState["ArmInZA"].insert(Def->getMangledName()); + else if (Def->isFlagSet(getEnumValueForFlag("IsOutZA"))) + IntrinsicsPerState["ArmOutZA"].insert(Def->getMangledName()); + else if (Def->isFlagSet(getEnumValueForFlag("IsInOutZA"))) + IntrinsicsPerState["ArmInOutZA"].insert(Def->getMangledName()); } - OS << "#ifdef GET_SME_BUILTIN_HAS_ZA_STATE\n"; - - for (auto HasZA : {true, false}) { - auto Names = DefsZAState[HasZA]; - for (auto Name : Names) + OS << "#ifdef GET_SME_BUILTIN_GET_STATE\n"; + for (auto &KV : IntrinsicsPerState) { + for (StringRef Name : KV.second) OS << "case SME::BI__builtin_sme_" << Name << ":\n"; - OS << " return " << (HasZA ? "true" : "false") << ";\n"; + OS << " return " << KV.first << ";\n"; } OS << "#endif\n\n"; } -- cgit v1.1