Skip to content

Commit 4759107

Browse files
committed
[RISCV] Add GISelPredicateCode binding and hasAllNBitUsers prototypes for staging adding full support
Signed-off-by: Luke Quinn <[email protected]>
1 parent ccd7795 commit 4759107

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

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

60+
// const MachineInstr &MI
61+
bool hasAllNBitUsers(const MachineInstr &MI, unsigned Bits, const unsigned Depth = 0) const;
62+
bool hasAllBUsers(const MachineInstr &MI) const { return hasAllNBitUsers(MI, 8); }
63+
bool hasAllHUsers(const MachineInstr &MI) const { return hasAllNBitUsers(MI, 16); }
64+
bool hasAllWUsers(const MachineInstr &MI) const { return hasAllNBitUsers(MI, 32); }
65+
6066
bool isRegInGprb(Register Reg) const;
6167
bool isRegInFprb(Register Reg) const;
6268

@@ -186,6 +192,10 @@ RISCVInstructionSelector::RISCVInstructionSelector(
186192
{
187193
}
188194

195+
bool RISCVInstructionSelector::hasAllNBitUsers(const MachineInstr &MI, unsigned Bits, const unsigned Depth) const {
196+
return false;
197+
};
198+
189199
InstructionSelector::ComplexRendererFns
190200
RISCVInstructionSelector::selectShiftMask(MachineOperand &Root,
191201
unsigned ShiftWidth) const {

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,15 +1945,19 @@ class binop_allhusers<SDPatternOperator operator>
19451945
: PatFrag<(ops node:$lhs, node:$rhs),
19461946
(XLenVT (operator node:$lhs, node:$rhs)), [{
19471947
return hasAllHUsers(Node);
1948-
}]>;
1948+
}]> {
1949+
let GISelPredicateCode = [{ return hasAllHUsers(MI); }];
1950+
}
19491951

19501952
// PatFrag to allow ADDW/SUBW/MULW/SLLW to be selected from i64 add/sub/mul/shl
19511953
// if only the lower 32 bits of their result is used.
19521954
class binop_allwusers<SDPatternOperator operator>
19531955
: PatFrag<(ops node:$lhs, node:$rhs),
19541956
(i64 (operator node:$lhs, node:$rhs)), [{
19551957
return hasAllWUsers(Node);
1956-
}]>;
1958+
}]> {
1959+
let GISelPredicateCode = [{ return hasAllWUsers(MI); }];
1960+
}
19571961

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

0 commit comments

Comments
 (0)