summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-01-19 18:44:44 -0800
committerJason Ekstrand <[email protected]>2016-01-19 19:00:00 -0800
commit891564adb90f090e0c635a30fb947baa0291703c (patch)
treeabde6f59ac08514b6887873fd25f512bb1e8bbd2 /src/glsl
parente79f8a4926dc79e32531f705b2db3bbd2d3984f4 (diff)
nir/spirv: Handle OpLine and OpNoLine in foreach_instruction
This way we don't have to explicitly handle them everywhere.
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/nir/spirv/spirv_to_nir.c38
-rw-r--r--src/glsl/nir/spirv/vtn_private.h6
2 files changed, 30 insertions, 14 deletions
diff --git a/src/glsl/nir/spirv/spirv_to_nir.c b/src/glsl/nir/spirv/spirv_to_nir.c
index 1fcdb1aa14a..a117175341e 100644
--- a/src/glsl/nir/spirv/spirv_to_nir.c
+++ b/src/glsl/nir/spirv/spirv_to_nir.c
@@ -192,19 +192,37 @@ const uint32_t *
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;
}
@@ -3498,10 +3516,6 @@ vtn_handle_variable_or_type_instruction(struct vtn_builder *b, SpvOp opcode,
assert(!"Invalid opcode types and variables section");
break;
- case SpvOpLine:
- case SpvOpNoLine:
- break; /* Ignored for now */
-
case SpvOpTypeVoid:
case SpvOpTypeBool:
case SpvOpTypeInt:
@@ -3555,10 +3569,6 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count)
{
switch (opcode) {
- case SpvOpLine:
- case SpvOpNoLine:
- break; /* Ignored for now */
-
case SpvOpLabel:
break;
diff --git a/src/glsl/nir/spirv/vtn_private.h b/src/glsl/nir/spirv/vtn_private.h
index cf75bc92a7a..a0cf1b9fd42 100644
--- a/src/glsl/nir/spirv/vtn_private.h
+++ b/src/glsl/nir/spirv/vtn_private.h
@@ -299,6 +299,12 @@ struct vtn_builder {
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