[mlir] Require explicit casts when using TypedValue
authorRahul Kayaith <rkayaith@gmail.com>
Sun, 29 Jan 2023 00:18:19 +0000 (19:18 -0500)
committerRahul Kayaith <rkayaith@gmail.com>
Thu, 2 Feb 2023 02:54:53 +0000 (21:54 -0500)
commit0ce25b12357b24d06cf08cc02719c144d567d5db
treeb8f6af713081e096076e66049f02be9046661f03
parenta0b21046d8a3891b36fc992d97bc9daf4b3ce385
[mlir] Require explicit casts when using TypedValue

Currently `TypedValue` can be constructed directly from `Value`, hiding
errors that could be caught at compile time. For example the following
will compile, but crash/assert at runtime:
```
void foo(TypedValue<IntegerType>);
void bar(TypedValue<FloatType> v) {
  foo(v);
}
```

This change removes the constructors and replaces them with explicit
llvm casts.

Depends on D142852

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D142855
16 files changed:
mlir/docs/Tutorials/Toy/Ch-4.md
mlir/examples/toy/Ch4/mlir/Dialect.cpp
mlir/examples/toy/Ch5/mlir/Dialect.cpp
mlir/examples/toy/Ch6/mlir/Dialect.cpp
mlir/examples/toy/Ch7/mlir/Dialect.cpp
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/Value.h
mlir/include/mlir/TableGen/Class.h
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.h
mlir/test/mlir-tblgen/op-operand.td
mlir/test/mlir-tblgen/op-result.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/unittests/IR/IRMapping.cpp