1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
// slang-serialize-container.h
#ifndef SLANG_SERIALIZE_CONTAINER_H
#define SLANG_SERIALIZE_CONTAINER_H
#include "../core/slang-riff.h"
#include "slang-ir-insts.h"
#include "slang-profile.h"
#include "slang-serialize-types.h"
namespace Slang
{
class EndToEndCompileRequest;
struct SerialContainerUtil
{
struct WriteOptions
{
/// The source manager that is used by `SourceLoc`s in the input.
///
/// If null, source location information will not be serialized
/// as part of the output.
///
/// If non-null, it must be the `SourceManager` that was used to
/// create any `SourceLoc`s that appear in the module(s) that get
/// written.
///
SourceManager* sourceManagerToUseWhenSerializingSourceLocs =
nullptr; ///< The source manager used for the SourceLoc in the input
};
struct ReadOptions
{
Session* session = nullptr;
SourceManager* sourceManager = nullptr;
NamePool* namePool = nullptr;
SharedASTBuilder* sharedASTBuilder = nullptr;
ASTBuilder* astBuilder =
nullptr; // Optional. If not provided will create one in SerialContainerData.
Linkage* linkage = nullptr;
DiagnosticSink* sink = nullptr;
bool readHeaderOnly = false;
String modulePath;
};
/// Verify IR serialization
static SlangResult verifyIRSerialize(
IRModule* module,
Session* session,
const WriteOptions& options);
/// Write the request to the stream
static SlangResult write(
FrontEndCompileRequest* frontEndReq,
const WriteOptions& options,
Stream* stream);
static SlangResult write(
EndToEndCompileRequest* request,
const WriteOptions& options,
Stream* stream);
static SlangResult write(Module* module, const WriteOptions& options, Stream* stream);
};
struct StringChunk : RIFF::DataChunk
{
public:
String getValue() const;
};
struct IRModuleChunk : RIFF::ListChunk
{
};
struct ASTModuleChunk : RIFF::ListChunk
{
};
struct ModuleChunk : RIFF::ListChunk
{
public:
static ModuleChunk const* find(RIFF::ListChunk const* baseChunk);
String getName() const;
IRModuleChunk const* findIR() const;
ASTModuleChunk const* findAST() const;
SHA1::Digest getDigest() const;
RIFF::ChunkList<StringChunk> getFileDependencies() const;
};
struct EntryPointChunk : RIFF::ListChunk
{
public:
String getMangledName() const;
String getName() const;
Profile getProfile() const;
};
struct ContainerChunk : RIFF::ListChunk
{
public:
static ContainerChunk const* find(RIFF::ListChunk const* baseChunk);
RIFF::ChunkList<ModuleChunk> getModules() const;
RIFF::ChunkList<EntryPointChunk> getEntryPoints() const;
};
struct DebugChunk : RIFF::ListChunk
{
public:
/// Search for a debug information chunk.
static DebugChunk const* find(RIFF::ListChunk const* baseChunk);
/// Search for a debug information chunk.
///
/// The search will initially look in `baseChunk`, but
/// if that fails, it will fall back to the `containerChunk`
/// if that is non-null.
///
static DebugChunk const* find(
RIFF::ListChunk const* baseChunk,
RIFF::ListChunk const* containerChunk);
};
SlangResult readSourceLocationsFromDebugChunk(
DebugChunk const* debugChunk,
SourceManager* sourceManager,
RefPtr<SerialSourceLocReader>& outReader);
} // namespace Slang
#endif
|