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

Function CheckIntegerWrapDecoration

source/val/validate_decorations.cpp:1975–2000  ·  view source on GitHub ↗

Returns SPV_SUCCESS if validation rules are satisfied for NoSignedWrap or NoUnsignedWrap decorations. Otherwise emits a diagnostic and returns something other than SPV_SUCCESS. Assumes each decoration on a group has been propagated down to the group members.

Source from the content-addressed store, hash-verified

1973// something other than SPV_SUCCESS. Assumes each decoration on a group has been
1974// propagated down to the group members.
1975spv_result_t CheckIntegerWrapDecoration(ValidationState_t& vstate,
1976 const Instruction& inst,
1977 const Decoration& decoration) {
1978 switch (inst.opcode()) {
1979 case spv::Op::OpIAdd:
1980 case spv::Op::OpISub:
1981 case spv::Op::OpIMul:
1982 case spv::Op::OpShiftLeftLogical:
1983 case spv::Op::OpSNegate:
1984 return SPV_SUCCESS;
1985 case spv::Op::OpExtInst:
1986 case spv::Op::OpExtInstWithForwardRefsKHR:
1987 // TODO(dneto): Only certain extended instructions allow these
1988 // decorations. For now allow anything.
1989 return SPV_SUCCESS;
1990 default:
1991 break;
1992 }
1993
1994 return vstate.diag(SPV_ERROR_INVALID_ID, &inst)
1995 << (decoration.dec_type() == spv::Decoration::NoSignedWrap
1996 ? "NoSignedWrap"
1997 : "NoUnsignedWrap")
1998 << " decoration may not be applied to "
1999 << spvOpcodeString(inst.opcode());
2000}
2001
2002// Returns SPV_SUCCESS if validation rules are satisfied for the Component
2003// decoration. Otherwise emits a diagnostic and returns something other than

Callers 1

Calls 4

spvOpcodeStringFunction · 0.85
diagMethod · 0.80
dec_typeMethod · 0.80
opcodeMethod · 0.45

Tested by

no test coverage detected