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

Function IntToWords

source/fuzz/fuzzer_util.cpp:1479–1501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1477}
1478
1479std::vector<uint32_t> IntToWords(uint64_t value, uint32_t width,
1480 bool is_signed) {
1481 assert(width <= 64 && "The bit width should not be more than 64 bits");
1482
1483 // Sign-extend or zero-extend the last |width| bits of |value|, depending on
1484 // |is_signed|.
1485 if (is_signed) {
1486 // Sign-extend by shifting left and then shifting right, interpreting the
1487 // integer as signed.
1488 value = static_cast<int64_t>(value << (64 - width)) >> (64 - width);
1489 } else {
1490 // Zero-extend by shifting left and then shifting right, interpreting the
1491 // integer as unsigned.
1492 value = (value << (64 - width)) >> (64 - width);
1493 }
1494
1495 std::vector<uint32_t> result;
1496 result.push_back(static_cast<uint32_t>(value));
1497 if (width > 32) {
1498 result.push_back(static_cast<uint32_t>(value >> 32));
1499 }
1500 return result;
1501}
1502
1503bool TypesAreEqualUpToSign(opt::IRContext* ir_context, uint32_t type1_id,
1504 uint32_t type2_id) {

Callers 2

TESTFunction · 0.85

Calls 1

push_backMethod · 0.45

Tested by 1

TESTFunction · 0.68