-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[RISCV] Simplify macros used by RISCVInstrInfo::convertToThreeAddress. NFC #144173
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
Conversation
…. NFC Merge some macros that are only used once by another macro. Rename macros to remove _MF4 where not needed. I suspect these are artifacts from FP being split from integer in the past.
@llvm/pr-subscribers-backend-risc-v Author: Craig Topper (topperc) ChangesMerge some macros that are only used once by another macro. I suspect these are artifacts from FP being split from integer in the past. Full diff: https://github.com/llvm/llvm-project/pull/144173.diff 1 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index e5d29e1a8b476..5264766c52271 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -4224,38 +4224,32 @@ bool RISCVInstrInfo::simplifyInstruction(MachineInstr &MI) const {
#define CASE_WIDEOP_OPCODE_COMMON(OP, LMUL) \
RISCV::PseudoV##OP##_##LMUL##_TIED
-#define CASE_WIDEOP_OPCODE_LMULS_MF4(OP) \
- CASE_WIDEOP_OPCODE_COMMON(OP, MF4): \
+#define CASE_WIDEOP_OPCODE_LMULS(OP) \
+ CASE_WIDEOP_OPCODE_COMMON(OP, MF8): \
+ case CASE_WIDEOP_OPCODE_COMMON(OP, MF4): \
case CASE_WIDEOP_OPCODE_COMMON(OP, MF2): \
case CASE_WIDEOP_OPCODE_COMMON(OP, M1): \
case CASE_WIDEOP_OPCODE_COMMON(OP, M2): \
case CASE_WIDEOP_OPCODE_COMMON(OP, M4)
-#define CASE_WIDEOP_OPCODE_LMULS(OP) \
- CASE_WIDEOP_OPCODE_COMMON(OP, MF8): \
- case CASE_WIDEOP_OPCODE_LMULS_MF4(OP)
-
#define CASE_WIDEOP_CHANGE_OPCODE_COMMON(OP, LMUL) \
case RISCV::PseudoV##OP##_##LMUL##_TIED: \
NewOpc = RISCV::PseudoV##OP##_##LMUL; \
break;
-#define CASE_WIDEOP_CHANGE_OPCODE_LMULS_MF4(OP) \
+#define CASE_WIDEOP_CHANGE_OPCODE_LMULS(OP) \
+ CASE_WIDEOP_CHANGE_OPCODE_COMMON(OP, MF8) \
CASE_WIDEOP_CHANGE_OPCODE_COMMON(OP, MF4) \
CASE_WIDEOP_CHANGE_OPCODE_COMMON(OP, MF2) \
CASE_WIDEOP_CHANGE_OPCODE_COMMON(OP, M1) \
CASE_WIDEOP_CHANGE_OPCODE_COMMON(OP, M2) \
CASE_WIDEOP_CHANGE_OPCODE_COMMON(OP, M4)
-#define CASE_WIDEOP_CHANGE_OPCODE_LMULS(OP) \
- CASE_WIDEOP_CHANGE_OPCODE_COMMON(OP, MF8) \
- CASE_WIDEOP_CHANGE_OPCODE_LMULS_MF4(OP)
-
// FP Widening Ops may by SEW aware. Create SEW aware cases for these cases.
#define CASE_FP_WIDEOP_OPCODE_COMMON(OP, LMUL, SEW) \
RISCV::PseudoV##OP##_##LMUL##_##SEW##_TIED
-#define CASE_FP_WIDEOP_OPCODE_LMULS_MF4(OP) \
+#define CASE_FP_WIDEOP_OPCODE_LMULS(OP) \
CASE_FP_WIDEOP_OPCODE_COMMON(OP, MF4, E16): \
case CASE_FP_WIDEOP_OPCODE_COMMON(OP, MF2, E16): \
case CASE_FP_WIDEOP_OPCODE_COMMON(OP, MF2, E32): \
@@ -4271,7 +4265,7 @@ bool RISCVInstrInfo::simplifyInstruction(MachineInstr &MI) const {
NewOpc = RISCV::PseudoV##OP##_##LMUL##_##SEW; \
break;
-#define CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS_MF4(OP) \
+#define CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS(OP) \
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, MF4, E16) \
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, MF2, E16) \
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, MF2, E32) \
@@ -4281,9 +4275,6 @@ bool RISCVInstrInfo::simplifyInstruction(MachineInstr &MI) const {
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M2, E32) \
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M4, E16) \
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M4, E32) \
-
-#define CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS(OP) \
- CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS_MF4(OP)
// clang-format on
MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
@@ -4293,8 +4284,8 @@ MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
switch (MI.getOpcode()) {
default:
return nullptr;
- case CASE_FP_WIDEOP_OPCODE_LMULS_MF4(FWADD_WV):
- case CASE_FP_WIDEOP_OPCODE_LMULS_MF4(FWSUB_WV): {
+ case CASE_FP_WIDEOP_OPCODE_LMULS(FWADD_WV):
+ case CASE_FP_WIDEOP_OPCODE_LMULS(FWSUB_WV): {
assert(RISCVII::hasVecPolicyOp(MI.getDesc().TSFlags) &&
MI.getNumExplicitOperands() == 7 &&
"Expect 7 explicit operands rd, rs2, rs1, rm, vl, sew, policy");
@@ -4307,8 +4298,8 @@ MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
switch (MI.getOpcode()) {
default:
llvm_unreachable("Unexpected opcode");
- CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS_MF4(FWADD_WV)
- CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS_MF4(FWSUB_WV)
+ CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS(FWADD_WV)
+ CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS(FWSUB_WV)
}
// clang-format on
@@ -4387,15 +4378,12 @@ MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
}
#undef CASE_WIDEOP_OPCODE_COMMON
-#undef CASE_WIDEOP_OPCODE_LMULS_MF4
#undef CASE_WIDEOP_OPCODE_LMULS
#undef CASE_WIDEOP_CHANGE_OPCODE_COMMON
-#undef CASE_WIDEOP_CHANGE_OPCODE_LMULS_MF4
#undef CASE_WIDEOP_CHANGE_OPCODE_LMULS
#undef CASE_FP_WIDEOP_OPCODE_COMMON
-#undef CASE_FP_WIDEOP_OPCODE_LMULS_MF4
+#undef CASE_FP_WIDEOP_OPCODE_LMULS
#undef CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON
-#undef CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS_MF4
#undef CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS
void RISCVInstrInfo::mulImm(MachineFunction &MF, MachineBasicBlock &MBB,
|
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions cpp -- llvm/lib/Target/RISCV/RISCVInstrInfo.cpp View the diff from clang-format here.diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 5264766c5..50bfd0d0e 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -4274,8 +4274,8 @@ bool RISCVInstrInfo::simplifyInstruction(MachineInstr &MI) const {
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M2, E16) \
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M2, E32) \
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M4, E16) \
- CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M4, E32) \
-// clang-format on
+ CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M4, E32) \
+ // clang-format on
MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
LiveVariables *LV,
|
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.
…. NFC (llvm#144173) Merge some macros that are only used once by another macro. Rename macros to remove _MF4 where not needed. I suspect these are artifacts from FP being split from integer in the past.
…. NFC (llvm#144173) Merge some macros that are only used once by another macro. Rename macros to remove _MF4 where not needed. I suspect these are artifacts from FP being split from integer in the past.
Merge some macros that are only used once by another macro.
Rename macros to remove _MF4 where not needed.
I suspect these are artifacts from FP being split from integer in the past.