MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / spvNamedIdAssignOrGet

Method spvNamedIdAssignOrGet

source/text_handler.cpp:189–215  ·  view source on GitHub ↗

This represents all of the data that is only valid for the duration of a single compilation.

Source from the content-addressed store, hash-verified

187// This represents all of the data that is only valid for the duration of
188// a single compilation.
189uint32_t AssemblyContext::spvNamedIdAssignOrGet(const char* textValue) {
190 if (!ids_to_preserve_.empty()) {
191 uint32_t id = 0;
192 if (spvtools::utils::ParseNumber(textValue, &id)) {
193 if (ids_to_preserve_.find(id) != ids_to_preserve_.end()) {
194 bound_ = std::max(bound_, id + 1);
195 return id;
196 }
197 }
198 }
199
200 const auto it = named_ids_.find(textValue);
201 if (it == named_ids_.end()) {
202 uint32_t id = next_id_++;
203 if (!ids_to_preserve_.empty()) {
204 while (ids_to_preserve_.find(id) != ids_to_preserve_.end()) {
205 id = next_id_++;
206 }
207 }
208
209 named_ids_.emplace(textValue, id);
210 bound_ = std::max(bound_, id + 1);
211 return id;
212 }
213
214 return it->second;
215}
216
217uint32_t AssemblyContext::getBound() const { return bound_; }
218

Callers 1

spvTextEncodeOperandFunction · 0.80

Calls 3

ParseNumberFunction · 0.85
emptyMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected