11 #include "mlir/Dialect/Func/IR/FuncOps.h"
15 using namespace circt;
33 return computeOperationCost(op);
37 if (
auto it = opCostCache.find(op); it != opCostCache.end())
42 if (isa<circt::comb::ConcatOp>(op))
44 else if (isa<circt::comb::ExtractOp>(op))
46 else if (
auto vecOp = dyn_cast<arc::VectorizeOp>(op)) {
52 for (
auto ®ion : op->getRegions()) {
53 for (
auto &block : region) {
54 for (
auto &innerOp : block) {
60 }
else if (
auto callableOp = dyn_cast<CallOpInterface>(op)) {
62 if (
auto *calledOp = callableOp.resolveCallable())
63 return opCostCache[callableOp] = computeOperationCost(calledOp);
64 }
else if (isa<func::FuncOp, arc::DefineOp, mlir::ModuleOp>(op)) {
66 for (
auto ®ion : op->getRegions())
67 for (
auto &block : region)
68 for (
auto &innerOp : block)
69 costs += computeOperationCost(&innerOp);
73 return opCostCache[op] = costs;
78 for (
auto inputVec : vecOp.getInputs()) {
79 if (
auto otherVecOp = inputVec[0].getDefiningOp<VectorizeOp>();
80 all_of(inputVec.begin(), inputVec.end(), [&](
auto element) {
81 return element.template getDefiningOp<VectorizeOp>() == otherVecOp;
92 : getShufflingCost(inputVec,
true);
102 size_t ArcCostModel::getShufflingCost(
const ValueRange &inputVec,
bool isSame) {
103 size_t totalCost = 0;
105 auto vecOp = inputVec[0].getDefiningOp<VectorizeOp>();
106 for (
auto [elem, orig] : llvm::zip(inputVec, vecOp.getResults()))
113 for (
size_t i = 0; i < inputVec.size(); ++i) {
114 auto otherVecOp = inputVec[i].getDefiningOp<VectorizeOp>();
124 size_t idx = find(otherVecOp.getResults().begin(),
125 otherVecOp.getResults().end(), inputVec[i]) -
126 otherVecOp.getResults().begin();
@ DIFFERENTVECTORSHUFFLECOST
@ DIFFERENTVECTORNOSHUFFLE
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
size_t vectorizeOpsBodyCost