CIRCT 22.0.0git
Loading...
Searching...
No Matches
Debug.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//
9// Utilities related to generating run-time debug information.
10//
11//===----------------------------------------------------------------------===//
12
13#include "circt/Support/Debug.h"
14#include "llvm/ADT/Twine.h"
15#include "llvm/Support/Debug.h"
16
17llvm::raw_ostream &circt::debugHeader(const llvm::Twine &str, unsigned width) {
18 auto &os = llvm::dbgs();
19 auto start = os.tell();
20 os << "===- " << str << " ";
21 auto endAct = os.tell() + 4; // 4 for "-==="
22 auto endExp = start + width;
23 while (endAct < endExp) {
24 os << '-';
25 ++endAct;
26 }
27 os << "-===";
28 return os;
29}
30
31llvm::raw_ostream &circt::debugPassHeader(const mlir::Pass *pass,
32 unsigned width) {
33 return debugHeader(llvm::Twine("Running ") + pass->getName());
34}
35
36llvm::raw_ostream &circt::debugFooter(unsigned width) {
37 auto &os = llvm::dbgs();
38 auto start = os.tell();
39 os << "===";
40 auto endAct = os.tell() + 3; // 3 for trailing "==="
41 auto endExp = start + width;
42 while (endAct < endExp) {
43 os << '-';
44 ++endAct;
45 }
46 os << "===";
47 return os;
48}
llvm::raw_ostream & debugHeader(const llvm::Twine &str, unsigned width=80)
Write a "header"-like string to the debug stream with a certain width.
Definition Debug.cpp:17
llvm::raw_ostream & debugPassHeader(const mlir::Pass *pass, unsigned width=80)
Write a boilerplate header for a pass to the debug stream.
Definition Debug.cpp:31
llvm::raw_ostream & debugFooter(unsigned width=80)
Write a boilerplate footer to the debug stream to indicate that a pass has ended.
Definition Debug.cpp:36