Skip to content

Commit b28b3d0

Browse files
committed
[RISCV] Add RISCVISD::VQDOT*_VL to RISCVSelectionDAGInfo::verifyTargetNode.
After seeing the bug that llvm#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 f7e172d commit b28b3d0

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

llvm/lib/Target/RISCV/RISCVSelectionDAGInfo.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,35 @@ 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() && MaskVT.getVectorElementType() == MVT::i1 &&
41+
MaskVT.getVectorElementCount() == VT.getVectorElementCount() &&
42+
"Expected mask VT to be an i1 scalable vector with same number of "
43+
"elements as the result");
44+
assert((N->getOperand(4).getValueType() == MVT::i32 ||
45+
N->getOperand(4).getValueType() == MVT::i64) &&
46+
"Expect VL operand to be i32 or i64");
47+
break;
48+
}
49+
}
50+
#endif
51+
}

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)