[llvm] 401308f - [RISCV] Use a tablegen class for AltFmtType. NFC (#163251)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 13 23:19:27 PDT 2025
Author: Craig Topper
Date: 2025-10-13T23:19:23-07:00
New Revision: 401308fc163521bffd700a2c55e88074148de404
URL: https://github.com/llvm/llvm-project/commit/401308fc163521bffd700a2c55e88074148de404
DIFF: https://github.com/llvm/llvm-project/commit/401308fc163521bffd700a2c55e88074148de404.diff
LOG: [RISCV] Use a tablegen class for AltFmtType. NFC (#163251)
This should provide stronger type checking to prevent misuse.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrFormats.td
llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrFormats.td b/llvm/lib/Target/RISCV/RISCVInstrFormats.td
index 5b06303092c0d..fee1d1596ff5c 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrFormats.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrFormats.td
@@ -177,7 +177,7 @@ def EltDepsVL : EltDeps<vl=1, mask=0>;
def EltDepsMask : EltDeps<vl=0, mask=1>;
def EltDepsVLMask : EltDeps<vl=1, mask=1>;
-class EEW <bits<2> val> {
+class EEW<bits<2> val> {
bits<2> Value = val;
}
def EEW1 : EEW<0>;
@@ -185,6 +185,13 @@ def EEWSEWx1 : EEW<1>;
def EEWSEWx2 : EEW<2>;
def EEWSEWx4 : EEW<3>;
+class AltFmtType<bits<2> val> {
+ bits<2> Value = val;
+}
+def DONT_CARE_ALTFMT : AltFmtType<0>;
+def IS_NOT_ALTFMT : AltFmtType<1>;
+def IS_ALTFMT : AltFmtType<2>;
+
class RVInstCommon<dag outs, dag ins, string opcodestr, string argstr,
list<dag> pattern, InstFormat format> : Instruction {
let Namespace = "RISCV";
@@ -271,8 +278,8 @@ class RVInstCommon<dag outs, dag ins, string opcodestr, string argstr,
// 0 -> Don't care about altfmt bit in VTYPE.
// 1 -> Is not altfmt.
// 2 -> Is altfmt(BF16).
- bits<2> AltFmtType = 0;
- let TSFlags{28-27} = AltFmtType;
+ AltFmtType AltFmtType = DONT_CARE_ALTFMT;
+ let TSFlags{28-27} = AltFmtType.Value;
// XSfmmbase
bit HasTWidenOp = 0;
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index c1b23afb2adb6..65865ce461624 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -128,9 +128,6 @@ defvar TAIL_AGNOSTIC = 1;
defvar TU_MU = 0;
defvar TA_MU = 1;
defvar TA_MA = 3;
-defvar DONT_CARE_ALTFMT = 0;
-defvar IS_NOT_ALTFMT = 1;
-defvar IS_ALTFMT = 2;
//===----------------------------------------------------------------------===//
// Utilities.
More information about the llvm-commits
mailing list