[llvm] [Mips] Add set directive support for EVA instructions (PR #225888)
Anand Mistry via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 01:47:02 PDT 2026
https://github.com/akmistry-msft updated https://github.com/llvm/llvm-project/pull/225888
>From 4b3d4ebfbbd335431cb826421445acd472674f64 Mon Sep 17 00:00:00 2001
From: Anand Mistry <anandmistry at microsoft.com>
Date: Wed, 23 Sep 2026 18:26:02 +0000
Subject: [PATCH] [Mips] Add set directive support for EVA instructions
---
.../Target/Mips/AsmParser/MipsAsmParser.cpp | 26 +++++++++++++++++++
.../Mips/MCTargetDesc/MipsTargetStreamer.cpp | 12 +++++++++
.../Mips/MCTargetDesc/MipsTargetStreamer.h | 4 +++
llvm/test/MC/Mips/eva/set-eva-directive.s | 9 +++++++
llvm/test/MC/Mips/eva/set-noeva-directive.s | 24 +++++++++++++++++
5 files changed, 75 insertions(+)
create mode 100644 llvm/test/MC/Mips/eva/set-eva-directive.s
create mode 100644 llvm/test/MC/Mips/eva/set-noeva-directive.s
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 21113e4ee7c3d3..48163a54f48374 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -397,6 +397,7 @@ class MipsAsmParser : public MCTargetAsmParser {
bool parseSetNoCRCDirective();
bool parseSetNoVirtDirective();
bool parseSetNoGINVDirective();
+ bool parseSetNoEVADirective();
bool parseSetAssignment();
@@ -7323,6 +7324,23 @@ bool MipsAsmParser::parseSetNoGINVDirective() {
return false;
}
+bool MipsAsmParser::parseSetNoEVADirective() {
+ MCAsmParser &Parser = getParser();
+ Parser.Lex(); // Eat "noeva".
+
+ // If this is not the end of the statement, report an error.
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
+ reportParseError("unexpected token, expected end of statement");
+ return false;
+ }
+
+ clearFeatureBits(Mips::FeatureEVA, "eva");
+
+ getTargetStreamer().emitDirectiveSetNoEVA();
+ Parser.Lex(); // Consume the EndOfStatement.
+ return false;
+}
+
bool MipsAsmParser::parseSetPopDirective() {
MCAsmParser &Parser = getParser();
SMLoc Loc = getLexer().getLoc();
@@ -7572,6 +7590,10 @@ bool MipsAsmParser::parseSetFeature(uint64_t Feature) {
setFeatureBits(Mips::FeatureGINV, "ginv");
getTargetStreamer().emitDirectiveSetGINV();
break;
+ case Mips::FeatureEVA:
+ setFeatureBits(Mips::FeatureEVA, "eva");
+ getTargetStreamer().emitDirectiveSetEVA();
+ break;
}
return false;
}
@@ -7955,6 +7977,10 @@ bool MipsAsmParser::parseDirectiveSet() {
return parseSetFeature(Mips::FeatureGINV);
if (IdVal == "noginv")
return parseSetNoGINVDirective();
+ if (IdVal == "eva")
+ return parseSetFeature(Mips::FeatureEVA);
+ if (IdVal == "noeva")
+ return parseSetNoEVADirective();
// It is just an identifier, look for an assignment.
return parseSetAssignment();
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
index abdb9778e82332..aef38feff47362 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
@@ -76,6 +76,8 @@ void MipsTargetStreamer::emitDirectiveSetVirt() {}
void MipsTargetStreamer::emitDirectiveSetNoVirt() {}
void MipsTargetStreamer::emitDirectiveSetGINV() {}
void MipsTargetStreamer::emitDirectiveSetNoGINV() {}
+void MipsTargetStreamer::emitDirectiveSetEVA() {}
+void MipsTargetStreamer::emitDirectiveSetNoEVA() {}
void MipsTargetStreamer::emitDirectiveSetAt() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveSetAtWithArg(unsigned RegNo) {
forbidModuleDirective();
@@ -526,6 +528,16 @@ void MipsTargetAsmStreamer::emitDirectiveSetNoGINV() {
MipsTargetStreamer::emitDirectiveSetNoGINV();
}
+void MipsTargetAsmStreamer::emitDirectiveSetEVA() {
+ OS << "\t.set\teva\n";
+ MipsTargetStreamer::emitDirectiveSetEVA();
+}
+
+void MipsTargetAsmStreamer::emitDirectiveSetNoEVA() {
+ OS << "\t.set\tnoeva\n";
+ MipsTargetStreamer::emitDirectiveSetNoEVA();
+}
+
void MipsTargetAsmStreamer::emitDirectiveSetAt() {
OS << "\t.set\tat\n";
MipsTargetStreamer::emitDirectiveSetAt();
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.h
index 71b5d165a9cb3b..bb540f3a1da0ef 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.h
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.h
@@ -53,6 +53,8 @@ class MipsTargetStreamer : public MCTargetStreamer {
virtual void emitDirectiveSetNoVirt();
virtual void emitDirectiveSetGINV();
virtual void emitDirectiveSetNoGINV();
+ virtual void emitDirectiveSetEVA();
+ virtual void emitDirectiveSetNoEVA();
virtual void emitDirectiveSetAt();
virtual void emitDirectiveSetAtWithArg(unsigned RegNo);
virtual void emitDirectiveSetNoAt();
@@ -245,6 +247,8 @@ class MipsTargetAsmStreamer : public MipsTargetStreamer {
void emitDirectiveSetNoVirt() override;
void emitDirectiveSetGINV() override;
void emitDirectiveSetNoGINV() override;
+ void emitDirectiveSetEVA() override;
+ void emitDirectiveSetNoEVA() override;
void emitDirectiveSetAt() override;
void emitDirectiveSetAtWithArg(unsigned RegNo) override;
void emitDirectiveSetNoAt() override;
diff --git a/llvm/test/MC/Mips/eva/set-eva-directive.s b/llvm/test/MC/Mips/eva/set-eva-directive.s
new file mode 100644
index 00000000000000..2882f01ba13569
--- /dev/null
+++ b/llvm/test/MC/Mips/eva/set-eva-directive.s
@@ -0,0 +1,9 @@
+# invalid operand for instructions that are invalid without -mattr=+eva flag
+#
+# RUN: llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips32r6 | FileCheck %s
+# RUN: llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r6 | FileCheck %s
+
+ .set noat
+ .set eva
+ tlbinv # CHECK: tlbinv # encoding: [0x42,0x00,0x00,0x03]
+ tlbinvf # CHECK: tlbinvf # encoding: [0x42,0x00,0x00,0x04]
diff --git a/llvm/test/MC/Mips/eva/set-noeva-directive.s b/llvm/test/MC/Mips/eva/set-noeva-directive.s
new file mode 100644
index 00000000000000..34b3052a9d74d8
--- /dev/null
+++ b/llvm/test/MC/Mips/eva/set-noeva-directive.s
@@ -0,0 +1,24 @@
+# invalid operand for instructions that are invalid without -mattr=+eva flag
+#
+# RUN: not llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips32r2 2>%t1
+# RUN: FileCheck %s < %t1
+# RUN: not llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips32r3 2>%t1
+# RUN: FileCheck %s < %t1
+# RUN: not llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips32r5 2>%t1
+# RUN: FileCheck %s < %t1
+# RUN: not llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips32r6 2>%t1
+# RUN: FileCheck %s < %t1
+# RUN: not llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r2 2>%t1
+# RUN: FileCheck %s < %t1
+# RUN: not llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r3 2>%t1
+# RUN: FileCheck %s < %t1
+# RUN: not llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r5 2>%t1
+# RUN: FileCheck %s < %t1
+# RUN: not llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r6 2>%t1
+# RUN: FileCheck %s < %t1
+
+ .set noat
+ .set eva
+ .set noeva
+ tlbinv # CHECK: :[[@LINE]]:{{[0-9]+}}: error: instruction requires a CPU feature not currently enabled
+ tlbinvf # CHECK: :[[@LINE]]:{{[0-9]+}}: error: instruction requires a CPU feature not currently enabled
More information about the llvm-commits
mailing list