i965: Mostly fix glsl-max-varyings.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_disasm.c
index 3e22ca6c99d58019c4ebe80306cd45e30c119323..23095d912a227c80e4fa2de6bd658d2144616cfa 100644 (file)
@@ -50,12 +50,14 @@ struct {
     [BRW_OPCODE_MAC] = { .name = "mac", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_MACH] = { .name = "mach", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_LINE] = { .name = "line", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_PLN] = { .name = "pln", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_SAD2] = { .name = "sad2", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_SADA2] = { .name = "sada2", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_DP4] = { .name = "dp4", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_DPH] = { .name = "dph", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_DP3] = { .name = "dp3", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_DP2] = { .name = "dp2", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_MATH] = { .name = "math", .nsrc = 2, .ndst = 1 },
 
     [BRW_OPCODE_AVG] = { .name = "avg", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_ADD] = { .name = "add", .nsrc = 2, .ndst = 1 },
@@ -73,10 +75,10 @@ struct {
     [BRW_OPCODE_NOP] = { .name = "nop", .nsrc = 0, .ndst = 0 },
     [BRW_OPCODE_JMPI] = { .name = "jmpi", .nsrc = 1, .ndst = 0 },
     [BRW_OPCODE_IF] = { .name = "if", .nsrc = 2, .ndst = 0 },
-    [BRW_OPCODE_IFF] = { .name = "iff", .nsrc = 1, .ndst = 01 },
-    [BRW_OPCODE_WHILE] = { .name = "while", .nsrc = 1, .ndst = 0 },
-    [BRW_OPCODE_ELSE] = { .name = "else", .nsrc = 1, .ndst = 0 },
-    [BRW_OPCODE_BREAK] = { .name = "break", .nsrc = 1, .ndst = 0 },
+    [BRW_OPCODE_IFF] = { .name = "iff", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_WHILE] = { .name = "while", .nsrc = 2, .ndst = 0 },
+    [BRW_OPCODE_ELSE] = { .name = "else", .nsrc = 2, .ndst = 0 },
+    [BRW_OPCODE_BREAK] = { .name = "break", .nsrc = 2, .ndst = 0 },
     [BRW_OPCODE_CONTINUE] = { .name = "cont", .nsrc = 1, .ndst = 0 },
     [BRW_OPCODE_HALT] = { .name = "halt", .nsrc = 1, .ndst = 0 },
     [BRW_OPCODE_MSAVE] = { .name = "msave", .nsrc = 1, .ndst = 1 },
@@ -85,7 +87,7 @@ struct {
     [BRW_OPCODE_POP] = { .name = "pop", .nsrc = 2, .ndst = 0 },
     [BRW_OPCODE_WAIT] = { .name = "wait", .nsrc = 1, .ndst = 0 },
     [BRW_OPCODE_DO] = { .name = "do", .nsrc = 0, .ndst = 0 },
-    [BRW_OPCODE_ENDIF] = { .name = "endif", .nsrc = 0, .ndst = 0 },
+    [BRW_OPCODE_ENDIF] = { .name = "endif", .nsrc = 2, .ndst = 0 },
 };
 
 char *conditional_modifier[16] = {
@@ -239,7 +241,7 @@ char *imm_encoding[8] = {
     [2] = "UW",
     [3] = "W",
     [5] = "VF",
-    [5] = "V",
+    [6] = "V",
     [7] = "F"
 };
 
@@ -321,6 +323,11 @@ char *math_precision[2] = {
     [1] = "partial_precision"
 };
 
+char *urb_opcode[2] = {
+    [0] = "urb_write",
+    [1] = "ff_sync",
+};
+
 char *urb_swizzle[4] = {
     [BRW_URB_SWIZZLE_NONE] = "",
     [BRW_URB_SWIZZLE_INTERLEAVE] = "interleave",
@@ -365,6 +372,7 @@ static int format (FILE *f, char *format, ...)
     va_start (args, format);
 
     vsnprintf (buf, sizeof (buf) - 1, format, args);
+    va_end (args);
     string (f, buf);
     return 0;
 }
@@ -771,7 +779,7 @@ static int src1 (FILE *file, struct brw_instruction *inst)
     }
 }
 
-int brw_disasm (FILE *file, struct brw_instruction *inst)
+int brw_disasm (FILE *file, struct brw_instruction *inst, int gen)
 {
     int        err = 0;
     int space = 0;
@@ -795,7 +803,11 @@ int brw_disasm (FILE *file, struct brw_instruction *inst)
     err |= control (file, "saturate", saturate, inst->header.saturate, NULL);
     err |= control (file, "debug control", debug_ctrl, inst->header.debug_control, NULL);
 
-    if (inst->header.opcode != BRW_OPCODE_SEND)
+    if (inst->header.opcode == BRW_OPCODE_MATH) {
+       string (file, " ");
+       err |= control (file, "function", math_function,
+                       inst->header.destreg__conditionalmod, NULL);
+    } else if (inst->header.opcode != BRW_OPCODE_SEND)
        err |= control (file, "conditional modifier", conditional_modifier,
                        inst->header.destreg__conditionalmod, NULL);
 
@@ -822,12 +834,22 @@ int brw_disasm (FILE *file, struct brw_instruction *inst)
     }
 
     if (inst->header.opcode == BRW_OPCODE_SEND) {
+       int target;
+
+       if (gen >= 6)
+           target = inst->header.destreg__conditionalmod;
+       else if (gen == 5)
+           target = inst->bits2.send_gen5.sfid;
+       else
+           target = inst->bits3.generic.msg_target;
+
        newline (file);
        pad (file, 16);
        space = 0;
        err |= control (file, "target function", target_function,
-                       inst->bits3.generic.msg_target, &space);
-       switch (inst->bits3.generic.msg_target) {
+                       target, &space);
+
+       switch (target) {
        case BRW_MESSAGE_TARGET_MATH:
            err |= control (file, "math function", math_function,
                            inst->bits3.math.function, &space);
@@ -849,16 +871,35 @@ int brw_disasm (FILE *file, struct brw_instruction *inst)
            string (file, ")");
            break;
        case BRW_MESSAGE_TARGET_DATAPORT_WRITE:
-           format (file, " (%d, %d, %d, %d)",
-                   inst->bits3.dp_write.binding_table_index,
-                   (inst->bits3.dp_write.pixel_scoreboard_clear << 3) |
-                   inst->bits3.dp_write.msg_control,
-                   inst->bits3.dp_write.msg_type,
-                   inst->bits3.dp_write.send_commit_msg);
+           if (gen >= 6) {
+               format (file, " (%d, %d, %d, %d, %d, %d)",
+                       inst->bits3.dp_render_cache.binding_table_index,
+                       inst->bits3.dp_render_cache.msg_control,
+                       inst->bits3.dp_render_cache.msg_type,
+                       inst->bits3.dp_render_cache.send_commit_msg,
+                       inst->bits3.dp_render_cache.msg_length,
+                       inst->bits3.dp_render_cache.response_length);
+           } else {
+               format (file, " (%d, %d, %d, %d)",
+                       inst->bits3.dp_write.binding_table_index,
+                       (inst->bits3.dp_write.pixel_scoreboard_clear << 3) |
+                       inst->bits3.dp_write.msg_control,
+                       inst->bits3.dp_write.msg_type,
+                       inst->bits3.dp_write.send_commit_msg);
+           }
            break;
        case BRW_MESSAGE_TARGET_URB:
-           format (file, " %d", inst->bits3.urb.offset);
+           if (gen >= 5) {
+               format (file, " %d", inst->bits3.urb_gen5.offset);
+           } else {
+               format (file, " %d", inst->bits3.urb.offset);
+           }
+
            space = 1;
+           if (gen >= 5) {
+               err |= control (file, "urb opcode", urb_opcode,
+                               inst->bits3.urb_gen5.opcode, &space);
+           }
            err |= control (file, "urb swizzle", urb_swizzle,
                            inst->bits3.urb.swizzle_control, &space);
            err |= control (file, "urb allocate", urb_allocate,
@@ -876,10 +917,17 @@ int brw_disasm (FILE *file, struct brw_instruction *inst)
        }
        if (space)
            string (file, " ");
-       format (file, "mlen %d",
-               inst->bits3.generic.msg_length);
-       format (file, " rlen %d",
-               inst->bits3.generic.response_length);
+       if (gen >= 5) {
+          format (file, "mlen %d",
+                  inst->bits3.generic_gen5.msg_length);
+          format (file, " rlen %d",
+                  inst->bits3.generic_gen5.response_length);
+       } else {
+          format (file, "mlen %d",
+                  inst->bits3.generic.msg_length);
+          format (file, " rlen %d",
+                  inst->bits3.generic.response_length);
+       }
     }
     pad (file, 64);
     if (inst->header.opcode != BRW_OPCODE_NOP) {