9#ifndef LLVM_TABLEGEN_STRINGTOOFFSETTABLE_H
10#define LLVM_TABLEGEN_STRINGTOOFFSETTABLE_H
27 std::string AggregateString;
37 size_t size()
const {
return AggregateString.size(); }
40 auto [
II, Inserted] = StringOffset.
insert({Str,
size()});
43 AggregateString.append(Str.begin(), Str.end());
45 AggregateString +=
'\0';
54 auto II = StringOffset.
find(Str);
55 if (
II == StringOffset.
end())
72 const Twine &Indent =
"")
const {
75#pragma GCC diagnostic push
76#pragma GCC diagnostic ignored "-Woverlength-strings"
78{0}static constexpr char {1}Storage[] = )",
84 bool UseChars = AggregateString.size() > (64 * 1024);
85 OS << (UseChars ?
"{\n" :
"\n");
87 llvm::ListSeparator LineSep(UseChars ?
",\n" :
"\n");
92 assert(Strings.front().empty() &&
"Expected empty initial string!");
93 assert(Strings.back().empty() &&
94 "Expected empty string at the end due to terminators!");
97 OS << LineSep << Indent <<
" ";
101 OS.write_escaped(Str);
106 llvm::ListSeparator CharSep(
", ");
108 OS << CharSep <<
"'";
112 OS << CharSep <<
"'\\0'";
114 OS << LineSep << Indent << (UseChars ?
"};" :
" ;");
118#pragma GCC diagnostic pop
121{0}static constexpr llvm::StringTable {1} =
134 unsigned CharsPrinted = 0;
135 for (
unsigned i = 0, e = EscapedStr.
size(); i != e; ++i) {
136 if (CharsPrinted > 70) {
144 if (EscapedStr[i] !=
'\\')
147 assert(i + 1 < EscapedStr.size() &&
"Incomplete escape sequence!");
148 if (
isDigit(EscapedStr[i + 1])) {
150 "Expected 3 digit octal escape!");
151 O << EscapedStr[++i];
152 O << EscapedStr[++i];
153 O << EscapedStr[++i];
156 O << EscapedStr[++i];
This file defines the StringMap class.
uint64_t IntrinsicInst * II
static bool isDigit(const char C)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
iterator find(StringRef Key)
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
StringRef - Represent a constant reference to a string, i.e.
StringToOffsetTable - This class uniques a bunch of nul-terminated strings and keeps track of their o...
void EmitString(raw_ostream &O) const
void EmitStringTableDef(raw_ostream &OS, const Twine &Name, const Twine &Indent="") const
unsigned GetOrAddStringOffset(StringRef Str, bool appendZero=true)
std::optional< unsigned > GetStringOffset(StringRef Str) const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '\t', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an esca...
A raw_ostream that writes to an SmallVector or SmallString.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)