vtn_foreach_instruction(struct vtn_builder *b, const uint32_t *start,
const uint32_t *end, vtn_instruction_handler handler)
{
+ b->file = NULL;
+ b->line = -1;
+ b->col = -1;
+
const uint32_t *w = start;
while (w < end) {
SpvOp opcode = w[0] & SpvOpCodeMask;
unsigned count = w[0] >> SpvWordCountShift;
assert(count >= 1 && w + count <= end);
- if (opcode == SpvOpNop) {
- w++;
- continue;
- }
+ switch (opcode) {
+ case SpvOpNop:
+ break; /* Do nothing */
- if (!handler(b, opcode, w, count))
- return w;
+ case SpvOpLine:
+ b->file = vtn_value(b, w[1], vtn_value_type_string)->str;
+ b->line = w[2];
+ b->col = w[3];
+ break;
+
+ case SpvOpNoLine:
+ b->file = NULL;
+ b->line = -1;
+ b->col = -1;
+ break;
+
+ default:
+ if (!handler(b, opcode, w, count))
+ return w;
+ break;
+ }
w += count;
}
assert(!"Invalid opcode types and variables section");
break;
- case SpvOpLine:
- case SpvOpNoLine:
- break; /* Ignored for now */
-
case SpvOpTypeVoid:
case SpvOpTypeBool:
case SpvOpTypeInt:
const uint32_t *w, unsigned count)
{
switch (opcode) {
- case SpvOpLine:
- case SpvOpNoLine:
- break; /* Ignored for now */
-
case SpvOpLabel:
break;
nir_function_impl *impl;
struct vtn_block *block;
+ /* Current file, line, and column. Useful for debugging. Set
+ * automatically by vtn_foreach_instruction.
+ */
+ char *file;
+ int line, col;
+
/*
* In SPIR-V, constants are global, whereas in NIR, the load_const
* instruction we use is per-function. So while we parse each function, we