9#ifndef LLVM_TABLEGEN_STRINGTOOFFSETTABLE_H
10#define LLVM_TABLEGEN_STRINGTOOFFSETTABLE_H
27 std::string AggregateString;
31 size_t size()
const {
return AggregateString.size(); }
34 auto [
II, Inserted] = StringOffset.
insert({Str,
size()});
37 AggregateString.append(Str.begin(), Str.end());
39 AggregateString +=
'\0';
48 auto II = StringOffset.
find(Str);
49 if (
II == StringOffset.
end())
57 const Twine &Indent =
" ")
const {
60#pragma GCC diagnostic push
61#pragma GCC diagnostic ignored "-Woverlength-strings"
66 for (
StringRef Str : split(AggregateString,
'\0')) {
67 OS <<
"\n" << Indent <<
" \"";
68 OS.write_escaped(Str);
73#pragma GCC diagnostic pop
85 unsigned CharsPrinted = 0;
86 for (
unsigned i = 0, e = EscapedStr.
size(); i != e; ++i) {
87 if (CharsPrinted > 70) {
95 if (EscapedStr[i] !=
'\\')
98 assert(i + 1 < EscapedStr.size() &&
"Incomplete escape sequence!");
99 if (
isDigit(EscapedStr[i + 1])) {
101 "Expected 3 digit octal escape!");
102 O << EscapedStr[++i];
103 O << EscapedStr[++i];
104 O << EscapedStr[++i];
107 O << EscapedStr[++i];
117 assert(AggregateString.find(
')') == std::string::npos &&
118 "can't emit raw string with closing parens");
121 for (
char C : AggregateString) {
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...
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 EmitCharArray(raw_ostream &O)
Emit the string using character literals.
unsigned GetOrAddStringOffset(StringRef Str, bool appendZero=true)
void EmitStringLiteralDef(raw_ostream &OS, const Twine &Decl, const Twine &Indent=" ") const
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)