[mlir] Add a new BranchOpInterface to allow for opaquely interfacing with branching...
authorRiver Riddle <riddleriver@gmail.com>
Thu, 5 Mar 2020 20:40:23 +0000 (12:40 -0800)
committerRiver Riddle <riddleriver@gmail.com>
Thu, 5 Mar 2020 20:50:35 +0000 (12:50 -0800)
commit621d7cca3751f934f991e34fe0e26187c33314f4
treeceb26c869f9fa2655b53d7f47db0db0578329be0
parentc0fd5e657e5d38a480d65b4e8f6f7a835afd6c76
[mlir] Add a new BranchOpInterface to allow for opaquely interfacing with branching terminator operations.

This interface contains the necessary components to provide the same builtin behavior that terminators have. This will be used in future revisions to remove many of the hardcoded constraints placed on successors and successor operands. The interface initially contains three methods:

```c++
// Return a set of values corresponding to the operands for successor 'index', or None if the operands do not correspond to materialized values.
Optional<OperandRange> getSuccessorOperands(unsigned index);

// Return true if this terminator can have it's successor operands erased.
bool canEraseSuccessorOperand();

// Erase the operand of a successor. This is only valid to call if 'canEraseSuccessorOperand' returns true.
void eraseSuccessorOperand(unsigned succIdx, unsigned opIdx);
```

Differential Revision: https://reviews.llvm.org/D75314
25 files changed:
mlir/include/mlir/Analysis/CMakeLists.txt
mlir/include/mlir/Analysis/ControlFlowInterfaces.h [new file with mode: 0644]
mlir/include/mlir/Analysis/ControlFlowInterfaces.td [new file with mode: 0644]
mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td
mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h
mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/include/mlir/IR/OperationSupport.h
mlir/lib/Analysis/CMakeLists.txt
mlir/lib/Analysis/ControlFlowInterfaces.cpp [new file with mode: 0644]
mlir/lib/Dialect/LLVMIR/CMakeLists.txt
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/SPIRV/CMakeLists.txt
mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
mlir/lib/Dialect/StandardOps/CMakeLists.txt
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/lib/IR/Operation.cpp
mlir/lib/IR/OperationSupport.cpp
mlir/test/lib/TestDialect/CMakeLists.txt
mlir/test/lib/TestDialect/TestDialect.cpp
mlir/test/lib/TestDialect/TestDialect.h
mlir/test/lib/TestDialect/TestOps.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp