Skip to content

Commit e8460ff

Browse files
committed
move verify to tablegen
1 parent f0f74ac commit e8460ff

File tree

2 files changed

+9
-39
lines changed

2 files changed

+9
-39
lines changed

mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLOps.td

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,13 @@ def SPIRV_GLFMixOp :
10311031

10321032
// -----
10331033

1034-
def SPIRV_GLDistanceOp : SPIRV_GLOp<"Distance", 67, [Pure]> {
1034+
def SPIRV_GLDistanceOp : SPIRV_GLOp<"Distance", 67, [
1035+
Pure,
1036+
AllElementTypesMatch<["p0", "p1"]>,
1037+
TypesMatchWith<"result type must match operand element type",
1038+
"p0", "result",
1039+
"::mlir::getElementTypeOrSelf($_self)">
1040+
]> {
10351041
let summary = "Return distance between two points";
10361042

10371043
let description = [{
@@ -1060,6 +1066,8 @@ def SPIRV_GLDistanceOp : SPIRV_GLOp<"Distance", 67, [Pure]> {
10601066
let assemblyFormat = [{
10611067
operands attr-dict `:` type($p0) `,` type($p1) `->` type($result)
10621068
}];
1069+
1070+
let hasVerifier = 0;
10631071
}
10641072

10651073
// -----

mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,41 +2094,3 @@ LogicalResult spirv::VectorTimesScalarOp::verify() {
20942094
return emitOpError("scalar operand and result element type match");
20952095
return success();
20962096
}
2097-
2098-
//===----------------------------------------------------------------------===//
2099-
// spirv.GLDistanceOp
2100-
//===----------------------------------------------------------------------===//
2101-
2102-
LogicalResult spirv::GLDistanceOp::verify() {
2103-
auto p0Type = getP0().getType();
2104-
auto p1Type = getP1().getType();
2105-
auto resultType = getResult().getType();
2106-
2107-
auto getFloatType = [](Type type) -> FloatType {
2108-
if (auto vectorType = llvm::dyn_cast<VectorType>(type))
2109-
return llvm::dyn_cast<FloatType>(vectorType.getElementType());
2110-
return llvm::dyn_cast<FloatType>(type);
2111-
};
2112-
2113-
FloatType p0FloatType = getFloatType(p0Type);
2114-
FloatType p1FloatType = getFloatType(p1Type);
2115-
FloatType resultFloatType = llvm::dyn_cast<FloatType>(resultType);
2116-
2117-
if (!p0FloatType || !p1FloatType || !resultFloatType)
2118-
return emitOpError(
2119-
"operands and result must be float scalar or vector of float");
2120-
2121-
if (p0FloatType != resultFloatType || p1FloatType != resultFloatType)
2122-
return emitOpError("operand and result element types must match");
2123-
2124-
if (auto p0Vec = llvm::dyn_cast<VectorType>(p0Type)) {
2125-
if (!llvm::dyn_cast<VectorType>(p1Type) ||
2126-
p0Vec.getShape() != llvm::dyn_cast<VectorType>(p1Type).getShape())
2127-
return emitOpError("vector operands must have same shape");
2128-
} else if (llvm::isa<VectorType>(p1Type)) {
2129-
return emitOpError(
2130-
"expected both operands to be scalars or both to be vectors");
2131-
}
2132-
2133-
return success();
2134-
}

0 commit comments

Comments
 (0)