summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_print.c
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2016-01-13 18:43:14 -0500
committerRob Clark <[email protected]>2016-02-09 17:30:33 -0500
commit1df3ecc1b87d95130165283154a13ea5b9a498d4 (patch)
treed007d515e3d34dc94d2a821f9fe679d3c687ce23 /src/compiler/nir/nir_print.c
parent8b0f6de73d7bf5cc2b9bb189e5a3fe4d48dd1017 (diff)
nir: const_index helpers
Direct access to intr->const_index[n], where different slots have different meanings, is somewhat confusing. Instead, let's put some extra info in nir_intrinsic_infos[] about which slots map to what, and add some get/set helpers. The helpers validate that the field being accessed (base/writemask/etc) is applicable for the intrinsic opc, for some extra safety. And nir_print can use this to dump out decoded const_index fields. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_print.c')
-rw-r--r--src/compiler/nir/nir_print.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 48ecb48a620..101688eb00f 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -444,15 +444,16 @@ print_deref(nir_deref_var *deref, print_state *state)
static void
print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
{
- unsigned num_srcs = nir_intrinsic_infos[instr->intrinsic].num_srcs;
+ const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic];
+ unsigned num_srcs = info->num_srcs;
FILE *fp = state->fp;
- if (nir_intrinsic_infos[instr->intrinsic].has_dest) {
+ if (info->has_dest) {
print_dest(&instr->dest, state);
fprintf(fp, " = ");
}
- fprintf(fp, "intrinsic %s (", nir_intrinsic_infos[instr->intrinsic].name);
+ fprintf(fp, "intrinsic %s (", info->name);
for (unsigned i = 0; i < num_srcs; i++) {
if (i != 0)
@@ -463,9 +464,7 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
fprintf(fp, ") (");
- unsigned num_vars = nir_intrinsic_infos[instr->intrinsic].num_variables;
-
- for (unsigned i = 0; i < num_vars; i++) {
+ for (unsigned i = 0; i < info->num_variables; i++) {
if (i != 0)
fprintf(fp, ", ");
@@ -474,9 +473,7 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
fprintf(fp, ") (");
- unsigned num_indices = nir_intrinsic_infos[instr->intrinsic].num_indices;
-
- for (unsigned i = 0; i < num_indices; i++) {
+ for (unsigned i = 0; i < info->num_indices; i++) {
if (i != 0)
fprintf(fp, ", ");
@@ -485,6 +482,31 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
fprintf(fp, ")");
+ static const char *index_name[NIR_INTRINSIC_NUM_INDEX_FLAGS] = {
+ [NIR_INTRINSIC_BASE] = "base",
+ [NIR_INTRINSIC_WRMASK] = "wrmask",
+ [NIR_INTRINSIC_STREAM_ID] = "stream-id",
+ [NIR_INTRINSIC_UCP_ID] = "ucp-id",
+ };
+ for (unsigned idx = 1; idx < NIR_INTRINSIC_NUM_INDEX_FLAGS; idx++) {
+ if (!info->index_map[idx])
+ continue;
+ fprintf(fp, " /*");
+ if (idx == NIR_INTRINSIC_WRMASK) {
+ /* special case wrmask to show it as a writemask.. */
+ unsigned wrmask = nir_intrinsic_write_mask(instr);
+ fprintf(fp, " wrmask=");
+ for (unsigned i = 0; i < 4; i++)
+ if ((wrmask >> i) & 1)
+ fprintf(fp, "%c", "xyzw"[i]);
+ } else {
+ unsigned off = info->index_map[idx] - 1;
+ assert(index_name[idx]); /* forgot to update index_name table? */
+ fprintf(fp, " %s=%d", index_name[idx], instr->const_index[off]);
+ }
+ fprintf(fp, " */");
+ }
+
if (!state->shader)
return;