Skip to content

Commit 91ce4aa

Browse files
committed
[RISCV] Add GISelPredicateCode TD bindings and hasAllNBitUsers prototypes for staging adding full support
Signed-off-by: Luke Quinn <[email protected]>
1 parent 99b2489 commit 91ce4aa

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ class RISCVInstructionSelector : public InstructionSelector {
5757
const TargetRegisterClass *
5858
getRegClassForTypeOnBank(LLT Ty, const RegisterBank &RB) const;
5959

60+
static constexpr unsigned MaxRecursionDepth = 6;
61+
62+
bool hasAllNBitUsers(const MachineInstr &MI, unsigned Bits,
63+
const unsigned Depth = 0) const;
64+
bool hasAllBUsers(const MachineInstr &MI) const {
65+
return hasAllNBitUsers(MI, 8);
66+
}
67+
bool hasAllHUsers(const MachineInstr &MI) const {
68+
return hasAllNBitUsers(MI, 16);
69+
}
70+
bool hasAllWUsers(const MachineInstr &MI) const {
71+
return hasAllNBitUsers(MI, 32);
72+
}
73+
6074
bool isRegInGprb(Register Reg) const;
6175
bool isRegInFprb(Register Reg) const;
6276

@@ -184,6 +198,10 @@ RISCVInstructionSelector::RISCVInstructionSelector(
184198
{
185199
}
186200

201+
bool RISCVInstructionSelector::hasAllNBitUsers(const MachineInstr &MI, unsigned Bits, const unsigned Depth) const {
202+
return false;
203+
};
204+
187205
InstructionSelector::ComplexRendererFns
188206
RISCVInstructionSelector::selectShiftMask(MachineOperand &Root,
189207
unsigned ShiftWidth) const {

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,15 +1949,19 @@ class binop_allhusers<SDPatternOperator operator>
19491949
: PatFrag<(ops node:$lhs, node:$rhs),
19501950
(XLenVT (operator node:$lhs, node:$rhs)), [{
19511951
return hasAllHUsers(Node);
1952-
}]>;
1952+
}]> {
1953+
let GISelPredicateCode = [{ return hasAllHUsers(MI); }];
1954+
}
19531955

19541956
// PatFrag to allow ADDW/SUBW/MULW/SLLW to be selected from i64 add/sub/mul/shl
19551957
// if only the lower 32 bits of their result is used.
19561958
class binop_allwusers<SDPatternOperator operator>
19571959
: PatFrag<(ops node:$lhs, node:$rhs),
19581960
(i64 (operator node:$lhs, node:$rhs)), [{
19591961
return hasAllWUsers(Node);
1960-
}]>;
1962+
}]> {
1963+
let GISelPredicateCode = [{ return hasAllWUsers(MI); }];
1964+
}
19611965

19621966
def sexti32_allwusers : PatFrag<(ops node:$src),
19631967
(sext_inreg node:$src, i32), [{

0 commit comments

Comments
 (0)