CIRCT  20.0.0git
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 
16 #include "circt/Target/DebugInfo.h"
17 #include "mlir/IR/BuiltinOps.h"
18 #include "mlir/Tools/mlir-translate/Translation.h"
19 
20 using namespace mlir;
21 
22 namespace circt {
23 namespace debug {
24 
25 static 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 = [] {
60  EmitHGLDDOptions opts;
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 
86 }
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.
Definition: EmitHGLDD.cpp:1032
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...
Definition: EmitHGLDD.cpp:1043
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: DebugAnalysis.h:21
Definition: debug.py:1
def reg(value, clock, reset=None, reset_value=None, name=None, sym_name=None)
Definition: seq.py:21
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