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

Method ComputeHashValue

source/opt/types.cpp:205–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205size_t Type::ComputeHashValue(size_t hash, SeenTypes* seen) const {
206 // Linear search through a dense, cache coherent vector is faster than O(log
207 // n) search in a complex data structure (eg std::set) for the generally small
208 // number of nodes. It also skips the overhead of an new/delete per Type
209 // (when inserting/removing from a set).
210 if (std::find(seen->begin(), seen->end(), this) != seen->end()) {
211 return hash;
212 }
213
214 seen->push_back(this);
215
216 hash = hash_combine(hash, uint32_t(kind_));
217 for (const auto& d : decorations_) {
218 hash = hash_combine(hash, d);
219 }
220
221 switch (kind_) {
222#define DeclareKindCase(type) \
223 case k##type: \
224 hash = As##type()->ComputeExtraStateHash(hash, seen); \
225 break
226 DeclareKindCase(Void);
227 DeclareKindCase(Bool);
228 DeclareKindCase(Integer);
229 DeclareKindCase(Float);
230 DeclareKindCase(Vector);
231 DeclareKindCase(Matrix);
232 DeclareKindCase(Image);
233 DeclareKindCase(Sampler);
234 DeclareKindCase(SampledImage);
235 DeclareKindCase(Array);
236 DeclareKindCase(RuntimeArray);
237 DeclareKindCase(NodePayloadArrayAMDX);
238 DeclareKindCase(Struct);
239 DeclareKindCase(Opaque);
240 DeclareKindCase(Pointer);
241 DeclareKindCase(Function);
242 DeclareKindCase(Event);
243 DeclareKindCase(DeviceEvent);
244 DeclareKindCase(ReserveId);
245 DeclareKindCase(Queue);
246 DeclareKindCase(Pipe);
247 DeclareKindCase(ForwardPointer);
248 DeclareKindCase(PipeStorage);
249 DeclareKindCase(NamedBarrier);
250 DeclareKindCase(AccelerationStructureNV);
251 DeclareKindCase(CooperativeMatrixNV);
252 DeclareKindCase(CooperativeMatrixKHR);
253 DeclareKindCase(CooperativeVectorNV);
254 DeclareKindCase(RayQueryKHR);
255 DeclareKindCase(HitObjectNV);
256 DeclareKindCase(HitObjectEXT);
257 DeclareKindCase(TensorLayoutNV);
258 DeclareKindCase(TensorViewNV);
259 DeclareKindCase(TensorARM);
260 DeclareKindCase(GraphARM);
261 DeclareKindCase(BufferEXT);
262#undef DeclareKindCase

Callers 1

ComputeExtraStateHashMethod · 0.80

Calls 6

findFunction · 0.85
hash_combineFunction · 0.85
pop_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected