machcap.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "gc.h"
  10. int
  11. machcap(Node *n)
  12. {
  13. if(n == Z)
  14. return 1; /* test */
  15. switch(n->op){
  16. case OADD:
  17. case OAND:
  18. case OOR:
  19. case OSUB:
  20. case OXOR:
  21. if(typev[n->left->type->etype])
  22. return 1;
  23. break;
  24. case OMUL:
  25. case OLMUL:
  26. case OASMUL:
  27. case OASLMUL:
  28. return 1;
  29. case OLSHR:
  30. case OASHR:
  31. case OASHL:
  32. case OASASHL:
  33. case OASASHR:
  34. case OASLSHR:
  35. return 1;
  36. case OCAST:
  37. if(typev[n->type->etype]) {
  38. if(!typefd[n->left->type->etype])
  39. return 1;
  40. } else if(!typefd[n->type->etype]) {
  41. if(typev[n->left->type->etype])
  42. return 1;
  43. }
  44. break;
  45. case OCOMMA:
  46. case OCOND:
  47. case OLIST:
  48. case OANDAND:
  49. case OOROR:
  50. case ONOT:
  51. return 1;
  52. case OCOM:
  53. case ONEG:
  54. if(typechl[n->left->type->etype])
  55. return 1;
  56. if(typev[n->left->type->etype])
  57. return 1;
  58. return 0;
  59. case OASADD:
  60. case OASSUB:
  61. case OASAND:
  62. case OASOR:
  63. case OASXOR:
  64. return 1;
  65. case OPOSTINC:
  66. case OPOSTDEC:
  67. case OPREINC:
  68. case OPREDEC:
  69. return 1;
  70. case OEQ:
  71. case ONE:
  72. case OLE:
  73. case OGT:
  74. case OLT:
  75. case OGE:
  76. case OHI:
  77. case OHS:
  78. case OLO:
  79. case OLS:
  80. return 1;
  81. case ODIV:
  82. case OLDIV:
  83. case OLMOD:
  84. case OMOD:
  85. return 0;
  86. case OASDIV:
  87. case OASLDIV:
  88. case OASLMOD:
  89. case OASMOD:
  90. return 0;
  91. }
  92. return 0;
  93. }