cs_debug.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. #include <stdio.h>
  7. #include <em_spec.h>
  8. #include "../share/types.h"
  9. #include "../share/debug.h"
  10. #include "../share/lset.h"
  11. #include "cs.h"
  12. #include "cs_aux.h"
  13. #include "cs_avail.h"
  14. #include "cs_entity.h"
  15. #ifdef VERBOSE
  16. extern char em_mnem[]; /* The mnemonics of the EM instructions. */
  17. static void showinstr(line_p lnp)
  18. {
  19. /* Makes the instruction in `lnp' human readable. Only lines that
  20. * can occur in expressions that are going to be eliminated are
  21. * properly handled.
  22. */
  23. if (INSTR(lnp) < sp_fmnem && INSTR(lnp) > sp_lmnem) {
  24. fprintf(stderr,"*** ?\n");
  25. return;
  26. }
  27. fprintf(stderr,"%s", &em_mnem[4 * (INSTR(lnp)-sp_fmnem)]);
  28. switch (TYPE(lnp)) {
  29. case OPNO:
  30. break;
  31. case OPSHORT:
  32. fprintf(stderr," %d", SHORT(lnp));
  33. break;
  34. case OPOBJECT:
  35. fprintf(stderr," %d", OBJ(lnp)->o_id);
  36. break;
  37. case OPOFFSET:
  38. fprintf(stderr," %ld", OFFSET(lnp));
  39. break;
  40. default:
  41. fprintf(stderr," ?");
  42. break;
  43. }
  44. fprintf(stderr,"\n");
  45. }
  46. void SHOWOCCUR(occur_p ocp)
  47. {
  48. /* Shows all instructions in an occurrence. */
  49. line_p lnp, next;
  50. if (verbose_flag) {
  51. for (lnp = ocp->oc_lfirst; lnp != (line_p) 0; lnp = next) {
  52. next = lnp == ocp->oc_llast ? (line_p) 0 : lnp->l_next;
  53. showinstr(lnp);
  54. }
  55. }
  56. }
  57. #endif
  58. #ifdef TRACE
  59. void SHOWAVAIL(avail_p avp)
  60. {
  61. /* Shows an available expression. */
  62. showinstr(avp->av_found);
  63. fprintf(stderr,"result %d,", avp->av_result);
  64. fprintf(stderr,"occurred %d times\n", Lnrelems(avp->av_occurs) + 1);
  65. }
  66. void OUTAVAILS()
  67. {
  68. avail_p ravp;
  69. fprintf(stderr,"AVAILABLE EXPRESSIONS\n");
  70. for (ravp = avails; ravp != (avail_p) 0; ravp = ravp->av_before) {
  71. SHOWAVAIL(ravp);
  72. fprintf(stderr,"\n");
  73. }
  74. }
  75. static char *enkinds[] = {
  76. "constant",
  77. "local",
  78. "external",
  79. "indirect",
  80. "offsetted",
  81. "address of local",
  82. "address of external",
  83. "address of offsetted",
  84. "address of local base",
  85. "address of argument base",
  86. "procedure",
  87. "floating zero",
  88. "array element",
  89. "local base",
  90. "heap pointer",
  91. "ignore mask"
  92. };
  93. void OUTENTITIES()
  94. {
  95. Lindex i;
  96. fprintf(stderr,"ENTITIES\n");
  97. for (i = Lfirst(entities); i != (Lindex) 0; i = Lnext(i, entities)) {
  98. entity_p rep = en_elem(i);
  99. fprintf(stderr,"%s,", enkinds[rep->en_kind]);
  100. fprintf(stderr,"size %ld,", rep->en_size);
  101. fprintf(stderr,"valno %d,", rep->en_vn);
  102. switch (rep->en_kind) {
  103. case ENCONST:
  104. fprintf(stderr,"$%ld\n", rep->en_val);
  105. break;
  106. case ENLOCAL:
  107. case ENALOCAL:
  108. fprintf(stderr,"%ld(LB)\n", rep->en_loc);
  109. break;
  110. case ENINDIR:
  111. fprintf(stderr,"*%d\n", rep->en_ind);
  112. break;
  113. case ENOFFSETTED:
  114. case ENAOFFSETTED:
  115. fprintf(stderr,"%ld(%d)\n", rep->en_off, rep->en_base);
  116. break;
  117. case ENALOCBASE:
  118. case ENAARGBASE:
  119. fprintf(stderr,"%ld levels\n", rep->en_levels);
  120. break;
  121. case ENARRELEM:
  122. fprintf(stderr,"%d[%d], ",rep->en_arbase,rep->en_index);
  123. fprintf(stderr,"rom at %d\n", rep->en_adesc);
  124. break;
  125. }
  126. fprintf(stderr,"\n");
  127. }
  128. }
  129. #endif /* TRACE */