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

Function GetWordsFromScalarIntConstant

source/opt/folding_rules.cpp:138–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138std::vector<uint32_t> GetWordsFromScalarIntConstant(
139 const analysis::IntConstant* c) {
140 assert(c != nullptr);
141 uint32_t width = c->type()->AsInteger()->width();
142 assert(width == 8 || width == 16 || width == 32 || width == 64);
143 if (width == 64) {
144 uint64_t uval = static_cast<uint64_t>(c->GetU64());
145 return ExtractInts(uval);
146 }
147 // Section 2.2.1 of the SPIR-V spec guarantees that all integer types
148 // smaller than 32-bits are automatically zero or sign extended to 32-bits.
149 return {c->GetU32BitValue()};
150}
151
152std::vector<uint32_t> GetWordsFromScalarFloatConstant(
153 const analysis::FloatConstant* c) {

Calls 6

ExtractIntsFunction · 0.85
AsIntegerMethod · 0.80
GetU64Method · 0.80
GetU32BitValueMethod · 0.80
widthMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected