diff options
author | Jason Ekstrand <[email protected]> | 2018-03-22 16:41:18 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-06-22 20:15:58 -0700 |
commit | c11833ab24dcba26de1b0a5805e35a5d6761514e (patch) | |
tree | 724a419f448204358d7dd732d51b724dea80bc17 /src/compiler/nir/nir_clone.c | |
parent | 58799b6a5b3e281365bce91fac2e54903fbd2c41 (diff) |
nir,spirv: Rework function calls
This commit completely reworks function calls in NIR. Instead of having
a set of variables for the parameters and return value, nir_call_instr
now has simply has a number of sources which get mapped to load_param
intrinsics inside the functions. It's up to the client API to build an
ABI on top of that. In SPIR-V, out parameters are handled by passing
the result of a deref through as an SSA value and storing to it.
This virtue of this approach can be seen by how much it allows us to
delete from core NIR. In particular, nir_inline_functions gets halved
and goes from a fairly difficult pass to understand in detail to almost
trivial. It also simplifies spirv_to_nir somewhat because NIR functions
never were a good fit for SPIR-V.
Unfortunately, there is no good way to do this without a mega-commit.
Core NIR and SPIR-V have to be changed at the same time. This also
requires changes to anv and radv because nir_inline_functions couldn't
handle deref instructions before this change and can't work without them
after this change.
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_clone.c')
-rw-r--r-- | src/compiler/nir/nir_clone.c | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index 76121d05a7e..4769fbd8bf9 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -536,10 +536,7 @@ clone_call(clone_state *state, const nir_call_instr *call) nir_call_instr *ncall = nir_call_instr_create(state->ns, ncallee); for (unsigned i = 0; i < ncall->num_params; i++) - ncall->params[i] = clone_deref_var(state, call->params[i], &ncall->instr); - - ncall->return_deref = clone_deref_var(state, call->return_deref, - &ncall->instr); + __clone_src(state, ncall, &ncall->params[i], &call->params[i]); return ncall; } @@ -721,14 +718,6 @@ clone_function_impl(clone_state *state, const nir_function_impl *fi) clone_reg_list(state, &nfi->registers, &fi->registers); nfi->reg_alloc = fi->reg_alloc; - nfi->num_params = fi->num_params; - nfi->params = ralloc_array(state->ns, nir_variable *, fi->num_params); - for (unsigned i = 0; i < fi->num_params; i++) { - nfi->params[i] = clone_variable(state, fi->params[i]); - } - if (fi->return_var) - nfi->return_var = clone_variable(state, fi->return_var); - assert(list_empty(&state->phi_srcs)); clone_cf_list(state, &nfi->body, &fi->body); @@ -770,8 +759,6 @@ clone_function(clone_state *state, const nir_function *fxn, nir_shader *ns) nfxn->params = ralloc_array(state->ns, nir_parameter, fxn->num_params); memcpy(nfxn->params, fxn->params, sizeof(nir_parameter) * fxn->num_params); - nfxn->return_type = fxn->return_type; - /* At first glance, it looks like we should clone the function_impl here. * However, call instructions need to be able to reference at least the * function and those will get processed as we clone the function_impls. |