[MLIR] Add a switch operation to the standard dialect
authorGeoffrey Martin-Noble <gcmn@google.com>
Tue, 13 Apr 2021 00:01:30 +0000 (17:01 -0700)
committerGeoffrey Martin-Noble <gcmn@google.com>
Tue, 13 Apr 2021 01:46:02 +0000 (18:46 -0700)
commitae33eef5055ef1f55df0df3be0b8851aaf9f4efd
tree61ee0d2dd4749bfb72157f594f7d45117bff1ee0
parentd926498d9febed7f703e29fd06f7825d54ee91a4
[MLIR] Add a switch operation to the standard dialect

This is similar to the definition of llvm.switch, providing
unstructured branch-based control flow. It differs from the LLVM
operation in that it accepts any signless integer (not only an i32),
takes no branch weights (the same as the Branch and CondBranch ops),
and has a slightly different syntax for the default case that includes
it in the list of cases with an explicit `default` keyword.

Also included are several canonicalizers.

See https://llvm.discourse.group/t/rfc-add-std-switch-and-scf-switch/3090

Reviewed By: rriddle, bondhugula

Differential Revision: https://reviews.llvm.org/D99925
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/include/mlir/IR/OpBase.td
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/test/Dialect/Standard/canonicalize-cf.mlir
mlir/test/Dialect/Standard/ops.mlir
mlir/test/Dialect/Standard/parser.mlir [new file with mode: 0644]