unsigned int has_smask : 1;
unsigned int mask_m_specified : 1;
unsigned int subvl : 2;
+ unsigned int destwid : 2;
+ unsigned int srcwid : 2;
};
static jmp_buf svp64_exception;
return str;
}
+struct svp64_width_map {
+ const char *str;
+ unsigned int len;
+ unsigned int width;
+};
+#define SVP64_WIDTH_MAP(STR, WIDTH) \
+ { STR, (sizeof (STR) - 1), WIDTH }
+
+static char *
+svp64_decode_width (char *str, unsigned int *width)
+{
+ size_t i;
+ static const struct svp64_width_map table[] = {
+ SVP64_WIDTH_MAP ("8", 3),
+ SVP64_WIDTH_MAP ("16", 2),
+ SVP64_WIDTH_MAP ("32", 1),
+ };
+
+ for (i = 0; i < (sizeof (table) / sizeof (table[0])); ++i)
+ {
+ const struct svp64_width_map *entry = &table[i];
+
+ if (strncmp (str, entry->str, entry->len) != 0)
+ continue;
+
+ str += entry->len;
+ if (! ISSPACE (*str) && *str != SVP64_SEP && *str != '\0')
+ {
+ str -= entry->len;
+ continue;
+ }
+
+ *width = entry->width;
+
+ *str++ = '\0';
+
+ return str;
+ }
+
+ return NULL;
+}
+
+static char *
+svp64_decode_w (char *str, struct svp64_ctx *svp64)
+{
+ char *iter;
+ unsigned int width;
+
+ str += (sizeof ("w=") - 1);
+ iter = svp64_decode_width (str, &width);
+ if (!iter)
+ svp64_raise (_("unrecognized mode: `%s'"), str);
+
+ svp64->srcwid = width;
+ svp64->destwid = width;
+
+ return iter;
+}
+
+static char *
+svp64_decode_dw (char *str, struct svp64_ctx *svp64)
+{
+ char *iter;
+ unsigned int width;
+
+ str += (sizeof ("dw=") - 1);
+ iter = svp64_decode_width (str, &width);
+ if (!iter)
+ svp64_raise (_("unrecognized mode: `%s'"), str);
+
+ svp64->destwid = width;
+
+ return iter;
+}
+
+static char *
+svp64_decode_sw (char *str, struct svp64_ctx *svp64)
+{
+ char *iter;
+ unsigned int width;
+
+ str += (sizeof ("sw=") - 1);
+ iter = svp64_decode_width (str, &width);
+ if (!iter)
+ svp64_raise (_("unrecognized mode: `%s'"), str);
+
+ svp64->srcwid = width;
+
+ return iter;
+}
+
static char *
svp64_decode_mode (char *str, struct svp64_ctx *svp64)
{
SVP64_DECODER ("vec2", svp64_decode_vec),
SVP64_DECODER ("vec3", svp64_decode_vec),
SVP64_DECODER ("vec4", svp64_decode_vec),
+ SVP64_DECODER ("w=" , svp64_decode_w),
+ SVP64_DECODER ("dw=" , svp64_decode_dw),
+ SVP64_DECODER ("sw=" , svp64_decode_sw),
};
for (i = 0; i < sizeof (table) / sizeof (table[0]); ++i)