New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RISCV][NFC] Move Zawrs/Zacas implementation to RISCVInstrInfoZa.td #76940
Conversation
@llvm/pr-subscribers-backend-risc-v Author: Wang Pengcheng (wangpc-pp) ChangesTo keep the structure of TableGen files clear. The definitions are simplified by the way. Full diff: https://github.com/llvm/llvm-project/pull/76940.diff 2 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index 35e8edf5d2fa72..066dd07a2ee7f0 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -729,22 +729,6 @@ def UNIMP : RVInstI<0b001, OPC_SYSTEM, (outs), (ins), "unimp", "">,
let imm12 = 0b110000000000;
}
-let Predicates = [HasStdExtZawrs] in {
-def WRS_NTO : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "wrs.nto", "">,
- Sched<[]> {
- let rs1 = 0;
- let rd = 0;
- let imm12 = 0b000000001101;
-}
-
-def WRS_STO : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "wrs.sto", "">,
- Sched<[]> {
- let rs1 = 0;
- let rd = 0;
- let imm12 = 0b000000011101;
-}
-} // Predicates = [HasStdExtZawrs]
-
} // hasSideEffects = 1, mayLoad = 0, mayStore = 0
def CSRRW : CSR_ir<0b001, "csrrw">;
@@ -2095,6 +2079,7 @@ include "RISCVInstrInfoM.td"
// Atomic
include "RISCVInstrInfoA.td"
+include "RISCVInstrInfoZawrs.td"
// Scalar FP
include "RISCVInstrInfoF.td"
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZawrs.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZawrs.td
new file mode 100644
index 00000000000000..fac95eec814a46
--- /dev/null
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZawrs.td
@@ -0,0 +1,26 @@
+//===-- RISCVInstrInfoZawrs.td --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file describes the RISC-V instructions from the standard
+// Wait-on-Reservation-Set (Zawrs) extension document.
+//
+//===----------------------------------------------------------------------===//
+
+let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in {
+class WRSInst<bits<12> funct12, string opcodestr>
+ : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), opcodestr, ""> {
+ let rs1 = 0;
+ let rd = 0;
+ let imm12 = funct12;
+}
+}
+
+let Predicates = [HasStdExtZawrs] in {
+def WRS_NTO : WRSInst<0b000000001101, "wrs.nto">, Sched<[]>;
+def WRS_STO : WRSInst<0b000000011101, "wrs.sto">, Sched<[]>;
+} // Predicates = [HasStdExtZawrs]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think it's not necessarily the case that every extension should have it's own file, but Zawrs would better belong in RISCVInstrInfoA or RISCVInstrInfoZa.td I think if we felt it didn't deserve its own file.
I agree. Adding a file for every extension doesn't scale well if we keep adding extensions at the rate we are. |
What about adding it to And what is the policy? Should we put all (or these simple ones) |
We could move Zacas there too.
It would be nice if you could always find a Zfoo extension by opening RISCVInstrInfoZfoo.td for RISCVInstrInfoZf.td Sadly, the subset extensions like Zmmul or Zca mean you'd need to look in the single-letter RISCVInstrInfo td file too. So that has to be a special case. |
To keep the structure of TableGen files clear. The definitions are simplified by the way.
b5bc3c6
to
c4e2d02
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…lvm#76940) To keep the structure of TableGen files clear. The definitions are simplified by the way.
To keep the structure of TableGen files clear.
The definitions are simplified by the way.