forked from OSchip/llvm-project
[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
This commit is contained in:
parent
4f5af9d70d
commit
141e5890d8
|
@ -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 = [{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue