Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[AArch64] Complete the list of extensions supported by .arch and .arc…
…h_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
  • Loading branch information
mstorsjo committed Jun 6, 2023
1 parent 9c1e558 commit 4b8d9ab
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 4 deletions.
2 changes: 2 additions & 0 deletions llvm/docs/ReleaseNotes.rst
Expand Up @@ -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
-----------------------------
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/TargetParser/AArch64TargetParser.h
Expand Up @@ -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},
Expand Down
22 changes: 18 additions & 4 deletions llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
Expand Up @@ -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) {
Expand Down
57 changes: 57 additions & 0 deletions llvm/test/MC/AArch64/directive-arch_extension.s
Expand Up @@ -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

0 comments on commit 4b8d9ab

Please sign in to comment.