[Mlir-commits] [mlir] 70b69c5 - [mlir] Rename Zero* traits to Zero*s
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri May 13 17:20:36 PDT 2022
Author: Mogball
Date: 2022-05-14T00:20:28Z
New Revision: 70b69c54fa8b24519cd549eec10e549471157bb8
URL: https://github.com/llvm/llvm-project/commit/70b69c54fa8b24519cd549eec10e549471157bb8
DIFF: https://github.com/llvm/llvm-project/commit/70b69c54fa8b24519cd549eec10e549471157bb8.diff
LOG: [mlir] Rename Zero* traits to Zero*s
Rename
ZeroResult -> ZeroResults
ZeroSuccessor -> ZeroSuccessors
ZeroRegion -> ZeroRegions
to be in line with ZeroOperands and grammatically correct.
Added:
Modified:
mlir/docs/Diagnostics.md
mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
mlir/include/mlir/IR/Builders.h
mlir/include/mlir/IR/ImplicitLocOpBuilder.h
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
mlir/include/mlir/Transforms/FoldUtils.h
mlir/lib/Dialect/PDL/IR/PDL.cpp
mlir/lib/IR/Operation.cpp
mlir/test/mlir-tblgen/op-decl-and-defs.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Removed:
################################################################################
diff --git a/mlir/docs/Diagnostics.md b/mlir/docs/Diagnostics.md
index f7e223d4f316f..5bb6ed572c398 100644
--- a/mlir/docs/Diagnostics.md
+++ b/mlir/docs/Diagnostics.md
@@ -194,7 +194,7 @@ test.mlir:3:3: note: diagnostic emitted with trace:
#3 0x000055dd3f998e87 mlir::Operation::emitError(llvm::Twine const&) /lib/IR/Operation.cpp:324:29
#4 0x000055dd3f99d21c mlir::Operation::emitOpError(llvm::Twine const&) /lib/IR/Operation.cpp:652:10
#5 0x000055dd3f96b01c mlir::OpTrait::HasParent<mlir::ModuleOp>::Impl<mlir::ModuleTerminatorOp>::verifyTrait(mlir::Operation*) /mlir/IR/OpDefinition.h:897:18
- #6 0x000055dd3f96ab38 mlir::Op<mlir::ModuleTerminatorOp, mlir::OpTrait::ZeroOperands, mlir::OpTrait::ZeroResult, mlir::OpTrait::HasParent<mlir::ModuleOp>::Impl, mlir::OpTrait::IsTerminator>::BaseVerifier<mlir::OpTrait::HasParent<mlir::ModuleOp>::Impl<mlir::ModuleTerminatorOp>, mlir::OpTrait::IsTerminator<mlir::ModuleTerminatorOp> >::verifyTrait(mlir::Operation*) /mlir/IR/OpDefinition.h:1052:29
+ #6 0x000055dd3f96ab38 mlir::Op<mlir::ModuleTerminatorOp, mlir::OpTrait::ZeroOperands, mlir::OpTrait::ZeroResults, mlir::OpTrait::HasParent<mlir::ModuleOp>::Impl, mlir::OpTrait::IsTerminator>::BaseVerifier<mlir::OpTrait::HasParent<mlir::ModuleOp>::Impl<mlir::ModuleTerminatorOp>, mlir::OpTrait::IsTerminator<mlir::ModuleTerminatorOp> >::verifyTrait(mlir::Operation*) /mlir/IR/OpDefinition.h:1052:29
# ...
"module_terminator"() : () -> ()
^
diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
index f6144e8678778..ef7753d71d4ac 100644
--- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
+++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
@@ -88,7 +88,7 @@ Region *getAffineScope(Operation *op);
// of striding).
class AffineDmaStartOp
: public Op<AffineDmaStartOp, OpTrait::MemRefsNormalizable,
- OpTrait::VariadicOperands, OpTrait::ZeroResult,
+ OpTrait::VariadicOperands, OpTrait::ZeroResults,
OpTrait::OpInvariants, AffineMapAccessInterface::Trait> {
public:
using Op::Op;
@@ -281,7 +281,7 @@ class AffineDmaStartOp
//
class AffineDmaWaitOp
: public Op<AffineDmaWaitOp, OpTrait::MemRefsNormalizable,
- OpTrait::VariadicOperands, OpTrait::ZeroResult,
+ OpTrait::VariadicOperands, OpTrait::ZeroResults,
OpTrait::OpInvariants, AffineMapAccessInterface::Trait> {
public:
using Op::Op;
diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index f4c8863624740..2a175bf63e6d8 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -476,7 +476,7 @@ class OpBuilder : public Builder {
/// Overload to create or fold a zero result operation.
template <typename OpTy, typename... Args>
- typename std::enable_if<OpTy::template hasTrait<OpTrait::ZeroResult>(),
+ typename std::enable_if<OpTy::template hasTrait<OpTrait::ZeroResults>(),
OpTy>::type
createOrFold(Location location, Args &&...args) {
auto op = create<OpTy>(location, std::forward<Args>(args)...);
diff --git a/mlir/include/mlir/IR/ImplicitLocOpBuilder.h b/mlir/include/mlir/IR/ImplicitLocOpBuilder.h
index 2f0a1969c0ae4..8bbee78f85812 100644
--- a/mlir/include/mlir/IR/ImplicitLocOpBuilder.h
+++ b/mlir/include/mlir/IR/ImplicitLocOpBuilder.h
@@ -85,7 +85,7 @@ class ImplicitLocOpBuilder : public mlir::OpBuilder {
/// Overload to create or fold a zero result operation.
template <typename OpTy, typename... Args>
- typename std::enable_if<OpTy::template hasTrait<mlir::OpTrait::ZeroResult>(),
+ typename std::enable_if<OpTy::template hasTrait<mlir::OpTrait::ZeroResults>(),
OpTy>::type
createOrFold(Args &&...args) {
return OpBuilder::createOrFold<OpTy>(curLoc, std::forward<Args>(args)...);
diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index 2c9633e8bad89..cb385867ad5bc 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -291,6 +291,13 @@ class DialectType<Dialect d, Pred condition, string descr = "",
class Variadic<Type type> : TypeConstraint<type.predicate, type.summary,
type.cppClassName> {
Type baseType = type;
+ int minSize = 0;
+}
+
+// A variadic type constraint of at least N types. It expands to N or more of
+// the base type.
+class VariadicAtLeast<int N, Type type> : Variadic<type> {
+ let minSize = N;
}
// A nested variadic type constraint. It expands to zero or more variadic ranges
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index be65f5e7afb16..33d962d01598a 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -269,11 +269,11 @@ LogicalResult verifyAtLeastNOperands(Operation *op, unsigned numOperands);
LogicalResult verifyOperandsAreFloatLike(Operation *op);
LogicalResult verifyOperandsAreSignlessIntegerLike(Operation *op);
LogicalResult verifySameTypeOperands(Operation *op);
-LogicalResult verifyZeroRegion(Operation *op);
+LogicalResult verifyZeroRegions(Operation *op);
LogicalResult verifyOneRegion(Operation *op);
LogicalResult verifyNRegions(Operation *op, unsigned numRegions);
LogicalResult verifyAtLeastNRegions(Operation *op, unsigned numRegions);
-LogicalResult verifyZeroResult(Operation *op);
+LogicalResult verifyZeroResults(Operation *op);
LogicalResult verifyOneResult(Operation *op);
LogicalResult verifyNResults(Operation *op, unsigned numOperands);
LogicalResult verifyAtLeastNResults(Operation *op, unsigned numOperands);
@@ -286,7 +286,7 @@ LogicalResult verifyResultsAreBoolLike(Operation *op);
LogicalResult verifyResultsAreFloatLike(Operation *op);
LogicalResult verifyResultsAreSignlessIntegerLike(Operation *op);
LogicalResult verifyIsTerminator(Operation *op);
-LogicalResult verifyZeroSuccessor(Operation *op);
+LogicalResult verifyZeroSuccessors(Operation *op);
LogicalResult verifyOneSuccessor(Operation *op);
LogicalResult verifyNSuccessors(Operation *op, unsigned numSuccessors);
LogicalResult verifyAtLeastNSuccessors(Operation *op, unsigned numSuccessors);
@@ -447,10 +447,10 @@ class VariadicOperands
/// This class provides verification for ops that are known to have zero
/// regions.
template <typename ConcreteType>
-class ZeroRegion : public TraitBase<ConcreteType, ZeroRegion> {
+class ZeroRegions : public TraitBase<ConcreteType, ZeroRegions> {
public:
static LogicalResult verifyTrait(Operation *op) {
- return impl::verifyZeroRegion(op);
+ return impl::verifyZeroRegions(op);
}
};
@@ -500,7 +500,7 @@ class OneRegion : public TraitBase<ConcreteType, OneRegion> {
template <unsigned N>
class NRegions {
public:
- static_assert(N > 1, "use ZeroRegion/OneRegion for N < 2");
+ static_assert(N > 1, "use ZeroRegions/OneRegion for N < 2");
template <typename ConcreteType>
class Impl
@@ -539,10 +539,10 @@ class VariadicRegions
/// This class provides return value APIs for ops that are known to have
/// zero results.
template <typename ConcreteType>
-class ZeroResult : public TraitBase<ConcreteType, ZeroResult> {
+class ZeroResults : public TraitBase<ConcreteType, ZeroResults> {
public:
static LogicalResult verifyTrait(Operation *op) {
- return impl::verifyZeroResult(op);
+ return impl::verifyZeroResults(op);
}
};
@@ -648,7 +648,7 @@ class OneTypedResult {
template <unsigned N>
class NResults {
public:
- static_assert(N > 1, "use ZeroResult/OneResult for N < 2");
+ static_assert(N > 1, "use ZeroResults/OneResult for N < 2");
template <typename ConcreteType>
class Impl
@@ -704,10 +704,10 @@ class IsTerminator : public TraitBase<ConcreteType, IsTerminator> {
/// This class provides verification for ops that are known to have zero
/// successors.
template <typename ConcreteType>
-class ZeroSuccessor : public TraitBase<ConcreteType, ZeroSuccessor> {
+class ZeroSuccessors : public TraitBase<ConcreteType, ZeroSuccessors> {
public:
static LogicalResult verifyTrait(Operation *op) {
- return impl::verifyZeroSuccessor(op);
+ return impl::verifyZeroSuccessors(op);
}
};
@@ -760,7 +760,7 @@ class OneSuccessor : public TraitBase<ConcreteType, OneSuccessor> {
template <unsigned N>
class NSuccessors {
public:
- static_assert(N > 1, "use ZeroSuccessor/OneSuccessor for N < 2");
+ static_assert(N > 1, "use ZeroSuccessors/OneSuccessor for N < 2");
template <typename ConcreteType>
class Impl : public detail::MultiSuccessorTraitBase<ConcreteType,
@@ -1211,7 +1211,7 @@ template <typename ConcreteType>
class AffineScope : public TraitBase<ConcreteType, AffineScope> {
public:
static LogicalResult verifyTrait(Operation *op) {
- static_assert(!ConcreteType::template hasTrait<ZeroRegion>(),
+ static_assert(!ConcreteType::template hasTrait<ZeroRegions>(),
"expected operation to have one or more regions");
return success();
}
@@ -1227,7 +1227,7 @@ class AutomaticAllocationScope
: public TraitBase<ConcreteType, AutomaticAllocationScope> {
public:
static LogicalResult verifyTrait(Operation *op) {
- static_assert(!ConcreteType::template hasTrait<ZeroRegion>(),
+ static_assert(!ConcreteType::template hasTrait<ZeroRegions>(),
"expected operation to have one or more regions");
return success();
}
diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
index e9be31ebcbef2..88c94a83aeb3d 100644
--- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
+++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
@@ -266,9 +266,9 @@ struct ReturnLike : public TraitBase<ConcreteType, ReturnLike> {
static LogicalResult verifyTrait(Operation *op) {
static_assert(ConcreteType::template hasTrait<IsTerminator>(),
"expected operation to be a terminator");
- static_assert(ConcreteType::template hasTrait<ZeroResult>(),
+ static_assert(ConcreteType::template hasTrait<ZeroResults>(),
"expected operation to have zero results");
- static_assert(ConcreteType::template hasTrait<ZeroSuccessor>(),
+ static_assert(ConcreteType::template hasTrait<ZeroSuccessors>(),
"expected operation to have zero successors");
return success();
}
diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
index 198a38ca04422..3eace4606fa6b 100644
--- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
+++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
@@ -198,7 +198,7 @@ def RegionBranchOpInterface : OpInterface<"RegionBranchOpInterface"> {
];
let verify = [{
- static_assert(!ConcreteOp::template hasTrait<OpTrait::ZeroRegion>(),
+ static_assert(!ConcreteOp::template hasTrait<OpTrait::ZeroRegions>(),
"expected operation to have non-zero regions");
return detail::verifyTypesAlongControlFlowEdges($_op);
}];
@@ -259,9 +259,9 @@ def RegionBranchTerminatorOpInterface :
let verify = [{
static_assert(ConcreteOp::template hasTrait<OpTrait::IsTerminator>(),
"expected operation to be a terminator");
- static_assert(ConcreteOp::template hasTrait<OpTrait::ZeroResult>(),
+ static_assert(ConcreteOp::template hasTrait<OpTrait::ZeroResults>(),
"expected operation to have zero results");
- static_assert(ConcreteOp::template hasTrait<OpTrait::ZeroSuccessor>(),
+ static_assert(ConcreteOp::template hasTrait<OpTrait::ZeroSuccessors>(),
"expected operation to have zero successors");
return success();
}];
diff --git a/mlir/include/mlir/Transforms/FoldUtils.h b/mlir/include/mlir/Transforms/FoldUtils.h
index e10955cfb324f..d323472ba49ac 100644
--- a/mlir/include/mlir/Transforms/FoldUtils.h
+++ b/mlir/include/mlir/Transforms/FoldUtils.h
@@ -96,7 +96,7 @@ class OperationFolder {
/// Overload to create or fold a zero result operation.
template <typename OpTy, typename... Args>
- typename std::enable_if<OpTy::template hasTrait<OpTrait::ZeroResult>(),
+ typename std::enable_if<OpTy::template hasTrait<OpTrait::ZeroResults>(),
OpTy>::type
create(OpBuilder &builder, Location location, Args &&... args) {
auto op = builder.create<OpTy>(location, std::forward<Args>(args)...);
diff --git a/mlir/lib/Dialect/PDL/IR/PDL.cpp b/mlir/lib/Dialect/PDL/IR/PDL.cpp
index 7fba6ca4e21b6..9d1684c0b9752 100644
--- a/mlir/lib/Dialect/PDL/IR/PDL.cpp
+++ b/mlir/lib/Dialect/PDL/IR/PDL.cpp
@@ -216,7 +216,7 @@ static LogicalResult verifyResultTypesAreInferrable(OperationOp op,
// should cover many cases in which the user intended to infer the results
// of an operation, but it isn't actually possible.
bool expectedAtLeastOneResult =
- !opName->hasTrait<OpTrait::ZeroResult>() &&
+ !opName->hasTrait<OpTrait::ZeroResults>() &&
!opName->hasTrait<OpTrait::VariadicResults>();
if (expectedAtLeastOneResult) {
return op
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index 5842275aae44a..d7d59055479ce 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -775,7 +775,7 @@ LogicalResult OpTrait::impl::verifySameTypeOperands(Operation *op) {
return success();
}
-LogicalResult OpTrait::impl::verifyZeroRegion(Operation *op) {
+LogicalResult OpTrait::impl::verifyZeroRegions(Operation *op) {
if (op->getNumRegions() != 0)
return op->emitOpError() << "requires zero regions";
return success();
@@ -801,7 +801,7 @@ LogicalResult OpTrait::impl::verifyAtLeastNRegions(Operation *op,
return success();
}
-LogicalResult OpTrait::impl::verifyZeroResult(Operation *op) {
+LogicalResult OpTrait::impl::verifyZeroResults(Operation *op) {
if (op->getNumResults() != 0)
return op->emitOpError() << "requires zero results";
return success();
@@ -931,7 +931,7 @@ static LogicalResult verifyTerminatorSuccessors(Operation *op) {
return success();
}
-LogicalResult OpTrait::impl::verifyZeroSuccessor(Operation *op) {
+LogicalResult OpTrait::impl::verifyZeroSuccessors(Operation *op) {
if (op->getNumSuccessors() != 0) {
return op->emitOpError("requires 0 successors but found ")
<< op->getNumSuccessors();
diff --git a/mlir/test/mlir-tblgen/op-decl-and-defs.td b/mlir/test/mlir-tblgen/op-decl-and-defs.td
index 9ca8efacdf624..1883b16f6fbaf 100644
--- a/mlir/test/mlir-tblgen/op-decl-and-defs.td
+++ b/mlir/test/mlir-tblgen/op-decl-and-defs.td
@@ -69,7 +69,7 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
// CHECK: ::mlir::ValueRange odsOperands;
// CHECK: };
-// CHECK: class AOp : public ::mlir::Op<AOp, ::mlir::OpTrait::AtLeastNRegions<1>::Impl, ::mlir::OpTrait::AtLeastNResults<1>::Impl, ::mlir::OpTrait::ZeroSuccessor, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsIsolatedFromAbove
+// CHECK: class AOp : public ::mlir::Op<AOp, ::mlir::OpTrait::AtLeastNRegions<1>::Impl, ::mlir::OpTrait::AtLeastNResults<1>::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsIsolatedFromAbove
// CHECK-NOT: ::mlir::OpTrait::IsIsolatedFromAbove
// CHECK: public:
// CHECK: using Op::Op;
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index c80fe5a22641e..2028fe417d2c4 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2647,7 +2647,7 @@ static void addSizeCountTrait(OpClass &opClass, StringRef traitKind,
}
switch (numTotal) {
case 0:
- opClass.addTrait("::mlir::OpTrait::Zero" + traitKind);
+ opClass.addTrait("::mlir::OpTrait::Zero" + traitKind + "s");
break;
case 1:
opClass.addTrait("::mlir::OpTrait::One" + traitKind);
@@ -2687,26 +2687,7 @@ void OpEmitter::genTraits() {
int numVariadicOperands = op.getNumVariableLengthOperands();
// Add operand size trait.
- if (numVariadicOperands != 0) {
- if (numOperands == numVariadicOperands)
- opClass.addTrait("::mlir::OpTrait::VariadicOperands");
- else
- opClass.addTrait("::mlir::OpTrait::AtLeastNOperands<" +
- Twine(numOperands - numVariadicOperands) + ">::Impl");
- } else {
- switch (numOperands) {
- case 0:
- opClass.addTrait("::mlir::OpTrait::ZeroOperands");
- break;
- case 1:
- opClass.addTrait("::mlir::OpTrait::OneOperand");
- break;
- default:
- opClass.addTrait("::mlir::OpTrait::NOperands<" + Twine(numOperands) +
- ">::Impl");
- break;
- }
- }
+ addSizeCountTrait(opClass, "Operand", numOperands, numVariadicOperands);
// The op traits defined internal are ensured that they can be verified
// earlier.
More information about the Mlir-commits
mailing list