[llvm] e9d4922 - [RISCV] Add tablegen helper classes to create PatFrag to check for one use. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 10 23:18:06 PST 2022
Author: Craig Topper
Date: 2022-03-10T23:14:21-08:00
New Revision: e9d4922543d3822c62bd64e39e437dc625f07f35
URL: https://github.com/llvm/llvm-project/commit/e9d4922543d3822c62bd64e39e437dc625f07f35
DIFF: https://github.com/llvm/llvm-project/commit/e9d4922543d3822c62bd64e39e437dc625f07f35.diff
LOG: [RISCV] Add tablegen helper classes to create PatFrag to check for one use. NFC
Reduces code and the class can be instantiated in isel patterns to
avoid creating more *_oneuse classes.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfo.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index 7f5b3c89124c1..b7fd6ab409333 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -1091,13 +1091,14 @@ def assertzexti32 : PatFrag<(ops node:$src), (assertzext node:$src), [{
}]>;
def zexti32 : ComplexPattern<i64, 1, "selectZExti32">;
-def add_oneuse : PatFrag<(ops node:$A, node:$B), (add node:$A, node:$B), [{
+class binop_oneuse<SDPatternOperator operator>
+ : PatFrag<(ops node:$A, node:$B),
+ (operator node:$A, node:$B), [{
return N->hasOneUse();
}]>;
-def mul_oneuse : PatFrag<(ops node:$A, node:$B), (mul node:$A, node:$B), [{
- return N->hasOneUse();
-}]>;
+def add_oneuse : binop_oneuse<add>;
+def mul_oneuse : binop_oneuse<mul>;
def mul_const_oneuse : PatFrag<(ops node:$A, node:$B),
(mul node:$A, node:$B), [{
@@ -1107,22 +1108,16 @@ def mul_const_oneuse : PatFrag<(ops node:$A, node:$B),
return false;
}]>;
-def sext_oneuse : PatFrag<(ops node:$A), (sext node:$A), [{
- return N->hasOneUse();
-}]>;
-
-def zext_oneuse : PatFrag<(ops node:$A), (zext node:$A), [{
+class unop_oneuse<SDPatternOperator operator>
+ : PatFrag<(ops node:$A),
+ (operator node:$A), [{
return N->hasOneUse();
}]>;
-def anyext_oneuse : PatFrag<(ops node:$A), (anyext node:$A), [{
- return N->hasOneUse();
-}]>;
-
-def fpext_oneuse : PatFrag<(ops node:$A),
- (any_fpextend node:$A), [{
- return N->hasOneUse();
-}]>;
+def sext_oneuse : unop_oneuse<sext>;
+def zext_oneuse : unop_oneuse<zext>;
+def anyext_oneuse : unop_oneuse<anyext>;
+def fpext_oneuse : unop_oneuse<any_fpextend>;
/// Simple arithmetic operations
More information about the llvm-commits
mailing list