i965: Assert that an OPCODE_IF was seen before an OPCODE_ELSE.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_disasm.c
index 7556e97cbabe3fab403a5510697f19b899464160..db3fc50a63b5e4ca43220d44690746550550047a 100644 (file)
@@ -27,7 +27,9 @@
 #include <unistd.h>
 #include <stdarg.h>
 
-#include "gen4asm.h"
+#include "main/mtypes.h"
+
+#include "brw_context.h"
 #include "brw_defines.h"
 
 struct {
@@ -48,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 },
@@ -71,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 },
@@ -83,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] = {
@@ -237,7 +241,7 @@ char *imm_encoding[8] = {
     [2] = "UW",
     [3] = "W",
     [5] = "VF",
-    [5] = "V",
+    [6] = "V",
     [7] = "F"
 };
 
@@ -363,6 +367,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;
 }
@@ -626,13 +631,13 @@ static int imm (FILE *file, GLuint type, struct brw_instruction *inst) {
        format (file, "0x%08xUD", inst->bits3.ud);
        break;
     case BRW_REGISTER_TYPE_D:
-       format (file, "%dD", inst->bits3.id);
+       format (file, "%dD", inst->bits3.d);
        break;
     case BRW_REGISTER_TYPE_UW:
        format (file, "0x%04xUW", (uint16_t) inst->bits3.ud);
        break;
     case BRW_REGISTER_TYPE_W:
-       format (file, "%dW", (int16_t) inst->bits3.id);
+       format (file, "%dW", (int16_t) inst->bits3.d);
        break;
     case BRW_REGISTER_TYPE_UB:
        format (file, "0x%02xUB", (int8_t) inst->bits3.ud);
@@ -644,7 +649,7 @@ static int imm (FILE *file, GLuint type, struct brw_instruction *inst) {
        format (file, "0x%08xV", inst->bits3.ud);
        break;
     case BRW_REGISTER_TYPE_F:
-       format (file, "%-gF", inst->bits3.fd);
+       format (file, "%-gF", inst->bits3.f);
     }
     return 0;
 }
@@ -769,7 +774,7 @@ static int src1 (FILE *file, struct brw_instruction *inst)
     }
 }
 
-int disasm (FILE *file, struct brw_instruction *inst)
+int brw_disasm (FILE *file, struct brw_instruction *inst)
 {
     int        err = 0;
     int space = 0;
@@ -793,7 +798,11 @@ int 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);