From: Dmitry Selyutin Date: Sun, 28 May 2023 22:04:56 +0000 (+0300) Subject: ppc: refactor assembly logic X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c5e0c6d12be998879bf6730c887323ee217248d;p=binutils-gdb.git ppc: refactor assembly logic --- diff --git a/gas/config/tc-ppc-svp64.c b/gas/config/tc-ppc-svp64.c index 91977b9d45a..bf8c0c947b7 100644 --- a/gas/config/tc-ppc-svp64.c +++ b/gas/config/tc-ppc-svp64.c @@ -591,8 +591,12 @@ static void svp64_decode (char *str, struct svp64_ctx *svp64) { char *opc; + size_t opclen; + char *args; + size_t argslen; char *iter; const struct svp64_record *record; + char *base = str; str += (sizeof ("sv.") - 1); if (! ISALPHA (*str)) @@ -601,6 +605,7 @@ svp64_decode (char *str, struct svp64_ctx *svp64) opc = str; for (; ! ISSPACE (*str) && *str != SVP64_SEP && *str != '\0'; ++str) ; + opclen = (str - opc); if (*str != '\0') *str++ = '\0'; @@ -614,6 +619,14 @@ svp64_decode (char *str, struct svp64_ctx *svp64) for (; (iter = svp64_decode_mode (str, svp64)) != NULL; str = iter) ; + + args = str; + argslen = strlen (args); + + memmove (base, opc, opclen); + base[opclen] = ' '; + memmove ((base + opclen + 1), args, argslen); + base[opclen + 1 + argslen] = '\0'; } static void @@ -862,7 +875,5 @@ svp64_assemble (char *str) svp64_decode (str, &svp64); svp64_validate_and_fix (&svp64); - as_warn (_("opcode ignored (desc=%p)"), svp64.desc); - memcpy (str, "nop", sizeof ("nop")); - md_assemble (str); + ppc_assemble (str, &svp64); } diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index 19a852f3aab..8bf7e6bc25d 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -36,6 +36,11 @@ #include "libxcoff.h" #endif +struct svp64_ctx; + +static void +ppc_assemble (char *str, struct svp64_ctx *svp64 ATTRIBUTE_UNUSED); + #include "tc-ppc-svp64.c" /* This is the assembler for the PowerPC or POWER (RS/6000) chips. */ @@ -3314,8 +3319,8 @@ is_svp64_insn (char *str) /* This routine is called for each instruction to be assembled. */ -void -md_assemble (char *str) +static void +ppc_assemble (char *str, struct svp64_ctx *svp64 ATTRIBUTE_UNUSED) { char *s; const struct powerpc_opcode *opcode; @@ -3342,6 +3347,7 @@ md_assemble (char *str) { if (is_svp64_insn (str)) { + *(s - 1) = ' '; /* restore the original string */ svp64_assemble (str); return; } @@ -4167,6 +4173,11 @@ md_assemble (char *str) } } +void +md_assemble (char *str) +{ + ppc_assemble (str, NULL); +} #ifdef OBJ_ELF /* For ELF, add support for SHT_ORDERED. */