CIRCT  19.0.0git
ApplyLoweringOptions.cpp
Go to the documentation of this file.
1 //===- ApplyLoweringOptions.cpp - Test pass for adding lowering options ---===//
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 // Pass for testing purposes to apply lowering options ot a module.
10 //
11 //===----------------------------------------------------------------------===//
12 
18 #include "mlir/Pass/Pass.h"
19 
20 namespace circt {
21 #define GEN_PASS_DEF_TESTAPPLYLOWERINGOPTION
22 #include "circt/Conversion/Passes.h.inc"
23 } // namespace circt
24 
25 using namespace circt;
26 namespace {
27 
28 struct TestApplyLoweringOptionPass
29  : public circt::impl::TestApplyLoweringOptionBase<
30  TestApplyLoweringOptionPass> {
31  TestApplyLoweringOptionPass() = default;
32  void runOnOperation() override {
33  if (!optionsString.hasValue()) {
34  markAllAnalysesPreserved();
35  return;
36  }
37  LoweringOptions opts(optionsString, [this](llvm::Twine tw) {
38  getOperation().emitError(tw);
39  signalPassFailure();
40  });
41  opts.setAsAttribute(getOperation());
42  }
43 };
44 } // namespace
45 
46 std::unique_ptr<mlir::Pass> circt::createTestApplyLoweringOptionPass() {
47  return std::make_unique<TestApplyLoweringOptionPass>();
48 }
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
std::unique_ptr< mlir::Pass > createTestApplyLoweringOptionPass(llvm::StringRef options)
Options which control the emission from CIRCT to Verilog.
void setAsAttribute(mlir::ModuleOp module)
Write the verilog emitter options to a module's attributes.