From: Dmitry Selyutin Date: Tue, 11 Apr 2023 18:27:24 +0000 (+0300) Subject: ppc/svp64: support w/dw/sw modes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=671a9778c7a30dd1cb3aac60c33d8773c2a315dd;p=binutils-gdb.git ppc/svp64: support w/dw/sw modes --- diff --git a/gas/config/tc-ppc-svp64.c b/gas/config/tc-ppc-svp64.c index e9bcb4121eb..f771151f088 100644 --- a/gas/config/tc-ppc-svp64.c +++ b/gas/config/tc-ppc-svp64.c @@ -33,6 +33,8 @@ struct svp64_ctx { 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; @@ -243,6 +245,97 @@ svp64_decode_vec (char *str, struct svp64_ctx *svp64) 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) { @@ -254,6 +347,9 @@ 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)