aboutsummaryrefslogtreecommitdiff
path: root/clang/utils
diff options
context:
space:
mode:
authorSander de Smalen <sander.desmalen@arm.com>2024-01-15 09:41:32 +0000
committerGitHub <noreply@github.com>2024-01-15 09:41:32 +0000
commit8e7f073eb42c92aa7a2b651ca314d7fcebf296e3 (patch)
tree1b6b5ddd8c7c88a0228b65dcdb4f0ffec8639e1f /clang/utils
parent06e3abcb54f339edc2ba757cfa947e024677b21e (diff)
downloadllvm-8e7f073eb42c92aa7a2b651ca314d7fcebf296e3.zip
llvm-8e7f073eb42c92aa7a2b651ca314d7fcebf296e3.tar.gz
llvm-8e7f073eb42c92aa7a2b651ca314d7fcebf296e3.tar.bz2
[Clang][AArch64] Change SME attributes for shared/new/preserved state. (#76971)
This patch replaces the `__arm_new_za`, `__arm_shared_za` and `__arm_preserves_za` attributes in favour of: * `__arm_new("za")` * `__arm_in("za")` * `__arm_out("za")` * `__arm_inout("za")` * `__arm_preserves("za")` As described in https://github.com/ARM-software/acle/pull/276. One change is that `__arm_in/out/inout/preserves(S)` are all mutually exclusive, whereas previously it was fine to write `__arm_shared_za __arm_preserves_za`. This case is now represented with `__arm_in("za")`. The current implementation uses the same LLVM attributes under the hood, since `__arm_in/out/inout` are all variations of "shared ZA", so can use the existing `aarch64_pstate_za_shared` attribute in LLVM. #77941 will add support for the new "zt0" state as introduced with SME2.
Diffstat (limited to 'clang/utils')
-rw-r--r--clang/utils/TableGen/ClangAttrEmitter.cpp32
-rw-r--r--clang/utils/TableGen/SveEmitter.cpp2
-rw-r--r--clang/utils/TableGen/TableGen.cpp21
-rw-r--r--clang/utils/TableGen/TableGenBackends.h4
4 files changed, 34 insertions, 25 deletions
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 4ec0057..c35490c 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3547,23 +3547,27 @@ static void GenerateHasAttrSpellingStringSwitch(
OS << " .Default(0);\n";
}
-// Emits the list of tokens for regular keyword attributes.
-void EmitClangAttrTokenKinds(RecordKeeper &Records, raw_ostream &OS) {
- emitSourceFileHeader("A list of tokens generated from the attribute"
- " definitions",
- OS);
+// Emits list of regular keyword attributes with info about their arguments.
+void EmitClangRegularKeywordAttributeInfo(RecordKeeper &Records,
+ raw_ostream &OS) {
+ emitSourceFileHeader(
+ "A list of regular keyword attributes generated from the attribute"
+ " definitions",
+ OS);
// Assume for now that the same token is not used in multiple regular
// keyword attributes.
for (auto *R : Records.getAllDerivedDefinitions("Attr"))
- for (const auto &S : GetFlattenedSpellings(*R))
- if (isRegularKeywordAttribute(S)) {
- if (!R->getValueAsListOfDefs("Args").empty())
- PrintError(R->getLoc(),
- "RegularKeyword attributes with arguments are not "
- "yet supported");
- OS << "KEYWORD_ATTRIBUTE("
- << S.getSpellingRecord().getValueAsString("Name") << ")\n";
- }
+ for (const auto &S : GetFlattenedSpellings(*R)) {
+ if (!isRegularKeywordAttribute(S))
+ continue;
+ std::vector<Record *> Args = R->getValueAsListOfDefs("Args");
+ bool HasArgs = llvm::any_of(
+ Args, [](const Record *Arg) { return !Arg->getValueAsBit("Fake"); });
+
+ OS << "KEYWORD_ATTRIBUTE("
+ << S.getSpellingRecord().getValueAsString("Name") << ", "
+ << (HasArgs ? "true" : "false") << ")\n";
+ }
OS << "#undef KEYWORD_ATTRIBUTE\n";
}
diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp
index 5de2223..060d79a 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -1619,7 +1619,7 @@ void SVEEmitter::createSMEHeader(raw_ostream &OS) {
OS << "}\n\n";
OS << "__ai __attribute__((target(\"sme\"))) void svundef_za(void) "
- "__arm_streaming_compatible __arm_shared_za "
+ "__arm_streaming_compatible __arm_out(\"za\") "
"{ }\n\n";
createCoreHeaderIntrinsics(OS, *this, ACLEKind::SME);
diff --git a/clang/utils/TableGen/TableGen.cpp b/clang/utils/TableGen/TableGen.cpp
index 3859555..158d10e 100644
--- a/clang/utils/TableGen/TableGen.cpp
+++ b/clang/utils/TableGen/TableGen.cpp
@@ -37,7 +37,7 @@ enum ActionType {
GenClangAttrSubjectMatchRuleList,
GenClangAttrPCHRead,
GenClangAttrPCHWrite,
- GenClangAttrTokenKinds,
+ GenClangRegularKeywordAttributeInfo,
GenClangAttrHasAttributeImpl,
GenClangAttrSpellingListIndex,
GenClangAttrASTVisitor,
@@ -150,8 +150,10 @@ cl::opt<ActionType> Action(
"Generate clang PCH attribute reader"),
clEnumValN(GenClangAttrPCHWrite, "gen-clang-attr-pch-write",
"Generate clang PCH attribute writer"),
- clEnumValN(GenClangAttrTokenKinds, "gen-clang-attr-token-kinds",
- "Generate a list of attribute-related clang tokens"),
+ clEnumValN(GenClangRegularKeywordAttributeInfo,
+ "gen-clang-regular-keyword-attr-info",
+ "Generate a list of regular keyword attributes with info "
+ "about their arguments"),
clEnumValN(GenClangAttrHasAttributeImpl,
"gen-clang-attr-has-attribute-impl",
"Generate a clang attribute spelling list"),
@@ -291,11 +293,14 @@ cl::opt<ActionType> Action(
"Generate riscv_vector_builtin_cg.inc for clang"),
clEnumValN(GenRISCVVectorBuiltinSema, "gen-riscv-vector-builtin-sema",
"Generate riscv_vector_builtin_sema.inc for clang"),
- clEnumValN(GenRISCVSiFiveVectorBuiltins, "gen-riscv-sifive-vector-builtins",
+ clEnumValN(GenRISCVSiFiveVectorBuiltins,
+ "gen-riscv-sifive-vector-builtins",
"Generate riscv_sifive_vector_builtins.inc for clang"),
- clEnumValN(GenRISCVSiFiveVectorBuiltinCG, "gen-riscv-sifive-vector-builtin-codegen",
+ clEnumValN(GenRISCVSiFiveVectorBuiltinCG,
+ "gen-riscv-sifive-vector-builtin-codegen",
"Generate riscv_sifive_vector_builtin_cg.inc for clang"),
- clEnumValN(GenRISCVSiFiveVectorBuiltinSema, "gen-riscv-sifive-vector-builtin-sema",
+ clEnumValN(GenRISCVSiFiveVectorBuiltinSema,
+ "gen-riscv-sifive-vector-builtin-sema",
"Generate riscv_sifive_vector_builtin_sema.inc for clang"),
clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
@@ -355,8 +360,8 @@ bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
case GenClangAttrPCHWrite:
EmitClangAttrPCHWrite(Records, OS);
break;
- case GenClangAttrTokenKinds:
- EmitClangAttrTokenKinds(Records, OS);
+ case GenClangRegularKeywordAttributeInfo:
+ EmitClangRegularKeywordAttributeInfo(Records, OS);
break;
case GenClangAttrHasAttributeImpl:
EmitClangAttrHasAttrImpl(Records, OS);
diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h
index faa0c5d..58a4af3 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -53,8 +53,8 @@ void EmitClangAttrSubjectMatchRuleList(llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangAttrPCHRead(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitClangAttrPCHWrite(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangAttrTokenKinds(llvm::RecordKeeper &Records,
- llvm::raw_ostream &OS);
+void EmitClangRegularKeywordAttributeInfo(llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
void EmitClangAttrHasAttrImpl(llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitClangAttrSpellingListIndex(llvm::RecordKeeper &Records,