[Mlir-commits] [mlir] 141e589 - [MLIR] Add an IfOp builder with results
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Mar 20 16:58:38 PDT 2020
Author: nmostafa
Date: 2020-03-20T16:53:56-07:00
New Revision: 141e5890d81294d618706752d2ba26fb6007cdd1
URL: https://github.com/llvm/llvm-project/commit/141e5890d81294d618706752d2ba26fb6007cdd1
DIFF: https://github.com/llvm/llvm-project/commit/141e5890d81294d618706752d2ba26fb6007cdd1.diff
LOG: [MLIR] Add an IfOp builder with results
Summary:
Add an additional builder to IfOp to allow the operation to
define operands.
Differential Revision: https://reviews.llvm.org/D76524
Added:
Modified:
mlir/include/mlir/Dialect/LoopOps/LoopOps.td
mlir/lib/Dialect/LoopOps/LoopOps.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td
index 84765222ce4c..a20c44fa5e16 100644
--- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td
+++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td
@@ -221,7 +221,10 @@ def IfOp : Loop_Op<"if",
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<"Builder *builder, OperationState &result, "
- "Value cond, bool withElseRegion">
+ "Value cond, bool withElseRegion">,
+ OpBuilder<"Builder *builder, OperationState &result, "
+ "TypeRange resultTypes, Value cond, "
+ "bool withElseRegion">
];
let extraClassDeclaration = [{
diff --git a/mlir/lib/Dialect/LoopOps/LoopOps.cpp b/mlir/lib/Dialect/LoopOps/LoopOps.cpp
index 4d1533aba859..5106cc63cb46 100644
--- a/mlir/lib/Dialect/LoopOps/LoopOps.cpp
+++ b/mlir/lib/Dialect/LoopOps/LoopOps.cpp
@@ -201,7 +201,13 @@ ForOp mlir::loop::getForInductionVarOwner(Value val) {
void IfOp::build(Builder *builder, OperationState &result, Value cond,
bool withElseRegion) {
+ build(builder, result, /*resultTypes=*/llvm::None, cond, withElseRegion);
+}
+
+void IfOp::build(Builder *builder, OperationState &result,
+ TypeRange resultTypes, Value cond, bool withElseRegion) {
result.addOperands(cond);
+ result.addTypes(resultTypes);
Region *thenRegion = result.addRegion();
Region *elseRegion = result.addRegion();
IfOp::ensureTerminator(*thenRegion, *builder, result.location);
More information about the Mlir-commits
mailing list