-
Notifications
You must be signed in to change notification settings - Fork 13.3k
/
Copy pathValueBoundsOpInterfaceImpl.cpp
51 lines (44 loc) · 1.89 KB
/
ValueBoundsOpInterfaceImpl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//===- ValueBoundsOpInterfaceImpl.cpp - Impl. of ValueBoundsOpInterface ---===//
//
// 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/Vector/IR/ValueBoundsOpInterfaceImpl.h"
#include "mlir/Dialect/Vector/IR/ScalableValueBoundsConstraintSet.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Interfaces/ValueBoundsOpInterface.h"
using namespace mlir;
namespace mlir::vector {
namespace {
struct VectorScaleOpInterface
: public ValueBoundsOpInterface::ExternalModel<VectorScaleOpInterface,
VectorScaleOp> {
void populateBoundsForIndexValue(Operation *op, Value value,
ValueBoundsConstraintSet &cstr) const {
auto *scalableCstr = dyn_cast<ScalableValueBoundsConstraintSet>(&cstr);
if (!scalableCstr)
return;
auto vscaleOp = cast<VectorScaleOp>(op);
assert(value == vscaleOp.getResult() && "invalid value");
if (auto vscale = scalableCstr->getVscaleValue()) {
// All copies of vscale are equivalent.
scalableCstr->bound(value) == cstr.getExpr(vscale);
} else {
// We know vscale is confined to [vscaleMin, vscaleMax].
scalableCstr->bound(value) >= scalableCstr->getVscaleMin();
scalableCstr->bound(value) <= scalableCstr->getVscaleMax();
scalableCstr->setVscale(vscaleOp);
}
}
};
} // namespace
} // namespace mlir::vector
void mlir::vector::registerValueBoundsOpInterfaceExternalModels(
DialectRegistry ®istry) {
registry.addExtension(+[](MLIRContext *ctx, vector::VectorDialect *dialect) {
vector::VectorScaleOp::attachInterface<vector::VectorScaleOpInterface>(
*ctx);
});
}