[Mlir-commits] [mlir] 09f7a55 - [mlir][Types][NFC] Move all of the builtin Type classes to BuiltinTypes.h
River Riddle
llvmlistbot at llvm.org
Thu Dec 3 18:02:50 PST 2020
Author: River Riddle
Date: 2020-12-03T18:02:10-08:00
New Revision: 09f7a55fad924b894fadef0f0edccffdfda7838a
URL: https://github.com/llvm/llvm-project/commit/09f7a55fad924b894fadef0f0edccffdfda7838a
DIFF: https://github.com/llvm/llvm-project/commit/09f7a55fad924b894fadef0f0edccffdfda7838a.diff
LOG: [mlir][Types][NFC] Move all of the builtin Type classes to BuiltinTypes.h
This is part of a larger refactoring the better congregates the builtin structures under the BuiltinDialect. This also removes the problematic "standard" naming that clashes with the "standard" dialect, which is not defined within IR/. A temporary forward is placed in StandardTypes.h to allow time for downstream users to replaced references.
Differential Revision: https://reviews.llvm.org/D92435
Added:
mlir/include/mlir-c/BuiltinTypes.h
mlir/include/mlir/IR/BuiltinTypes.h
mlir/lib/CAPI/IR/BuiltinTypes.cpp
mlir/lib/IR/BuiltinTypes.cpp
Modified:
debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp
flang/include/flang/Lower/Mangler.h
flang/lib/Lower/ConvertType.cpp
flang/lib/Lower/RTBuilder.h
mlir/docs/Dialects/LLVM.md
mlir/docs/Dialects/SPIR-V.md
mlir/docs/LangRef.md
mlir/docs/Rationale/Rationale.md
mlir/docs/ShapeInference.md
mlir/examples/toy/Ch2/mlir/Dialect.cpp
mlir/examples/toy/Ch2/mlir/MLIRGen.cpp
mlir/examples/toy/Ch3/mlir/Dialect.cpp
mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
mlir/examples/toy/Ch4/include/toy/Dialect.h
mlir/examples/toy/Ch4/mlir/Dialect.cpp
mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
mlir/examples/toy/Ch5/include/toy/Dialect.h
mlir/examples/toy/Ch5/mlir/Dialect.cpp
mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
mlir/examples/toy/Ch6/include/toy/Dialect.h
mlir/examples/toy/Ch6/mlir/Dialect.cpp
mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
mlir/examples/toy/Ch7/include/toy/Dialect.h
mlir/examples/toy/Ch7/mlir/Dialect.cpp
mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h
mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
mlir/include/mlir/Dialect/Async/IR/Async.h
mlir/include/mlir/Dialect/CommonFolders.h
mlir/include/mlir/Dialect/GPU/GPUDialect.h
mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h
mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h
mlir/include/mlir/Dialect/Quant/QuantOps.h
mlir/include/mlir/Dialect/Quant/QuantTypes.h
mlir/include/mlir/Dialect/Quant/UniformSupport.h
mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h
mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h
mlir/include/mlir/Dialect/Vector/VectorOps.h
mlir/include/mlir/EDSC/Builders.h
mlir/include/mlir/IR/Builders.h
mlir/include/mlir/IR/FunctionSupport.h
mlir/include/mlir/IR/Matchers.h
mlir/include/mlir/IR/OpImplementation.h
mlir/include/mlir/IR/StandardTypes.h
mlir/include/mlir/IR/Types.h
mlir/include/mlir/Interfaces/VectorInterfaces.h
mlir/include/mlir/Interfaces/ViewLikeInterface.h
mlir/lib/Bindings/Python/IRModules.cpp
mlir/lib/CAPI/IR/CMakeLists.txt
mlir/lib/CAPI/IR/StandardAttributes.cpp
mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp
mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
mlir/lib/Dialect/PDL/IR/PDL.cpp
mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp
mlir/lib/Dialect/Quant/IR/QuantOps.cpp
mlir/lib/Dialect/Quant/IR/QuantTypes.cpp
mlir/lib/Dialect/Quant/IR/TypeDetail.h
mlir/lib/Dialect/Quant/IR/TypeParser.cpp
mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
mlir/lib/Dialect/Quant/Utils/QuantizeUtils.cpp
mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp
mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp
mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp
mlir/lib/Dialect/Shape/IR/Shape.cpp
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
mlir/lib/Dialect/Traits.cpp
mlir/lib/ExecutionEngine/JitRunner.cpp
mlir/lib/IR/AffineMap.cpp
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/AttributeDetail.h
mlir/lib/IR/Builders.cpp
mlir/lib/IR/BuiltinDialect.cpp
mlir/lib/IR/CMakeLists.txt
mlir/lib/IR/Operation.cpp
mlir/lib/IR/OperationSupport.cpp
mlir/lib/IR/TypeDetail.h
mlir/lib/IR/TypeUtilities.cpp
mlir/lib/IR/Types.cpp
mlir/lib/IR/Value.cpp
mlir/lib/Interfaces/ControlFlowInterfaces.cpp
mlir/lib/Interfaces/InferTypeOpInterface.cpp
mlir/lib/Parser/AttributeParser.cpp
mlir/lib/Parser/DialectSymbolParser.cpp
mlir/lib/Parser/TypeParser.cpp
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/lib/Transforms/ViewOpGraph.cpp
mlir/test/Bindings/Python/ir_types.py
mlir/test/CAPI/ir.c
mlir/test/EDSC/builder-api-test.cpp
mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
mlir/test/lib/Dialect/Test/TestDialect.h
mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp
mlir/unittests/Dialect/Quant/QuantizationUtilsTest.cpp
mlir/unittests/IR/AttributeTest.cpp
mlir/unittests/IR/OperationSupportTest.cpp
mlir/unittests/TableGen/OpBuildGen.cpp
mlir/unittests/TableGen/StructsGenTest.cpp
mlir/utils/gdb-scripts/prettyprinters.py
Removed:
mlir/include/mlir-c/StandardTypes.h
mlir/lib/CAPI/IR/StandardTypes.cpp
mlir/lib/IR/StandardTypes.cpp
################################################################################
diff --git a/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp b/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp
index 548a9ed2a206..4f94b3c6f6fa 100644
--- a/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp
+++ b/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp
@@ -1,8 +1,8 @@
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Identifier.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/OperationSupport.h"
-#include "mlir/IR/StandardTypes.h"
mlir::MLIRContext Context;
diff --git a/flang/include/flang/Lower/Mangler.h b/flang/include/flang/Lower/Mangler.h
index 7e18c069fc34..0029772e0978 100644
--- a/flang/include/flang/Lower/Mangler.h
+++ b/flang/include/flang/Lower/Mangler.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_LOWER_MANGLER_H
#define FORTRAN_LOWER_MANGLER_H
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "llvm/ADT/StringRef.h"
#include <string>
diff --git a/flang/lib/Lower/ConvertType.cpp b/flang/lib/Lower/ConvertType.cpp
index c01c6bc64595..746d7ade9972 100644
--- a/flang/lib/Lower/ConvertType.cpp
+++ b/flang/lib/Lower/ConvertType.cpp
@@ -13,7 +13,7 @@
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
#include "mlir/IR/Builders.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#undef QUOTE
#undef TODO
diff --git a/flang/lib/Lower/RTBuilder.h b/flang/lib/Lower/RTBuilder.h
index 3855f6816d6e..4805eb322660 100644
--- a/flang/lib/Lower/RTBuilder.h
+++ b/flang/lib/Lower/RTBuilder.h
@@ -19,8 +19,8 @@
#include "flang/Lower/ConvertType.h"
#include "flang/Optimizer/Dialect/FIRType.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/SmallVector.h"
#include <functional>
diff --git a/mlir/docs/Dialects/LLVM.md b/mlir/docs/Dialects/LLVM.md
index 9f423c0b3323..9e2dbd65b4a3 100644
--- a/mlir/docs/Dialects/LLVM.md
+++ b/mlir/docs/Dialects/LLVM.md
@@ -370,7 +370,7 @@ constants must be created as SSA values before being used in other operations.
`llvm.mlir.constant` creates such values for scalars and vectors. It has a
mandatory `value` attribute, which may be an integer, floating point attribute;
dense or sparse attribute containing integers or floats. The type of the
-attribute is one of the corresponding MLIR standard types. It may be omitted for
+attribute is one of the corresponding MLIR builtin types. It may be omitted for
`i64` and `f64` types that are implied. The operation produces a new SSA value
of the specified LLVM IR dialect type. The type of that value _must_ correspond
to the attribute type converted to LLVM IR.
diff --git a/mlir/docs/Dialects/SPIR-V.md b/mlir/docs/Dialects/SPIR-V.md
index 0d1aefae1440..3432ddfdbd14 100644
--- a/mlir/docs/Dialects/SPIR-V.md
+++ b/mlir/docs/Dialects/SPIR-V.md
@@ -159,7 +159,7 @@ instructions are represented in the SPIR-V dialect:
#### Model types with MLIR custom types
-* Types are represented using MLIR standard types and SPIR-V dialect specific
+* Types are represented using MLIR builtin types and SPIR-V dialect specific
types. There are no type declaration ops in the SPIR-V dialect. More
discussions can be found in the [Types](#types) section later.
@@ -247,9 +247,9 @@ encode them directly in the dialect-specific type.
Theoretically we can define all SPIR-V types using MLIR extensible type system,
but other than representational purity, it does not buy us more. Instead, we
need to maintain the code and invest in pretty printing them. So we prefer to
-use builtin/standard types if possible.
+use builtin types if possible.
-The SPIR-V dialect reuses standard integer, float, and vector types:
+The SPIR-V dialect reuses builtin integer, float, and vector types:
Specification | Dialect
:----------------------------------: | :-------------------------------:
@@ -1005,10 +1005,10 @@ register other legality constraints into the returned `SPIRVConversionTarget`.
### `SPIRVTypeConverter`
The `mlir::SPIRVTypeConverter` derives from `mlir::TypeConverter` and provides
-type conversion for standard types to SPIR-V types conforming to the [target
-environment](#target-environment) it is constructed with. If the required
-extension/capability for the resultant type is not available in the given
-target environment, `convertType()` will return a null type.
+type conversion for builtin types to SPIR-V types conforming to the
+[target environment](#target-environment) it is constructed with. If the
+required extension/capability for the resultant type is not available in the
+given target environment, `convertType()` will return a null type.
Standard scalar types are converted to their corresponding SPIR-V scalar types.
diff --git a/mlir/docs/LangRef.md b/mlir/docs/LangRef.md
index fd78d51afd6d..d32b6148030a 100644
--- a/mlir/docs/LangRef.md
+++ b/mlir/docs/LangRef.md
@@ -702,7 +702,7 @@ defines the relation between the region results and the operation results.
Each value in MLIR has a type defined by the type system below. There are a
number of primitive types (like integers) and also aggregate types for tensors
-and memory buffers. MLIR [standard types](#standard-types) do not include
+and memory buffers. MLIR [builtin types](#builtin-types) do not include
structures, arrays, or dictionaries.
MLIR has an open type system (i.e. there is no fixed list of types), and types
@@ -710,7 +710,7 @@ may have application-specific semantics. For example, MLIR supports a set of
[dialect types](#dialect-types).
```
-type ::= type-alias | dialect-type | standard-type
+type ::= type-alias | dialect-type | builtin-type
type-list-no-parens ::= type (`,` type)*
type-list-parens ::= `(` `)`
@@ -807,13 +807,13 @@ characters.
See [here](Tutorials/DefiningAttributesAndTypes.md) to learn how to define dialect types.
-### Standard Types
+### Builtin Types
-Standard types are a core set of [dialect types](#dialect-types) that are
-defined in a builtin dialect and thus available to all users of MLIR.
+Builtin types are a core set of [dialect types](#dialect-types) that are defined
+in a builtin dialect and thus available to all users of MLIR.
```
-standard-type ::= complex-type
+builtin-type ::= complex-type
| float-type
| function-type
| index-type
diff --git a/mlir/docs/Rationale/Rationale.md b/mlir/docs/Rationale/Rationale.md
index 8e1e2a984c07..f09f03b946a8 100644
--- a/mlir/docs/Rationale/Rationale.md
+++ b/mlir/docs/Rationale/Rationale.md
@@ -439,23 +439,23 @@ understand. When types of a dialect are:
* In operations of other dialects
- - For standard/builtin operations, only standard/builtin types are
- allowed. This restriction allows for operations to clearly understand
- the invariants that they are working under.
+ - For standard/builtin operations, only builtin types are allowed. This
+ restriction allows for operations to clearly understand the invariants
+ that they are working under.
- Outside of standard/builtin operations, dialects are expected to verify
the allowable operation types per operation.
* In types of other dialects
- - For standard/builtin types, these types are allowed to contain types
- from other dialects. This simplifies the type system and removes the
- need for dialects to redefine all of the standard aggregate types, e.g.
- tensor, as well as the memref type. Dialects are expected to verify that
- a specific type is valid within a standard type, e.g. if a type can be
- an element of a tensor.
+ - For builtin types, these types are allowed to contain types from other
+ dialects. This simplifies the type system and removes the need for
+ dialects to redefine all of the builtin aggregate types, e.g. tensor, as
+ well as the memref type. Dialects are expected to verify that a specific
+ type is valid within a builtin type, e.g. if a type can be an element of
+ a tensor.
- For dialect types, the dialect is expected to verify any type
- invariants, e.g. if the standard tensor type can contain a specific type
- of that dialect.
+ invariants, e.g. if the tensor type can contain a specific type of that
+ dialect.
#### Separating builtin and standard types
diff --git a/mlir/docs/ShapeInference.md b/mlir/docs/ShapeInference.md
index 76a97791d815..00cd30318a6d 100644
--- a/mlir/docs/ShapeInference.md
+++ b/mlir/docs/ShapeInference.md
@@ -292,4 +292,4 @@ the shape function. The reference implementation is general and can support the
arbitrary computations needed to specify output shapes.
[InferTypeOpInterface]: https://github.com/llvm/llvm-project/tree/master/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
-[ShapedType]: https://github.com/llvm/llvm-project/tree/master/mlir/include/mlir/IR/StandardTypes.h
+[ShapedType]: https://github.com/llvm/llvm-project/tree/master/mlir/include/mlir/IR/BuiltinTypes.h
diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp
index 86d638395268..0e715c9aafa4 100644
--- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp
@@ -14,8 +14,8 @@
#include "toy/Dialect.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
using namespace mlir;
using namespace mlir::toy;
diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp
index 94d85132dbb5..282a1bc76815 100644
--- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp
@@ -18,8 +18,8 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Verifier.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp
index 86d638395268..0e715c9aafa4 100644
--- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp
@@ -14,8 +14,8 @@
#include "toy/Dialect.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
using namespace mlir;
using namespace mlir::toy;
diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
index 94d85132dbb5..282a1bc76815 100644
--- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
@@ -18,8 +18,8 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Verifier.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/mlir/examples/toy/Ch4/include/toy/Dialect.h b/mlir/examples/toy/Ch4/include/toy/Dialect.h
index 0c01501e9550..3c266cf02d6d 100644
--- a/mlir/examples/toy/Ch4/include/toy/Dialect.h
+++ b/mlir/examples/toy/Ch4/include/toy/Dialect.h
@@ -15,8 +15,8 @@
#define MLIR_TUTORIAL_TOY_DIALECT_H_
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "toy/ShapeInferenceInterface.h"
diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp
index f286e7357346..09875f7bdac1 100644
--- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp
@@ -14,8 +14,8 @@
#include "toy/Dialect.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Transforms/InliningUtils.h"
using namespace mlir;
diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
index 34f1dd47d07f..c92010594ed5 100644
--- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
@@ -18,8 +18,8 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Verifier.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/mlir/examples/toy/Ch5/include/toy/Dialect.h b/mlir/examples/toy/Ch5/include/toy/Dialect.h
index 0c01501e9550..3c266cf02d6d 100644
--- a/mlir/examples/toy/Ch5/include/toy/Dialect.h
+++ b/mlir/examples/toy/Ch5/include/toy/Dialect.h
@@ -15,8 +15,8 @@
#define MLIR_TUTORIAL_TOY_DIALECT_H_
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "toy/ShapeInferenceInterface.h"
diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp
index 76fa9559e01f..045673e67f79 100644
--- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp
@@ -14,8 +14,8 @@
#include "toy/Dialect.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Transforms/InliningUtils.h"
using namespace mlir;
diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
index 34f1dd47d07f..c92010594ed5 100644
--- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
@@ -18,8 +18,8 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Verifier.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/mlir/examples/toy/Ch6/include/toy/Dialect.h b/mlir/examples/toy/Ch6/include/toy/Dialect.h
index 0c01501e9550..3c266cf02d6d 100644
--- a/mlir/examples/toy/Ch6/include/toy/Dialect.h
+++ b/mlir/examples/toy/Ch6/include/toy/Dialect.h
@@ -15,8 +15,8 @@
#define MLIR_TUTORIAL_TOY_DIALECT_H_
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "toy/ShapeInferenceInterface.h"
diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp
index 76fa9559e01f..045673e67f79 100644
--- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp
@@ -14,8 +14,8 @@
#include "toy/Dialect.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Transforms/InliningUtils.h"
using namespace mlir;
diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
index 34f1dd47d07f..c92010594ed5 100644
--- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
@@ -18,8 +18,8 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Verifier.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/mlir/examples/toy/Ch7/include/toy/Dialect.h b/mlir/examples/toy/Ch7/include/toy/Dialect.h
index bba2f91bc7cc..15b55d03f77e 100644
--- a/mlir/examples/toy/Ch7/include/toy/Dialect.h
+++ b/mlir/examples/toy/Ch7/include/toy/Dialect.h
@@ -15,8 +15,8 @@
#define MLIR_TUTORIAL_TOY_DIALECT_H_
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "toy/ShapeInferenceInterface.h"
diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp
index 6743be592bfe..032d7a61fb90 100644
--- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp
@@ -14,9 +14,9 @@
#include "toy/Dialect.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Transforms/InliningUtils.h"
using namespace mlir;
diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
index 51e6d01a1306..401e4eb961cc 100644
--- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
@@ -18,8 +18,8 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Verifier.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/mlir/include/mlir-c/StandardTypes.h b/mlir/include/mlir-c/BuiltinTypes.h
similarity index 98%
rename from mlir/include/mlir-c/StandardTypes.h
rename to mlir/include/mlir-c/BuiltinTypes.h
index 14d9bcc51986..77898be41565 100644
--- a/mlir/include/mlir-c/StandardTypes.h
+++ b/mlir/include/mlir-c/BuiltinTypes.h
@@ -1,4 +1,4 @@
-//===-- mlir-c/StandardTypes.h - C API for MLIR Standard types ----*- C -*-===//
+//===-- mlir-c/BuiltinTypes.h - C API for MLIR Builtin types ------*- C -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM
// Exceptions.
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_C_STANDARDTYPES_H
-#define MLIR_C_STANDARDTYPES_H
+#ifndef MLIR_C_BUILTINTYPES_H
+#define MLIR_C_BUILTINTYPES_H
#include "mlir-c/AffineMap.h"
#include "mlir-c/IR.h"
@@ -316,4 +316,4 @@ MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetResult(MlirType type,
}
#endif
-#endif // MLIR_C_STANDARDTYPES_H
+#endif // MLIR_C_BUILTINTYPES_H
diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
index edfd8c96eaa7..7b8bcdff4deb 100644
--- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
+++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
@@ -89,7 +89,7 @@ class LLVMTypeConverter : public TypeConverter {
/// Promote the bare pointers in 'values' that resulted from memrefs to
/// descriptors. 'stdTypes' holds the types of 'values' before the conversion
- /// to the LLVM-IR dialect (i.e., MemRefType, or any other Standard type).
+ /// to the LLVM-IR dialect (i.e., MemRefType, or any other builtin type).
void promoteBarePtrsToDescriptors(ConversionPatternRewriter &rewriter,
Location loc, ArrayRef<Type> stdTypes,
SmallVectorImpl<Value> &values);
diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h b/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h
index 1f4fdb6126fe..66b427cec11a 100644
--- a/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h
+++ b/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h
@@ -14,8 +14,8 @@
#define MLIR_DIALECT_AFFINE_IR_AFFINEMEMORYOPDIALECT_H_
#include "mlir/IR/AffineMap.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpDefinition.h"
-#include "mlir/IR/StandardTypes.h"
namespace mlir {
#include "mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h.inc"
diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
index 19500c53ea60..c4bed26bfc29 100644
--- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
+++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
@@ -18,9 +18,9 @@
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
diff --git a/mlir/include/mlir/Dialect/Async/IR/Async.h b/mlir/include/mlir/Dialect/Async/IR/Async.h
index d0664b08c0fb..ed5238bef60c 100644
--- a/mlir/include/mlir/Dialect/Async/IR/Async.h
+++ b/mlir/include/mlir/Dialect/Async/IR/Async.h
@@ -15,10 +15,10 @@
#define MLIR_DIALECT_ASYNC_IR_ASYNC_H
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
diff --git a/mlir/include/mlir/Dialect/CommonFolders.h b/mlir/include/mlir/Dialect/CommonFolders.h
index e1f7be89a4e6..574aab190302 100644
--- a/mlir/include/mlir/Dialect/CommonFolders.h
+++ b/mlir/include/mlir/Dialect/CommonFolders.h
@@ -16,7 +16,7 @@
#define MLIR_DIALECT_COMMONFOLDERS_H
#include "mlir/IR/Attributes.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/mlir/include/mlir/Dialect/GPU/GPUDialect.h b/mlir/include/mlir/Dialect/GPU/GPUDialect.h
index 99f388b4db51..1e43ebeb55be 100644
--- a/mlir/include/mlir/Dialect/GPU/GPUDialect.h
+++ b/mlir/include/mlir/Dialect/GPU/GPUDialect.h
@@ -15,11 +15,11 @@
#define MLIR_DIALECT_GPU_GPUDIALECT_H
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/FunctionSupport.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h
index f8002279132f..2438338a534f 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h
@@ -18,8 +18,8 @@
#include "mlir/IR/BlockAndValueMapping.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinDialect.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpDefinition.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/IR/Types.h"
#include "mlir/Interfaces/CopyOpInterface.h"
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h
index ca604d68ab27..adfa6a6f1af9 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h
@@ -13,8 +13,8 @@
#include "mlir/Dialect/Utils/StructuredOpsUtils.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpDefinition.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Support/LLVM.h"
namespace mlir {
diff --git a/mlir/include/mlir/Dialect/Quant/QuantOps.h b/mlir/include/mlir/Dialect/Quant/QuantOps.h
index 00a6032a2fea..9dc6b1ddd5e0 100644
--- a/mlir/include/mlir/Dialect/Quant/QuantOps.h
+++ b/mlir/include/mlir/Dialect/Quant/QuantOps.h
@@ -11,9 +11,9 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Types.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "llvm/Support/MathExtras.h"
diff --git a/mlir/include/mlir/Dialect/Quant/QuantTypes.h b/mlir/include/mlir/Dialect/Quant/QuantTypes.h
index 7add13636695..47e70fe48354 100644
--- a/mlir/include/mlir/Dialect/Quant/QuantTypes.h
+++ b/mlir/include/mlir/Dialect/Quant/QuantTypes.h
@@ -11,9 +11,9 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Types.h"
#include "llvm/Support/MathExtras.h"
diff --git a/mlir/include/mlir/Dialect/Quant/UniformSupport.h b/mlir/include/mlir/Dialect/Quant/UniformSupport.h
index 30c4db0abc8e..91f2a798430c 100644
--- a/mlir/include/mlir/Dialect/Quant/UniformSupport.h
+++ b/mlir/include/mlir/Dialect/Quant/UniformSupport.h
@@ -10,7 +10,7 @@
#define MLIR_DIALECT_QUANT_UNIFORMSUPPORT_H_
#include "mlir/Dialect/Quant/QuantTypes.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Types.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
index 02a1f0861da8..1ebf702ff8a2 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
+++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
@@ -21,7 +21,7 @@
namespace mlir {
-/// Type conversion from standard types to SPIR-V types for shader interface.
+/// Type conversion from builtin types to SPIR-V types for shader interface.
///
/// Non-32-bit scalar types require special hardware support that may not exist
/// on all GPUs. This is reflected in SPIR-V as that non-32-bit scalar types
diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h
index 75d8f8025841..9f621cd6526b 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h
+++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h
@@ -13,9 +13,9 @@
#ifndef MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
#define MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Location.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/TypeSupport.h"
#include "mlir/IR/Types.h"
diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
index 10ea561aa83d..e2b9470f19a7 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
@@ -15,9 +15,9 @@
#define MLIR_DIALECT_STANDARDOPS_IR_OPS_H
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
diff --git a/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h b/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h
index b257abe0ef30..0a55b68b350e 100644
--- a/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h
+++ b/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This header file define utilities that operate on standard types and are
+// This header file define utilities that operate on builtin types and are
// useful across multiple dialects that use structured ops abstractions. These
// abstractions consist of define custom operations that encode and transport
// information about their semantics (e.g. type of iterators like parallel,
diff --git a/mlir/include/mlir/Dialect/Vector/VectorOps.h b/mlir/include/mlir/Dialect/Vector/VectorOps.h
index 0a8e5b679277..95964665ced6 100644
--- a/mlir/include/mlir/Dialect/Vector/VectorOps.h
+++ b/mlir/include/mlir/Dialect/Vector/VectorOps.h
@@ -15,9 +15,9 @@
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Attributes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Interfaces/VectorInterfaces.h"
#include "mlir/Interfaces/ViewLikeInterface.h"
diff --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h
index 83b6634bf8e2..f904f2a53eb0 100644
--- a/mlir/include/mlir/EDSC/Builders.h
+++ b/mlir/include/mlir/EDSC/Builders.h
@@ -16,7 +16,7 @@
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/Builders.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Types.h"
namespace mlir {
diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index 761a74b1c489..f5650480e3ca 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -20,7 +20,9 @@ class FileLineColLoc;
class Type;
class PrimitiveType;
class IntegerType;
+class FloatType;
class FunctionType;
+class IndexType;
class MemRefType;
class VectorType;
class RankedTensorType;
diff --git a/mlir/include/mlir/IR/BuiltinTypes.h b/mlir/include/mlir/IR/BuiltinTypes.h
new file mode 100644
index 000000000000..ea231fb1d27d
--- /dev/null
+++ b/mlir/include/mlir/IR/BuiltinTypes.h
@@ -0,0 +1,821 @@
+//===- BuiltinTypes.h - MLIR Builtin Type Classes ---------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_IR_BUILTINTYPES_H
+#define MLIR_IR_BUILTINTYPES_H
+
+#include "mlir/IR/Types.h"
+
+namespace llvm {
+struct fltSemantics;
+} // namespace llvm
+
+namespace mlir {
+class AffineExpr;
+class AffineMap;
+class FloatType;
+class Identifier;
+class IndexType;
+class IntegerType;
+class Location;
+class MLIRContext;
+class TypeRange;
+
+namespace detail {
+
+struct BaseMemRefTypeStorage;
+struct ComplexTypeStorage;
+struct FunctionTypeStorage;
+struct IntegerTypeStorage;
+struct MemRefTypeStorage;
+struct OpaqueTypeStorage;
+struct RankedTensorTypeStorage;
+struct ShapedTypeStorage;
+struct TupleTypeStorage;
+struct UnrankedMemRefTypeStorage;
+struct UnrankedTensorTypeStorage;
+struct VectorTypeStorage;
+
+} // namespace detail
+
+//===----------------------------------------------------------------------===//
+// ComplexType
+//===----------------------------------------------------------------------===//
+
+/// The 'complex' type represents a complex number with a parameterized element
+/// type, which is composed of a real and imaginary value of that element type.
+///
+/// The element must be a floating point or integer scalar type.
+///
+class ComplexType
+ : public Type::TypeBase<ComplexType, Type, detail::ComplexTypeStorage> {
+public:
+ using Base::Base;
+
+ /// Get or create a ComplexType with the provided element type.
+ static ComplexType get(Type elementType);
+
+ /// Get or create a ComplexType with the provided element type. This emits
+ /// and error at the specified location and returns null if the element type
+ /// isn't supported.
+ static ComplexType getChecked(Type elementType, Location location);
+
+ /// Verify the construction of an integer type.
+ static LogicalResult verifyConstructionInvariants(Location loc,
+ Type elementType);
+
+ Type getElementType();
+};
+
+//===----------------------------------------------------------------------===//
+// IndexType
+//===----------------------------------------------------------------------===//
+
+/// Index is a special integer-like type with unknown platform-dependent bit
+/// width.
+class IndexType : public Type::TypeBase<IndexType, Type, TypeStorage> {
+public:
+ using Base::Base;
+
+ /// Get an instance of the IndexType.
+ static IndexType get(MLIRContext *context);
+
+ /// Storage bit width used for IndexType by internal compiler data structures.
+ static constexpr unsigned kInternalStorageBitWidth = 64;
+};
+
+//===----------------------------------------------------------------------===//
+// IntegerType
+//===----------------------------------------------------------------------===//
+
+/// Integer types can have arbitrary bitwidth up to a large fixed limit.
+class IntegerType
+ : public Type::TypeBase<IntegerType, Type, detail::IntegerTypeStorage> {
+public:
+ using Base::Base;
+
+ /// Signedness semantics.
+ enum SignednessSemantics : uint32_t {
+ Signless, /// No signedness semantics
+ Signed, /// Signed integer
+ Unsigned, /// Unsigned integer
+ };
+
+ /// Get or create a new IntegerType of the given width within the context.
+ /// The created IntegerType is signless (i.e., no signedness semantics).
+ /// Assume the width is within the allowed range and assert on failures. Use
+ /// getChecked to handle failures gracefully.
+ static IntegerType get(unsigned width, MLIRContext *context);
+
+ /// Get or create a new IntegerType of the given width within the context.
+ /// The created IntegerType has signedness semantics as indicated via
+ /// `signedness`. Assume the width is within the allowed range and assert on
+ /// failures. Use getChecked to handle failures gracefully.
+ static IntegerType get(unsigned width, SignednessSemantics signedness,
+ MLIRContext *context);
+
+ /// Get or create a new IntegerType of the given width within the context,
+ /// defined at the given, potentially unknown, location. The created
+ /// IntegerType is signless (i.e., no signedness semantics). If the width is
+ /// outside the allowed range, emit errors and return a null type.
+ static IntegerType getChecked(unsigned width, Location location);
+
+ /// Get or create a new IntegerType of the given width within the context,
+ /// defined at the given, potentially unknown, location. The created
+ /// IntegerType has signedness semantics as indicated via `signedness`. If the
+ /// width is outside the allowed range, emit errors and return a null type.
+ static IntegerType getChecked(unsigned width, SignednessSemantics signedness,
+ Location location);
+
+ /// Verify the construction of an integer type.
+ static LogicalResult
+ verifyConstructionInvariants(Location loc, unsigned width,
+ SignednessSemantics signedness);
+
+ /// Return the bitwidth of this integer type.
+ unsigned getWidth() const;
+
+ /// Return the signedness semantics of this integer type.
+ SignednessSemantics getSignedness() const;
+
+ /// Return true if this is a signless integer type.
+ bool isSignless() const { return getSignedness() == Signless; }
+ /// Return true if this is a signed integer type.
+ bool isSigned() const { return getSignedness() == Signed; }
+ /// Return true if this is an unsigned integer type.
+ bool isUnsigned() const { return getSignedness() == Unsigned; }
+
+ /// Integer representation maximal bitwidth.
+ static constexpr unsigned kMaxWidth = 4096;
+};
+
+//===----------------------------------------------------------------------===//
+// FloatType
+//===----------------------------------------------------------------------===//
+
+class FloatType : public Type {
+public:
+ using Type::Type;
+
+ // Convenience factories.
+ static FloatType getBF16(MLIRContext *ctx);
+ static FloatType getF16(MLIRContext *ctx);
+ static FloatType getF32(MLIRContext *ctx);
+ static FloatType getF64(MLIRContext *ctx);
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
+ static bool classof(Type type);
+
+ /// Return the bitwidth of this float type.
+ unsigned getWidth();
+
+ /// Return the floating semantics of this float type.
+ const llvm::fltSemantics &getFloatSemantics();
+};
+
+//===----------------------------------------------------------------------===//
+// BFloat16Type
+
+class BFloat16Type
+ : public Type::TypeBase<BFloat16Type, FloatType, TypeStorage> {
+public:
+ using Base::Base;
+
+ /// Return an instance of the bfloat16 type.
+ static BFloat16Type get(MLIRContext *context);
+};
+
+inline FloatType FloatType::getBF16(MLIRContext *ctx) {
+ return BFloat16Type::get(ctx);
+}
+
+//===----------------------------------------------------------------------===//
+// Float16Type
+
+class Float16Type : public Type::TypeBase<Float16Type, FloatType, TypeStorage> {
+public:
+ using Base::Base;
+
+ /// Return an instance of the float16 type.
+ static Float16Type get(MLIRContext *context);
+};
+
+inline FloatType FloatType::getF16(MLIRContext *ctx) {
+ return Float16Type::get(ctx);
+}
+
+//===----------------------------------------------------------------------===//
+// Float32Type
+
+class Float32Type : public Type::TypeBase<Float32Type, FloatType, TypeStorage> {
+public:
+ using Base::Base;
+
+ /// Return an instance of the float32 type.
+ static Float32Type get(MLIRContext *context);
+};
+
+inline FloatType FloatType::getF32(MLIRContext *ctx) {
+ return Float32Type::get(ctx);
+}
+
+//===----------------------------------------------------------------------===//
+// Float64Type
+
+class Float64Type : public Type::TypeBase<Float64Type, FloatType, TypeStorage> {
+public:
+ using Base::Base;
+
+ /// Return an instance of the float64 type.
+ static Float64Type get(MLIRContext *context);
+};
+
+inline FloatType FloatType::getF64(MLIRContext *ctx) {
+ return Float64Type::get(ctx);
+}
+
+//===----------------------------------------------------------------------===//
+// FunctionType
+//===----------------------------------------------------------------------===//
+
+/// Function types map from a list of inputs to a list of results.
+class FunctionType
+ : public Type::TypeBase<FunctionType, Type, detail::FunctionTypeStorage> {
+public:
+ using Base::Base;
+
+ static FunctionType get(TypeRange inputs, TypeRange results,
+ MLIRContext *context);
+
+ /// Input types.
+ unsigned getNumInputs() const;
+ Type getInput(unsigned i) const { return getInputs()[i]; }
+ ArrayRef<Type> getInputs() const;
+
+ /// Result types.
+ unsigned getNumResults() const;
+ Type getResult(unsigned i) const { return getResults()[i]; }
+ ArrayRef<Type> getResults() const;
+
+ /// Returns a new function type without the specified arguments and results.
+ FunctionType getWithoutArgsAndResults(ArrayRef<unsigned> argIndices,
+ ArrayRef<unsigned> resultIndices);
+};
+
+//===----------------------------------------------------------------------===//
+// NoneType
+//===----------------------------------------------------------------------===//
+
+/// NoneType is a unit type, i.e. a type with exactly one possible value, where
+/// its value does not have a defined dynamic representation.
+class NoneType : public Type::TypeBase<NoneType, Type, TypeStorage> {
+public:
+ using Base::Base;
+
+ /// Get an instance of the NoneType.
+ static NoneType get(MLIRContext *context);
+};
+
+//===----------------------------------------------------------------------===//
+// OpaqueType
+//===----------------------------------------------------------------------===//
+
+/// Opaque types represent types of non-registered dialects. These are types
+/// represented in their raw string form, and can only usefully be tested for
+/// type equality.
+class OpaqueType
+ : public Type::TypeBase<OpaqueType, Type, detail::OpaqueTypeStorage> {
+public:
+ using Base::Base;
+
+ /// Get or create a new OpaqueType with the provided dialect and string data.
+ static OpaqueType get(Identifier dialect, StringRef typeData,
+ MLIRContext *context);
+
+ /// Get or create a new OpaqueType with the provided dialect and string data.
+ /// If the given identifier is not a valid namespace for a dialect, then a
+ /// null type is returned.
+ static OpaqueType getChecked(Identifier dialect, StringRef typeData,
+ MLIRContext *context, Location location);
+
+ /// Returns the dialect namespace of the opaque type.
+ Identifier getDialectNamespace() const;
+
+ /// Returns the raw type data of the opaque type.
+ StringRef getTypeData() const;
+
+ /// Verify the construction of an opaque type.
+ static LogicalResult verifyConstructionInvariants(Location loc,
+ Identifier dialect,
+ StringRef typeData);
+};
+
+//===----------------------------------------------------------------------===//
+// ShapedType
+//===----------------------------------------------------------------------===//
+
+/// This is a common base class between Vector, UnrankedTensor, RankedTensor,
+/// and MemRef types because they share behavior and semantics around shape,
+/// rank, and fixed element type. Any type with these semantics should inherit
+/// from ShapedType.
+class ShapedType : public Type {
+public:
+ using ImplType = detail::ShapedTypeStorage;
+ using Type::Type;
+
+ // TODO: merge these two special values in a single one used everywhere.
+ // Unfortunately, uses of `-1` have crept deep into the codebase now and are
+ // hard to track.
+ static constexpr int64_t kDynamicSize = -1;
+ static constexpr int64_t kDynamicStrideOrOffset =
+ std::numeric_limits<int64_t>::min();
+
+ /// Return the element type.
+ Type getElementType() const;
+
+ /// If an element type is an integer or a float, return its width. Otherwise,
+ /// abort.
+ unsigned getElementTypeBitWidth() const;
+
+ /// If it has static shape, return the number of elements. Otherwise, abort.
+ int64_t getNumElements() const;
+
+ /// If this is a ranked type, return the rank. Otherwise, abort.
+ int64_t getRank() const;
+
+ /// Whether or not this is a ranked type. Memrefs, vectors and ranked tensors
+ /// have a rank, while unranked tensors do not.
+ bool hasRank() const;
+
+ /// If this is a ranked type, return the shape. Otherwise, abort.
+ ArrayRef<int64_t> getShape() const;
+
+ /// If this is unranked type or any dimension has unknown size (<0), it
+ /// doesn't have static shape. If all dimensions have known size (>= 0), it
+ /// has static shape.
+ bool hasStaticShape() const;
+
+ /// If this has a static shape and the shape is equal to `shape` return true.
+ bool hasStaticShape(ArrayRef<int64_t> shape) const;
+
+ /// If this is a ranked type, return the number of dimensions with dynamic
+ /// size. Otherwise, abort.
+ int64_t getNumDynamicDims() const;
+
+ /// If this is ranked type, return the size of the specified dimension.
+ /// Otherwise, abort.
+ int64_t getDimSize(unsigned idx) const;
+
+ /// Returns true if this dimension has a dynamic size (for ranked types);
+ /// aborts for unranked types.
+ bool isDynamicDim(unsigned idx) const;
+
+ /// Returns the position of the dynamic dimension relative to just the dynamic
+ /// dimensions, given its `index` within the shape.
+ unsigned getDynamicDimIndex(unsigned index) const;
+
+ /// Get the total amount of bits occupied by a value of this type. This does
+ /// not take into account any memory layout or widening constraints, e.g. a
+ /// vector<3xi57> is reported to occupy 3x57=171 bit, even though in practice
+ /// it will likely be stored as in a 4xi64 vector register. Fail an assertion
+ /// if the size cannot be computed statically, i.e. if the type has a dynamic
+ /// shape or if its elemental type does not have a known bit width.
+ int64_t getSizeInBits() const;
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
+ static bool classof(Type type);
+
+ /// Whether the given dimension size indicates a dynamic dimension.
+ static constexpr bool isDynamic(int64_t dSize) {
+ return dSize == kDynamicSize;
+ }
+ static constexpr bool isDynamicStrideOrOffset(int64_t dStrideOrOffset) {
+ return dStrideOrOffset == kDynamicStrideOrOffset;
+ }
+};
+
+//===----------------------------------------------------------------------===//
+// VectorType
+//===----------------------------------------------------------------------===//
+
+/// Vector types represent multi-dimensional SIMD vectors, and have a fixed
+/// known constant shape with one or more dimension.
+class VectorType
+ : public Type::TypeBase<VectorType, ShapedType, detail::VectorTypeStorage> {
+public:
+ using Base::Base;
+
+ /// Get or create a new VectorType of the provided shape and element type.
+ /// Assumes the arguments define a well-formed VectorType.
+ static VectorType get(ArrayRef<int64_t> shape, Type elementType);
+
+ /// Get or create a new VectorType of the provided shape and element type
+ /// declared at the given, potentially unknown, location. If the VectorType
+ /// defined by the arguments would be ill-formed, emit errors and return
+ /// nullptr-wrapping type.
+ static VectorType getChecked(ArrayRef<int64_t> shape, Type elementType,
+ Location location);
+
+ /// Verify the construction of a vector type.
+ static LogicalResult verifyConstructionInvariants(Location loc,
+ ArrayRef<int64_t> shape,
+ Type elementType);
+
+ /// Returns true of the given type can be used as an element of a vector type.
+ /// In particular, vectors can consist of integer or float primitives.
+ static bool isValidElementType(Type t) {
+ return t.isa<IntegerType, FloatType>();
+ }
+
+ ArrayRef<int64_t> getShape() const;
+};
+
+//===----------------------------------------------------------------------===//
+// TensorType
+//===----------------------------------------------------------------------===//
+
+/// Tensor types represent multi-dimensional arrays, and have two variants:
+/// RankedTensorType and UnrankedTensorType.
+class TensorType : public ShapedType {
+public:
+ using ShapedType::ShapedType;
+
+ /// Return true if the specified element type is ok in a tensor.
+ static bool isValidElementType(Type type);
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
+ static bool classof(Type type);
+};
+
+//===----------------------------------------------------------------------===//
+// RankedTensorType
+
+/// Ranked tensor types represent multi-dimensional arrays that have a shape
+/// with a fixed number of dimensions. Each shape element can be a non-negative
+/// integer or unknown (represented by -1).
+class RankedTensorType
+ : public Type::TypeBase<RankedTensorType, TensorType,
+ detail::RankedTensorTypeStorage> {
+public:
+ using Base::Base;
+
+ /// Get or create a new RankedTensorType of the provided shape and element
+ /// type. Assumes the arguments define a well-formed type.
+ static RankedTensorType get(ArrayRef<int64_t> shape, Type elementType);
+
+ /// Get or create a new RankedTensorType of the provided shape and element
+ /// type declared at the given, potentially unknown, location. If the
+ /// RankedTensorType defined by the arguments would be ill-formed, emit errors
+ /// and return a nullptr-wrapping type.
+ static RankedTensorType getChecked(ArrayRef<int64_t> shape, Type elementType,
+ Location location);
+
+ /// Verify the construction of a ranked tensor type.
+ static LogicalResult verifyConstructionInvariants(Location loc,
+ ArrayRef<int64_t> shape,
+ Type elementType);
+
+ ArrayRef<int64_t> getShape() const;
+};
+
+//===----------------------------------------------------------------------===//
+// UnrankedTensorType
+
+/// Unranked tensor types represent multi-dimensional arrays that have an
+/// unknown shape.
+class UnrankedTensorType
+ : public Type::TypeBase<UnrankedTensorType, TensorType,
+ detail::UnrankedTensorTypeStorage> {
+public:
+ using Base::Base;
+
+ /// Get or create a new UnrankedTensorType of the provided shape and element
+ /// type. Assumes the arguments define a well-formed type.
+ static UnrankedTensorType get(Type elementType);
+
+ /// Get or create a new UnrankedTensorType of the provided shape and element
+ /// type declared at the given, potentially unknown, location. If the
+ /// UnrankedTensorType defined by the arguments would be ill-formed, emit
+ /// errors and return a nullptr-wrapping type.
+ static UnrankedTensorType getChecked(Type elementType, Location location);
+
+ /// Verify the construction of a unranked tensor type.
+ static LogicalResult verifyConstructionInvariants(Location loc,
+ Type elementType);
+
+ ArrayRef<int64_t> getShape() const { return llvm::None; }
+};
+
+//===----------------------------------------------------------------------===//
+// BaseMemRefType
+//===----------------------------------------------------------------------===//
+
+/// Base MemRef for Ranked and Unranked variants
+class BaseMemRefType : public ShapedType {
+public:
+ using ImplType = detail::BaseMemRefTypeStorage;
+ using ShapedType::ShapedType;
+
+ /// Return true if the specified element type is ok in a memref.
+ static bool isValidElementType(Type type) {
+ return type.isIntOrIndexOrFloat() || type.isa<VectorType, ComplexType>();
+ }
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast.
+ static bool classof(Type type);
+
+ /// Returns the memory space in which data referred to by this memref resides.
+ unsigned getMemorySpace() const;
+};
+
+//===----------------------------------------------------------------------===//
+// MemRefType
+
+/// MemRef types represent a region of memory that have a shape with a fixed
+/// number of dimensions. Each shape element can be a non-negative integer or
+/// unknown (represented by -1). MemRef types also have an affine map
+/// composition, represented as an array AffineMap pointers.
+class MemRefType : public Type::TypeBase<MemRefType, BaseMemRefType,
+ detail::MemRefTypeStorage> {
+public:
+ /// This is a builder type that keeps local references to arguments. Arguments
+ /// that are passed into the builder must out-live the builder.
+ class Builder {
+ public:
+ // Build from another MemRefType.
+ explicit Builder(MemRefType other)
+ : shape(other.getShape()), elementType(other.getElementType()),
+ affineMaps(other.getAffineMaps()),
+ memorySpace(other.getMemorySpace()) {}
+
+ // Build from scratch.
+ Builder(ArrayRef<int64_t> shape, Type elementType)
+ : shape(shape), elementType(elementType), affineMaps(), memorySpace(0) {
+ }
+
+ Builder &setShape(ArrayRef<int64_t> newShape) {
+ shape = newShape;
+ return *this;
+ }
+
+ Builder &setElementType(Type newElementType) {
+ elementType = newElementType;
+ return *this;
+ }
+
+ Builder &setAffineMaps(ArrayRef<AffineMap> newAffineMaps) {
+ affineMaps = newAffineMaps;
+ return *this;
+ }
+
+ Builder &setMemorySpace(unsigned newMemorySpace) {
+ memorySpace = newMemorySpace;
+ return *this;
+ }
+
+ operator MemRefType() {
+ return MemRefType::get(shape, elementType, affineMaps, memorySpace);
+ }
+
+ private:
+ ArrayRef<int64_t> shape;
+ Type elementType;
+ ArrayRef<AffineMap> affineMaps;
+ unsigned memorySpace;
+ };
+
+ using Base::Base;
+
+ /// Get or create a new MemRefType based on shape, element type, affine
+ /// map composition, and memory space. Assumes the arguments define a
+ /// well-formed MemRef type. Use getChecked to gracefully handle MemRefType
+ /// construction failures.
+ static MemRefType get(ArrayRef<int64_t> shape, Type elementType,
+ ArrayRef<AffineMap> affineMapComposition = {},
+ unsigned memorySpace = 0);
+
+ /// Get or create a new MemRefType based on shape, element type, affine
+ /// map composition, and memory space declared at the given location.
+ /// If the location is unknown, the last argument should be an instance of
+ /// UnknownLoc. If the MemRefType defined by the arguments would be
+ /// ill-formed, emits errors (to the handler registered with the context or to
+ /// the error stream) and returns nullptr.
+ static MemRefType getChecked(ArrayRef<int64_t> shape, Type elementType,
+ ArrayRef<AffineMap> affineMapComposition,
+ unsigned memorySpace, Location location);
+
+ ArrayRef<int64_t> getShape() const;
+
+ /// Returns an array of affine map pointers representing the memref affine
+ /// map composition.
+ ArrayRef<AffineMap> getAffineMaps() const;
+
+ // TODO: merge these two special values in a single one used everywhere.
+ // Unfortunately, uses of `-1` have crept deep into the codebase now and are
+ // hard to track.
+ static int64_t getDynamicStrideOrOffset() {
+ return ShapedType::kDynamicStrideOrOffset;
+ }
+
+private:
+ /// Get or create a new MemRefType defined by the arguments. If the resulting
+ /// type would be ill-formed, return nullptr. If the location is provided,
+ /// emit detailed error messages.
+ static MemRefType getImpl(ArrayRef<int64_t> shape, Type elementType,
+ ArrayRef<AffineMap> affineMapComposition,
+ unsigned memorySpace, Optional<Location> location);
+ using Base::getImpl;
+};
+
+//===----------------------------------------------------------------------===//
+// UnrankedMemRefType
+
+/// Unranked MemRef type represent multi-dimensional MemRefs that
+/// have an unknown rank.
+class UnrankedMemRefType
+ : public Type::TypeBase<UnrankedMemRefType, BaseMemRefType,
+ detail::UnrankedMemRefTypeStorage> {
+public:
+ using Base::Base;
+
+ /// Get or create a new UnrankedMemRefType of the provided element
+ /// type and memory space
+ static UnrankedMemRefType get(Type elementType, unsigned memorySpace);
+
+ /// Get or create a new UnrankedMemRefType of the provided element
+ /// type and memory space declared at the given, potentially unknown,
+ /// location. If the UnrankedMemRefType defined by the arguments would be
+ /// ill-formed, emit errors and return a nullptr-wrapping type.
+ static UnrankedMemRefType getChecked(Type elementType, unsigned memorySpace,
+ Location location);
+
+ /// Verify the construction of a unranked memref type.
+ static LogicalResult verifyConstructionInvariants(Location loc,
+ Type elementType,
+ unsigned memorySpace);
+
+ ArrayRef<int64_t> getShape() const { return llvm::None; }
+};
+
+//===----------------------------------------------------------------------===//
+// TupleType
+//===----------------------------------------------------------------------===//
+
+/// Tuple types represent a collection of other types. Note: This type merely
+/// provides a common mechanism for representing tuples in MLIR. It is up to
+/// dialect authors to provides operations for manipulating them, e.g.
+/// extract_tuple_element. When possible, users should prefer multi-result
+/// operations in the place of tuples.
+class TupleType
+ : public Type::TypeBase<TupleType, Type, detail::TupleTypeStorage> {
+public:
+ using Base::Base;
+
+ /// Get or create a new TupleType with the provided element types. Assumes the
+ /// arguments define a well-formed type.
+ static TupleType get(TypeRange elementTypes, MLIRContext *context);
+
+ /// Get or create an empty tuple type.
+ static TupleType get(MLIRContext *context);
+
+ /// Return the elements types for this tuple.
+ ArrayRef<Type> getTypes() const;
+
+ /// Accumulate the types contained in this tuple and tuples nested within it.
+ /// Note that this only flattens nested tuples, not any other container type,
+ /// e.g. a tuple<i32, tensor<i32>, tuple<f32, tuple<i64>>> is flattened to
+ /// (i32, tensor<i32>, f32, i64)
+ void getFlattenedTypes(SmallVectorImpl<Type> &types);
+
+ /// Return the number of held types.
+ size_t size() const;
+
+ /// Iterate over the held elements.
+ using iterator = ArrayRef<Type>::iterator;
+ iterator begin() const { return getTypes().begin(); }
+ iterator end() const { return getTypes().end(); }
+
+ /// Return the element type at index 'index'.
+ Type getType(size_t index) const {
+ assert(index < size() && "invalid index for tuple type");
+ return getTypes()[index];
+ }
+};
+
+//===----------------------------------------------------------------------===//
+// Deferred Method Definitions
+//===----------------------------------------------------------------------===//
+
+inline bool BaseMemRefType::classof(Type type) {
+ return type.isa<MemRefType, UnrankedMemRefType>();
+}
+
+inline bool FloatType::classof(Type type) {
+ return type.isa<BFloat16Type, Float16Type, Float32Type, Float64Type>();
+}
+
+inline bool ShapedType::classof(Type type) {
+ return type.isa<RankedTensorType, VectorType, UnrankedTensorType,
+ UnrankedMemRefType, MemRefType>();
+}
+
+inline bool TensorType::classof(Type type) {
+ return type.isa<RankedTensorType, UnrankedTensorType>();
+}
+
+//===----------------------------------------------------------------------===//
+// Type Utilities
+//===----------------------------------------------------------------------===//
+
+/// Returns the strides of the MemRef if the layout map is in strided form.
+/// MemRefs with layout maps in strided form include:
+/// 1. empty or identity layout map, in which case the stride information is
+/// the canonical form computed from sizes;
+/// 2. single affine map layout of the form `K + k0 * d0 + ... kn * dn`,
+/// where K and ki's are constants or symbols.
+///
+/// A stride specification is a list of integer values that are either static
+/// or dynamic (encoded with getDynamicStrideOrOffset()). Strides encode the
+/// distance in the number of elements between successive entries along a
+/// particular dimension. For example, `memref<42x16xf32, (64 * d0 + d1)>`
+/// specifies a view into a non-contiguous memory region of `42` by `16` `f32`
+/// elements in which the distance between two consecutive elements along the
+/// outer dimension is `1` and the distance between two consecutive elements
+/// along the inner dimension is `64`.
+///
+/// Returns whether a simple strided form can be extracted from the composition
+/// of the layout map.
+///
+/// The convention is that the strides for dimensions d0, .. dn appear in
+/// order to make indexing intuitive into the result.
+LogicalResult getStridesAndOffset(MemRefType t,
+ SmallVectorImpl<int64_t> &strides,
+ int64_t &offset);
+LogicalResult getStridesAndOffset(MemRefType t,
+ SmallVectorImpl<AffineExpr> &strides,
+ AffineExpr &offset);
+
+/// Given a list of strides (in which MemRefType::getDynamicStrideOrOffset()
+/// represents a dynamic value), return the single result AffineMap which
+/// represents the linearized strided layout map. Dimensions correspond to the
+/// offset followed by the strides in order. Symbols are inserted for each
+/// dynamic dimension in order. A stride cannot take value `0`.
+///
+/// Examples:
+/// =========
+///
+/// 1. For offset: 0 strides: ?, ?, 1 return
+/// (i, j, k)[M, N]->(M * i + N * j + k)
+///
+/// 2. For offset: 3 strides: 32, ?, 16 return
+/// (i, j, k)[M]->(3 + 32 * i + M * j + 16 * k)
+///
+/// 3. For offset: ? strides: ?, ?, ? return
+/// (i, j, k)[off, M, N, P]->(off + M * i + N * j + P * k)
+AffineMap makeStridedLinearLayoutMap(ArrayRef<int64_t> strides, int64_t offset,
+ MLIRContext *context);
+
+/// Return a version of `t` with identity layout if it can be determined
+/// statically that the layout is the canonical contiguous strided layout.
+/// Otherwise pass `t`'s layout into `simplifyAffineMap` and return a copy of
+/// `t` with simplified layout.
+MemRefType canonicalizeStridedLayout(MemRefType t);
+
+/// Return a version of `t` with a layout that has all dynamic offset and
+/// strides. This is used to erase the static layout.
+MemRefType eraseStridedLayout(MemRefType t);
+
+/// Given MemRef `sizes` that are either static or dynamic, returns the
+/// canonical "contiguous" strides AffineExpr. Strides are multiplicative and
+/// once a dynamic dimension is encountered, all canonical strides become
+/// dynamic and need to be encoded with a
diff erent symbol.
+/// For canonical strides expressions, the offset is always 0 and and fastest
+/// varying stride is always `1`.
+///
+/// Examples:
+/// - memref<3x4x5xf32> has canonical stride expression
+/// `20*exprs[0] + 5*exprs[1] + exprs[2]`.
+/// - memref<3x?x5xf32> has canonical stride expression
+/// `s0*exprs[0] + 5*exprs[1] + exprs[2]`.
+/// - memref<3x4x?xf32> has canonical stride expression
+/// `s1*exprs[0] + s0*exprs[1] + exprs[2]`.
+AffineExpr makeCanonicalStridedLayoutExpr(ArrayRef<int64_t> sizes,
+ ArrayRef<AffineExpr> exprs,
+ MLIRContext *context);
+
+/// Return the result of makeCanonicalStrudedLayoutExpr for the common case
+/// where `exprs` is {d0, d1, .., d_(sizes.size()-1)}
+AffineExpr makeCanonicalStridedLayoutExpr(ArrayRef<int64_t> sizes,
+ MLIRContext *context);
+
+/// Return true if the layout for `t` is compatible with strided semantics.
+bool isStrided(MemRefType t);
+
+} // end namespace mlir
+
+#endif // MLIR_IR_BUILTINTYPES_H
diff --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h
index 524b58e37210..324e777ec788 100644
--- a/mlir/include/mlir/IR/FunctionSupport.h
+++ b/mlir/include/mlir/IR/FunctionSupport.h
@@ -14,6 +14,7 @@
#ifndef MLIR_IR_FUNCTIONSUPPORT_H
#define MLIR_IR_FUNCTIONSUPPORT_H
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpDefinition.h"
#include "llvm/ADT/SmallString.h"
diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h
index 72e17e1699a0..bbf117e5c8bd 100644
--- a/mlir/include/mlir/IR/Matchers.h
+++ b/mlir/include/mlir/IR/Matchers.h
@@ -15,8 +15,8 @@
#ifndef MLIR_MATCHERS_H
#define MLIR_MATCHERS_H
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpDefinition.h"
-#include "mlir/IR/StandardTypes.h"
namespace mlir {
diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index f918c605d7e9..5cf05e058166 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -13,6 +13,7 @@
#ifndef MLIR_IR_OPIMPLEMENTATION_H
#define MLIR_IR_OPIMPLEMENTATION_H
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectInterface.h"
#include "mlir/IR/OpDefinition.h"
#include "llvm/ADT/Twine.h"
diff --git a/mlir/include/mlir/IR/StandardTypes.h b/mlir/include/mlir/IR/StandardTypes.h
index 5cd2e8a117d0..bf186ef46019 100644
--- a/mlir/include/mlir/IR/StandardTypes.h
+++ b/mlir/include/mlir/IR/StandardTypes.h
@@ -9,747 +9,8 @@
#ifndef MLIR_IR_STANDARDTYPES_H
#define MLIR_IR_STANDARDTYPES_H
-#include "mlir/IR/Types.h"
-
-namespace llvm {
-struct fltSemantics;
-} // namespace llvm
-
-namespace mlir {
-class AffineExpr;
-class AffineMap;
-class FloatType;
-class IndexType;
-class IntegerType;
-class Location;
-class MLIRContext;
-
-namespace detail {
-
-struct IntegerTypeStorage;
-struct ShapedTypeStorage;
-struct VectorTypeStorage;
-struct RankedTensorTypeStorage;
-struct UnrankedTensorTypeStorage;
-struct BaseMemRefTypeStorage;
-struct MemRefTypeStorage;
-struct UnrankedMemRefTypeStorage;
-struct ComplexTypeStorage;
-struct TupleTypeStorage;
-
-} // namespace detail
-
-//===----------------------------------------------------------------------===//
-// ComplexType
-//===----------------------------------------------------------------------===//
-
-/// The 'complex' type represents a complex number with a parameterized element
-/// type, which is composed of a real and imaginary value of that element type.
-///
-/// The element must be a floating point or integer scalar type.
-///
-class ComplexType
- : public Type::TypeBase<ComplexType, Type, detail::ComplexTypeStorage> {
-public:
- using Base::Base;
-
- /// Get or create a ComplexType with the provided element type.
- static ComplexType get(Type elementType);
-
- /// Get or create a ComplexType with the provided element type. This emits
- /// and error at the specified location and returns null if the element type
- /// isn't supported.
- static ComplexType getChecked(Type elementType, Location location);
-
- /// Verify the construction of an integer type.
- static LogicalResult verifyConstructionInvariants(Location loc,
- Type elementType);
-
- Type getElementType();
-};
-
-//===----------------------------------------------------------------------===//
-// IndexType
-//===----------------------------------------------------------------------===//
-
-/// Index is a special integer-like type with unknown platform-dependent bit
-/// width.
-class IndexType : public Type::TypeBase<IndexType, Type, TypeStorage> {
-public:
- using Base::Base;
-
- /// Get an instance of the IndexType.
- static IndexType get(MLIRContext *context);
-
- /// Storage bit width used for IndexType by internal compiler data structures.
- static constexpr unsigned kInternalStorageBitWidth = 64;
-};
-
-//===----------------------------------------------------------------------===//
-// IntegerType
-//===----------------------------------------------------------------------===//
-
-/// Integer types can have arbitrary bitwidth up to a large fixed limit.
-class IntegerType
- : public Type::TypeBase<IntegerType, Type, detail::IntegerTypeStorage> {
-public:
- using Base::Base;
-
- /// Signedness semantics.
- enum SignednessSemantics : uint32_t {
- Signless, /// No signedness semantics
- Signed, /// Signed integer
- Unsigned, /// Unsigned integer
- };
-
- /// Get or create a new IntegerType of the given width within the context.
- /// The created IntegerType is signless (i.e., no signedness semantics).
- /// Assume the width is within the allowed range and assert on failures. Use
- /// getChecked to handle failures gracefully.
- static IntegerType get(unsigned width, MLIRContext *context);
-
- /// Get or create a new IntegerType of the given width within the context.
- /// The created IntegerType has signedness semantics as indicated via
- /// `signedness`. Assume the width is within the allowed range and assert on
- /// failures. Use getChecked to handle failures gracefully.
- static IntegerType get(unsigned width, SignednessSemantics signedness,
- MLIRContext *context);
-
- /// Get or create a new IntegerType of the given width within the context,
- /// defined at the given, potentially unknown, location. The created
- /// IntegerType is signless (i.e., no signedness semantics). If the width is
- /// outside the allowed range, emit errors and return a null type.
- static IntegerType getChecked(unsigned width, Location location);
-
- /// Get or create a new IntegerType of the given width within the context,
- /// defined at the given, potentially unknown, location. The created
- /// IntegerType has signedness semantics as indicated via `signedness`. If the
- /// width is outside the allowed range, emit errors and return a null type.
- static IntegerType getChecked(unsigned width, SignednessSemantics signedness,
- Location location);
-
- /// Verify the construction of an integer type.
- static LogicalResult
- verifyConstructionInvariants(Location loc, unsigned width,
- SignednessSemantics signedness);
-
- /// Return the bitwidth of this integer type.
- unsigned getWidth() const;
-
- /// Return the signedness semantics of this integer type.
- SignednessSemantics getSignedness() const;
-
- /// Return true if this is a signless integer type.
- bool isSignless() const { return getSignedness() == Signless; }
- /// Return true if this is a signed integer type.
- bool isSigned() const { return getSignedness() == Signed; }
- /// Return true if this is an unsigned integer type.
- bool isUnsigned() const { return getSignedness() == Unsigned; }
-
- /// Integer representation maximal bitwidth.
- static constexpr unsigned kMaxWidth = 4096;
-};
-
-//===----------------------------------------------------------------------===//
-// FloatType
-//===----------------------------------------------------------------------===//
-
-class FloatType : public Type {
-public:
- using Type::Type;
-
- // Convenience factories.
- static FloatType getBF16(MLIRContext *ctx);
- static FloatType getF16(MLIRContext *ctx);
- static FloatType getF32(MLIRContext *ctx);
- static FloatType getF64(MLIRContext *ctx);
-
- /// Methods for support type inquiry through isa, cast, and dyn_cast.
- static bool classof(Type type);
-
- /// Return the bitwidth of this float type.
- unsigned getWidth();
-
- /// Return the floating semantics of this float type.
- const llvm::fltSemantics &getFloatSemantics();
-};
-
-//===----------------------------------------------------------------------===//
-// BFloat16Type
-
-class BFloat16Type
- : public Type::TypeBase<BFloat16Type, FloatType, TypeStorage> {
-public:
- using Base::Base;
-
- /// Return an instance of the bfloat16 type.
- static BFloat16Type get(MLIRContext *context);
-};
-
-inline FloatType FloatType::getBF16(MLIRContext *ctx) {
- return BFloat16Type::get(ctx);
-}
-
-//===----------------------------------------------------------------------===//
-// Float16Type
-
-class Float16Type : public Type::TypeBase<Float16Type, FloatType, TypeStorage> {
-public:
- using Base::Base;
-
- /// Return an instance of the float16 type.
- static Float16Type get(MLIRContext *context);
-};
-
-inline FloatType FloatType::getF16(MLIRContext *ctx) {
- return Float16Type::get(ctx);
-}
-
-//===----------------------------------------------------------------------===//
-// Float32Type
-
-class Float32Type : public Type::TypeBase<Float32Type, FloatType, TypeStorage> {
-public:
- using Base::Base;
-
- /// Return an instance of the float32 type.
- static Float32Type get(MLIRContext *context);
-};
-
-inline FloatType FloatType::getF32(MLIRContext *ctx) {
- return Float32Type::get(ctx);
-}
-
-//===----------------------------------------------------------------------===//
-// Float64Type
-
-class Float64Type : public Type::TypeBase<Float64Type, FloatType, TypeStorage> {
-public:
- using Base::Base;
-
- /// Return an instance of the float64 type.
- static Float64Type get(MLIRContext *context);
-};
-
-inline FloatType FloatType::getF64(MLIRContext *ctx) {
- return Float64Type::get(ctx);
-}
-
-//===----------------------------------------------------------------------===//
-// NoneType
-//===----------------------------------------------------------------------===//
-
-/// NoneType is a unit type, i.e. a type with exactly one possible value, where
-/// its value does not have a defined dynamic representation.
-class NoneType : public Type::TypeBase<NoneType, Type, TypeStorage> {
-public:
- using Base::Base;
-
- /// Get an instance of the NoneType.
- static NoneType get(MLIRContext *context);
-};
-
-//===----------------------------------------------------------------------===//
-// ShapedType
-//===----------------------------------------------------------------------===//
-
-/// This is a common base class between Vector, UnrankedTensor, RankedTensor,
-/// and MemRef types because they share behavior and semantics around shape,
-/// rank, and fixed element type. Any type with these semantics should inherit
-/// from ShapedType.
-class ShapedType : public Type {
-public:
- using ImplType = detail::ShapedTypeStorage;
- using Type::Type;
-
- // TODO: merge these two special values in a single one used everywhere.
- // Unfortunately, uses of `-1` have crept deep into the codebase now and are
- // hard to track.
- static constexpr int64_t kDynamicSize = -1;
- static constexpr int64_t kDynamicStrideOrOffset =
- std::numeric_limits<int64_t>::min();
-
- /// Return the element type.
- Type getElementType() const;
-
- /// If an element type is an integer or a float, return its width. Otherwise,
- /// abort.
- unsigned getElementTypeBitWidth() const;
-
- /// If it has static shape, return the number of elements. Otherwise, abort.
- int64_t getNumElements() const;
-
- /// If this is a ranked type, return the rank. Otherwise, abort.
- int64_t getRank() const;
-
- /// Whether or not this is a ranked type. Memrefs, vectors and ranked tensors
- /// have a rank, while unranked tensors do not.
- bool hasRank() const;
-
- /// If this is a ranked type, return the shape. Otherwise, abort.
- ArrayRef<int64_t> getShape() const;
-
- /// If this is unranked type or any dimension has unknown size (<0), it
- /// doesn't have static shape. If all dimensions have known size (>= 0), it
- /// has static shape.
- bool hasStaticShape() const;
-
- /// If this has a static shape and the shape is equal to `shape` return true.
- bool hasStaticShape(ArrayRef<int64_t> shape) const;
-
- /// If this is a ranked type, return the number of dimensions with dynamic
- /// size. Otherwise, abort.
- int64_t getNumDynamicDims() const;
-
- /// If this is ranked type, return the size of the specified dimension.
- /// Otherwise, abort.
- int64_t getDimSize(unsigned idx) const;
-
- /// Returns true if this dimension has a dynamic size (for ranked types);
- /// aborts for unranked types.
- bool isDynamicDim(unsigned idx) const;
-
- /// Returns the position of the dynamic dimension relative to just the dynamic
- /// dimensions, given its `index` within the shape.
- unsigned getDynamicDimIndex(unsigned index) const;
-
- /// Get the total amount of bits occupied by a value of this type. This does
- /// not take into account any memory layout or widening constraints, e.g. a
- /// vector<3xi57> is reported to occupy 3x57=171 bit, even though in practice
- /// it will likely be stored as in a 4xi64 vector register. Fail an assertion
- /// if the size cannot be computed statically, i.e. if the type has a dynamic
- /// shape or if its elemental type does not have a known bit width.
- int64_t getSizeInBits() const;
-
- /// Methods for support type inquiry through isa, cast, and dyn_cast.
- static bool classof(Type type);
-
- /// Whether the given dimension size indicates a dynamic dimension.
- static constexpr bool isDynamic(int64_t dSize) {
- return dSize == kDynamicSize;
- }
- static constexpr bool isDynamicStrideOrOffset(int64_t dStrideOrOffset) {
- return dStrideOrOffset == kDynamicStrideOrOffset;
- }
-};
-
-//===----------------------------------------------------------------------===//
-// VectorType
-//===----------------------------------------------------------------------===//
-
-/// Vector types represent multi-dimensional SIMD vectors, and have a fixed
-/// known constant shape with one or more dimension.
-class VectorType
- : public Type::TypeBase<VectorType, ShapedType, detail::VectorTypeStorage> {
-public:
- using Base::Base;
-
- /// Get or create a new VectorType of the provided shape and element type.
- /// Assumes the arguments define a well-formed VectorType.
- static VectorType get(ArrayRef<int64_t> shape, Type elementType);
-
- /// Get or create a new VectorType of the provided shape and element type
- /// declared at the given, potentially unknown, location. If the VectorType
- /// defined by the arguments would be ill-formed, emit errors and return
- /// nullptr-wrapping type.
- static VectorType getChecked(ArrayRef<int64_t> shape, Type elementType,
- Location location);
-
- /// Verify the construction of a vector type.
- static LogicalResult verifyConstructionInvariants(Location loc,
- ArrayRef<int64_t> shape,
- Type elementType);
-
- /// Returns true of the given type can be used as an element of a vector type.
- /// In particular, vectors can consist of integer or float primitives.
- static bool isValidElementType(Type t) {
- return t.isa<IntegerType, FloatType>();
- }
-
- ArrayRef<int64_t> getShape() const;
-};
-
-//===----------------------------------------------------------------------===//
-// TensorType
-//===----------------------------------------------------------------------===//
-
-/// Tensor types represent multi-dimensional arrays, and have two variants:
-/// RankedTensorType and UnrankedTensorType.
-class TensorType : public ShapedType {
-public:
- using ShapedType::ShapedType;
-
- /// Return true if the specified element type is ok in a tensor.
- static bool isValidElementType(Type type);
-
- /// Methods for support type inquiry through isa, cast, and dyn_cast.
- static bool classof(Type type);
-};
-
-//===----------------------------------------------------------------------===//
-// RankedTensorType
-
-/// Ranked tensor types represent multi-dimensional arrays that have a shape
-/// with a fixed number of dimensions. Each shape element can be a non-negative
-/// integer or unknown (represented by -1).
-class RankedTensorType
- : public Type::TypeBase<RankedTensorType, TensorType,
- detail::RankedTensorTypeStorage> {
-public:
- using Base::Base;
-
- /// Get or create a new RankedTensorType of the provided shape and element
- /// type. Assumes the arguments define a well-formed type.
- static RankedTensorType get(ArrayRef<int64_t> shape, Type elementType);
-
- /// Get or create a new RankedTensorType of the provided shape and element
- /// type declared at the given, potentially unknown, location. If the
- /// RankedTensorType defined by the arguments would be ill-formed, emit errors
- /// and return a nullptr-wrapping type.
- static RankedTensorType getChecked(ArrayRef<int64_t> shape, Type elementType,
- Location location);
-
- /// Verify the construction of a ranked tensor type.
- static LogicalResult verifyConstructionInvariants(Location loc,
- ArrayRef<int64_t> shape,
- Type elementType);
-
- ArrayRef<int64_t> getShape() const;
-};
-
-//===----------------------------------------------------------------------===//
-// UnrankedTensorType
-
-/// Unranked tensor types represent multi-dimensional arrays that have an
-/// unknown shape.
-class UnrankedTensorType
- : public Type::TypeBase<UnrankedTensorType, TensorType,
- detail::UnrankedTensorTypeStorage> {
-public:
- using Base::Base;
-
- /// Get or create a new UnrankedTensorType of the provided shape and element
- /// type. Assumes the arguments define a well-formed type.
- static UnrankedTensorType get(Type elementType);
-
- /// Get or create a new UnrankedTensorType of the provided shape and element
- /// type declared at the given, potentially unknown, location. If the
- /// UnrankedTensorType defined by the arguments would be ill-formed, emit
- /// errors and return a nullptr-wrapping type.
- static UnrankedTensorType getChecked(Type elementType, Location location);
-
- /// Verify the construction of a unranked tensor type.
- static LogicalResult verifyConstructionInvariants(Location loc,
- Type elementType);
-
- ArrayRef<int64_t> getShape() const { return llvm::None; }
-};
-
-//===----------------------------------------------------------------------===//
-// BaseMemRefType
-//===----------------------------------------------------------------------===//
-
-/// Base MemRef for Ranked and Unranked variants
-class BaseMemRefType : public ShapedType {
-public:
- using ImplType = detail::BaseMemRefTypeStorage;
- using ShapedType::ShapedType;
-
- /// Return true if the specified element type is ok in a memref.
- static bool isValidElementType(Type type) {
- return type.isIntOrIndexOrFloat() || type.isa<VectorType, ComplexType>();
- }
-
- /// Methods for support type inquiry through isa, cast, and dyn_cast.
- static bool classof(Type type);
-
- /// Returns the memory space in which data referred to by this memref resides.
- unsigned getMemorySpace() const;
-};
-
-//===----------------------------------------------------------------------===//
-// MemRefType
-
-/// MemRef types represent a region of memory that have a shape with a fixed
-/// number of dimensions. Each shape element can be a non-negative integer or
-/// unknown (represented by -1). MemRef types also have an affine map
-/// composition, represented as an array AffineMap pointers.
-class MemRefType : public Type::TypeBase<MemRefType, BaseMemRefType,
- detail::MemRefTypeStorage> {
-public:
- /// This is a builder type that keeps local references to arguments. Arguments
- /// that are passed into the builder must out-live the builder.
- class Builder {
- public:
- // Build from another MemRefType.
- explicit Builder(MemRefType other)
- : shape(other.getShape()), elementType(other.getElementType()),
- affineMaps(other.getAffineMaps()),
- memorySpace(other.getMemorySpace()) {}
-
- // Build from scratch.
- Builder(ArrayRef<int64_t> shape, Type elementType)
- : shape(shape), elementType(elementType), affineMaps(), memorySpace(0) {
- }
-
- Builder &setShape(ArrayRef<int64_t> newShape) {
- shape = newShape;
- return *this;
- }
-
- Builder &setElementType(Type newElementType) {
- elementType = newElementType;
- return *this;
- }
-
- Builder &setAffineMaps(ArrayRef<AffineMap> newAffineMaps) {
- affineMaps = newAffineMaps;
- return *this;
- }
-
- Builder &setMemorySpace(unsigned newMemorySpace) {
- memorySpace = newMemorySpace;
- return *this;
- }
-
- operator MemRefType() {
- return MemRefType::get(shape, elementType, affineMaps, memorySpace);
- }
-
- private:
- ArrayRef<int64_t> shape;
- Type elementType;
- ArrayRef<AffineMap> affineMaps;
- unsigned memorySpace;
- };
-
- using Base::Base;
-
- /// Get or create a new MemRefType based on shape, element type, affine
- /// map composition, and memory space. Assumes the arguments define a
- /// well-formed MemRef type. Use getChecked to gracefully handle MemRefType
- /// construction failures.
- static MemRefType get(ArrayRef<int64_t> shape, Type elementType,
- ArrayRef<AffineMap> affineMapComposition = {},
- unsigned memorySpace = 0);
-
- /// Get or create a new MemRefType based on shape, element type, affine
- /// map composition, and memory space declared at the given location.
- /// If the location is unknown, the last argument should be an instance of
- /// UnknownLoc. If the MemRefType defined by the arguments would be
- /// ill-formed, emits errors (to the handler registered with the context or to
- /// the error stream) and returns nullptr.
- static MemRefType getChecked(ArrayRef<int64_t> shape, Type elementType,
- ArrayRef<AffineMap> affineMapComposition,
- unsigned memorySpace, Location location);
-
- ArrayRef<int64_t> getShape() const;
-
- /// Returns an array of affine map pointers representing the memref affine
- /// map composition.
- ArrayRef<AffineMap> getAffineMaps() const;
-
- // TODO: merge these two special values in a single one used everywhere.
- // Unfortunately, uses of `-1` have crept deep into the codebase now and are
- // hard to track.
- static int64_t getDynamicStrideOrOffset() {
- return ShapedType::kDynamicStrideOrOffset;
- }
-
-private:
- /// Get or create a new MemRefType defined by the arguments. If the resulting
- /// type would be ill-formed, return nullptr. If the location is provided,
- /// emit detailed error messages.
- static MemRefType getImpl(ArrayRef<int64_t> shape, Type elementType,
- ArrayRef<AffineMap> affineMapComposition,
- unsigned memorySpace, Optional<Location> location);
- using Base::getImpl;
-};
-
-//===----------------------------------------------------------------------===//
-// UnrankedMemRefType
-
-/// Unranked MemRef type represent multi-dimensional MemRefs that
-/// have an unknown rank.
-class UnrankedMemRefType
- : public Type::TypeBase<UnrankedMemRefType, BaseMemRefType,
- detail::UnrankedMemRefTypeStorage> {
-public:
- using Base::Base;
-
- /// Get or create a new UnrankedMemRefType of the provided element
- /// type and memory space
- static UnrankedMemRefType get(Type elementType, unsigned memorySpace);
-
- /// Get or create a new UnrankedMemRefType of the provided element
- /// type and memory space declared at the given, potentially unknown,
- /// location. If the UnrankedMemRefType defined by the arguments would be
- /// ill-formed, emit errors and return a nullptr-wrapping type.
- static UnrankedMemRefType getChecked(Type elementType, unsigned memorySpace,
- Location location);
-
- /// Verify the construction of a unranked memref type.
- static LogicalResult verifyConstructionInvariants(Location loc,
- Type elementType,
- unsigned memorySpace);
-
- ArrayRef<int64_t> getShape() const { return llvm::None; }
-};
-
-//===----------------------------------------------------------------------===//
-// TupleType
-//===----------------------------------------------------------------------===//
-
-/// Tuple types represent a collection of other types. Note: This type merely
-/// provides a common mechanism for representing tuples in MLIR. It is up to
-/// dialect authors to provides operations for manipulating them, e.g.
-/// extract_tuple_element. When possible, users should prefer multi-result
-/// operations in the place of tuples.
-class TupleType
- : public Type::TypeBase<TupleType, Type, detail::TupleTypeStorage> {
-public:
- using Base::Base;
-
- /// Get or create a new TupleType with the provided element types. Assumes the
- /// arguments define a well-formed type.
- static TupleType get(TypeRange elementTypes, MLIRContext *context);
-
- /// Get or create an empty tuple type.
- static TupleType get(MLIRContext *context);
-
- /// Return the elements types for this tuple.
- ArrayRef<Type> getTypes() const;
-
- /// Accumulate the types contained in this tuple and tuples nested within it.
- /// Note that this only flattens nested tuples, not any other container type,
- /// e.g. a tuple<i32, tensor<i32>, tuple<f32, tuple<i64>>> is flattened to
- /// (i32, tensor<i32>, f32, i64)
- void getFlattenedTypes(SmallVectorImpl<Type> &types);
-
- /// Return the number of held types.
- size_t size() const;
-
- /// Iterate over the held elements.
- using iterator = ArrayRef<Type>::iterator;
- iterator begin() const { return getTypes().begin(); }
- iterator end() const { return getTypes().end(); }
-
- /// Return the element type at index 'index'.
- Type getType(size_t index) const {
- assert(index < size() && "invalid index for tuple type");
- return getTypes()[index];
- }
-};
-
-//===----------------------------------------------------------------------===//
-// Deferred Method Definitions
-//===----------------------------------------------------------------------===//
-
-inline bool BaseMemRefType::classof(Type type) {
- return type.isa<MemRefType, UnrankedMemRefType>();
-}
-
-inline bool FloatType::classof(Type type) {
- return type.isa<BFloat16Type, Float16Type, Float32Type, Float64Type>();
-}
-
-inline bool ShapedType::classof(Type type) {
- return type.isa<RankedTensorType, VectorType, UnrankedTensorType,
- UnrankedMemRefType, MemRefType>();
-}
-
-inline bool TensorType::classof(Type type) {
- return type.isa<RankedTensorType, UnrankedTensorType>();
-}
-
-//===----------------------------------------------------------------------===//
-// Type Utilities
-//===----------------------------------------------------------------------===//
-
-/// Returns the strides of the MemRef if the layout map is in strided form.
-/// MemRefs with layout maps in strided form include:
-/// 1. empty or identity layout map, in which case the stride information is
-/// the canonical form computed from sizes;
-/// 2. single affine map layout of the form `K + k0 * d0 + ... kn * dn`,
-/// where K and ki's are constants or symbols.
-///
-/// A stride specification is a list of integer values that are either static
-/// or dynamic (encoded with getDynamicStrideOrOffset()). Strides encode the
-/// distance in the number of elements between successive entries along a
-/// particular dimension. For example, `memref<42x16xf32, (64 * d0 + d1)>`
-/// specifies a view into a non-contiguous memory region of `42` by `16` `f32`
-/// elements in which the distance between two consecutive elements along the
-/// outer dimension is `1` and the distance between two consecutive elements
-/// along the inner dimension is `64`.
-///
-/// Returns whether a simple strided form can be extracted from the composition
-/// of the layout map.
-///
-/// The convention is that the strides for dimensions d0, .. dn appear in
-/// order to make indexing intuitive into the result.
-LogicalResult getStridesAndOffset(MemRefType t,
- SmallVectorImpl<int64_t> &strides,
- int64_t &offset);
-LogicalResult getStridesAndOffset(MemRefType t,
- SmallVectorImpl<AffineExpr> &strides,
- AffineExpr &offset);
-
-/// Given a list of strides (in which MemRefType::getDynamicStrideOrOffset()
-/// represents a dynamic value), return the single result AffineMap which
-/// represents the linearized strided layout map. Dimensions correspond to the
-/// offset followed by the strides in order. Symbols are inserted for each
-/// dynamic dimension in order. A stride cannot take value `0`.
-///
-/// Examples:
-/// =========
-///
-/// 1. For offset: 0 strides: ?, ?, 1 return
-/// (i, j, k)[M, N]->(M * i + N * j + k)
-///
-/// 2. For offset: 3 strides: 32, ?, 16 return
-/// (i, j, k)[M]->(3 + 32 * i + M * j + 16 * k)
-///
-/// 3. For offset: ? strides: ?, ?, ? return
-/// (i, j, k)[off, M, N, P]->(off + M * i + N * j + P * k)
-AffineMap makeStridedLinearLayoutMap(ArrayRef<int64_t> strides, int64_t offset,
- MLIRContext *context);
-
-/// Return a version of `t` with identity layout if it can be determined
-/// statically that the layout is the canonical contiguous strided layout.
-/// Otherwise pass `t`'s layout into `simplifyAffineMap` and return a copy of
-/// `t` with simplified layout.
-MemRefType canonicalizeStridedLayout(MemRefType t);
-
-/// Return a version of `t` with a layout that has all dynamic offset and
-/// strides. This is used to erase the static layout.
-MemRefType eraseStridedLayout(MemRefType t);
-
-/// Given MemRef `sizes` that are either static or dynamic, returns the
-/// canonical "contiguous" strides AffineExpr. Strides are multiplicative and
-/// once a dynamic dimension is encountered, all canonical strides become
-/// dynamic and need to be encoded with a
diff erent symbol.
-/// For canonical strides expressions, the offset is always 0 and and fastest
-/// varying stride is always `1`.
-///
-/// Examples:
-/// - memref<3x4x5xf32> has canonical stride expression
-/// `20*exprs[0] + 5*exprs[1] + exprs[2]`.
-/// - memref<3x?x5xf32> has canonical stride expression
-/// `s0*exprs[0] + 5*exprs[1] + exprs[2]`.
-/// - memref<3x4x?xf32> has canonical stride expression
-/// `s1*exprs[0] + s0*exprs[1] + exprs[2]`.
-AffineExpr makeCanonicalStridedLayoutExpr(ArrayRef<int64_t> sizes,
- ArrayRef<AffineExpr> exprs,
- MLIRContext *context);
-
-/// Return the result of makeCanonicalStrudedLayoutExpr for the common case
-/// where `exprs` is {d0, d1, .., d_(sizes.size()-1)}
-AffineExpr makeCanonicalStridedLayoutExpr(ArrayRef<int64_t> sizes,
- MLIRContext *context);
-
-/// Return true if the layout for `t` is compatible with strided semantics.
-bool isStrided(MemRefType t);
-
-} // end namespace mlir
+/// TODO: Remove this file when all references have been replaced by
+/// BuiltinTypes.h.
+#include "mlir/IR/BuiltinTypes.h"
#endif // MLIR_IR_STANDARDTYPES_H
diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index 46335373348f..a800c5b1193d 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -15,19 +15,6 @@
#include "llvm/Support/PointerLikeTypeTraits.h"
namespace mlir {
-class FloatType;
-class Identifier;
-class IndexType;
-class IntegerType;
-class MLIRContext;
-class TypeStorage;
-class TypeRange;
-
-namespace detail {
-struct FunctionTypeStorage;
-struct OpaqueTypeStorage;
-} // namespace detail
-
/// Instances of the Type class are uniqued, have an immutable identifier and an
/// optional mutable component. They wrap a pointer to the storage object owned
/// by MLIRContext. Therefore, instances of Type are passed around by value.
@@ -226,66 +213,8 @@ class TypeInterface : public detail::Interface<ConcreteType, Type, Traits, Type,
};
//===----------------------------------------------------------------------===//
-// FunctionType
-//===----------------------------------------------------------------------===//
-
-/// Function types map from a list of inputs to a list of results.
-class FunctionType
- : public Type::TypeBase<FunctionType, Type, detail::FunctionTypeStorage> {
-public:
- using Base::Base;
-
- static FunctionType get(TypeRange inputs, TypeRange results,
- MLIRContext *context);
-
- /// Input types.
- unsigned getNumInputs() const;
- Type getInput(unsigned i) const { return getInputs()[i]; }
- ArrayRef<Type> getInputs() const;
-
- /// Result types.
- unsigned getNumResults() const;
- Type getResult(unsigned i) const { return getResults()[i]; }
- ArrayRef<Type> getResults() const;
-
- /// Returns a new function type without the specified arguments and results.
- FunctionType getWithoutArgsAndResults(ArrayRef<unsigned> argIndices,
- ArrayRef<unsigned> resultIndices);
-};
-
+// Type Utils
//===----------------------------------------------------------------------===//
-// OpaqueType
-//===----------------------------------------------------------------------===//
-
-/// Opaque types represent types of non-registered dialects. These are types
-/// represented in their raw string form, and can only usefully be tested for
-/// type equality.
-class OpaqueType
- : public Type::TypeBase<OpaqueType, Type, detail::OpaqueTypeStorage> {
-public:
- using Base::Base;
-
- /// Get or create a new OpaqueType with the provided dialect and string data.
- static OpaqueType get(Identifier dialect, StringRef typeData,
- MLIRContext *context);
-
- /// Get or create a new OpaqueType with the provided dialect and string data.
- /// If the given identifier is not a valid namespace for a dialect, then a
- /// null type is returned.
- static OpaqueType getChecked(Identifier dialect, StringRef typeData,
- MLIRContext *context, Location location);
-
- /// Returns the dialect namespace of the opaque type.
- Identifier getDialectNamespace() const;
-
- /// Returns the raw type data of the opaque type.
- StringRef getTypeData() const;
-
- /// Verify the construction of an opaque type.
- static LogicalResult verifyConstructionInvariants(Location loc,
- Identifier dialect,
- StringRef typeData);
-};
// Make Type hashable.
inline ::llvm::hash_code hash_value(Type arg) {
diff --git a/mlir/include/mlir/Interfaces/VectorInterfaces.h b/mlir/include/mlir/Interfaces/VectorInterfaces.h
index 2134969e4020..7ae4ee35de33 100644
--- a/mlir/include/mlir/Interfaces/VectorInterfaces.h
+++ b/mlir/include/mlir/Interfaces/VectorInterfaces.h
@@ -14,8 +14,8 @@
#define MLIR_INTERFACES_VECTORINTERFACES_H
#include "mlir/IR/AffineMap.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpDefinition.h"
-#include "mlir/IR/StandardTypes.h"
/// Include the generated interface declarations.
#include "mlir/Interfaces/VectorInterfaces.h.inc"
diff --git a/mlir/include/mlir/Interfaces/ViewLikeInterface.h b/mlir/include/mlir/Interfaces/ViewLikeInterface.h
index b7d796f39f4d..d62b25cb0e27 100644
--- a/mlir/include/mlir/Interfaces/ViewLikeInterface.h
+++ b/mlir/include/mlir/Interfaces/ViewLikeInterface.h
@@ -14,8 +14,8 @@
#define MLIR_INTERFACES_VIEWLIKEINTERFACE_H_
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
namespace mlir {
/// Auxiliary range data structure to unpack the offset, size and stride
diff --git a/mlir/lib/Bindings/Python/IRModules.cpp b/mlir/lib/Bindings/Python/IRModules.cpp
index fde95a57b6ce..d413816a45fa 100644
--- a/mlir/lib/Bindings/Python/IRModules.cpp
+++ b/mlir/lib/Bindings/Python/IRModules.cpp
@@ -12,9 +12,9 @@
#include "PybindUtils.h"
#include "mlir-c/Bindings/Python/Interop.h"
+#include "mlir-c/BuiltinTypes.h"
#include "mlir-c/Registration.h"
#include "mlir-c/StandardAttributes.h"
-#include "mlir-c/StandardTypes.h"
#include "llvm/ADT/SmallVector.h"
#include <pybind11/stl.h>
@@ -1923,7 +1923,7 @@ class PyUnitAttribute : public PyConcreteAttribute<PyUnitAttribute> {
} // namespace
//------------------------------------------------------------------------------
-// Standard type subclasses.
+// Builtin type subclasses.
//------------------------------------------------------------------------------
namespace {
@@ -3105,7 +3105,7 @@ void mlir::python::populateIRSubmodule(py::module &m) {
return printAccum.join();
});
- // Standard type bindings.
+ // Builtin type bindings.
PyIntegerType::bind(m);
PyIndexType::bind(m);
PyBF16Type::bind(m);
diff --git a/mlir/lib/CAPI/IR/StandardTypes.cpp b/mlir/lib/CAPI/IR/BuiltinTypes.cpp
similarity index 98%
rename from mlir/lib/CAPI/IR/StandardTypes.cpp
rename to mlir/lib/CAPI/IR/BuiltinTypes.cpp
index f920512474fa..5d738b4c9dde 100644
--- a/mlir/lib/CAPI/IR/StandardTypes.cpp
+++ b/mlir/lib/CAPI/IR/BuiltinTypes.cpp
@@ -1,4 +1,4 @@
-//===- StandardTypes.cpp - C Interface to MLIR Standard Types -------------===//
+//===- BuiltinTypes.cpp - C Interface to MLIR Builtin Types ---------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "mlir-c/StandardTypes.h"
+#include "mlir-c/BuiltinTypes.h"
#include "mlir-c/AffineMap.h"
#include "mlir-c/IR.h"
#include "mlir/CAPI/AffineMap.h"
#include "mlir/CAPI/IR.h"
#include "mlir/IR/AffineMap.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Types.h"
using namespace mlir;
diff --git a/mlir/lib/CAPI/IR/CMakeLists.txt b/mlir/lib/CAPI/IR/CMakeLists.txt
index 4b5883040f06..427c0a655309 100644
--- a/mlir/lib/CAPI/IR/CMakeLists.txt
+++ b/mlir/lib/CAPI/IR/CMakeLists.txt
@@ -2,11 +2,11 @@
add_mlir_public_c_api_library(MLIRCAPIIR
AffineExpr.cpp
AffineMap.cpp
+ BuiltinTypes.cpp
Diagnostics.cpp
IR.cpp
Pass.cpp
StandardAttributes.cpp
- StandardTypes.cpp
Support.cpp
LINK_LIBS PUBLIC
diff --git a/mlir/lib/CAPI/IR/StandardAttributes.cpp b/mlir/lib/CAPI/IR/StandardAttributes.cpp
index 886d1682b4e4..9c48bc963794 100644
--- a/mlir/lib/CAPI/IR/StandardAttributes.cpp
+++ b/mlir/lib/CAPI/IR/StandardAttributes.cpp
@@ -11,7 +11,7 @@
#include "mlir/CAPI/IR.h"
#include "mlir/CAPI/Support.h"
#include "mlir/IR/Attributes.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
using namespace mlir;
diff --git a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
index edfbdc907551..ad84216d1e3b 100644
--- a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
+++ b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
@@ -22,7 +22,7 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/DataLayout.h"
diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
index 4fb9982fbce8..2da29303513f 100644
--- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
+++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
@@ -23,7 +23,7 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
using namespace mlir;
diff --git a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
index fcef3e528169..f32c664c17c4 100644
--- a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
+++ b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
@@ -26,10 +26,10 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/PatternMatch.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Types.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/DialectConversion.h"
diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index beecf7541b0e..f54ffc1c9d6c 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -109,7 +109,7 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
if (options.indexBitwidth == kDeriveIndexBitwidthFromDataLayout)
this->options.indexBitwidth = options.dataLayout.getPointerSizeInBits();
- // Register conversions for the standard types.
+ // Register conversions for the builtin types.
addConversion([&](ComplexType type) { return convertComplexType(type); });
addConversion([&](FloatType type) { return convertFloatType(type); });
addConversion([&](FunctionType type) { return convertFunctionType(type); });
@@ -430,7 +430,7 @@ Type LLVMTypeConverter::convertCallingConventionType(Type type) {
/// Promote the bare pointers in 'values' that resulted from memrefs to
/// descriptors. 'stdTypes' holds they types of 'values' before the conversion
-/// to the LLVM-IR dialect (i.e., MemRefType, or any other Standard type).
+/// to the LLVM-IR dialect (i.e., MemRefType, or any other builtin type).
void LLVMTypeConverter::promoteBarePtrsToDescriptors(
ConversionPatternRewriter &rewriter, Location loc, ArrayRef<Type> stdTypes,
SmallVectorImpl<Value> &values) {
diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
index 6abc82530ae6..1c7aec1f55a3 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
@@ -647,8 +647,8 @@ LogicalResult ConstantCompositeOpPattern::matchAndRewrite(
}
// Unfortunately, we cannot use dialect-specific types for element
- // attributes; element attributes only works with standard types. So we need
- // to prepare another converted standard types for the destination elements
+ // attributes; element attributes only works with builtin types. So we need
+ // to prepare another converted builtin types for the destination elements
// attribute.
if (dstAttrType.isa<RankedTensorType>())
dstAttrType = RankedTensorType::get(dstAttrType.getShape(), dstElemType);
diff --git a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
index cde397a92463..eb237cf35154 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
@@ -17,7 +17,7 @@
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Dialect/Vector/VectorOps.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
using namespace mlir;
diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
index 72d0d7d92c5f..b3fa315b75a3 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
@@ -13,7 +13,7 @@
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Dialect/Vector/VectorOps.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Target/LLVMIR/TypeTranslation.h"
#include "mlir/Transforms/DialectConversion.h"
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index 4f00a3257b25..e9d8009fb2e9 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -17,11 +17,11 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/FunctionImplementation.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/PatternMatch.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/TypeSwitch.h"
using namespace mlir;
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 8161a0c83ce4..76182c7868d7 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -14,10 +14,10 @@
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/FunctionImplementation.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/AsmParser/Parser.h"
diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
index e13a83854b1e..19c42c1e990c 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
@@ -17,10 +17,10 @@
#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/OperationSupport.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Function.h"
diff --git a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
index afdd9537c679..8d0c96ce2aa1 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
@@ -18,9 +18,9 @@
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Operation.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Function.h"
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp
index 4c7be45796f2..c77398def98c 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp
@@ -12,9 +12,9 @@
#include "mlir/Dialect/Linalg/IR/LinalgTypes.h"
#include "mlir/Dialect/Linalg/IR/LinalgOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/DialectImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Parser.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Transforms/InliningUtils.h"
diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
index ae2d1c1080d1..fcbb4cec7200 100644
--- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
+++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
@@ -9,8 +9,8 @@
#include "mlir/Dialect/OpenACC/OpenACC.h"
#include "mlir/Dialect/OpenACC/OpenACCOpsEnums.cpp.inc"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
using namespace mlir;
using namespace acc;
diff --git a/mlir/lib/Dialect/PDL/IR/PDL.cpp b/mlir/lib/Dialect/PDL/IR/PDL.cpp
index d8baac0d0c39..951c76246b12 100644
--- a/mlir/lib/Dialect/PDL/IR/PDL.cpp
+++ b/mlir/lib/Dialect/PDL/IR/PDL.cpp
@@ -8,8 +8,8 @@
#include "mlir/Dialect/PDL/IR/PDL.h"
#include "mlir/Dialect/PDL/IR/PDLTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "llvm/ADT/StringSwitch.h"
diff --git a/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp b/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp
index 2119d7aeeea2..762887f4bf31 100644
--- a/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp
+++ b/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp
@@ -8,8 +8,8 @@
#include "mlir/Dialect/PDLInterp/IR/PDLInterp.h"
#include "mlir/Dialect/PDL/IR/PDLTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
-#include "mlir/IR/StandardTypes.h"
using namespace mlir;
using namespace mlir::pdl_interp;
diff --git a/mlir/lib/Dialect/Quant/IR/QuantOps.cpp b/mlir/lib/Dialect/Quant/IR/QuantOps.cpp
index 62a527b13243..fa64e4dd5411 100644
--- a/mlir/lib/Dialect/Quant/IR/QuantOps.cpp
+++ b/mlir/lib/Dialect/Quant/IR/QuantOps.cpp
@@ -10,10 +10,10 @@
#include "TypeDetail.h"
#include "mlir/Dialect/Quant/QuantTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/MathExtras.h"
diff --git a/mlir/lib/Dialect/Quant/IR/QuantTypes.cpp b/mlir/lib/Dialect/Quant/IR/QuantTypes.cpp
index 66d804c8763a..195847d5d602 100644
--- a/mlir/lib/Dialect/Quant/IR/QuantTypes.cpp
+++ b/mlir/lib/Dialect/Quant/IR/QuantTypes.cpp
@@ -10,8 +10,8 @@
#include "TypeDetail.h"
#include "mlir/Dialect/Quant/QuantOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/MathExtras.h"
diff --git a/mlir/lib/Dialect/Quant/IR/TypeDetail.h b/mlir/lib/Dialect/Quant/IR/TypeDetail.h
index 82b28e8e06f6..ef098811927c 100644
--- a/mlir/lib/Dialect/Quant/IR/TypeDetail.h
+++ b/mlir/lib/Dialect/Quant/IR/TypeDetail.h
@@ -9,7 +9,7 @@
#ifndef TYPE_DETAIL_H_
#define TYPE_DETAIL_H_
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/TypeSupport.h"
#include "mlir/IR/Types.h"
#include "llvm/ADT/DenseMap.h"
diff --git a/mlir/lib/Dialect/Quant/IR/TypeParser.cpp b/mlir/lib/Dialect/Quant/IR/TypeParser.cpp
index 70539183b6f4..4a62bfe8c9fc 100644
--- a/mlir/lib/Dialect/Quant/IR/TypeParser.cpp
+++ b/mlir/lib/Dialect/Quant/IR/TypeParser.cpp
@@ -8,9 +8,9 @@
#include "mlir/Dialect/Quant/QuantOps.h"
#include "mlir/Dialect/Quant/QuantTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/Location.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Types.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/StringSwitch.h"
diff --git a/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp b/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
index d98116d41cfc..8eae27d263c5 100644
--- a/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
+++ b/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
@@ -12,8 +12,8 @@
#include "mlir/Dialect/Quant/QuantizeUtils.h"
#include "mlir/Dialect/Quant/UniformSupport.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Matchers.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
using namespace mlir;
diff --git a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
index 2eb1a90556ff..ed665df81855 100644
--- a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
+++ b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
@@ -11,7 +11,7 @@
#include "mlir/Dialect/Quant/Passes.h"
#include "mlir/Dialect/Quant/QuantOps.h"
#include "mlir/Dialect/Quant/UniformSupport.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
using namespace mlir;
diff --git a/mlir/lib/Dialect/Quant/Utils/QuantizeUtils.cpp b/mlir/lib/Dialect/Quant/Utils/QuantizeUtils.cpp
index 7b475d31914b..220e8cea75bf 100644
--- a/mlir/lib/Dialect/Quant/Utils/QuantizeUtils.cpp
+++ b/mlir/lib/Dialect/Quant/Utils/QuantizeUtils.cpp
@@ -9,7 +9,7 @@
#include "mlir/Dialect/Quant/QuantizeUtils.h"
#include "mlir/Dialect/Quant/UniformSupport.h"
#include "mlir/IR/Attributes.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
using namespace mlir;
using namespace mlir::quant;
diff --git a/mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp b/mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp
index bde201e1ef1f..aadbf1382652 100644
--- a/mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp
+++ b/mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Quant/UniformSupport.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include <numeric>
using namespace mlir;
diff --git a/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp
index 49f1b94d5f26..26d7067ad91f 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp
@@ -16,9 +16,9 @@
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/TargetAndABI.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Parser.h"
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/DenseMap.h"
diff --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
index a2e57319a5db..10260b8029c6 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
@@ -414,7 +414,7 @@ SPIRVTypeConverter::SPIRVTypeConverter(spirv::TargetEnvAttr targetAttr)
// All other cases failed. Then we cannot convert this type.
addConversion([](Type type) { return llvm::None; });
- // Allow all SPIR-V dialect specific types. This assumes all standard types
+ // Allow all SPIR-V dialect specific types. This assumes all builtin types
// adopted in the SPIR-V dialect (i.e., IntegerType, FloatType, VectorType)
// were tried before.
//
diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
index a45b9c54265e..6a13a5513fc7 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
@@ -19,9 +19,9 @@
#include "mlir/Dialect/SPIRV/TargetAndABI.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/FunctionImplementation.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/bit.h"
diff --git a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp
index c38f2fdbe785..15fafddf9f24 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp
@@ -13,8 +13,8 @@
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/IR/Attributes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Identifier.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringExtras.h"
diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp
index 73f7450d778c..fe57f7d7a52e 100644
--- a/mlir/lib/Dialect/Shape/IR/Shape.cpp
+++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp
@@ -11,9 +11,9 @@
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Dialect/Traits.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/PatternMatch.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/TypeSwitch.h"
diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
index b5d5ef703aa0..300b8a42656c 100644
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -14,10 +14,10 @@
#include "mlir/IR/BlockAndValueMapping.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/PatternMatch.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/IR/Value.h"
#include "mlir/Support/MathExtras.h"
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index a609e64cb7d7..e50dab12aaf1 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -15,7 +15,7 @@
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Dialect/Tosa/Utils/QuantUtils.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Transforms/FoldUtils.h"
#include "mlir/Transforms/InliningUtils.h"
#include "mlir/Transforms/RegionUtils.h"
diff --git a/mlir/lib/Dialect/Traits.cpp b/mlir/lib/Dialect/Traits.cpp
index ca7a25dae035..b7d1bc876f2d 100644
--- a/mlir/lib/Dialect/Traits.cpp
+++ b/mlir/lib/Dialect/Traits.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Traits.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/TypeUtilities.h"
#include "llvm/Support/FormatVariadic.h"
diff --git a/mlir/lib/ExecutionEngine/JitRunner.cpp b/mlir/lib/ExecutionEngine/JitRunner.cpp
index d9e0ff63c125..a323e68170c1 100644
--- a/mlir/lib/ExecutionEngine/JitRunner.cpp
+++ b/mlir/lib/ExecutionEngine/JitRunner.cpp
@@ -19,8 +19,8 @@
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/ExecutionEngine/ExecutionEngine.h"
#include "mlir/ExecutionEngine/OptUtils.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/InitAllDialects.h"
#include "mlir/Parser.h"
#include "mlir/Support/FileUtilities.h"
diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp
index cc2cb8be4f3c..1913fde9de1e 100644
--- a/mlir/lib/IR/AffineMap.cpp
+++ b/mlir/lib/IR/AffineMap.cpp
@@ -9,7 +9,7 @@
#include "mlir/IR/AffineMap.h"
#include "AffineMapDetail.h"
#include "mlir/IR/Attributes.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Support/MathExtras.h"
#include "llvm/ADT/SmallSet.h"
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 14281f707fcd..49e7048cfb13 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -15,13 +15,13 @@
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/AsmState.h"
#include "mlir/IR/Attributes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/Operation.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/MapVector.h"
diff --git a/mlir/lib/IR/AttributeDetail.h b/mlir/lib/IR/AttributeDetail.h
index 1c4acf81c88b..3a140790fe51 100644
--- a/mlir/lib/IR/AttributeDetail.h
+++ b/mlir/lib/IR/AttributeDetail.h
@@ -15,10 +15,10 @@
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Attributes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Identifier.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Support/StorageUniquer.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/PointerIntPair.h"
diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp
index f97719a00333..72fb240f6be1 100644
--- a/mlir/lib/IR/Builders.cpp
+++ b/mlir/lib/IR/Builders.cpp
@@ -10,11 +10,11 @@
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/BlockAndValueMapping.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/IR/Matchers.h"
-#include "mlir/IR/StandardTypes.h"
-#include "mlir/IR/SymbolTable.h"
+#include "llvm/Support/raw_ostream.h"
using namespace mlir;
diff --git a/mlir/lib/IR/BuiltinDialect.cpp b/mlir/lib/IR/BuiltinDialect.cpp
index 8f872ac7c9ab..b125ae01882b 100644
--- a/mlir/lib/IR/BuiltinDialect.cpp
+++ b/mlir/lib/IR/BuiltinDialect.cpp
@@ -15,9 +15,9 @@
#include "mlir/IR/BlockAndValueMapping.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/FunctionImplementation.h"
#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/MapVector.h"
using namespace mlir;
diff --git a/mlir/lib/IR/StandardTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp
similarity index 88%
rename from mlir/lib/IR/StandardTypes.cpp
rename to mlir/lib/IR/BuiltinTypes.cpp
index f2835bbd3702..237525ffd10d 100644
--- a/mlir/lib/IR/StandardTypes.cpp
+++ b/mlir/lib/IR/BuiltinTypes.cpp
@@ -1,4 +1,4 @@
-//===- StandardTypes.cpp - MLIR Standard Type Classes ---------------------===//
+//===- BuiltinTypes.cpp - MLIR Builtin Type Classes -----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,97 +6,19 @@
//
//===----------------------------------------------------------------------===//
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "TypeDetail.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Dialect.h"
#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/Twine.h"
using namespace mlir;
using namespace mlir::detail;
-//===----------------------------------------------------------------------===//
-// Type
-//===----------------------------------------------------------------------===//
-
-bool Type::isBF16() const { return isa<BFloat16Type>(); }
-bool Type::isF16() const { return isa<Float16Type>(); }
-bool Type::isF32() const { return isa<Float32Type>(); }
-bool Type::isF64() const { return isa<Float64Type>(); }
-
-bool Type::isIndex() const { return isa<IndexType>(); }
-
-/// Return true if this is an integer type with the specified width.
-bool Type::isInteger(unsigned width) const {
- if (auto intTy = dyn_cast<IntegerType>())
- return intTy.getWidth() == width;
- return false;
-}
-
-bool Type::isSignlessInteger() const {
- if (auto intTy = dyn_cast<IntegerType>())
- return intTy.isSignless();
- return false;
-}
-
-bool Type::isSignlessInteger(unsigned width) const {
- if (auto intTy = dyn_cast<IntegerType>())
- return intTy.isSignless() && intTy.getWidth() == width;
- return false;
-}
-
-bool Type::isSignedInteger() const {
- if (auto intTy = dyn_cast<IntegerType>())
- return intTy.isSigned();
- return false;
-}
-
-bool Type::isSignedInteger(unsigned width) const {
- if (auto intTy = dyn_cast<IntegerType>())
- return intTy.isSigned() && intTy.getWidth() == width;
- return false;
-}
-
-bool Type::isUnsignedInteger() const {
- if (auto intTy = dyn_cast<IntegerType>())
- return intTy.isUnsigned();
- return false;
-}
-
-bool Type::isUnsignedInteger(unsigned width) const {
- if (auto intTy = dyn_cast<IntegerType>())
- return intTy.isUnsigned() && intTy.getWidth() == width;
- return false;
-}
-
-bool Type::isSignlessIntOrIndex() const {
- return isSignlessInteger() || isa<IndexType>();
-}
-
-bool Type::isSignlessIntOrIndexOrFloat() const {
- return isSignlessInteger() || isa<IndexType, FloatType>();
-}
-
-bool Type::isSignlessIntOrFloat() const {
- return isSignlessInteger() || isa<FloatType>();
-}
-
-bool Type::isIntOrIndex() const { return isa<IntegerType>() || isIndex(); }
-
-bool Type::isIntOrFloat() const { return isa<IntegerType, FloatType>(); }
-
-bool Type::isIntOrIndexOrFloat() const { return isIntOrFloat() || isIndex(); }
-
-unsigned Type::getIntOrFloatBitWidth() const {
- assert(isIntOrFloat() && "only integers and floats have a bitwidth");
- if (auto intType = dyn_cast<IntegerType>())
- return intType.getWidth();
- return cast<FloatType>().getWidth();
-}
-
//===----------------------------------------------------------------------===//
/// ComplexType
//===----------------------------------------------------------------------===//
@@ -170,6 +92,100 @@ const llvm::fltSemantics &FloatType::getFloatSemantics() {
llvm_unreachable("non-floating point type used");
}
+//===----------------------------------------------------------------------===//
+// FunctionType
+//===----------------------------------------------------------------------===//
+
+FunctionType FunctionType::get(TypeRange inputs, TypeRange results,
+ MLIRContext *context) {
+ return Base::get(context, inputs, results);
+}
+
+unsigned FunctionType::getNumInputs() const { return getImpl()->numInputs; }
+
+ArrayRef<Type> FunctionType::getInputs() const {
+ return getImpl()->getInputs();
+}
+
+unsigned FunctionType::getNumResults() const { return getImpl()->numResults; }
+
+ArrayRef<Type> FunctionType::getResults() const {
+ return getImpl()->getResults();
+}
+
+/// Helper to call a callback once on each index in the range
+/// [0, `totalIndices`), *except* for the indices given in `indices`.
+/// `indices` is allowed to have duplicates and can be in any order.
+inline void iterateIndicesExcept(unsigned totalIndices,
+ ArrayRef<unsigned> indices,
+ function_ref<void(unsigned)> callback) {
+ llvm::BitVector skipIndices(totalIndices);
+ for (unsigned i : indices)
+ skipIndices.set(i);
+
+ for (unsigned i = 0; i < totalIndices; ++i)
+ if (!skipIndices.test(i))
+ callback(i);
+}
+
+/// Returns a new function type without the specified arguments and results.
+FunctionType
+FunctionType::getWithoutArgsAndResults(ArrayRef<unsigned> argIndices,
+ ArrayRef<unsigned> resultIndices) {
+ ArrayRef<Type> newInputTypes = getInputs();
+ SmallVector<Type, 4> newInputTypesBuffer;
+ if (!argIndices.empty()) {
+ unsigned originalNumArgs = getNumInputs();
+ iterateIndicesExcept(originalNumArgs, argIndices, [&](unsigned i) {
+ newInputTypesBuffer.emplace_back(getInput(i));
+ });
+ newInputTypes = newInputTypesBuffer;
+ }
+
+ ArrayRef<Type> newResultTypes = getResults();
+ SmallVector<Type, 4> newResultTypesBuffer;
+ if (!resultIndices.empty()) {
+ unsigned originalNumResults = getNumResults();
+ iterateIndicesExcept(originalNumResults, resultIndices, [&](unsigned i) {
+ newResultTypesBuffer.emplace_back(getResult(i));
+ });
+ newResultTypes = newResultTypesBuffer;
+ }
+
+ return get(newInputTypes, newResultTypes, getContext());
+}
+
+//===----------------------------------------------------------------------===//
+// OpaqueType
+//===----------------------------------------------------------------------===//
+
+OpaqueType OpaqueType::get(Identifier dialect, StringRef typeData,
+ MLIRContext *context) {
+ return Base::get(context, dialect, typeData);
+}
+
+OpaqueType OpaqueType::getChecked(Identifier dialect, StringRef typeData,
+ MLIRContext *context, Location location) {
+ return Base::getChecked(location, dialect, typeData);
+}
+
+/// Returns the dialect namespace of the opaque type.
+Identifier OpaqueType::getDialectNamespace() const {
+ return getImpl()->dialectNamespace;
+}
+
+/// Returns the raw type data of the opaque type.
+StringRef OpaqueType::getTypeData() const { return getImpl()->typeData; }
+
+/// Verify the construction of an opaque type.
+LogicalResult OpaqueType::verifyConstructionInvariants(Location loc,
+ Identifier dialect,
+ StringRef typeData) {
+ if (!Dialect::isValidNamespace(dialect.strref()))
+ return emitError(loc, "invalid dialect namespace '") << dialect << "'";
+ return success();
+}
+
//===----------------------------------------------------------------------===//
// ShapedType
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/IR/CMakeLists.txt b/mlir/lib/IR/CMakeLists.txt
index 5a8d3e20df6a..9e7af9047692 100644
--- a/mlir/lib/IR/CMakeLists.txt
+++ b/mlir/lib/IR/CMakeLists.txt
@@ -6,6 +6,7 @@ add_mlir_library(MLIRIR
Block.cpp
Builders.cpp
BuiltinDialect.cpp
+ BuiltinTypes.cpp
Diagnostics.cpp
Dialect.cpp
Dominance.cpp
@@ -19,7 +20,6 @@ add_mlir_library(MLIRIR
PatternMatch.cpp
Region.cpp
RegionKindInterface.cpp
- StandardTypes.cpp
SymbolTable.cpp
Types.cpp
TypeRange.cpp
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index 3037bf082d58..60b0f87932ee 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -8,10 +8,10 @@
#include "mlir/IR/Operation.h"
#include "mlir/IR/BlockAndValueMapping.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/PatternMatch.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Interfaces/FoldInterfaces.h"
#include <numeric>
diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp
index c7aa0e323088..32d64ac32272 100644
--- a/mlir/lib/IR/OperationSupport.cpp
+++ b/mlir/lib/IR/OperationSupport.cpp
@@ -13,9 +13,9 @@
#include "mlir/IR/OperationSupport.h"
#include "mlir/IR/Block.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/Operation.h"
-#include "mlir/IR/StandardTypes.h"
using namespace mlir;
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/IR/TypeDetail.h b/mlir/lib/IR/TypeDetail.h
index 954d0745239a..cd027cde722b 100644
--- a/mlir/lib/IR/TypeDetail.h
+++ b/mlir/lib/IR/TypeDetail.h
@@ -13,10 +13,10 @@
#define TYPEDETAIL_H_
#include "mlir/IR/AffineMap.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Identifier.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/OperationSupport.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/TypeRange.h"
#include "llvm/ADT/bit.h"
#include "llvm/Support/TrailingObjects.h"
diff --git a/mlir/lib/IR/TypeUtilities.cpp b/mlir/lib/IR/TypeUtilities.cpp
index 3b69a0aff831..6018f2161bd2 100644
--- a/mlir/lib/IR/TypeUtilities.cpp
+++ b/mlir/lib/IR/TypeUtilities.cpp
@@ -12,7 +12,7 @@
#include "mlir/IR/TypeUtilities.h"
#include "mlir/IR/Attributes.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Types.h"
#include "mlir/IR/Value.h"
diff --git a/mlir/lib/IR/Types.cpp b/mlir/lib/IR/Types.cpp
index f3c1c2c11247..473c1bb218aa 100644
--- a/mlir/lib/IR/Types.cpp
+++ b/mlir/lib/IR/Types.cpp
@@ -6,13 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "mlir/IR/Types.h"
-#include "TypeDetail.h"
-#include "mlir/IR/Diagnostics.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
-#include "mlir/Support/LLVM.h"
-#include "llvm/ADT/BitVector.h"
-#include "llvm/ADT/Twine.h"
using namespace mlir;
using namespace mlir::detail;
@@ -27,96 +22,77 @@ Dialect &Type::getDialect() const {
MLIRContext *Type::getContext() const { return getDialect().getContext(); }
-//===----------------------------------------------------------------------===//
-// FunctionType
-//===----------------------------------------------------------------------===//
+bool Type::isBF16() const { return isa<BFloat16Type>(); }
+bool Type::isF16() const { return isa<Float16Type>(); }
+bool Type::isF32() const { return isa<Float32Type>(); }
+bool Type::isF64() const { return isa<Float64Type>(); }
-FunctionType FunctionType::get(TypeRange inputs, TypeRange results,
- MLIRContext *context) {
- return Base::get(context, inputs, results);
-}
+bool Type::isIndex() const { return isa<IndexType>(); }
-unsigned FunctionType::getNumInputs() const { return getImpl()->numInputs; }
+/// Return true if this is an integer type with the specified width.
+bool Type::isInteger(unsigned width) const {
+ if (auto intTy = dyn_cast<IntegerType>())
+ return intTy.getWidth() == width;
+ return false;
+}
-ArrayRef<Type> FunctionType::getInputs() const {
- return getImpl()->getInputs();
+bool Type::isSignlessInteger() const {
+ if (auto intTy = dyn_cast<IntegerType>())
+ return intTy.isSignless();
+ return false;
}
-unsigned FunctionType::getNumResults() const { return getImpl()->numResults; }
+bool Type::isSignlessInteger(unsigned width) const {
+ if (auto intTy = dyn_cast<IntegerType>())
+ return intTy.isSignless() && intTy.getWidth() == width;
+ return false;
+}
-ArrayRef<Type> FunctionType::getResults() const {
- return getImpl()->getResults();
+bool Type::isSignedInteger() const {
+ if (auto intTy = dyn_cast<IntegerType>())
+ return intTy.isSigned();
+ return false;
}
-/// Helper to call a callback once on each index in the range
-/// [0, `totalIndices`), *except* for the indices given in `indices`.
-/// `indices` is allowed to have duplicates and can be in any order.
-inline void iterateIndicesExcept(unsigned totalIndices,
- ArrayRef<unsigned> indices,
- function_ref<void(unsigned)> callback) {
- llvm::BitVector skipIndices(totalIndices);
- for (unsigned i : indices)
- skipIndices.set(i);
-
- for (unsigned i = 0; i < totalIndices; ++i)
- if (!skipIndices.test(i))
- callback(i);
+bool Type::isSignedInteger(unsigned width) const {
+ if (auto intTy = dyn_cast<IntegerType>())
+ return intTy.isSigned() && intTy.getWidth() == width;
+ return false;
}
-/// Returns a new function type without the specified arguments and results.
-FunctionType
-FunctionType::getWithoutArgsAndResults(ArrayRef<unsigned> argIndices,
- ArrayRef<unsigned> resultIndices) {
- ArrayRef<Type> newInputTypes = getInputs();
- SmallVector<Type, 4> newInputTypesBuffer;
- if (!argIndices.empty()) {
- unsigned originalNumArgs = getNumInputs();
- iterateIndicesExcept(originalNumArgs, argIndices, [&](unsigned i) {
- newInputTypesBuffer.emplace_back(getInput(i));
- });
- newInputTypes = newInputTypesBuffer;
- }
-
- ArrayRef<Type> newResultTypes = getResults();
- SmallVector<Type, 4> newResultTypesBuffer;
- if (!resultIndices.empty()) {
- unsigned originalNumResults = getNumResults();
- iterateIndicesExcept(originalNumResults, resultIndices, [&](unsigned i) {
- newResultTypesBuffer.emplace_back(getResult(i));
- });
- newResultTypes = newResultTypesBuffer;
- }
-
- return get(newInputTypes, newResultTypes, getContext());
+bool Type::isUnsignedInteger() const {
+ if (auto intTy = dyn_cast<IntegerType>())
+ return intTy.isUnsigned();
+ return false;
}
-//===----------------------------------------------------------------------===//
-// OpaqueType
-//===----------------------------------------------------------------------===//
+bool Type::isUnsignedInteger(unsigned width) const {
+ if (auto intTy = dyn_cast<IntegerType>())
+ return intTy.isUnsigned() && intTy.getWidth() == width;
+ return false;
+}
-OpaqueType OpaqueType::get(Identifier dialect, StringRef typeData,
- MLIRContext *context) {
- return Base::get(context, dialect, typeData);
+bool Type::isSignlessIntOrIndex() const {
+ return isSignlessInteger() || isa<IndexType>();
}
-OpaqueType OpaqueType::getChecked(Identifier dialect, StringRef typeData,
- MLIRContext *context, Location location) {
- return Base::getChecked(location, dialect, typeData);
+bool Type::isSignlessIntOrIndexOrFloat() const {
+ return isSignlessInteger() || isa<IndexType, FloatType>();
}
-/// Returns the dialect namespace of the opaque type.
-Identifier OpaqueType::getDialectNamespace() const {
- return getImpl()->dialectNamespace;
+bool Type::isSignlessIntOrFloat() const {
+ return isSignlessInteger() || isa<FloatType>();
}
-/// Returns the raw type data of the opaque type.
-StringRef OpaqueType::getTypeData() const { return getImpl()->typeData; }
+bool Type::isIntOrIndex() const { return isa<IntegerType>() || isIndex(); }
+
+bool Type::isIntOrFloat() const { return isa<IntegerType, FloatType>(); }
+
+bool Type::isIntOrIndexOrFloat() const { return isIntOrFloat() || isIndex(); }
-/// Verify the construction of an opaque type.
-LogicalResult OpaqueType::verifyConstructionInvariants(Location loc,
- Identifier dialect,
- StringRef typeData) {
- if (!Dialect::isValidNamespace(dialect.strref()))
- return emitError(loc, "invalid dialect namespace '") << dialect << "'";
- return success();
+unsigned Type::getIntOrFloatBitWidth() const {
+ assert(isIntOrFloat() && "only integers and floats have a bitwidth");
+ if (auto intType = dyn_cast<IntegerType>())
+ return intType.getWidth();
+ return cast<FloatType>().getWidth();
}
diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp
index 776b32a73d58..7ec497c6b6ac 100644
--- a/mlir/lib/IR/Value.cpp
+++ b/mlir/lib/IR/Value.cpp
@@ -8,8 +8,8 @@
#include "mlir/IR/Value.h"
#include "mlir/IR/Block.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Operation.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/SmallPtrSet.h"
using namespace mlir;
diff --git a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
index 5b845584b2e8..57641e26935d 100644
--- a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
+++ b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "mlir/Interfaces/ControlFlowInterfaces.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "llvm/ADT/SmallPtrSet.h"
using namespace mlir;
diff --git a/mlir/lib/Interfaces/InferTypeOpInterface.cpp b/mlir/lib/Interfaces/InferTypeOpInterface.cpp
index 70dbc05592b7..4712f5f26870 100644
--- a/mlir/lib/Interfaces/InferTypeOpInterface.cpp
+++ b/mlir/lib/Interfaces/InferTypeOpInterface.cpp
@@ -13,7 +13,7 @@
#include "mlir/Interfaces/InferTypeOpInterface.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
using namespace mlir;
diff --git a/mlir/lib/Parser/AttributeParser.cpp b/mlir/lib/Parser/AttributeParser.cpp
index 6edc98d145c6..2e385cfa30e7 100644
--- a/mlir/lib/Parser/AttributeParser.cpp
+++ b/mlir/lib/Parser/AttributeParser.cpp
@@ -12,9 +12,9 @@
#include "Parser.h"
#include "mlir/IR/AffineMap.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/IntegerSet.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Endian.h"
diff --git a/mlir/lib/Parser/DialectSymbolParser.cpp b/mlir/lib/Parser/DialectSymbolParser.cpp
index 7782b59ab1a6..3bbc495cab65 100644
--- a/mlir/lib/Parser/DialectSymbolParser.cpp
+++ b/mlir/lib/Parser/DialectSymbolParser.cpp
@@ -12,9 +12,9 @@
//===----------------------------------------------------------------------===//
#include "Parser.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/DialectImplementation.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/Support/SourceMgr.h"
using namespace mlir;
diff --git a/mlir/lib/Parser/TypeParser.cpp b/mlir/lib/Parser/TypeParser.cpp
index c3087c15b0c5..1e7cffbe4db6 100644
--- a/mlir/lib/Parser/TypeParser.cpp
+++ b/mlir/lib/Parser/TypeParser.cpp
@@ -12,7 +12,7 @@
#include "Parser.h"
#include "mlir/IR/AffineMap.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
using namespace mlir;
using namespace mlir::detail;
diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
index 52ff4cfa6177..38b54ebadfc7 100644
--- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -13,8 +13,8 @@
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Target/LLVMIR.h"
#include "mlir/Target/LLVMIR/TypeTranslation.h"
#include "mlir/Translation.h"
@@ -85,8 +85,8 @@ class Importer {
LogicalResult processBranchArgs(llvm::Instruction *br,
llvm::BasicBlock *target,
SmallVectorImpl<Value> &blockArguments);
- /// Returns the standard type equivalent to be used in attributes for the
- /// given LLVM IR dialect type.
+ /// Returns the builtin type equivalent to be used in attributes for the given
+ /// LLVM IR dialect type.
Type getStdTypeForAttr(LLVMType type);
/// Return `value` as an attribute to attach to a GlobalOp.
Attribute getConstantAsAttr(llvm::Constant *value);
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 8553c5bd851f..e73ac109079d 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -18,8 +18,8 @@
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/RegionGraphTraits.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Target/LLVMIR/TypeTranslation.h"
#include "llvm/ADT/TypeSwitch.h"
diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp
index 62c6ce7e01d6..97fe7b2d45bb 100644
--- a/mlir/lib/Transforms/ViewOpGraph.cpp
+++ b/mlir/lib/Transforms/ViewOpGraph.cpp
@@ -9,8 +9,8 @@
#include "mlir/Transforms/ViewOpGraph.h"
#include "PassDetail.h"
#include "mlir/IR/Block.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Operation.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/Support/CommandLine.h"
using namespace mlir;
diff --git a/mlir/test/Bindings/Python/ir_types.py b/mlir/test/Bindings/Python/ir_types.py
index 2f37d08aee32..a65095c4289e 100644
--- a/mlir/test/Bindings/Python/ir_types.py
+++ b/mlir/test/Bindings/Python/ir_types.py
@@ -197,10 +197,11 @@ def testComplexType():
run(testComplexType)
+
# CHECK-LABEL: TEST: testConcreteShapedType
-# Shaped type is not a kind of standard types, it is the base class for
-# vectors, memrefs and tensors, so this test case uses an instance of vector
-# to test the shaped type. The class hierarchy is preserved on the python side.
+# Shaped type is not a kind of builtin types, it is the base class for vectors,
+# memrefs and tensors, so this test case uses an instance of vector to test the
+# shaped type. The class hierarchy is preserved on the python side.
def testConcreteShapedType():
with Context() as ctx:
vector = VectorType(Type.parse("vector<2x3xf32>"))
diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c
index 4e2ad0bb6661..723e96bc8ce7 100644
--- a/mlir/test/CAPI/ir.c
+++ b/mlir/test/CAPI/ir.c
@@ -13,11 +13,11 @@
#include "mlir-c/IR.h"
#include "mlir-c/AffineExpr.h"
#include "mlir-c/AffineMap.h"
+#include "mlir-c/BuiltinTypes.h"
#include "mlir-c/Diagnostics.h"
#include "mlir-c/Registration.h"
#include "mlir-c/StandardAttributes.h"
#include "mlir-c/StandardDialect.h"
-#include "mlir-c/StandardTypes.h"
#include <assert.h>
#include <math.h>
@@ -549,12 +549,12 @@ static void buildWithInsertionsAndPrint(MlirContext ctx) {
// clang-format on
}
-/// Dumps instances of all standard types to check that C API works correctly.
-/// Additionally, performs simple identity checks that a standard type
+/// Dumps instances of all builtin types to check that C API works correctly.
+/// Additionally, performs simple identity checks that a builtin type
/// constructed with C API can be inspected and has the expected type. The
-/// latter achieves full coverage of C API for standard types. Returns 0 on
+/// latter achieves full coverage of C API for builtin types. Returns 0 on
/// success and a non-zero error code on failure.
-static int printStandardTypes(MlirContext ctx) {
+static int printBuiltinTypes(MlirContext ctx) {
// Integer types.
MlirType i32 = mlirIntegerTypeGet(ctx, 32);
MlirType si32 = mlirIntegerTypeSignedGet(ctx, 32);
@@ -1332,7 +1332,7 @@ int main() {
return 1;
buildWithInsertionsAndPrint(ctx);
- if (printStandardTypes(ctx))
+ if (printBuiltinTypes(ctx))
return 2;
if (printStandardAttributes(ctx))
return 3;
diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp
index ae9615a40775..7918b7d020ee 100644
--- a/mlir/test/EDSC/builder-api-test.cpp
+++ b/mlir/test/EDSC/builder-api-test.cpp
@@ -18,9 +18,9 @@
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Types.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
diff --git a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
index 25cc2a6e160d..35de0ba404df 100644
--- a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
@@ -18,8 +18,8 @@
#include "mlir/Dialect/Vector/VectorOps.h"
#include "mlir/Dialect/Vector/VectorUtils.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Diagnostics.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/LoopUtils.h"
#include "mlir/Transforms/Passes.h"
diff --git a/mlir/test/lib/Dialect/Test/TestDialect.h b/mlir/test/lib/Dialect/Test/TestDialect.h
index 732cf5165cb6..ef53006cabd4 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.h
+++ b/mlir/test/lib/Dialect/Test/TestDialect.h
@@ -17,11 +17,11 @@
#include "TestInterfaces.h"
#include "mlir/Dialect/Traits.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/RegionKindInterface.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
diff --git a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
index 77787cc90620..3e8c4bdc6865 100644
--- a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
+++ b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
@@ -15,8 +15,8 @@
#include "mlir/Dialect/Tosa/Transforms/PassDetail.h"
#include "mlir/Dialect/Tosa/Transforms/Passes.h"
#include "mlir/Dialect/Tosa/Utils/QuantUtils.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Matchers.h"
-#include "mlir/IR/StandardTypes.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
diff --git a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp
index e2a67b710ada..3d7625973126 100644
--- a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp
+++ b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/StandardOps/IR/Ops.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/Passes.h"
diff --git a/mlir/unittests/Dialect/Quant/QuantizationUtilsTest.cpp b/mlir/unittests/Dialect/Quant/QuantizationUtilsTest.cpp
index 85735c040bce..d7af2250a381 100644
--- a/mlir/unittests/Dialect/Quant/QuantizationUtilsTest.cpp
+++ b/mlir/unittests/Dialect/Quant/QuantizationUtilsTest.cpp
@@ -10,7 +10,7 @@
#include "mlir/Dialect/Quant/QuantizeUtils.h"
#include "mlir/Dialect/Quant/UniformSupport.h"
#include "mlir/IR/Attributes.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
diff --git a/mlir/unittests/IR/AttributeTest.cpp b/mlir/unittests/IR/AttributeTest.cpp
index df449a0da75c..9d47a5c96406 100644
--- a/mlir/unittests/IR/AttributeTest.cpp
+++ b/mlir/unittests/IR/AttributeTest.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "mlir/IR/Attributes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Identifier.h"
-#include "mlir/IR/StandardTypes.h"
#include "gtest/gtest.h"
using namespace mlir;
diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp
index 356e849bc495..c48e8623c609 100644
--- a/mlir/unittests/IR/OperationSupportTest.cpp
+++ b/mlir/unittests/IR/OperationSupportTest.cpp
@@ -8,7 +8,7 @@
#include "mlir/IR/OperationSupport.h"
#include "mlir/IR/Builders.h"
-#include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "gtest/gtest.h"
using namespace mlir;
diff --git a/mlir/unittests/TableGen/OpBuildGen.cpp b/mlir/unittests/TableGen/OpBuildGen.cpp
index d742e3927f55..c5ef9230536e 100644
--- a/mlir/unittests/TableGen/OpBuildGen.cpp
+++ b/mlir/unittests/TableGen/OpBuildGen.cpp
@@ -13,9 +13,9 @@
#include "TestDialect.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/Identifier.h"
-#include "mlir/IR/StandardTypes.h"
#include "gmock/gmock.h"
#include <vector>
diff --git a/mlir/unittests/TableGen/StructsGenTest.cpp b/mlir/unittests/TableGen/StructsGenTest.cpp
index d089ac5f37c8..c1c883619de9 100644
--- a/mlir/unittests/TableGen/StructsGenTest.cpp
+++ b/mlir/unittests/TableGen/StructsGenTest.cpp
@@ -8,8 +8,8 @@
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Identifier.h"
-#include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringSwitch.h"
diff --git a/mlir/utils/gdb-scripts/prettyprinters.py b/mlir/utils/gdb-scripts/prettyprinters.py
index 6dd97c60f1e5..243998ee1ea4 100644
--- a/mlir/utils/gdb-scripts/prettyprinters.py
+++ b/mlir/utils/gdb-scripts/prettyprinters.py
@@ -196,7 +196,7 @@ def children(self):
'DenseIntOrFPElementsAttr',
'OpaqueElementsAttr',
'SparseElementsAttr',
- # mlir/IR/StandardTypes.h
+ # mlir/IR/BuiltinTypes.h
'ComplexType',
'IndexType',
'IntegerType',
More information about the Mlir-commits
mailing list