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 
13 #include "../PassDetail.h"
19 
20 using namespace circt;
21 
22 namespace {
23 
24 struct TestApplyLoweringOptionPass
25  : public TestApplyLoweringOptionBase<TestApplyLoweringOptionPass> {
26  TestApplyLoweringOptionPass() = default;
27  void runOnOperation() override {
28  if (!options.hasValue()) {
29  markAllAnalysesPreserved();
30  return;
31  }
32  LoweringOptions opts(options, [this](llvm::Twine tw) {
33  getOperation().emitError(tw);
34  signalPassFailure();
35  });
36  opts.setAsAttribute(getOperation());
37  }
38 };
39 } // namespace
40 
41 std::unique_ptr<mlir::Pass> circt::createTestApplyLoweringOptionPass() {
42  return std::make_unique<TestApplyLoweringOptionPass>();
43 }
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.