summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_search.h
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2016-10-05 18:09:25 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2016-10-06 09:16:24 -0700
commit7a3bcadf4e665ff80775f520715061f4e3d63823 (patch)
tree8864e241d35256e3c90146e10d8c30d882a790aa /src/compiler/nir/nir_search.h
parente00fdd643b98c0ec22a05089c338cb5142003282 (diff)
downloadexternal_mesa3d-7a3bcadf4e665ff80775f520715061f4e3d63823.zip
external_mesa3d-7a3bcadf4e665ff80775f520715061f4e3d63823.tar.gz
external_mesa3d-7a3bcadf4e665ff80775f520715061f4e3d63823.tar.bz2
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 <jason@jlekstrand.net> Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
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 f55d797..dec19d5 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,