From: Nicolas Vasilache Date: Thu, 23 Apr 2020 18:10:24 +0000 (-0400) Subject: [mlir][EDSC] Hotfix - Provide impl for `negate` X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=37d417bb0adca62b6902dd27019465f9ae4319a5;p=platform%2Fupstream%2Fllvm.git [mlir][EDSC] Hotfix - Provide impl for `negate` 367229e100eca714276253bf95a0dd3d084a9624 retired ValueHandle but mistakenly removed the implementation for `negate` which was not tested and would result in linking errors. This revision adds the implementation back and provides a test. --- diff --git a/mlir/lib/Dialect/Affine/EDSC/Builders.cpp b/mlir/lib/Dialect/Affine/EDSC/Builders.cpp index 2cecb0c..0e1b2a5 100644 --- a/mlir/lib/Dialect/Affine/EDSC/Builders.cpp +++ b/mlir/lib/Dialect/Affine/EDSC/Builders.cpp @@ -191,6 +191,11 @@ Value mlir::edsc::op::ceilDiv(Value lhs, Value rhs) { lhs, rhs, [](AffineExpr d0, AffineExpr d1) { return d0.ceilDiv(d1); }); } +Value mlir::edsc::op::negate(Value value) { + assert(value.getType().isInteger(1) && "expected boolean expression"); + return ValueBuilder(1, 1) - value; +} + Value mlir::edsc::op::operator&&(Value lhs, Value rhs) { assert(lhs.getType().isInteger(1) && "expected boolean expression on LHS"); assert(rhs.getType().isInteger(1) && "expected boolean expression on RHS"); diff --git a/mlir/lib/Dialect/LoopOps/EDSC/Builders.cpp b/mlir/lib/Dialect/LoopOps/EDSC/Builders.cpp index 7775d8d..fec803d 100644 --- a/mlir/lib/Dialect/LoopOps/EDSC/Builders.cpp +++ b/mlir/lib/Dialect/LoopOps/EDSC/Builders.cpp @@ -79,14 +79,11 @@ mlir::edsc::LoopNestBuilder::LoopNestBuilder::operator()( } LoopBuilder mlir::edsc::makeParallelLoopBuilder(MutableArrayRef ivs, - ArrayRef lbHandles, - ArrayRef ubHandles, + ArrayRef lbs, + ArrayRef ubs, ArrayRef steps) { LoopBuilder result; - auto opHandle = OperationHandle::create( - SmallVector(lbHandles.begin(), lbHandles.end()), - SmallVector(ubHandles.begin(), ubHandles.end()), - SmallVector(steps.begin(), steps.end())); + auto opHandle = OperationHandle::create(lbs, ubs, steps); loop::ParallelOp parallelOp = cast(*opHandle.getOperation()); @@ -96,12 +93,13 @@ LoopBuilder mlir::edsc::makeParallelLoopBuilder(MutableArrayRef ivs, return result; } -mlir::edsc::LoopBuilder mlir::edsc::makeLoopBuilder( - Value *iv, Value lbHandle, Value ubHandle, Value stepHandle, - MutableArrayRef iterArgsHandles, ValueRange iterArgsInitValues) { +mlir::edsc::LoopBuilder +mlir::edsc::makeLoopBuilder(Value *iv, Value lb, Value ub, Value step, + MutableArrayRef iterArgsHandles, + ValueRange iterArgsInitValues) { mlir::edsc::LoopBuilder result; - auto forOp = OperationHandle::createOp( - lbHandle, ubHandle, stepHandle, iterArgsInitValues); + auto forOp = + OperationHandle::createOp(lb, ub, step, iterArgsInitValues); *iv = forOp.getInductionVar(); auto *body = loop::getForInductionVarOwner(*iv).getBody(); for (size_t i = 0, e = iterArgsHandles.size(); i < e; ++i) { diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp index 75e85ea..76f478f 100644 --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -470,13 +470,16 @@ TEST_FUNC(operator_and) { ScopedContext scope(builder, f.getLoc()); using op::operator&&; + using op::negate; Value lhs(f.getArgument(0)); Value rhs(f.getArgument(1)); - lhs &&rhs; + negate(lhs && rhs); // CHECK-LABEL: @operator_and // CHECK: [[ARG0:%.*]]: i1, [[ARG1:%.*]]: i1 - // CHECK: and [[ARG0]], [[ARG1]] + // CHECK: [[AND:%.*]] = and [[ARG0]], [[ARG1]] + // CHECK: [[TRUE:%.*]] = constant 1 : i1 + // CHECK: subi [[TRUE]], [[AND]] : i1 f.print(llvm::outs()); f.erase(); }