mesa/src/compiler/spirv
Jason Ekstrand fa5a36dbd4 spirv: Rewrite CFG construction
This commit completely rewrites the way we extract a structured CFG from
SPIR-V.  The new approach is different in a few ways:

 1. It does a breadth-first search instead of depth-first.  This means
    that we've visited the merge node for a construct before we visit
    any of the nodes inside the construct.  This makes it easier to
    validate things like loop and switch nesting.

 2. We record more information in the CFG.  Earlier commits added a
    parent pointer to vtn_cf_node but we now record all of the merge and
    other special blocks for each CFG node.  This lets us validate
    things more precisely.

 3. It makes heavy use of merge blocks for walking the CFG.  Previously,
    we sort of used them as hints for trying to guess the CFG structure
    but things got dicey whenever a merge was missing.  We had some
    heuristics for how to handle short-circuiting if statements but it
    was a bunch of special cases.

    Now, we make them a fundamental part of walking the CFG.  When we
    encounter a control-flow construct, we add the body components of
    the construct to the BFS work list and then jump to the merge block
    if one exists to continue scanning the current CFG nesting level.
    If no merge block exists, we assume that means that control-flow
    never re-converges in a normal way and that the only way to get back
    to normality is with a direct jump such as a loop break or continue.
    This should make things far more robust when trying to deal with the
    more creative placement (or lack thereof) of merge instructions.

Reviewed-by: Alan Baker <alanbaker@google.com>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3820>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3820>
2020-04-03 20:54:00 +00:00
..
gl_spirv.c spirv: Rename vtn_decoration literals to operands 2019-04-23 14:58:01 -07:00
GLSL.ext.AMD.h spirv: import AMD extensions header from glslang 2018-03-07 23:09:58 +01:00
GLSL.std.450.h spirv: bump headers to SPIRV 1.1 2017-01-25 17:22:23 +00:00
meson.build meson: Build with Python 3 2018-08-10 15:15:09 -07:00
nir_spirv.h nir, intel: Move use_scoped_memory_barrier to nir_options 2020-02-24 19:12:11 +00:00
OpenCL.std.h spirv: Update the OpenCL.std.h header 2019-06-04 12:12:51 -07:00
spirv.core.grammar.json spirv: Update JSON and headers to 1.5 2019-09-16 19:17:26 -07:00
spirv.h spirv: Update JSON and headers to 1.5 2019-09-16 19:17:26 -07:00
spirv2nir.c spirv2nir: Add kernel spirv support 2020-02-14 11:14:58 +00:00
spirv_info.h spirv: Add imageoperands_to_string helper 2019-10-24 11:39:56 -07:00
spirv_info_c.py spirv: Add imageoperands_to_string helper 2019-10-24 11:39:56 -07:00
spirv_to_nir.c spirv: Make vtn_function a vtn_cf_node 2020-04-03 20:54:00 +00:00
vtn_alu.c nir/spirv: Translate SPIR-V to NIR for new INTEL_shader_integer_functions2 opcodes 2020-01-23 00:18:57 +00:00
vtn_amd.c spirv: implement SPV_AMD_shader_explicit_vertex_parameter 2020-01-29 09:49:50 +00:00
vtn_cfg.c spirv: Rewrite CFG construction 2020-04-03 20:54:00 +00:00
vtn_gather_types_c.py spirv: Add a prepass to set types on vtn_values 2017-12-11 22:28:34 -08:00
vtn_glsl450.c compiler/nir: move build_log helper into builtin-builder 2020-03-26 10:14:22 +00:00
vtn_opencl.c vtn/opencl: add rint-support 2020-03-26 10:14:22 +00:00
vtn_private.h spirv: Rewrite CFG construction 2020-04-03 20:54:00 +00:00
vtn_subgroup.c spirv: fix lowering of OpGroupNonUniformAllEqual 2019-11-19 18:01:13 +00:00
vtn_variables.c compiler/spirv: Add support for non-constant initializers 2020-02-12 15:41:49 +00:00