reg.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef NORCSID
  2. static char rcsid[] = "$Header$";
  3. #endif
  4. #include "assert.h"
  5. #include "param.h"
  6. #include "types.h"
  7. #include "line.h"
  8. #include "shc.h"
  9. #include "proinf.h"
  10. #include "alloc.h"
  11. #include <em_spec.h>
  12. #include <em_pseu.h>
  13. #include <em_mes.h>
  14. #include "ext.h"
  15. /*
  16. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  17. * See the copyright notice in the ACK home directory, in the file "Copyright".
  18. *
  19. * Author: Hans van Staveren
  20. */
  21. regvar(ap) register arg_p ap; {
  22. register reg_p rp;
  23. register i;
  24. rp = newreg();
  25. i=0;
  26. while (ap!=(arg_p)0 && ap->a_typ==ARGOFF && i<4) {
  27. rp->r_par[i++]=ap->a_a.a_offset;
  28. ap=ap->a_next;
  29. }
  30. /*
  31. * Omit incomplete messages
  32. */
  33. switch(i) {
  34. default:assert(FALSE);
  35. case 0:
  36. case 1:
  37. case 2: oldreg(rp); return;
  38. case 3: rp->r_par[3]= (offset) 0; break;
  39. case 4: break;
  40. }
  41. rp->r_next = curpro.freg;
  42. curpro.freg = rp;
  43. }
  44. inreg(off) offset off; {
  45. register reg_p rp;
  46. for (rp=curpro.freg; rp != (reg_p) 0; rp=rp->r_next)
  47. if( rp->r_par[0] == off)
  48. return(TRUE);
  49. return(FALSE);
  50. }
  51. outregs() {
  52. register reg_p rp,tp;
  53. register i;
  54. for(rp=curpro.freg; rp != (reg_p) 0; rp = tp) {
  55. tp = rp->r_next;
  56. outinst(ps_mes);
  57. outoff((offset)ms_reg);
  58. for(i=0;i<4;i++)
  59. outoff(rp->r_par[i]);
  60. outinst(sp_cend);
  61. oldreg(rp);
  62. }
  63. /* List of register messages is followed by an empty ms_reg
  64. * unless an ms_gto was in this procedure, then the ms_gto
  65. * will be output. Kludgy.
  66. */
  67. outinst(ps_mes);
  68. outoff((offset)(curpro.gtoproc? ms_gto : ms_reg));
  69. outinst(sp_cend);
  70. curpro.freg = (reg_p) 0;
  71. }
  72. /* outsth() handles the output of the stackheight messages */
  73. outsth() {
  74. register lblst_p lp = est_list;
  75. if (state == NO_STACK_MES) return;
  76. while(lp != NULL) {
  77. if ((lp->ll_height != 0) && !(lp->ll_num->n_flags & NUMCOND)) {
  78. outinst(ps_mes);
  79. outoff((offset)ms_sth);
  80. outoff((offset)lp->ll_num->n_number);
  81. outoff((offset)lp->ll_height);
  82. outoff((offset)lp->ll_fallthrough);
  83. outinst(sp_cend);
  84. }
  85. lp = lp->ll_next;
  86. }
  87. }
  88. incregusage(off) offset off; {
  89. register reg_p rp;
  90. #ifndef GLOBAL_OPT
  91. /* If we're optimizing the output of the global optimizer
  92. * we must not change the count fields of the register messages.
  93. */
  94. for(rp=curpro.freg; rp != (reg_p) 0; rp=rp->r_next)
  95. if (rp->r_par[0]==off) {
  96. rp->r_par[3]++;
  97. return;
  98. }
  99. #endif
  100. }