Skip to content

Commit

Permalink
[AArch64] clang support for Armv8.8/9.3 MOPS
Browse files Browse the repository at this point in the history
This introduces clang command line support for the new Armv8.8-A and
Armv9.3-A instructions for standardising memcpy, memset and memmove
operations, which was previously introduced into LLVM in
https://reviews.llvm.org/D116157.

Patch by Lucas Prates, Tomas Matheson and Son Tuan Vu.

Differential Revision: https://reviews.llvm.org/D117271
  • Loading branch information
pratlucas authored and tyb-arm committed Jan 15, 2022
1 parent 0b010ef commit c84b8be
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/AArch64.cpp
Expand Up @@ -544,6 +544,7 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasMatmulFP32 = false;
HasLSE = false;
HasHBC = false;
HasMOPS = false;

ArchKind = llvm::AArch64::ArchKind::INVALID;

Expand Down
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/AArch64.h
Expand Up @@ -54,6 +54,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
bool HasLSE;
bool HasFlagM;
bool HasHBC;
bool HasMOPS;

llvm::AArch64::ArchKind ArchKind;

Expand Down
6 changes: 6 additions & 0 deletions clang/test/Driver/aarch64-mops.c
@@ -0,0 +1,6 @@
// Test that target feature mops is implemented and available correctly
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+mops %s 2>&1 | FileCheck %s
// CHECK: "-target-feature" "+mops"

// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+nomops %s 2>&1 | FileCheck %s --check-prefix=NO_MOPS
// NO_MOPS: "-target-feature" "-mops"
1 change: 1 addition & 0 deletions llvm/include/llvm/Support/AArch64TargetParser.def
Expand Up @@ -145,6 +145,7 @@ AARCH64_ARCH_EXT_NAME("sme", AArch64::AEK_SME, "+sme",
AARCH64_ARCH_EXT_NAME("sme-f64", AArch64::AEK_SMEF64, "+sme-f64", "-sme-f64")
AARCH64_ARCH_EXT_NAME("sme-i64", AArch64::AEK_SMEI64, "+sme-i64", "-sme-i64")
AARCH64_ARCH_EXT_NAME("hbc", AArch64::AEK_HBC, "+hbc", "-hbc")
AARCH64_ARCH_EXT_NAME("mops", AArch64::AEK_MOPS, "+mops", "-mops")
#undef AARCH64_ARCH_EXT_NAME

#ifndef AARCH64_CPU_NAME
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Support/AArch64TargetParser.h
Expand Up @@ -70,6 +70,7 @@ enum ArchExtKind : uint64_t {
AEK_SMEF64 = 1ULL << 38,
AEK_SMEI64 = 1ULL << 39,
AEK_HBC = 1ULL << 40,
AEK_MOPS = 1ULL << 41,
};

enum class ArchKind {
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/AArch64TargetParser.cpp
Expand Up @@ -116,6 +116,8 @@ bool AArch64::getExtensionFeatures(uint64_t Extensions,
Features.push_back("+sme-i64");
if (Extensions & AArch64::AEK_HBC)
Features.push_back("+hbc");
if (Extensions & AArch64::AEK_MOPS)
Features.push_back("+mops");

return true;
}
Expand Down
1 change: 1 addition & 0 deletions llvm/unittests/Support/TargetParserTest.cpp
Expand Up @@ -1519,6 +1519,7 @@ TEST(TargetParserTest, AArch64ArchExtFeature) {
{"sme-f64", "nosme-f64", "+sme-f64", "-sme-f64"},
{"sme-i64", "nosme-i64", "+sme-i64", "-sme-i64"},
{"hbc", "nohbc", "+hbc", "-hbc"},
{"mops", "nomops", "+mops", "-mops"},
};

for (unsigned i = 0; i < array_lengthof(ArchExt); i++) {
Expand Down

0 comments on commit c84b8be

Please sign in to comment.