This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: hash function for assembly hash table



bje wrote:

: Doing some debugging yesterday, I noticed that the cgen-generated
: assembler uses a very simplistic hash function when building the hash
: table used in assembly.  It uses:
:       mnemonic[0] % 127

This is just the default.

: [...]
: By changing the hash function to something more slightly
: sophisticated:
:      sum (all mnemonic chars) % 127
: This yields a *much* better distribution [...]

One problem with this is that it's hard for the target-independent
code to identify the end of the mnemonic.  There exist instruction
sets which separate the mnemonic proper with dots from various
optional appended operands.  (I suppose cgen might have enough
information to deduce the boundaries.)

In any case, for an even better hash function (with a collision rate
much nearer 0%), see the "Improving gas error messages" thread on this
very mailing list about four months ago.


- FChE


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]