aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv/vtn_private.h
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-12-11 21:42:34 -0800
committerJason Ekstrand <[email protected]>2018-01-08 14:57:44 -0800
commit296046556ac89cae6ad73f4195025ffd2203c919 (patch)
tree6d2638371fcf065c59484a645b68d3f067bf3eaf /src/compiler/spirv/vtn_private.h
parent22980f941e67fc66a25b5bb28b2bfa3dbef80e75 (diff)
spirv: Add better error messages in vtn_value helpers
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/compiler/spirv/vtn_private.h')
-rw-r--r--src/compiler/spirv/vtn_private.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 7cb69d78430..f7d8f49c98e 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -585,14 +585,24 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa,
struct vtn_type *ptr_type);
static inline struct vtn_value *
+vtn_untyped_value(struct vtn_builder *b, uint32_t value_id)
+{
+ vtn_fail_if(value_id >= b->value_id_bound,
+ "SPIR-V id %u is out-of-bounds", value_id);
+ return &b->values[value_id];
+}
+
+static inline struct vtn_value *
vtn_push_value(struct vtn_builder *b, uint32_t value_id,
enum vtn_value_type value_type)
{
- assert(value_id < b->value_id_bound);
- assert(b->values[value_id].value_type == vtn_value_type_invalid);
+ struct vtn_value *val = vtn_untyped_value(b, value_id);
- b->values[value_id].value_type = value_type;
+ vtn_fail_if(val->value_type != vtn_value_type_invalid,
+ "SPIR-V id %u has already been written by another instruction",
+ value_id);
+ val->value_type = value_type;
return &b->values[value_id];
}
@@ -612,18 +622,12 @@ vtn_push_ssa(struct vtn_builder *b, uint32_t value_id,
}
static inline struct vtn_value *
-vtn_untyped_value(struct vtn_builder *b, uint32_t value_id)
-{
- assert(value_id < b->value_id_bound);
- return &b->values[value_id];
-}
-
-static inline struct vtn_value *
vtn_value(struct vtn_builder *b, uint32_t value_id,
enum vtn_value_type value_type)
{
struct vtn_value *val = vtn_untyped_value(b, value_id);
- assert(val->value_type == value_type);
+ vtn_fail_if(val->value_type != value_type,
+ "SPIR-V id %u is the wrong kind of value", value_id);
return val;
}