Skip to content

Commit

Permalink
[AArch64] Add +flagm archictecture option, allowing the v8.4a flag mo…
Browse files Browse the repository at this point in the history
…dification extension.

Differential Revision: https://reviews.llvm.org/D94081
  • Loading branch information
MarkMurrayARM committed Jan 8, 2021
1 parent af7cce2 commit 7d4a8bc
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 20 deletions.
2 changes: 2 additions & 0 deletions clang/lib/Basic/Targets/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasLSE = true;
if (Feature == "+ls64")
HasLS64 = true;
if (Feature == "+flagm")
HasFlagM = true;
}

setDataLayout();
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/AArch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
bool HasMatmulFP64;
bool HasMatmulFP32;
bool HasLSE;
bool HasFlagM;

llvm::AArch64::ArchKind ArchKind;

Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Support/AArch64TargetParser.def
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ AARCH64_ARCH_EXT_NAME("tme", AArch64::AEK_TME, "+tme", "-tme"
AARCH64_ARCH_EXT_NAME("ls64", AArch64::AEK_LS64, "+ls64", "-ls64")
AARCH64_ARCH_EXT_NAME("brbe", AArch64::AEK_BRBE, "+brbe", "-brbe")
AARCH64_ARCH_EXT_NAME("pauth", AArch64::AEK_PAUTH, "+pauth", "-pauth")
AARCH64_ARCH_EXT_NAME("flagm", AArch64::AEK_FLAGM, "+flagm", "-flagm")
#undef AARCH64_ARCH_EXT_NAME

#ifndef AARCH64_CPU_NAME
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Support/AArch64TargetParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ enum ArchExtKind : uint64_t {
AEK_LS64 = 1ULL << 33,
AEK_BRBE = 1ULL << 34,
AEK_PAUTH = 1ULL << 35,
AEK_FLAGM = 1ULL << 36,
};

enum class ArchKind {
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/AArch64TargetParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ bool AArch64::getExtensionFeatures(uint64_t Extensions,
Features.push_back("+brbe");
if (Extensions & AEK_PAUTH)
Features.push_back("+pauth");
if (Extensions & AEK_FLAGM)
Features.push_back("+flagm");

return true;
}
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Target/AArch64/AArch64.td
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ def FeatureTLB_RMI : SubtargetFeature<
"tlb-rmi", "HasTLB_RMI", "true",
"Enable v8.4-A TLB Range and Maintenance Instructions">;

def FeatureFMI : SubtargetFeature<
"fmi", "HasFMI", "true",
def FeatureFlagM : SubtargetFeature<
"flagm", "HasFlagM", "true",
"Enable v8.4-A Flag Manipulation Instructions">;

// 8.4 RCPC enchancements: LDAPR & STLR instructions with Immediate Offset
Expand Down Expand Up @@ -445,7 +445,7 @@ def HasV8_4aOps : SubtargetFeature<"v8.4a", "HasV8_4aOps", "true",
"Support ARM v8.4a instructions", [HasV8_3aOps, FeatureDotProd,
FeatureNV, FeatureMPAM, FeatureDIT,
FeatureTRACEV8_4, FeatureAM, FeatureSEL2, FeaturePMU, FeatureTLB_RMI,
FeatureFMI, FeatureRCPC_IMMO]>;
FeatureFlagM, FeatureRCPC_IMMO]>;

def HasV8_5aOps : SubtargetFeature<
"v8.5a", "HasV8_5aOps", "true", "Support ARM v8.5a instructions",
Expand Down Expand Up @@ -474,7 +474,7 @@ def HasV8_0rOps : SubtargetFeature<
FeaturePAuth, FeatureRCPC,
//v8.4
FeatureDotProd, FeatureFP16FML, FeatureTRACEV8_4,
FeatureTLB_RMI, FeatureFMI, FeatureDIT, FeatureSEL2, FeatureRCPC_IMMO,
FeatureTLB_RMI, FeatureFlagM, FeatureDIT, FeatureSEL2, FeatureRCPC_IMMO,
//v8.5
FeatureSSBS, FeaturePredRes, FeatureSB, FeatureSpecRestrict]>;

Expand Down Expand Up @@ -697,7 +697,7 @@ def ProcA78C : SubtargetFeature<"cortex-a78c", "ARMProcFamily",
HasV8_2aOps,
FeatureCrypto,
FeatureDotProd,
FeatureFMI,
FeatureFlagM,
FeatureFP16FML,
FeatureFPARMv8,
FeatureFullFP16,
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/AArch64/AArch64InstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def HasPMU : Predicate<"Subtarget->hasPMU()">,
def HasTLB_RMI : Predicate<"Subtarget->hasTLB_RMI()">,
AssemblerPredicate<(all_of FeatureTLB_RMI), "tlb-rmi">;

def HasFMI : Predicate<"Subtarget->hasFMI()">,
AssemblerPredicate<(all_of FeatureFMI), "fmi">;
def HasFlagM : Predicate<"Subtarget->hasFlagM()">,
AssemblerPredicate<(all_of FeatureFlagM), "flagm">;

def HasRCPC_IMMO : Predicate<"Subtarget->hasRCPCImm()">,
AssemblerPredicate<(all_of FeatureRCPC_IMMO), "rcpc-immo">;
Expand Down Expand Up @@ -1149,15 +1149,15 @@ def FJCVTZS : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
} // HasJS, HasFPARMv8

// v8.4 Flag manipulation instructions
let Predicates = [HasFMI], Defs = [NZCV], Uses = [NZCV] in {
let Predicates = [HasFlagM], Defs = [NZCV], Uses = [NZCV] in {
def CFINV : SimpleSystemI<0, (ins), "cfinv", "">, Sched<[WriteSys]> {
let Inst{20-5} = 0b0000001000000000;
}
def SETF8 : BaseFlagManipulation<0, 0, (ins GPR32:$Rn), "setf8", "{\t$Rn}">;
def SETF16 : BaseFlagManipulation<0, 1, (ins GPR32:$Rn), "setf16", "{\t$Rn}">;
def RMIF : FlagRotate<(ins GPR64:$Rn, uimm6:$imm, imm0_15:$mask), "rmif",
"{\t$Rn, $imm, $mask}">;
} // HasFMI
} // HasFlagM

// v8.5 flag manipulation instructions
let Predicates = [HasAltNZCV], Uses = [NZCV], Defs = [NZCV] in {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AArch64/AArch64Subtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
bool HasSEL2 = false;
bool HasPMU = false;
bool HasTLB_RMI = false;
bool HasFMI = false;
bool HasFlagM = false;
bool HasRCPC_IMMO = false;

bool HasLSLFast = false;
Expand Down Expand Up @@ -513,7 +513,7 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
bool hasSEL2() const { return HasSEL2; }
bool hasPMU() const { return HasPMU; }
bool hasTLB_RMI() const { return HasTLB_RMI; }
bool hasFMI() const { return HasFMI; }
bool hasFlagM() const { return HasFlagM; }
bool hasRCPC_IMMO() const { return HasRCPC_IMMO; }

bool addrSinkUsingGEPs() const override {
Expand Down
18 changes: 9 additions & 9 deletions llvm/test/MC/AArch64/armv8.4a-flag.s
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+v8.4a %s -o - | \
// RUN: FileCheck %s

// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+fmi %s -o - 2>&1 | \
// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+flagm %s -o - 2>&1 | \
// RUN: FileCheck %s

// RUN: not llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=-v8.4a %s -o - 2>&1 | \
// RUN: FileCheck %s --check-prefix=ERROR

// RUN: not llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+v8.4a,-fmi %s -o - 2>&1 | \
// RUN: not llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+v8.4a,-flagm %s -o - 2>&1 | \
// RUN: FileCheck %s --check-prefix=ERROR

//------------------------------------------------------------------------------
Expand All @@ -30,24 +30,24 @@
//CHECK-NEXT: rmif x1, #63, #15 // encoding: [0x2f,0x84,0x1f,0xba]
//CHECK-NEXT: rmif xzr, #63, #15 // encoding: [0xef,0x87,0x1f,0xba]

//ERROR: error: instruction requires: fmi
//ERROR: error: instruction requires: flagm
//ERROR-NEXT: cfinv
//ERROR-NEXT: ^
//ERROR-NEXT: error: instruction requires: fmi
//ERROR-NEXT: error: instruction requires: flagm
//ERROR-NEXT: setf8 w1
//ERROR-NEXT: ^
//ERROR-NEXT: error: instruction requires: fmi
//ERROR-NEXT: error: instruction requires: flagm
//ERROR-NEXT: setf8 wzr
//ERROR-NEXT: ^
//ERROR-NEXT: error: instruction requires: fmi
//ERROR-NEXT: error: instruction requires: flagm
//ERROR-NEXT: setf16 w1
//ERROR-NEXT: ^
//ERROR-NEXT: error: instruction requires: fmi
//ERROR-NEXT: error: instruction requires: flagm
//ERROR-NEXT: setf16 wzr
//ERROR-NEXT: ^
//ERROR-NEXT: error: instruction requires: fmi
//ERROR-NEXT: error: instruction requires: flagm
//ERROR-NEXT: rmif x1, #63, #15
//ERROR-NEXT: ^
//ERROR-NEXT: error: instruction requires: fmi
//ERROR-NEXT: error: instruction requires: flagm
//ERROR-NEXT: rmif xzr, #63, #15
//ERROR-NEXT: ^
1 change: 1 addition & 0 deletions llvm/unittests/Support/TargetParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,7 @@ TEST(TargetParserTest, AArch64ArchFeatures) {
TEST(TargetParserTest, AArch64ArchExtFeature) {
const char *ArchExt[][4] = {{"crc", "nocrc", "+crc", "-crc"},
{"crypto", "nocrypto", "+crypto", "-crypto"},
{"flagm", "noflagm", "+flagm", "-flagm"},
{"fp", "nofp", "+fp-armv8", "-fp-armv8"},
{"simd", "nosimd", "+neon", "-neon"},
{"fp16", "nofp16", "+fullfp16", "-fullfp16"},
Expand Down

0 comments on commit 7d4a8bc

Please sign in to comment.