[Mlir-commits] [mlir] [mlir][IR] Add `ScalarTypeInterface` and use as `VectorType` element type (PR #132400)

Krzysztof Drewniak llvmlistbot at llvm.org
Fri Mar 21 13:49:14 PDT 2025


================
@@ -16,7 +16,40 @@
 
 include "mlir/IR/OpBase.td"
 
-def FloatTypeInterface : TypeInterface<"FloatType"> {
+//===----------------------------------------------------------------------===//
+// ScalarTypeInterface
+//===----------------------------------------------------------------------===//
+
+def ScalarTypeInterface : TypeInterface<"ScalarTypeInterface"> {
+  let cppNamespace = "::mlir";
+  let description = [{
+    Indication that this type is a scalar type.
+
+    The bitwidth of a scalar type is a fixed constant but may be unknown in the
+    absence of data layout information.
+
+    Scalar types are POD (plain-old-data) entities that have an in-memory
+    representation: scalar values can be loaded/store from/to memory, so
+    abstract types like function types or async tokens cannot be scalar types.
+
+    Scalar types should be limited to types that can lower to something that
+    egress dialects would consider a valid vector element type.
----------------
krzysz00 wrote:

~~A scalar type is a type that people would generally consider a scalar type. Integers, floats, and pointers are examples of scalars, shaped types (like tensors, vectors, and arrays), tuples, and other complex structures are examples of non-scalar types.~~

(There's my mostly-joking submission to the definition question)

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


More information about the Mlir-commits mailing list