ic_lookup.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* I N T E R M E D I A T E C O D E
  7. *
  8. * L O O K - U P R O U T I N E S
  9. */
  10. /* During Intermediate Code generation data label names ('symbols'),
  11. * procedure names and instruction labels (numbers) are translated
  12. * to resp. a data block pointer, a proc pointer and a label identifier.
  13. * We use three hash tables for this purpose (symhash, prochash, numhash).
  14. * Every name/number is hashed to an index in a specific table. A table
  15. * entry contains a list of structs (sym, prc, num), each one representing
  16. * a 'synonym'. (Synonyms are names/numbers having the same hash value).
  17. */
  18. /* status passed as argument to look_up routines:
  19. * resp. used occurrence, defining occurrence, occurrence in
  20. * a MES ms_ext pseudo.
  21. */
  22. #define OCCURRING 0
  23. #define DEFINING 1
  24. #define IMPORTING 2
  25. #define NSYMHASH 127
  26. #define NPROCHASH 127
  27. #define NNUMHASH 37
  28. extern sym_p symhash[];
  29. extern prc_p prochash[];
  30. extern num_p numhash[];
  31. lab_id instr_lab(short number);
  32. /* Maps EM labels to sequential
  33. * integers.
  34. */
  35. dblock_p symlookup(char *name, int status);
  36. /* Look up the data block with
  37. * the given name.
  38. */
  39. dblock_p getsym(int status);
  40. /* Read and look up a symbol.
  41. * If this is the first occurrence
  42. * of it, then make it external
  43. * (if status=OCCURRING) or
  44. * internal (if DEFINING).
  45. */
  46. proc_p getproc(int status);
  47. /* Same as getsym, but for procedure
  48. * names.
  49. */
  50. proc_p proclookup(char *name, int status);
  51. /* Find (in the hashtable) the
  52. * procedure with the given name.
  53. */
  54. void cleaninstrlabs();
  55. /* Forget about all instruction labels.
  56. */
  57. void dump_procnames(prc_p hash[], int n, FILE *f);
  58. /* Save the names of the procedures
  59. * in file f; hash is the hashtable
  60. * used and n is its length.
  61. */
  62. void cleanprocs(prc_p hash[], int n, int mask);
  63. /* Make the names of all procedures
  64. * for which p_flags1&mask = 0 invisible
  65. */
  66. void cleandblocks(sym_p hash[], int n, int mask);
  67. /* Make the names of all data blocks
  68. * for which d_flags1&mask = 0 invisible
  69. */
  70. void dump_dblocknames(sym_p hash[], int n, FILE *f);