CIRCT
20.0.0git
Loading...
Searching...
No Matches
lib
Support
PrettyPrinterHelpers.cpp
Go to the documentation of this file.
1
//===- PrettyPrinterHelpers.cpp - Pretty printing helpers -----------------===//
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
// Helper classes for using PrettyPrinter.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "
circt/Support/PrettyPrinterHelpers.h
"
14
15
#include "llvm/ADT/SmallString.h"
16
#include "llvm/Support/raw_ostream.h"
17
#include <array>
18
19
namespace
circt
{
20
namespace
pretty {
21
22
//===----------------------------------------------------------------------===//
23
// Convenience builders.
24
//===----------------------------------------------------------------------===//
25
26
void
TokenStringSaver::clear
() {
alloc
.Reset(); }
27
28
/// Add multiple non-breaking spaces as a single token.
29
void
detail::emitNBSP
(
unsigned
n, llvm::function_ref<
void
(
Token
)> add) {
30
static
const
std::array<char, 128> spaces = ([]()
constexpr
{
31
std::array<char, 128> s = {};
32
for
(
auto
&c : s)
33
c =
' '
;
34
return
s;
35
})();
36
37
const
auto
size = spaces.size();
38
if
(n <= size) {
39
if
(n != 0)
40
add(
StringToken
({spaces.data(), n}));
41
return
;
42
}
43
while
(n) {
44
auto
chunk = std::min<uint32_t>(n, size);
45
add(
StringToken
({spaces.data(), chunk}));
46
n -= chunk;
47
}
48
}
49
50
}
// end namespace pretty
51
}
// end namespace circt
PrettyPrinterHelpers.h
circt::pretty::TokenStringSaver::clear
void clear() override
PrettyPrinter::Listener::clear – indicates no external refs.
Definition
PrettyPrinterHelpers.cpp:26
circt::pretty::TokenStringSaver::alloc
llvm::BumpPtrAllocator alloc
Definition
PrettyPrinterHelpers.h:157
circt::pretty::Token
Definition
PrettyPrinter.h:51
circt::pretty::detail::emitNBSP
void emitNBSP(unsigned n, llvm::function_ref< void(Token)> add)
Add multiple non-breaking spaces as a single token.
Definition
PrettyPrinterHelpers.cpp:29
circt
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition
DebugAnalysis.h:21
circt::pretty::StringToken
Token types.
Definition
PrettyPrinter.h:138
Generated on Thu Jan 23 2025 00:07:33 for CIRCT by
1.9.8