cs_debug.c 3.1 KB

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