This is the mail archive of the
cgen@sources.redhat.com
mailing list for the CGEN project.
Re: hash function for assembly hash table
- To: bje at redhat dot com (Ben Elliston)
- Subject: Re: hash function for assembly hash table
- From: fche at redhat dot com (Frank Ch. Eigler)
- Date: 26 Mar 2001 18:30:09 -0500
- Cc: cgen at sources dot redhat dot com
- References: <15039.52892.996310.33439.cygnus.local.cgen@scooby.apac.redhat.com>
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