diff options
author | Nick Clifton <nickc@redhat.com> | 2005-04-12 08:42:41 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2005-04-12 08:42:41 +0000 |
commit | 4bdd3565f140b0555071cea0d917a6e1e1e16d23 (patch) | |
tree | 3a11fa3961a9b46622ee2e5ad1dd2ddec7cc0427 /gas | |
parent | f394e3dd2e2f699104a24e7ba2a486d2f2b79807 (diff) | |
download | gdb-4bdd3565f140b0555071cea0d917a6e1e1e16d23.zip gdb-4bdd3565f140b0555071cea0d917a6e1e1e16d23.tar.gz gdb-4bdd3565f140b0555071cea0d917a6e1e1e16d23.tar.bz2 |
* hash.c (DEFAULT_SIZE): Delete. Replace with:
(gas_hash_table_size): New static variable.
(set_gas_hash_table_size): New function: Records a requested size for the hash tables.
(get_gas_hash_table_size): New function: Return a prime number near the requested size of the hash table.
(hash_new): Use get_gas_hash_table_size.
* hash.h: Add a prototype for set_gas_hash_table_size.
* as.c (show_usage): Add description of new switches: --hash-size and --reduce-memory-overheads.
(option_values): Add OPTION_HASH_TABLE_SIZE and OPTION_REDUCE_MEMORY_OVERHEADS.
(std_longpopts): Add entries for the new options.
(parse_args): Handle the new options.
* Makefile.am: Add a dependency of as.c on hash.h.
* Makefile.in: Regenerate.
* doc/as.texinfo: Document the new switches.
* NEWS: Mention the new switches.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 21 | ||||
-rw-r--r-- | gas/Makefile.am | 2 | ||||
-rw-r--r-- | gas/Makefile.in | 2 | ||||
-rw-r--r-- | gas/NEWS | 6 | ||||
-rw-r--r-- | gas/as.c | 29 | ||||
-rw-r--r-- | gas/doc/as.texinfo | 29 | ||||
-rw-r--r-- | gas/hash.c | 46 | ||||
-rw-r--r-- | gas/hash.h | 4 |
8 files changed, 120 insertions, 19 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 174b084..d79bea3 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,26 @@ 2005-04-12 Nick Clifton <nickc@redhat.com> + * hash.c (DEFAULT_SIZE): Delete. Replace with: + (gas_hash_table_size): New static variable. + (set_gas_hash_table_size): New function: Records a requested size + for the hash tables. + (get_gas_hash_table_size): New function: Return a prime number + near the requested size of the hash table. + (hash_new): Use get_gas_hash_table_size. + * hash.h: Add a prototype for set_gas_hash_table_size. + * as.c (show_usage): Add description of new switches: --hash-size + and --reduce-memory-overheads. + (option_values): Add OPTION_HASH_TABLE_SIZE and + OPTION_REDUCE_MEMORY_OVERHEADS. + (std_longpopts): Add entries for the new options. + (parse_args): Handle the new options. + * Makefile.am: Add a dependency of as.c on hash.h. + * Makefile.in: Regenerate. + * doc/as.texinfo: Document the new switches. + * NEWS: Mention the new switches. + +2005-04-12 Nick Clifton <nickc@redhat.com> + PR gas/818 * config/tc-hppa.c (pre_defined_registers): Fix %farg[0-3] synonyms. diff --git a/gas/Makefile.am b/gas/Makefile.am index ba855776..c03e580 100644 --- a/gas/Makefile.am +++ b/gas/Makefile.am @@ -2441,7 +2441,7 @@ BMKDEP = #DO NOT PUT ANYTHING BETWEEN THIS LINE AND THE MATCHING WARNING ABOVE. #MKDEP DO NOT PUT ANYTHING BETWEEN THIS LINE AND THE MATCHING WARNING BELOW. app.o: app.c $(INCDIR)/symcat.h as.o: as.c $(INCDIR)/symcat.h subsegs.h $(INCDIR)/obstack.h \ - output-file.h sb.h macro.h dwarf2dbg.h dw2gencfi.h \ + output-file.h sb.h macro.h dwarf2dbg.h dw2gencfi.h hash.h \ $(INCDIR)/elf/dwarf2.h $(BFDVER_H) atof-generic.o: atof-generic.c $(INCDIR)/symcat.h $(INCDIR)/safe-ctype.h bignum-copy.o: bignum-copy.c $(INCDIR)/symcat.h diff --git a/gas/Makefile.in b/gas/Makefile.in index 87efb13..e3554ba 100644 --- a/gas/Makefile.in +++ b/gas/Makefile.in @@ -3358,7 +3358,7 @@ dep-am: DEP #MKDEP DO NOT PUT ANYTHING BETWEEN THIS LINE AND THE MATCHING WARNING BELOW. app.o: app.c $(INCDIR)/symcat.h as.o: as.c $(INCDIR)/symcat.h subsegs.h $(INCDIR)/obstack.h \ - output-file.h sb.h macro.h dwarf2dbg.h dw2gencfi.h \ + output-file.h sb.h macro.h dwarf2dbg.h dw2gencfi.h hash.h \ $(INCDIR)/elf/dwarf2.h $(BFDVER_H) atof-generic.o: atof-generic.c $(INCDIR)/symcat.h $(INCDIR)/safe-ctype.h bignum-copy.o: bignum-copy.c $(INCDIR)/symcat.h @@ -1,11 +1,15 @@ -*- text -*- +* Added --reduce-memory-overheads switch to reduce the size of the hash + tables used, at the expense of longer assembly times, and + --hash-size=<NUMBER> to set the size of the hash tables used by gas. + * Macro names and macro parameter names can now be any identifier that would also be legal as a symbol elsewhere. For macro parameter names, this is known to cause problems in certain sources when the respective target uses characters inconsistently, and thus macro parameter references may no longer be recognized as such (see the documentation for details). - + * Support the .f_floating, .d_floating, .g_floating and .h_floating directives for the VAX target in order to be more compatible with the VAX MACRO assembler. @@ -42,6 +42,7 @@ #include "macro.h" #include "dwarf2dbg.h" #include "dw2gencfi.h" +#include "hash.h" #ifdef BFD_ASSEMBLER #include "bfdver.h" @@ -292,6 +293,8 @@ Options:\n\ fprintf (stream, _("\ --gdwarf-2 generate DWARF2 debugging information\n")); fprintf (stream, _("\ + --hash-size=<value> set the hash table size close to <value>\n")); + fprintf (stream, _("\ --help show this message and exit\n")); fprintf (stream, _("\ --target-help show target specific options\n")); @@ -314,6 +317,10 @@ Options:\n\ fprintf (stream, _("\ -R fold data section into text section\n")); fprintf (stream, _("\ + --reduce-memory-overheads \n\ + prefer smaller memory use at the cost of longer\n\ + assembly times\n")); + fprintf (stream, _("\ --statistics print various measured statistics from execution\n")); fprintf (stream, _("\ --strip-local-absolute strip local absolute symbols\n")); @@ -426,6 +433,8 @@ parse_args (int * pargc, char *** pargv) OPTION_EXECSTACK, OPTION_NOEXECSTACK, OPTION_ALTERNATE, + OPTION_HASH_TABLE_SIZE, + OPTION_REDUCE_MEMORY_OVERHEADS, OPTION_WARN_FATAL /* When you add options here, check that they do not collide with OPTION_MD_BASE. See as.h. */ @@ -457,6 +466,7 @@ parse_args (int * pargc, char *** pargv) ,{"gen-debug", no_argument, NULL, 'g'} ,{"gstabs", no_argument, NULL, OPTION_GSTABS} ,{"gstabs+", no_argument, NULL, OPTION_GSTABS_PLUS} + ,{"hash-size", required_argument, NULL, OPTION_HASH_TABLE_SIZE} ,{"help", no_argument, NULL, OPTION_HELP} /* New option for extending instruction set (see also -t above). The "-t file" or "--itbl file" option extends the basic set of @@ -478,6 +488,7 @@ parse_args (int * pargc, char *** pargv) ,{"mri", no_argument, NULL, 'M'} ,{"nocpp", no_argument, NULL, OPTION_NOCPP} ,{"no-warn", no_argument, NULL, 'W'} + ,{"reduce-memory-overheads", no_argument, NULL, OPTION_REDUCE_MEMORY_OVERHEADS} ,{"statistics", no_argument, NULL, OPTION_STATISTICS} ,{"strip-local-absolute", no_argument, NULL, OPTION_STRIP_LOCAL_ABSOLUTE} ,{"version", no_argument, NULL, OPTION_VERSION} @@ -865,6 +876,24 @@ the GNU General Public License. This program has absolutely no warranty.\n")); case 'X': /* -X means treat warnings as errors. */ break; + + case OPTION_REDUCE_MEMORY_OVERHEADS: + /* The only change we make at the moment is to reduce + the size of the hash tables that we use. */ + set_gas_hash_table_size (4051); + break; + + case OPTION_HASH_TABLE_SIZE: + { + bfd_size_type new_size; + + new_size = strtoul (optarg, NULL, 0); + if (new_size) + set_gas_hash_table_size (new_size); + else + as_fatal (_("--hash-size needs a numeric argument")); + break; + } } } diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index 02e4ab4..7b14c0b 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -227,14 +227,15 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}. @smallexample @c man begin SYNOPSIS @value{AS} [@b{-a}[@b{cdhlns}][=@var{file}]] [@b{--alternate}] [@b{-D}] - [@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{-g}] [@b{--gstabs}] [@b{--gstabs+}] - [@b{--gdwarf-2}] [@b{--help}] [@b{-I} @var{dir}] [@b{-J}] [@b{-K}] [@b{-L}] - [@b{--listing-lhs-width}=@var{NUM}] [@b{--listing-lhs-width2}=@var{NUM}] - [@b{--listing-rhs-width}=@var{NUM}] [@b{--listing-cont-lines}=@var{NUM}] - [@b{--keep-locals}] [@b{-o} @var{objfile}] [@b{-R}] [@b{--statistics}] [@b{-v}] - [@b{-version}] [@b{--version}] [@b{-W}] [@b{--warn}] [@b{--fatal-warnings}] - [@b{-w}] [@b{-x}] [@b{-Z}] [@b{--target-help}] [@var{target-options}] - [@b{--}|@var{files} @dots{}] + [@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{-g}] [@b{--gstabs}] + [@b{--gstabs+}] [@b{--gdwarf-2}] [@b{--help}] [@b{-I} @var{dir}] [@b{-J}] + [@b{-K}] [@b{-L}] [@b{--listing-lhs-width}=@var{NUM}] + [@b{--listing-lhs-width2}=@var{NUM}] [@b{--listing-rhs-width}=@var{NUM}] + [@b{--listing-cont-lines}=@var{NUM}] [@b{--keep-locals}] [@b{-o} + @var{objfile}] [@b{-R}] [@b{--reduce-memory-overheads}] [@b{--statistics}] + [@b{-v}] [@b{-version}] [@b{--version}] [@b{-W}] [@b{--warn}] + [@b{--fatal-warnings}] [@b{-w}] [@b{-x}] [@b{-Z}] [@b{--target-help}] + [@var{target-options}] [@b{--}|@var{files} @dots{}] @c @c Target dependent options are listed below. Keep the list sorted. @c Add an empty line for separation. @@ -554,6 +555,18 @@ Name the object-file output from @command{@value{AS}} @var{objfile}. @item -R Fold the data section into the text section. +@kindex --hash-size=@var{number} +Set the default size of GAS's hash tables to a prime number close to +@var{number}. Increasing this value can reduce the length of time it takes the +assembler to perform its tasks, at the expense of increasing the assembler's +memory requirements. Similarly reducing this value can reduce the memory +requirements at the expense of speed. + +@item --reduce-memory-overheads +This option reduces GAS's memory requirements, at the expense of making the +assembly processes slower. Currently this switch is a synonym for +@samp{--hash-size=4051}, but in the future it may have other effects as well. + @item --statistics Print the maximum space (in bytes) and total time (in seconds) used by assembly. @@ -1,6 +1,6 @@ /* hash.c -- gas hash table code Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, - 2000, 2001, 2002, 2003 + 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -33,10 +33,6 @@ #include "safe-ctype.h" #include "obstack.h" -/* The default number of entries to use when creating a hash table. */ - -#define DEFAULT_SIZE (4051) - /* An entry in a hash table. */ struct hash_entry { @@ -72,6 +68,40 @@ struct hash_control { #endif /* HASH_STATISTICS */ }; +/* The default number of entries to use when creating a hash table. + Note this value can be reduced to 4051 by using the command line + switch --reduce-memory-overheads, or set to other values by using + the --hash-size=<NUMBER> switch. */ + +static unsigned int gas_hash_table_size = 65537; + +void +set_gas_hash_table_size (unsigned int size) +{ + gas_hash_table_size = size; +} + +/* FIXME: This function should be amalgmated with bfd/hash.c:bfd_hash_set_default_size(). */ +static unsigned int +get_gas_hash_table_size (void) +{ + /* Extend this prime list if you want more granularity of hash table size. */ + static const unsigned int hash_size_primes[] = + { + 1021, 4051, 8599, 16699, 65537 + }; + unsigned int index; + + /* Work out the best prime number near the hash_size. + FIXME: This could be a more sophisticated algorithm, + but is it really worth implementing it ? */ + for (index = 0; index < ARRAY_SIZE (hash_size_primes) - 1; ++index) + if (gas_hash_table_size <= hash_size_primes[index]) + break; + + return hash_size_primes[index]; +} + /* Create a hash table. This return a control block. */ struct hash_control * @@ -81,12 +111,12 @@ hash_new (void) struct hash_control *ret; unsigned int alloc; - size = DEFAULT_SIZE; + size = get_gas_hash_table_size (); - ret = (struct hash_control *) xmalloc (sizeof *ret); + ret = xmalloc (sizeof *ret); obstack_begin (&ret->memory, chunksize); alloc = size * sizeof (struct hash_entry *); - ret->table = (struct hash_entry **) obstack_alloc (&ret->memory, alloc); + ret->table = obstack_alloc (&ret->memory, alloc); memset (ret->table, 0, alloc); ret->size = size; @@ -24,6 +24,10 @@ struct hash_control; +/* Set the size of the hash table used. */ + +void set_gas_hash_table_size (unsigned int); + /* Create a hash table. This return a control block. */ extern struct hash_control *hash_new (void); |