[mlir] introduce type constraints for operands of LLVM dialect operations
authorAlex Zinenko <zinenko@google.com>
Fri, 4 Sep 2020 08:00:09 +0000 (10:00 +0200)
committerAlex Zinenko <zinenko@google.com>
Fri, 4 Sep 2020 08:01:59 +0000 (10:01 +0200)
commitaec9e20a3e9a4f25a5b1e07816c95f970300d918
tree725a3a35d54ed002407ef906090b27745db9fac6
parentbdc4c0bc5c5e522aa770363fa6f50a3d5a5eadc2
[mlir] introduce type constraints for operands of LLVM dialect operations

Historically, the operations in the MLIR's LLVM dialect only checked that the
operand are of LLVM dialect type without more detailed constraints. This was
due to LLVM dialect types wrapping LLVM IR types and having clunky verification
methods. With the new first-class modeling, it is possible to define type
constraints similarly to other dialects and use them to enforce some
correctness rules in verifiers instead of having LLVM assert during translation
to LLVM IR. This hardening discovered several issues where MLIR was producing
LLVM dialect operations that cannot exist in LLVM IR.

Depends On D85900

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D85901
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
mlir/test/Dialect/LLVMIR/invalid.mlir