CIRCT 20.0.0git
Loading...
Searching...
No Matches
PrintCostModel.cpp
Go to the documentation of this file.
1//===- DummyAnalysisTester.cpp --------------------------------------------===//
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// This is a dummy pass to test the cost model results it doesn't do any thing.
10// just walks over the ops to compute some statistics.
11//
12//===----------------------------------------------------------------------===//
13
17#include "mlir/IR/MLIRContext.h"
18#include "mlir/Pass/Pass.h"
19
20#define DEBUG_TYPE "arc-print-cost-model"
21
22namespace circt {
23namespace arc {
24#define GEN_PASS_DEF_PRINTCOSTMODEL
25#include "circt/Dialect/Arc/ArcPasses.h.inc"
26} // namespace arc
27} // namespace circt
28
29using namespace circt;
30using namespace arc;
31
32namespace {
33struct PrintCostModelPass
34 : public arc::impl::PrintCostModelBase<PrintCostModelPass> {
35 void runOnOperation() override;
36};
37} // namespace
38
39void PrintCostModelPass::runOnOperation() {
40 OperationCosts statVars;
41 ArcCostModel arcCostModel;
42 for (auto moduleOp : getOperation().getOps<hw::HWModuleOp>()) {
43 moduleOp.walk([&](Operation *op) { statVars += arcCostModel.getCost(op); });
44 }
45
46 moduleCost = statVars.totalCost();
47 packingCost = statVars.packingCost;
48 shufflingCost = statVars.shufflingCost;
49 vectoroizeOpsBodyCost = statVars.vectorizeOpsBodyCost;
50 allVectorizeOpsCost = statVars.packingCost + statVars.shufflingCost +
51 statVars.vectorizeOpsBodyCost;
52}
53
54std::unique_ptr<Pass> arc::createPrintCostModelPass() {
55 return std::make_unique<PrintCostModelPass>();
56}
OperationCosts getCost(Operation *op)
std::unique_ptr< mlir::Pass > createPrintCostModelPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition hw.py:1