[SPIRV] Emit NonSemantic DebugDeclare, DebugExpression and DebugOperation.
Add support for
[DebugDeclare](https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.Shader.DebugInfo.html#DebugDeclare),
[DebugExpression](https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.Shader.DebugInfo.html#DebugExpression)
and
[DebugOperation](https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.Shader.DebugInfo.html#DebugOperation).
Changes:
- Emit DebugDeclare from an indirect DBG_VALUE whose location register is
defined by OpVariable, which is what the spec requires of the Variable
operand. #dbg_declare does not survive as its own opcode in MIR, IRTranslator
lowers it to an indirect DBG_VALUE.
- Skip every other shape instead of emitting an invalid instruction: an access
chain into a field, an OpFunctionParameter for a byval argument, a constant
address, a register left without a def after dead storage was erased, a
variadic #dbg_value, an expression using an unmapped operation, and a variable
whose DebugLocalVariable was not emitted.
- Collect expressions from MIR, so DebugExpression and DebugOperation are
emitted at module scope and shared by every declare using the same
DIExpression.
- Map the nine operations the instruction set defines, and reject an
expression whole when an argument does not fit in 32 bits (as per spec).
- Cache DebugLocalVariable result ids, which emitDebugLocalVariable already
returned but nothing stored.
- Add tests for each emitted and skipped case, for the interaction with
DebugLine and DebugScope, and for the expression operations.
spirv-val and the spec disagree in two places, in opposite directions:
- DebugDeclare's Variable operand: spirv-val accepts an OpFunctionParameter,
while the spec names only OpVariable. This patch follows the spec, so the byval
case is skipped even though spirv-val would take it, see
debug-declare-function-parameter.ll.
- DebugGlobalVariable's Variable operand: spirv-val rejects a DebugExpression
there although the spec permits one, KhronosGroup/SPIRV-Tools#6469, see debug-global-variable-constant-value.ll.