Message ID | 56348b352663d99cc4fda4fdd3f0fe207eca4e93.1574423265.git.andrew.burgess@embecosm.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
On Fri, 22 Nov 2019 04:10:25 PST (-0800), andrew.burgess@embecosm.com wrote: > We build a hash table of all register classes and numbers. The hash > key is the register name and the hash value is the class and number > encoded into a single value, which is of type 'void *'. > > When we pull the values out of the hash we cast them to be a pointer > to a structure, however, we never access the fields of that structure, > we just decode the register class and number from the pointer value > itself. > > This commit removes the structure and treats the encoded class and > number as a 'void *' during hash lookup. > > gas/ChangeLog: > > * config/tc-riscv.c (struct regname): Delete. > (hash_reg_names): Handle value as 'void *'. > > Change-Id: Ie7d8f46ca3798f56f4af94395279de684f87f9cc > --- > gas/ChangeLog | 5 +++++ > gas/config/tc-riscv.c | 8 +------- > 2 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c > index e50505138e9..5d95ee8eee3 100644 > --- a/gas/config/tc-riscv.c > +++ b/gas/config/tc-riscv.c > @@ -446,12 +446,6 @@ opcode_name_lookup (char **s) > return o; > } > > -struct regname > -{ > - const char *name; > - unsigned int num; > -}; > - > enum reg_class > { > RCLASS_GPR, > @@ -489,7 +483,7 @@ hash_reg_names (enum reg_class class, const char * const names[], unsigned n) > static unsigned int > reg_lookup_internal (const char *s, enum reg_class class) > { > - struct regname *r = (struct regname *) hash_find (reg_names_hash, s); > + void *r = hash_find (reg_names_hash, s); > > if (r == NULL || DECODE_REG_CLASS (r) != class) > return -1; Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index e50505138e9..5d95ee8eee3 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -446,12 +446,6 @@ opcode_name_lookup (char **s) return o; } -struct regname -{ - const char *name; - unsigned int num; -}; - enum reg_class { RCLASS_GPR, @@ -489,7 +483,7 @@ hash_reg_names (enum reg_class class, const char * const names[], unsigned n) static unsigned int reg_lookup_internal (const char *s, enum reg_class class) { - struct regname *r = (struct regname *) hash_find (reg_names_hash, s); + void *r = hash_find (reg_names_hash, s); if (r == NULL || DECODE_REG_CLASS (r) != class) return -1;