CIRCT  19.0.0git
LowerIntrinsics.cpp
Go to the documentation of this file.
1 //===- LowerIntrinsics.cpp - Lower Intrinsics -------------------*- C++ -*-===//
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 file defines the LowerIntrinsics pass. This pass processes FIRRTL
10 // generic intrinsic operations and rewrites to their implementation.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "PassDetails.h"
16 
17 using namespace circt;
18 using namespace firrtl;
19 
20 //===----------------------------------------------------------------------===//
21 // Pass Infrastructure
22 //===----------------------------------------------------------------------===//
23 
24 namespace {
25 struct LowerIntrinsicsPass : public LowerIntrinsicsBase<LowerIntrinsicsPass> {
26  LogicalResult initialize(MLIRContext *context) override;
27  void runOnOperation() override;
28 
29  std::shared_ptr<IntrinsicLowerings> lowering;
30 };
31 } // namespace
32 
33 /// Initialize the conversions for use during execution.
34 LogicalResult LowerIntrinsicsPass::initialize(MLIRContext *context) {
35  IntrinsicLowerings lowering(context);
36 
37  IntrinsicLoweringInterfaceCollection loweringCollection(context);
38  loweringCollection.populateIntrinsicLowerings(lowering);
39 
40  this->lowering = std::make_shared<IntrinsicLowerings>(std::move(lowering));
41  return success();
42 }
43 
44 // This is the main entrypoint for the lowering pass.
45 void LowerIntrinsicsPass::runOnOperation() {
46  auto result = lowering->lower(getOperation());
47  if (failed(result))
48  return signalPassFailure();
49 
50  numConverted += *result;
51 
52  if (*result == 0)
53  markAllAnalysesPreserved();
54 }
55 
56 /// This is the pass constructor.
57 std::unique_ptr<mlir::Pass> circt::firrtl::createLowerIntrinsicsPass() {
58  return std::make_unique<LowerIntrinsicsPass>();
59 }
Lowering helper which collects all intrinsic converters.
std::unique_ptr< mlir::Pass > createLowerIntrinsicsPass()
This is the pass constructor.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21