CIRCT 22.0.0git
Loading...
Searching...
No Matches
PrintTestNamesPass.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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
11#include "circt/Support/Path.h"
12
13namespace circt {
14namespace rtg {
15#define GEN_PASS_DEF_PRINTTESTNAMESPASS
16#include "circt/Dialect/RTG/Transforms/RTGPasses.h.inc"
17} // namespace rtg
18} // namespace circt
19
20using namespace mlir;
21using namespace circt;
22
23//===----------------------------------------------------------------------===//
24// Print Test Names Pass
25//===----------------------------------------------------------------------===//
26
27namespace {
28struct PrintTestNamesPass
29 : public rtg::impl::PrintTestNamesPassBase<PrintTestNamesPass> {
30 using Base::Base;
31 void runOnOperation() override;
32};
33} // namespace
34
35void PrintTestNamesPass::runOnOperation() {
36 auto output = createOutputFile(filename, "", [&]() {
37 return mlir::emitError(UnknownLoc::get(&getContext()));
38 });
39 if (!output)
40 return signalPassFailure();
41
42 llvm::raw_ostream &os = output->os();
43
44 for (auto testOp : getOperation().getOps<rtg::TestOp>())
45 os << testOp.getSymName() << "," << testOp.getTemplateName() << "\n";
46
47 output->keep();
48 markAllAnalysesPreserved();
49}
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
std::unique_ptr< llvm::ToolOutputFile > createOutputFile(StringRef filename, StringRef dirname, function_ref< InFlightDiagnostic()> emitError)
Creates an output file with the given filename in the specified directory.
Definition Path.cpp:37
Definition rtg.py:1