CIRCT 20.0.0git
Loading...
Searching...
No Matches
ArcCostModel.h
Go to the documentation of this file.
1//===- ArcCostModel.h -----------------------------------------------------===//
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#ifndef CIRCT_DIALECT_ARC_ARCCOSTMODEL_H
10#define CIRCT_DIALECT_ARC_ARCCOSTMODEL_H
11
13#include "mlir/IR/Operation.h"
14#include "mlir/Pass/AnalysisManager.h"
15
16using namespace mlir;
17
18namespace circt {
19namespace arc {
20
22 size_t normalCost{0};
23 size_t packingCost{0};
24 size_t shufflingCost{0};
26 size_t totalCost() const {
28 }
30 this->normalCost += other.normalCost;
31 this->packingCost += other.packingCost;
32 this->shufflingCost += other.shufflingCost;
34 return *this;
35 }
36};
37
39public:
40 OperationCosts getCost(Operation *op);
41
42private:
44
45 // gets the cost to pack the vectors we have some cases we need to consider:
46 // 1: the input is scalar so we can give it a cost of 1
47 // 2: the input is a result of another vector but with no shuffling so the
48 // is 0
49 // 3: the input is a result of another vector but with some shuffling so
50 // the cost is the (number of out of order elements) * 2
51 // 4: the input is a mix of some vectors:
52 // a) same order we multiply by 2
53 // b) shuffling we multiply by 3
54 OperationCosts getInputVectorsCost(VectorizeOp vecOp);
55 size_t getShufflingCost(const ValueRange &inputVec, bool isSame = false);
56 DenseMap<Operation *, OperationCosts> opCostCache;
57};
58
59} // namespace arc
60} // namespace circt
61
62#endif // CIRCT_DIALECT_ARC_ARCCOSTMODEL_H
OperationCosts getInputVectorsCost(VectorizeOp vecOp)
DenseMap< Operation *, OperationCosts > opCostCache
OperationCosts computeOperationCost(Operation *op)
OperationCosts getCost(Operation *op)
size_t getShufflingCost(const ValueRange &inputVec, bool isSame=false)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
OperationCosts & operator+=(const OperationCosts &other)