CIRCT  19.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 
15 #include "circt/Target/DebugInfo.h"
16 #include "mlir/IR/BuiltinOps.h"
17 #include "mlir/Tools/mlir-translate/Translation.h"
18 
19 using namespace mlir;
20 
21 namespace circt {
22 namespace debug {
23 
24 static void registerDialects(DialectRegistry &registry) {
25  registry.insert<comb::CombDialect>();
26  registry.insert<debug::DebugDialect>();
27  registry.insert<hw::HWDialect>();
28  registry.insert<seq::SeqDialect>();
29  registry.insert<sv::SVDialect>();
30  registry.insert<om::OMDialect>();
31 }
32 
34  TranslateFromMLIRRegistration reg(
35  "dump-di", "dump debug information in human-readable form",
36  [](ModuleOp op, raw_ostream &output) {
37  return dumpDebugInfo(op, output);
38  },
40 }
41 
43  static llvm::cl::opt<std::string> directory(
44  "hgldd-output-dir", llvm::cl::desc("Output directory for HGLDD files"),
45  llvm::cl::init(""));
46  static llvm::cl::opt<std::string> sourcePrefix(
47  "hgldd-source-prefix", llvm::cl::desc("Prefix for source file locations"),
48  llvm::cl::init(""));
49  static llvm::cl::opt<std::string> outputPrefix(
50  "hgldd-output-prefix", llvm::cl::desc("Prefix for output file locations"),
51  llvm::cl::init(""));
52  static llvm::cl::opt<bool> onlyExistingFileLocs(
53  "hgldd-only-existing-file-locs",
54  llvm::cl::desc("Only consider locations in files that exist on disk"),
55  llvm::cl::init(false));
56 
57  auto getOptions = [] {
58  EmitHGLDDOptions opts;
59  opts.sourceFilePrefix = sourcePrefix;
60  opts.outputFilePrefix = outputPrefix;
61  opts.outputDirectory = directory;
62  opts.onlyExistingFileLocs = onlyExistingFileLocs;
63  return opts;
64  };
65 
66  static TranslateFromMLIRRegistration reg1(
67  "emit-hgldd", "emit HGLDD debug information",
68  [=](ModuleOp op, raw_ostream &output) {
69  return emitHGLDD(op, output, getOptions());
70  },
72 
73  static TranslateFromMLIRRegistration reg2(
74  "emit-split-hgldd", "emit HGLDD debug information as separate files",
75  [=](ModuleOp op, raw_ostream &output) {
76  return emitSplitHGLDD(op, getOptions());
77  },
79 }
80 
84 }
85 
86 } // namespace debug
87 } // 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.
This file defines an intermediate representation for circuits acting as an abstraction for constraint...
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:20
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