CIRCT 20.0.0git
Loading...
Searching...
No Matches
TranslateRegistration.cpp
Go to the documentation of this file.
1//===- TranslateRegistration.cpp - Register translation -------------------===//
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
17#include "mlir/IR/BuiltinOps.h"
18#include "mlir/Tools/mlir-translate/Translation.h"
19
20using namespace mlir;
21
22namespace circt {
23namespace debug {
24
25static void registerDialects(DialectRegistry &registry) {
26 registry.insert<comb::CombDialect>();
27 registry.insert<debug::DebugDialect>();
28 registry.insert<emit::EmitDialect>();
29 registry.insert<hw::HWDialect>();
30 registry.insert<seq::SeqDialect>();
31 registry.insert<sv::SVDialect>();
32 registry.insert<om::OMDialect>();
33}
34
36 TranslateFromMLIRRegistration reg(
37 "dump-di", "dump debug information in human-readable form",
38 [](ModuleOp op, raw_ostream &output) {
39 return dumpDebugInfo(op, output);
40 },
42}
43
45 static llvm::cl::opt<std::string> directory(
46 "hgldd-output-dir", llvm::cl::desc("Output directory for HGLDD files"),
47 llvm::cl::init(""));
48 static llvm::cl::opt<std::string> sourcePrefix(
49 "hgldd-source-prefix", llvm::cl::desc("Prefix for source file locations"),
50 llvm::cl::init(""));
51 static llvm::cl::opt<std::string> outputPrefix(
52 "hgldd-output-prefix", llvm::cl::desc("Prefix for output file locations"),
53 llvm::cl::init(""));
54 static llvm::cl::opt<bool> onlyExistingFileLocs(
55 "hgldd-only-existing-file-locs",
56 llvm::cl::desc("Only consider locations in files that exist on disk"),
57 llvm::cl::init(false));
58
59 auto getOptions = [] {
61 opts.sourceFilePrefix = sourcePrefix;
62 opts.outputFilePrefix = outputPrefix;
63 opts.outputDirectory = directory;
64 opts.onlyExistingFileLocs = onlyExistingFileLocs;
65 return opts;
66 };
67
68 static TranslateFromMLIRRegistration reg1(
69 "emit-hgldd", "emit HGLDD debug information",
70 [=](ModuleOp op, raw_ostream &output) {
71 return emitHGLDD(op, output, getOptions());
72 },
74
75 static TranslateFromMLIRRegistration reg2(
76 "emit-split-hgldd", "emit HGLDD debug information as separate files",
77 [=](ModuleOp op, raw_ostream &output) {
78 return emitSplitHGLDD(op, getOptions());
79 },
81}
82
87
88} // namespace debug
89} // namespace circt
LogicalResult emitHGLDD(Operation *module, llvm::raw_ostream &os, const EmitHGLDDOptions &options={})
Serialize the debug information in the given module into the HGLDD format and writes it to output.
void registerTranslations()
Register all debug information emission flavors as from-MLIR translations.
LogicalResult emitSplitHGLDD(Operation *module, const EmitHGLDDOptions &options={})
Serialize the debug information in the given module into the HGLDD format and emit one companion HGLD...
static void registerDialects(DialectRegistry &registry)
LogicalResult dumpDebugInfo(Operation *module, llvm::raw_ostream &os)
Dump the debug information in the given module in a human-readable format.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition debug.py:1
Options for HGLDD emission.
Definition DebugInfo.h:29
bool onlyExistingFileLocs
Only consider location information for files that actually exist on disk.
Definition DebugInfo.h:44
StringRef outputDirectory
The directory in which to place HGLDD output files.
Definition DebugInfo.h:39
StringRef sourceFilePrefix
A prefix prepended to all source file locations.
Definition DebugInfo.h:33
StringRef outputFilePrefix
A prefix prepended to all output file locations.
Definition DebugInfo.h:37