[Mlir-commits] [mlir] 4b52665 - [mlir][irdl] NFC: Ensure ops ends with `Op` suffix

Mathieu Fehr llvmlistbot at llvm.org
Thu Jun 8 05:09:11 PDT 2023


Author: Mathieu Fehr
Date: 2023-06-08T13:11:43+01:00
New Revision: 4b526657809a9507731e6b9a88c591b20bdbb8ca

URL: https://github.com/llvm/llvm-project/commit/4b526657809a9507731e6b9a88c591b20bdbb8ca
DIFF: https://github.com/llvm/llvm-project/commit/4b526657809a9507731e6b9a88c591b20bdbb8ca.diff

LOG: [mlir][irdl] NFC: Ensure ops ends with `Op` suffix

IRDL operations were inconsistent in their naming. They now
all end with the `Op` suffix.

Reviewed By: rriddle, jpienaar

Differential Revision: https://reviews.llvm.org/D152354

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/IRDL/IR/IRDLOps.td
    mlir/lib/Dialect/IRDL/IR/IRDLOps.cpp
    mlir/lib/Dialect/IRDL/IRDLLoading.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/IRDL/IR/IRDLOps.td b/mlir/include/mlir/Dialect/IRDL/IR/IRDLOps.td
index f451db3215846..2428500871fd3 100644
--- a/mlir/include/mlir/Dialect/IRDL/IR/IRDLOps.td
+++ b/mlir/include/mlir/Dialect/IRDL/IR/IRDLOps.td
@@ -269,7 +269,7 @@ class IRDL_ConstraintOp<string mnemonic, list<Trait> traits = []>
         DeclareOpInterfaceMethods<VerifyConstraintInterface>] # traits> {
 }
 
-def IRDL_Is : IRDL_ConstraintOp<"is",
+def IRDL_IsOp : IRDL_ConstraintOp<"is",
     [ParentOneOf<["TypeOp", "AttributeOp", "OperationOp"]>, Pure]> {
   let summary = "Constraints an attribute/type to be a specific attribute instance";
   let description = [{
@@ -296,7 +296,7 @@ def IRDL_Is : IRDL_ConstraintOp<"is",
   let assemblyFormat = " $expected ` ` attr-dict ";
 }
 
-def IRDL_Parametric : IRDL_ConstraintOp<"parametric",
+def IRDL_ParametricOp : IRDL_ConstraintOp<"parametric",
     [ParentOneOf<["TypeOp", "AttributeOp", "OperationOp"]>, Pure]> {
   let summary = "Constraints an attribute/type base and its parameters";
   let description = [{
@@ -331,7 +331,7 @@ def IRDL_Parametric : IRDL_ConstraintOp<"parametric",
   let assemblyFormat = " $base_type `<` $args `>` ` ` attr-dict ";
 }
 
-def IRDL_Any : IRDL_ConstraintOp<"any",
+def IRDL_AnyOp : IRDL_ConstraintOp<"any",
     [ParentOneOf<["TypeOp", "AttributeOp", "OperationOp"]>]> {
   let summary = "Accept any type or attribute";
   let description = [{
@@ -356,7 +356,7 @@ def IRDL_Any : IRDL_ConstraintOp<"any",
   let assemblyFormat = " attr-dict ";
 }
 
-def IRDL_AnyOf : IRDL_ConstraintOp<"any_of",
+def IRDL_AnyOfOp : IRDL_ConstraintOp<"any_of",
                   [ParentOneOf<["TypeOp", "AttributeOp", "OperationOp"]>,
                    SameOperandsAndResultType]> {
   let summary = "Constraints to the union of the provided constraints";
@@ -389,7 +389,7 @@ def IRDL_AnyOf : IRDL_ConstraintOp<"any_of",
   let assemblyFormat = [{ `(` $args `)` ` ` attr-dict }];
 }
 
-def IRDL_AllOf : IRDL_ConstraintOp<"all_of",
+def IRDL_AllOfOp : IRDL_ConstraintOp<"all_of",
                  [ParentOneOf<["TypeOp", "AttributeOp", "OperationOp"]>,
                   SameOperandsAndResultType]> {
   let summary = "Constraints to the intersection of the provided constraints";

diff  --git a/mlir/lib/Dialect/IRDL/IR/IRDLOps.cpp b/mlir/lib/Dialect/IRDL/IR/IRDLOps.cpp
index c0e839720200b..9a79f9fa55a21 100644
--- a/mlir/lib/Dialect/IRDL/IR/IRDLOps.cpp
+++ b/mlir/lib/Dialect/IRDL/IR/IRDLOps.cpp
@@ -11,7 +11,7 @@
 using namespace mlir;
 using namespace mlir::irdl;
 
-std::unique_ptr<Constraint> Is::getVerifier(
+std::unique_ptr<Constraint> IsOp::getVerifier(
     ArrayRef<Value> valueToConstr,
     DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>> const &types,
     DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>> const
@@ -19,7 +19,7 @@ std::unique_ptr<Constraint> Is::getVerifier(
   return std::make_unique<IsConstraint>(getExpectedAttr());
 }
 
-std::unique_ptr<Constraint> Parametric::getVerifier(
+std::unique_ptr<Constraint> ParametricOp::getVerifier(
     ArrayRef<Value> valueToConstr,
     DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>> const &types,
     DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>> const
@@ -55,7 +55,7 @@ std::unique_ptr<Constraint> Parametric::getVerifier(
                    "either a type or an attribute definition");
 }
 
-std::unique_ptr<Constraint> AnyOf::getVerifier(
+std::unique_ptr<Constraint> AnyOfOp::getVerifier(
     ArrayRef<Value> valueToConstr,
     DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>> const &types,
     DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>> const
@@ -73,7 +73,7 @@ std::unique_ptr<Constraint> AnyOf::getVerifier(
   return std::make_unique<AnyOfConstraint>(constraints);
 }
 
-std::unique_ptr<Constraint> AllOf::getVerifier(
+std::unique_ptr<Constraint> AllOfOp::getVerifier(
     ArrayRef<Value> valueToConstr,
     DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>> const &types,
     DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>> const
@@ -91,7 +91,7 @@ std::unique_ptr<Constraint> AllOf::getVerifier(
   return std::make_unique<AllOfConstraint>(constraints);
 }
 
-std::unique_ptr<Constraint> Any::getVerifier(
+std::unique_ptr<Constraint> AnyOp::getVerifier(
     ArrayRef<Value> valueToConstr,
     DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>> const &types,
     DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>> const

diff  --git a/mlir/lib/Dialect/IRDL/IRDLLoading.cpp b/mlir/lib/Dialect/IRDL/IRDLLoading.cpp
index 07f0e4e5e443e..f49eb26f7b26e 100644
--- a/mlir/lib/Dialect/IRDL/IRDLLoading.cpp
+++ b/mlir/lib/Dialect/IRDL/IRDLLoading.cpp
@@ -252,7 +252,7 @@ static bool getBases(Operation *op, SmallPtrSet<TypeID, 4> &paramIds,
                      SmallPtrSet<Operation *, 4> &paramIrdlOps,
                      SmallPtrSet<TypeID, 4> &isIds) {
   // For `irdl.any_of`, we get the bases from all its arguments.
-  if (auto anyOf = dyn_cast<AnyOf>(op)) {
+  if (auto anyOf = dyn_cast<AnyOfOp>(op)) {
     bool has_any = false;
     for (Value arg : anyOf.getArgs())
       has_any &= getBases(arg.getDefiningOp(), paramIds, paramIrdlOps, isIds);
@@ -261,12 +261,12 @@ static bool getBases(Operation *op, SmallPtrSet<TypeID, 4> &paramIds,
 
   // For `irdl.all_of`, we get the bases from the first argument.
   // This is restrictive, but we can relax it later if needed.
-  if (auto allOf = dyn_cast<AllOf>(op))
+  if (auto allOf = dyn_cast<AllOfOp>(op))
     return getBases(allOf.getArgs()[0].getDefiningOp(), paramIds, paramIrdlOps,
                     isIds);
 
   // For `irdl.parametric`, we get directly the base from the operation.
-  if (auto params = dyn_cast<Parametric>(op)) {
+  if (auto params = dyn_cast<ParametricOp>(op)) {
     SymbolRefAttr symRef = params.getBaseType();
     Operation *defOp = SymbolTable::lookupNearestSymbolFrom(op, symRef);
     assert(defOp && "symbol reference should refer to an existing operation");
@@ -275,7 +275,7 @@ static bool getBases(Operation *op, SmallPtrSet<TypeID, 4> &paramIds,
   }
 
   // For `irdl.is`, we get the base TypeID directly.
-  if (auto is = dyn_cast<Is>(op)) {
+  if (auto is = dyn_cast<IsOp>(op)) {
     Attribute expected = is.getExpected();
     isIds.insert(expected.getTypeID());
     return false;
@@ -283,7 +283,7 @@ static bool getBases(Operation *op, SmallPtrSet<TypeID, 4> &paramIds,
 
   // For `irdl.any`, we return `false` since we can match any type or attribute
   // base.
-  if (auto isA = dyn_cast<Any>(op))
+  if (auto isA = dyn_cast<AnyOp>(op))
     return true;
 
   llvm_unreachable("unknown IRDL constraint");
@@ -300,7 +300,7 @@ static bool getBases(Operation *op, SmallPtrSet<TypeID, 4> &paramIds,
 /// that they are disjoint between `parametric` and `is` operations.
 /// This restriction will be relaxed in the future, when we will change our
 /// algorithm to be non-greedy.
-static LogicalResult checkCorrectAnyOf(AnyOf anyOf) {
+static LogicalResult checkCorrectAnyOf(AnyOfOp anyOf) {
   SmallPtrSet<TypeID, 4> paramIds;
   SmallPtrSet<Operation *, 4> paramIrdlOps;
   SmallPtrSet<TypeID, 4> isIds;
@@ -404,8 +404,8 @@ preallocateAttrDefs(ModuleOp op,
 LogicalResult mlir::irdl::loadDialects(ModuleOp op) {
   // First, check that all any_of constraints are in a correct form.
   // This is to ensure we can do the verification correctly.
-  WalkResult anyOfCorrects =
-      op.walk([](AnyOf anyOf) { return (WalkResult)checkCorrectAnyOf(anyOf); });
+  WalkResult anyOfCorrects = op.walk(
+      [](AnyOfOp anyOf) { return (WalkResult)checkCorrectAnyOf(anyOf); });
   if (anyOfCorrects.wasInterrupted())
     return op.emitError("any_of constraints are not in the correct form");
 


        


More information about the Mlir-commits mailing list