[llvm] 4b8d9ab - [AArch64] Complete the list of extensions supported by .arch and .arch_extension

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 01:50:29 PDT 2023


Author: Martin Storsjö
Date: 2023-06-06T11:50:03+03:00
New Revision: 4b8d9abca7d0280878fb12de331e688ee85d7cd8

URL: https://github.com/llvm/llvm-project/commit/4b8d9abca7d0280878fb12de331e688ee85d7cd8
DIFF: https://github.com/llvm/llvm-project/commit/4b8d9abca7d0280878fb12de331e688ee85d7cd8.diff

LOG: [AArch64] Complete the list of extensions supported by .arch and .arch_extension

This brings the list of extensions supported here up to date
with what is supported by current git versions of binutils.

Also add a comment to AArch64TargetParser to remind people to
consider adding new ones to the list supported in assembly.

In the case of the "rdma" extension, there's a slight surprise:
LLVM knows of the extension under the name "rdm", while binutils
has it named "rdma". However, binutils appears to accept any
abbreviated prefix of an arch extension, so it does accept the
form "rdm" too even if it formally considers it called "rdma".

Support both spellings for the extensions here, for simplicity.

Differential Revision: https://reviews.llvm.org/D151981

Added: 
    

Modified: 
    llvm/docs/ReleaseNotes.rst
    llvm/include/llvm/TargetParser/AArch64TargetParser.h
    llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
    llvm/test/MC/AArch64/directive-arch_extension.s

Removed: 
    


################################################################################
diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 23daea3c87b85..1c4f3274806d3 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -93,6 +93,8 @@ Changes to the AArch64 Backend
 * Added Assembly Support for the 2022 A-profile extensions FEAT_GCS (Guarded
   Control Stacks), FEAT_CHK (Check Feature Status), and FEAT_ATS1A.
 * Support for preserve_all calling convention is added.
+* Added support for missing arch extensions in the assembly directives
+  ``.arch <level>+<ext>`` and ``.arch_extension``.
 
 Changes to the AMDGPU Backend
 -----------------------------

diff  --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 5dc2dc3e54eaa..dc4cdfa8e90ac 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -176,6 +176,8 @@ struct ExtensionInfo {
       1000; // Maximum priority for FMV feature
 };
 
+// NOTE: If adding a new extension here, consider adding it to ExtensionMap
+// in AArch64AsmParser too, if supported as an extension name by binutils.
 // clang-format off
 inline constexpr ExtensionInfo Extensions[] = {
     {"aes", AArch64::AEK_AES, "+aes", "-aes", FEAT_AES, "+fp-armv8,+neon", 150},

diff  --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index beb360342f913..3703cd03e10e7 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -3677,10 +3677,24 @@ static const struct Extension {
     {"cssc", {AArch64::FeatureCSSC}},
     {"rcpc3", {AArch64::FeatureRCPC3}},
     {"gcs", {AArch64::FeatureGCS}},
-    // FIXME: Unsupported extensions
-    {"lor", {}},
-    {"rdma", {}},
-    {"profile", {}},
+    {"bf16", {AArch64::FeatureBF16}},
+    {"compnum", {AArch64::FeatureComplxNum}},
+    {"dotprod", {AArch64::FeatureDotProd}},
+    {"f32mm", {AArch64::FeatureMatMulFP32}},
+    {"f64mm", {AArch64::FeatureMatMulFP64}},
+    {"fp16", {AArch64::FeatureFullFP16}},
+    {"fp16fml", {AArch64::FeatureFP16FML}},
+    {"i8mm", {AArch64::FeatureMatMulInt8}},
+    {"lor", {AArch64::FeatureLOR}},
+    {"profile", {AArch64::FeatureSPE}},
+    // "rdma" is the name documented by binutils for the feature, but
+    // binutils also accepts incomplete prefixes of features, so "rdm"
+    // works too. Support both spellings here.
+    {"rdm", {AArch64::FeatureRDM}},
+    {"rdma", {AArch64::FeatureRDM}},
+    {"sb", {AArch64::FeatureSB}},
+    {"ssbs", {AArch64::FeatureSSBS}},
+    {"tme", {AArch64::FeatureTME}},
 };
 
 static void setRequiredFeatureString(FeatureBitset FBS, std::string &Str) {

diff  --git a/llvm/test/MC/AArch64/directive-arch_extension.s b/llvm/test/MC/AArch64/directive-arch_extension.s
index b5bbee7910561..8a0e1ac471cea 100644
--- a/llvm/test/MC/AArch64/directive-arch_extension.s
+++ b/llvm/test/MC/AArch64/directive-arch_extension.s
@@ -132,3 +132,60 @@ umax x0, x1, x2
 .arch_extension gcs
 gcspushm x0
 // CHECK: gcspushm x0
+
+.arch_extension bf16
+bfdot v0.2s, v0.4h, v0.4h
+// CHECK: bfdot v0.2s, v0.4h, v0.4h
+
+.arch_extension compnum
+fcmla v1.2d, v2.2d, v3.2d, #0
+// CHECK: fcmla v1.2d, v2.2d, v3.2d, #0
+
+.arch_extension dotprod
+udot v0.4s, v0.16b, v0.16b
+// CHECK: udot v0.4s, v0.16b, v0.16b
+
+.arch_extension f32mm
+fmmla z0.s, z1.s, z2.s
+// CHECK: fmmla z0.s, z1.s, z2.s
+
+.arch_extension f64mm
+fmmla z0.d, z1.d, z2.d
+// CHECK: fmmla z0.d, z1.d, z2.d
+
+.arch_extension fp16
+fadd v0.8h, v0.8h, v0.8h
+// CHECK: fadd v0.8h, v0.8h, v0.8h
+
+.arch_extension fp16fml
+fmlal v0.2s, v1.2h, v2.2h
+// CHECK: fmlal v0.2s, v1.2h, v2.2h
+
+.arch_extension i8mm
+usdot v0.4s, v0.16b, v0.16b
+// CHECK: usdot v0.4s, v0.16b, v0.16b
+
+.arch_extension lor
+stllr x0, [x0]
+// CHECK: stllr x0, [x0]
+
+.arch_extension profile
+msr PMBLIMITR_EL1, x0
+// CHECK: msr PMBLIMITR_EL1, x0
+
+.arch_extension rdm
+.arch_extension rdma
+sqrdmlah v0.8h, v0.8h, v0.8h
+// CHECK: sqrdmlah v0.8h, v0.8h, v0.8h
+
+.arch_extension sb
+sb
+// CHECK: sb
+
+.arch_extension ssbs
+msr SSBS, #1
+// CHECK: msr SSBS, #1
+
+.arch_extension tme
+tstart x0
+// CHECK: tstart x0


        


More information about the llvm-commits mailing list