[Mlir-commits] [mlir] [mlir][linalg][nfc] Code refactoring of LinalgOps.cpp (PR #164274)
Adam Siemieniuk
llvmlistbot at llvm.org
Tue Oct 21 02:29:03 PDT 2025
================
@@ -0,0 +1,148 @@
+//===- RegionBuilderHelper.h - Region-Builder-Helper class declaration ----===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Helper builds the unary, binary, and type conversion functions defined by the
+// DSL. See LinalgNamedStructuredOps.yamlgen.cpp.inc for the code that uses this
+// class.
+//
+// Implementations of the math functions must be polymorphic over numeric types,
+// internally performing necessary casts. If the function application makes no
+// sense, then the only recourse is to assert and return nullptr. This can be
+// extended later if it becomes possible to fail construction of the region. The
+// invariant should be enforced at a higher level.
+//
+// TODO: These helpers are currently type polymorphic over the class of integer
+// and floating point types, but they will not internally cast within bit
+// widths of a class (mixed precision such as i8->i32) or across classes
+// (i.e. mixed float and integer). Many such combinations are ambiguous or need
+// to be handled with care and work is being considered to extend the op
+// language to make such cases explicit. In the mean-time, violating this will
+// fail verification, which is deemed acceptable.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_LINALG_REGION_BUILDER_HELPER_H
+#define MLIR_LINALG_REGION_BUILDER_HELPER_H
+
+#include "mlir/Dialect/Arith/IR/Arith.h"
----------------
adam-smnk wrote:
Most of these includes should be moved to the source file.
Also could you cleanup unused ones?
For example, I don't see any need for memref, tensor etc.
https://github.com/llvm/llvm-project/pull/164274
More information about the Mlir-commits
mailing list