[Mlir-commits] [llvm] [mlir] [MLIR][IR] Add ConstantLikeInterface for extensible constant creation (PR #177740)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Jan 23 23:00:21 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- mlir/include/mlir/IR/ConstantLikeInterface.h mlir/lib/IR/ConstantLikeInterface.cpp mlir/unittests/IR/ConstantLikeInterfaceTest.cpp mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp mlir/lib/IR/Builders.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/unittests/IR/ConstantLikeInterfaceTest.cpp b/mlir/unittests/IR/ConstantLikeInterfaceTest.cpp
index 123e60187..d843cd168 100644
--- a/mlir/unittests/IR/ConstantLikeInterfaceTest.cpp
+++ b/mlir/unittests/IR/ConstantLikeInterfaceTest.cpp
@@ -362,7 +362,8 @@ TEST(ConstantLikeInterfaceTest, BuilderGetZeroAttrUsesInterface) {
   ASSERT_TRUE(customZero != nullptr);
   auto customIntAttr = dyn_cast<IntegerAttr>(customZero);
   ASSERT_TRUE(customIntAttr != nullptr);
-  EXPECT_EQ(customIntAttr.getInt(), 0); // 0 * 2 = 0 (still 0, but via interface)
+  EXPECT_EQ(customIntAttr.getInt(),
+            0); // 0 * 2 = 0 (still 0, but via interface)
 }
 
 TEST(ConstantLikeInterfaceTest, BuilderGetOneAttrUsesInterface) {
@@ -487,12 +488,14 @@ TEST(ConstantLikeInterfaceTest, MultipleTypesWithDifferentBehavior) {
   TypedAttr intAttr = intIface.createConstantAttr(10);
   TypedAttr floatAttr = floatIface.createConstantAttr(10);
 
-  EXPECT_EQ(cast<IntegerAttr>(intAttr).getInt(), 20);         // 10 * 2
-  EXPECT_DOUBLE_EQ(cast<FloatAttr>(floatAttr).getValueAsDouble(), 110.0); // 10 + 100
+  EXPECT_EQ(cast<IntegerAttr>(intAttr).getInt(), 20); // 10 * 2
+  EXPECT_DOUBLE_EQ(cast<FloatAttr>(floatAttr).getValueAsDouble(),
+                   110.0); // 10 + 100
 
   // Create constant ops for both.
   Operation *intConstOp = intIface.createConstantOp(builder, loc, intAttr);
-  Operation *floatConstOp = floatIface.createConstantOp(builder, loc, floatAttr);
+  Operation *floatConstOp =
+      floatIface.createConstantOp(builder, loc, floatAttr);
 
   ASSERT_TRUE(intConstOp != nullptr);
   ASSERT_TRUE(floatConstOp != nullptr);
@@ -502,7 +505,8 @@ TEST(ConstantLikeInterfaceTest, MultipleTypesWithDifferentBehavior) {
   EXPECT_TRUE(isa<arith::ConstantOp>(floatConstOp));
 
   auto intResult = cast<arith::ConstantOp>(intConstOp).getResult().getType();
-  auto floatResult = cast<arith::ConstantOp>(floatConstOp).getResult().getType();
+  auto floatResult =
+      cast<arith::ConstantOp>(floatConstOp).getResult().getType();
 
   EXPECT_TRUE(isa<IntegerType>(intResult));
   EXPECT_TRUE(isa<Float32Type>(floatResult));

``````````

</details>


https://github.com/llvm/llvm-project/pull/177740


More information about the Mlir-commits mailing list