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

Method EvalConstantValInt64

source/val/validation_state.cpp:1803–1827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1801}
1802
1803bool ValidationState_t::EvalConstantValInt64(uint32_t id, int64_t* val) const {
1804 const Instruction* inst = FindDef(id);
1805 if (!inst) {
1806 assert(0 && "Instruction not found");
1807 return false;
1808 }
1809
1810 if (!IsIntScalarType(inst->type_id())) return false;
1811
1812 if (inst->opcode() == spv::Op::OpConstantNull) {
1813 *val = 0;
1814 } else if (inst->opcode() != spv::Op::OpConstant) {
1815 // Spec constant values cannot be evaluated so don't consider constant for
1816 // static validation
1817 return false;
1818 } else if (inst->words().size() == 4) {
1819 *val = int32_t(inst->word(3));
1820 } else {
1821 assert(inst->words().size() == 5);
1822 const uint32_t lo_word = inst->word(3);
1823 const uint32_t hi_word = inst->word(4);
1824 *val = static_cast<int64_t>(uint64_t(lo_word) | uint64_t(hi_word) << 32);
1825 }
1826 return true;
1827}
1828
1829// <is_int32, is_const_int32, value>
1830std::tuple<bool, bool, uint32_t> ValidationState_t::EvalInt32IfConst(

Callers 3

ValidateTypeArrayFunction · 0.80
ValidateAccessChainFunction · 0.80

Calls 4

wordMethod · 0.80
type_idMethod · 0.45
opcodeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected