9 #ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H 10 #define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H 24 #include <type_traits> 45 return Writer->getOffset();
47 return Reader->getOffset();
61 : Streamer(&Streamer) {}
69 return (Streamer !=
nullptr) && (Reader ==
nullptr) && (Writer ==
nullptr);
72 return (Reader !=
nullptr) && (Streamer ==
nullptr) && (Writer ==
nullptr);
75 return (Writer !=
nullptr) && (Streamer ==
nullptr) && (Reader ==
nullptr);
83 StringRef((reinterpret_cast<const char *>(&Value)),
sizeof(Value));
84 Streamer->EmitBytes(BytesSR);
85 incrStreamedLen(
sizeof(
T));
90 return Writer->writeObject(Value);
93 if (
auto EC = Reader->readObject(ValuePtr))
101 emitComment(Comment);
102 Streamer->EmitIntValue((
int)Value,
sizeof(
T));
103 incrStreamedLen(
sizeof(
T));
108 return Writer->writeInteger(Value);
110 return Reader->readInteger(Value);
114 if (!isStreaming() &&
sizeof(Value) > maxFieldLength())
117 using U =
typename std::underlying_type<T>::type;
120 if (isWriting() || isStreaming())
121 X = static_cast<U>(Value);
123 if (
auto EC = mapInteger(X, Comment))
127 Value = static_cast<T>(X);
133 Error mapEncodedInteger(uint64_t &Value,
const Twine &Comment =
"");
138 Error mapStringZVectorZ(std::vector<StringRef> &Value,
139 const Twine &Comment =
"");
141 template <
typename SizeType,
typename T,
typename ElementMapper>
143 const Twine &Comment =
"") {
146 Size =
static_cast<SizeType
>(Items.size());
147 emitComment(Comment);
148 Streamer->EmitIntValue(Size,
sizeof(Size));
149 incrStreamedLen(
sizeof(Size));
151 for (
auto &
X : Items) {
152 if (
auto EC = Mapper(*
this,
X))
155 }
else if (isWriting()) {
156 Size =
static_cast<SizeType
>(Items.size());
157 if (
auto EC = Writer->writeInteger(Size))
160 for (
auto &
X : Items) {
161 if (
auto EC = Mapper(*
this,
X))
165 if (
auto EC = Reader->readInteger(Size))
167 for (SizeType
I = 0;
I <
Size; ++
I) {
168 typename T::value_type Item;
169 if (
auto EC = Mapper(*
this, Item))
171 Items.push_back(Item);
178 template <
typename T,
typename ElementMapper>
180 const Twine &Comment =
"") {
181 emitComment(Comment);
182 if (isStreaming() || isWriting()) {
183 for (
auto &Item : Items) {
184 if (
auto EC = Mapper(*
this, Item))
188 typename T::value_type
Field;
190 while (!Reader->empty() && Reader->peek() < 0xf0 ) {
191 if (
auto EC = Mapper(*
this, Field))
193 Items.push_back(Field);
200 Error mapByteVectorTail(std::vector<uint8_t> &Bytes,
201 const Twine &Comment =
"");
213 if (isStreaming() && Streamer->isVerboseAsm())
214 Streamer->AddRawComment(T);
218 void emitEncodedSignedInteger(
const int64_t &Value,
219 const Twine &Comment =
"");
220 void emitEncodedUnsignedInteger(
const uint64_t &Value,
221 const Twine &Comment =
"");
222 Error writeEncodedSignedInteger(
const int64_t &Value);
223 Error writeEncodedUnsignedInteger(
const uint64_t &Value);
225 void incrStreamedLen(
const uint64_t &Len) {
230 void resetStreamedLen() {
235 void emitComment(
const Twine &Comment) {
236 if (isStreaming() && Streamer->isVerboseAsm()) {
237 Twine TComment(Comment);
239 Streamer->AddComment(TComment);
250 assert(CurrentOffset >= BeginOffset);
252 uint32_t BytesUsed = CurrentOffset - BeginOffset;
253 if (BytesUsed >= *MaxLength)
255 return *MaxLength - BytesUsed;
264 uint64_t StreamedLen = 0;
270 #endif // LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H Error mapVectorN(T &Items, const ElementMapper &Mapper, const Twine &Comment="")
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
virtual std::string getTypeName(TypeIndex TI)=0
This class represents lattice values for constants.
virtual bool isVerboseAsm()=0
Error mapObject(T &Value)
bool isTriviallyEmpty() const
Check if this twine is trivially empty; a false return value does not necessarily mean the twine is e...
CodeViewRecordIO(BinaryStreamWriter &Writer)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This represents the 'GUID' type from windows.h.
Error mapVectorTail(T &Items, const ElementMapper &Mapper, const Twine &Comment="")
Error mapEnum(T &Value, const Twine &Comment="")
Error mapInteger(T &Value, const Twine &Comment="")
Provides write only access to a subclass of WritableBinaryStream.
CodeViewRecordIO(BinaryStreamReader &Reader)
virtual void EmitBytes(StringRef Data)=0
void emitRawComment(const Twine &T)
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t getStreamedLen()
virtual void EmitIntValue(uint64_t Value, unsigned Size)=0
static ErrorSuccess success()
Create a success value.
virtual void AddRawComment(const Twine &T)=0
virtual ~CodeViewRecordStreamer()=default
virtual void AddComment(const Twine &T)=0
CodeViewRecordIO(CodeViewRecordStreamer &Streamer)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
virtual void EmitBinaryData(StringRef Data)=0