Skip to content

Commit 11f915f

Browse files
authored
[RISCV] Add RISCVISD::VQDOT*_VL to RISCVSelectionDAGInfo::verifyTargetNode. (#142202)
After seeing the bug that #142185 fixed, I thought it might be a good idea to start verifying that nodes are formed correctly. This patch introduces the verifyTargetNode function and adds these opcodes. More opcodes can be added in later patches.
1 parent 26b81c4 commit 11f915f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

llvm/lib/Target/RISCV/RISCVSelectionDAGInfo.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,36 @@ RISCVSelectionDAGInfo::RISCVSelectionDAGInfo()
1717
: SelectionDAGGenTargetInfo(RISCVGenSDNodeInfo) {}
1818

1919
RISCVSelectionDAGInfo::~RISCVSelectionDAGInfo() = default;
20+
21+
void RISCVSelectionDAGInfo::verifyTargetNode(const SelectionDAG &DAG,
22+
const SDNode *N) const {
23+
#ifndef NDEBUG
24+
switch (N->getOpcode()) {
25+
default:
26+
return SelectionDAGGenTargetInfo::verifyTargetNode(DAG, N);
27+
case RISCVISD::VQDOT_VL:
28+
case RISCVISD::VQDOTU_VL:
29+
case RISCVISD::VQDOTSU_VL: {
30+
assert(N->getNumValues() == 1 && "Expected one result!");
31+
assert(N->getNumOperands() == 5 && "Expected five operands!");
32+
EVT VT = N->getValueType(0);
33+
assert(VT.isScalableVector() && VT.getVectorElementType() == MVT::i32 &&
34+
"Expected result to be an i32 scalable vector");
35+
assert(N->getOperand(0).getValueType() == VT &&
36+
N->getOperand(1).getValueType() == VT &&
37+
N->getOperand(2).getValueType() == VT &&
38+
"Expected result and first 3 operands to have the same type!");
39+
EVT MaskVT = N->getOperand(3).getValueType();
40+
assert(MaskVT.isScalableVector() &&
41+
MaskVT.getVectorElementType() == MVT::i1 &&
42+
MaskVT.getVectorElementCount() == VT.getVectorElementCount() &&
43+
"Expected mask VT to be an i1 scalable vector with same number of "
44+
"elements as the result");
45+
assert((N->getOperand(4).getValueType() == MVT::i32 ||
46+
N->getOperand(4).getValueType() == MVT::i64) &&
47+
"Expect VL operand to be i32 or i64");
48+
break;
49+
}
50+
}
51+
#endif
52+
}

llvm/lib/Target/RISCV/RISCVSelectionDAGInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class RISCVSelectionDAGInfo : public SelectionDAGGenTargetInfo {
3131

3232
~RISCVSelectionDAGInfo() override;
3333

34+
void verifyTargetNode(const SelectionDAG &DAG,
35+
const SDNode *N) const override;
36+
3437
bool hasPassthruOp(unsigned Opcode) const {
3538
return GenNodeInfo.getDesc(Opcode).TSFlags & RISCVISD::HasPassthruOpMask;
3639
}

0 commit comments

Comments
 (0)