MLIR
22.0.0git
lib
Dialect
Vector
IR
ValueBoundsOpInterfaceImpl.cpp
Go to the documentation of this file.
1
//===- ValueBoundsOpInterfaceImpl.cpp - Impl. of ValueBoundsOpInterface ---===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "
mlir/Dialect/Vector/IR/ValueBoundsOpInterfaceImpl.h
"
10
11
#include "
mlir/Dialect/Vector/IR/ScalableValueBoundsConstraintSet.h
"
12
#include "
mlir/Dialect/Vector/IR/VectorOps.h
"
13
#include "
mlir/Interfaces/ValueBoundsOpInterface.h
"
14
15
using namespace
mlir
;
16
17
namespace
mlir::vector
{
18
namespace
{
19
20
struct
VectorScaleOpInterface
21
:
public
ValueBoundsOpInterface::ExternalModel<VectorScaleOpInterface,
22
VectorScaleOp> {
23
void
populateBoundsForIndexValue(Operation *op, Value value,
24
ValueBoundsConstraintSet &cstr)
const
{
25
auto
*scalableCstr = dyn_cast<ScalableValueBoundsConstraintSet>(&cstr);
26
if
(!scalableCstr)
27
return
;
28
auto
vscaleOp = cast<VectorScaleOp>(op);
29
assert(value == vscaleOp.getResult() &&
"invalid value"
);
30
if
(
auto
vscale = scalableCstr->getVscaleValue()) {
31
// All copies of vscale are equivalent.
32
scalableCstr->bound(value) == cstr.
getExpr
(vscale);
33
}
else
{
34
// We know vscale is confined to [vscaleMin, vscaleMax].
35
scalableCstr->bound(value) >= scalableCstr->getVscaleMin();
36
scalableCstr->bound(value) <= scalableCstr->getVscaleMax();
37
scalableCstr->setVscale(vscaleOp);
38
}
39
}
40
};
41
42
}
// namespace
43
}
// namespace mlir::vector
44
45
void
mlir::vector::registerValueBoundsOpInterfaceExternalModels
(
46
DialectRegistry
®istry) {
47
registry.
addExtension
(+[](
MLIRContext
*ctx, vector::VectorDialect *dialect) {
48
vector::VectorScaleOp::attachInterface<vector::VectorScaleOpInterface>(
49
*ctx);
50
});
51
}
ScalableValueBoundsConstraintSet.h
ValueBoundsOpInterface.h
VectorOps.h
ValueBoundsOpInterfaceImpl.h
mlir::DialectRegistry
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Definition
DialectRegistry.h:139
mlir::DialectRegistry::addExtension
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
Definition
DialectRegistry.h:215
mlir::MLIRContext
MLIRContext is the top-level object for a collection of MLIR operations.
Definition
MLIRContext.h:63
mlir::ValueBoundsConstraintSet::getExpr
AffineExpr getExpr(Value value, std::optional< int64_t > dim=std::nullopt)
Return an expression that represents the given index-typed value or shaped value dimension.
Definition
ValueBoundsOpInterface.cpp:203
mlir::vector
Definition
ConvertVectorToLLVM.h:22
mlir::vector::registerValueBoundsOpInterfaceExternalModels
void registerValueBoundsOpInterfaceExternalModels(DialectRegistry ®istry)
Definition
ValueBoundsOpInterfaceImpl.cpp:45
mlir
Include the generated interface declarations.
Definition
AliasAnalysis.h:19
Generated on
for MLIR by
1.14.0