diff options
author | Jason Ekstrand <[email protected]> | 2018-03-20 11:11:25 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-06-22 20:15:54 -0700 |
commit | a406f7e0c9ab1ff36ae2d9fe377415bf41bace5a (patch) | |
tree | 21ab59aaf789e5ea244d673dc58c0fb22f99dcd1 /src/compiler/nir/nir_deref.h | |
parent | 535289a3a97b104dc128d633785fae3936e3b120 (diff) |
nir: Add a deref path helper struct
This commit introduces a new nir_deref.h header for helpers that are
less common and really only needed by a few heavy-duty passes. In this
header is a new struct for representing a full deref path which can be
walked in either direction.
v2 (Jason Ekstrand):
- Assert that deref != NULL (Caio)
- Fill _short_path with 0xdeadbeef in debug builds when not used (Caio)
- Make nir_deref_path a typedef (Rob)
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Acked-by: Rob Clark <[email protected]>
Acked-by: Bas Nieuwenhuizen <[email protected]>
Acked-by: Dave Airlie <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_deref.h')
-rw-r--r-- | src/compiler/nir/nir_deref.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_deref.h b/src/compiler/nir/nir_deref.h new file mode 100644 index 00000000000..0980bae7215 --- /dev/null +++ b/src/compiler/nir/nir_deref.h @@ -0,0 +1,55 @@ +/* + * Copyright © 2018 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef NIR_DEREF_H +#define NIR_DEREF_H + +#include "nir.h" +#include "nir_builder.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + /** Short path so we can keep it on the stack most of the time. */ + nir_deref_instr *_short_path[7]; + + /** A null-terminated array view of a deref chain + * + * The first element of this array will be the variable dereference + * followed by every deref_instr on the path to the final one. The last + * element in the array is a NULL pointer which acts as a terminator. + */ + nir_deref_instr **path; +} nir_deref_path; + +void nir_deref_path_init(nir_deref_path *path, + nir_deref_instr *deref, void *mem_ctx); +void nir_deref_path_finish(nir_deref_path *path); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* NIR_DEREF_H */ |