| 1801 | } |
| 1802 | |
| 1803 | bool 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> |
| 1830 | std::tuple<bool, bool, uint32_t> ValidationState_t::EvalInt32IfConst( |
no test coverage detected