//===- Intrinsics.cpp - MLIR Operations for Declarative Builders ----------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/IR/AffineExpr.h" using namespace mlir; using namespace mlir::edsc; OperationHandle mlir::edsc::intrinsics::std_br(BlockHandle bh, ArrayRef operands) { assert(bh && "Expected already captured BlockHandle"); for (auto &o : operands) { (void)o; assert(o && "Expected already captured Value"); } SmallVector ops(operands.begin(), operands.end()); return OperationHandle::create(bh.getBlock(), ops); } OperationHandle mlir::edsc::intrinsics::std_br(BlockHandle *bh, ArrayRef types, MutableArrayRef captures, ArrayRef operands) { assert(!*bh && "Unexpected already captured BlockHandle"); BlockBuilder(bh, types, captures)(/* no body */); SmallVector ops(operands.begin(), operands.end()); return OperationHandle::create(bh->getBlock(), ops); } OperationHandle mlir::edsc::intrinsics::std_cond_br( Value cond, BlockHandle trueBranch, ArrayRef trueOperands, BlockHandle falseBranch, ArrayRef falseOperands) { SmallVector trueOps(trueOperands.begin(), trueOperands.end()); SmallVector falseOps(falseOperands.begin(), falseOperands.end()); return OperationHandle::create( cond, trueBranch.getBlock(), trueOps, falseBranch.getBlock(), falseOps); } OperationHandle mlir::edsc::intrinsics::std_cond_br( Value cond, BlockHandle *trueBranch, ArrayRef trueTypes, MutableArrayRef trueCaptures, ArrayRef trueOperands, BlockHandle *falseBranch, ArrayRef falseTypes, MutableArrayRef falseCaptures, ArrayRef falseOperands) { assert(!*trueBranch && "Unexpected already captured BlockHandle"); assert(!*falseBranch && "Unexpected already captured BlockHandle"); BlockBuilder(trueBranch, trueTypes, trueCaptures)(/* no body */); BlockBuilder(falseBranch, falseTypes, falseCaptures)(/* no body */); SmallVector trueOps(trueOperands.begin(), trueOperands.end()); SmallVector falseOps(falseOperands.begin(), falseOperands.end()); return OperationHandle::create( cond, trueBranch->getBlock(), trueOps, falseBranch->getBlock(), falseOps); }