[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.
This commit is contained in:
Craig Topper 2022-03-10 22:53:22 -08:00
parent b905864845
commit e9d4922543

View File

@ -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), [{
class unop_oneuse<SDPatternOperator operator>
: PatFrag<(ops node:$A),
(operator node:$A), [{
return N->hasOneUse();
}]>;
def zext_oneuse : PatFrag<(ops node:$A), (zext 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