From: Chris Morin Date: Tue, 29 Dec 2020 22:04:55 +0000 (+0000) Subject: [MLIR] Make ComplexType buildable if its element type is buildable X-Git-Tag: llvmorg-13-init~2419 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2c8f5bd53945a209cd3cd851c63df3713fa0f9bd;p=platform%2Fupstream%2Fllvm.git [MLIR] Make ComplexType buildable if its element type is buildable If a ComplexType's element type is buildable, then that ComplexType should be buildable. This is accomplished by the introduction of a new ODS class called `SameBuildabilityAs`. This can be used by other types that are conditionally buildable. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D93892 --- diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 857a652..c65cc22 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -333,6 +333,13 @@ class BuildableType { code builderCall = builder; } +// A type that's buildable iff the type passed as an argument is buildable. +// This is intended for use by types like container types, which are only +// buildable if the type of their elements is buildable. +class SameBuildabilityAs { + code builderCall = !if(!empty(type.builderCall), "", builder); +} + // Any type at all. def AnyType : Type, "any type">; @@ -479,7 +486,9 @@ class Complex "$_self.cast<::mlir::ComplexType>().getElementType()", type.predicate>]>, "complex type with " # type.description # " elements", - "::mlir::ComplexType"> { + "::mlir::ComplexType">, + SameBuildabilityAs { Type elementType = type; } diff --git a/mlir/test/mlir-tblgen/types.mlir b/mlir/test/mlir-tblgen/types.mlir index 5e4dac3..61727d1 100644 --- a/mlir/test/mlir-tblgen/types.mlir +++ b/mlir/test/mlir-tblgen/types.mlir @@ -58,7 +58,7 @@ func @complex_f64_tensor_success() { // ----- func @complex_f64_failure() { - // expected-error@+1 {{must be complex type with 64-bit float elements}} + // expected-error@+1 {{op inferred type incompatible with return type of operation}} "test.complex_f64"() : () -> (f64) return }