PPC: remove indirection from struct pd_reg

Message ID 57d5110e-3327-ee71-4794-16807a0f3ea9@suse.com
State Accepted
Headers
Series PPC: remove indirection from struct pd_reg |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

Jan Beulich Aug. 11, 2023, 1:16 p.m. UTC
  The longest register name is 5 characters (plus a nul one), so using a
4- or 8-byte pointer to get at it is neither space nor time efficient.
Embed the names right into the array. For PIE this also reduces the
number of base relocations in the final image.
---
Of course this way the structure isn't a power of 2 in size anymore.
While adding padding would still keep overall size below the original
for 64-bit code, in 32-bit code the space savings would likely be lost.
  

Comments

Alan Modra Aug. 11, 2023, 10:30 p.m. UTC | #1
On Fri, Aug 11, 2023 at 03:16:21PM +0200, Jan Beulich wrote:
> --- a/gas/config/tc-ppc.c
> +++ b/gas/config/tc-ppc.c
> @@ -279,7 +279,7 @@ const pseudo_typeS md_pseudo_table[] =
>  /* Structure to hold information about predefined registers.  */
>  struct pd_reg
>    {
> -    const char *name;
> +    char name[6];
>      unsigned short value;
>      unsigned short flags;
>    };

Thanks!
  

Patch

--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -279,7 +279,7 @@  const pseudo_typeS md_pseudo_table[] =
 /* Structure to hold information about predefined registers.  */
 struct pd_reg
   {
-    const char *name;
+    char name[6];
     unsigned short value;
     unsigned short flags;
   };