13#include "llvm/ADT/SmallString.h"
17#define GEN_PASS_DEF_INSERTTESTTOFILEMAPPINGPASS
18#include "circt/Dialect/RTG/Transforms/RTGPasses.h.inc"
31struct InsertTestToFileMappingPass
32 :
public rtg::impl::InsertTestToFileMappingPassBase<
33 InsertTestToFileMappingPass> {
35 void runOnOperation()
override;
39void InsertTestToFileMappingPass::runOnOperation() {
40 SmallVector<TestOp> tests(getOperation().getOps<TestOp>());
41 auto loc = getOperation().getLoc();
43 OpBuilder builder = OpBuilder::atBlockEnd(getOperation().getBody());
44 auto fileOp = emit::FileOp::create(builder, loc, path);
45 builder.setInsertionPointToStart(fileOp.getBody());
46 for (
auto testOp : tests)
47 emit::RefOp::create(builder, loc, testOp.getSymNameAttr());
52 if (path.empty() || path ==
"-") {
53 emitError(loc,
"path must be specified when split-output is set");
54 return signalPassFailure();
57 for (
auto testOp : tests) {
58 OpBuilder builder = OpBuilder::atBlockEnd(getOperation().getBody());
59 llvm::SmallString<128> filename(path.getValue());
61 auto fileOp = emit::FileOp::create(builder, loc, filename);
62 OpBuilder::InsertionGuard guard(builder);
63 builder.setInsertionPointToStart(fileOp.getBody());
64 emit::RefOp::create(builder, loc, testOp.getSymNameAttr());
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
void appendPossiblyAbsolutePath(llvm::SmallVectorImpl< char > &base, const llvm::Twine &suffix)
Append a path to an existing path, replacing it if the other path is absolute.