summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_search.h
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-10-05 18:09:25 -0700
committerJason Ekstrand <[email protected]>2016-10-06 09:16:24 -0700
commit7a3bcadf4e665ff80775f520715061f4e3d63823 (patch)
tree8864e241d35256e3c90146e10d8c30d882a790aa /src/compiler/nir/nir_search.h
parente00fdd643b98c0ec22a05089c338cb5142003282 (diff)
nir: Add asserts to the casting functions
This makes calling nir_foo_as_bar a bit safer because we're no longer 100% trusting in the caller to ensure that it's safe. The caller still needs to do the right thing but this ensures that we catch invalid casts with an assert rather than by reading garbage data. The one downside is that we do use the casts a bit in nir_validate and it's not a validate_assert. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_search.h')
-rw-r--r--src/compiler/nir/nir_search.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/compiler/nir/nir_search.h b/src/compiler/nir/nir_search.h
index f55d797e05e..dec19d53df7 100644
--- a/src/compiler/nir/nir_search.h
+++ b/src/compiler/nir/nir_search.h
@@ -106,11 +106,14 @@ typedef struct {
} nir_search_expression;
NIR_DEFINE_CAST(nir_search_value_as_variable, nir_search_value,
- nir_search_variable, value)
+ nir_search_variable, value,
+ type, nir_search_value_variable)
NIR_DEFINE_CAST(nir_search_value_as_constant, nir_search_value,
- nir_search_constant, value)
+ nir_search_constant, value,
+ type, nir_search_value_constant)
NIR_DEFINE_CAST(nir_search_value_as_expression, nir_search_value,
- nir_search_expression, value)
+ nir_search_expression, value,
+ type, nir_search_value_expression)
nir_alu_instr *
nir_replace_instr(nir_alu_instr *instr, const nir_search_expression *search,