1
0

machcap.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // return 0;
  14. if(n == Z)
  15. return 1; /* test */
  16. switch(n->op) {
  17. case OMUL:
  18. case OLMUL:
  19. case OASMUL:
  20. case OASLMUL:
  21. if(typechl[n->type->etype])
  22. return 1;
  23. if(typev[n->type->etype]) {
  24. // if(typev[n->type->etype] && n->right->op == OCONST) {
  25. // if(hi64v(n->right) == 0)
  26. return 1;
  27. }
  28. break;
  29. case OCOM:
  30. case ONEG:
  31. case OADD:
  32. case OAND:
  33. case OOR:
  34. case OSUB:
  35. case OXOR:
  36. case OASHL:
  37. case OLSHR:
  38. case OASHR:
  39. if(typechlv[n->left->type->etype])
  40. return 1;
  41. break;
  42. case OCAST:
  43. if(typev[n->type->etype]) {
  44. if(typechlp[n->left->type->etype])
  45. return 1;
  46. }
  47. else if(!typefd[n->type->etype]) {
  48. if(typev[n->left->type->etype])
  49. return 1;
  50. }
  51. break;
  52. case OCOND:
  53. case OCOMMA:
  54. case OLIST:
  55. case OANDAND:
  56. case OOROR:
  57. case ONOT:
  58. case ODOT:
  59. return 1;
  60. case OASADD:
  61. case OASSUB:
  62. case OASAND:
  63. case OASOR:
  64. case OASXOR:
  65. return 1;
  66. case OASASHL:
  67. case OASASHR:
  68. case OASLSHR:
  69. return 1;
  70. case OPOSTINC:
  71. case OPOSTDEC:
  72. case OPREINC:
  73. case OPREDEC:
  74. return 1;
  75. case OEQ:
  76. case ONE:
  77. case OLE:
  78. case OGT:
  79. case OLT:
  80. case OGE:
  81. case OHI:
  82. case OHS:
  83. case OLO:
  84. case OLS:
  85. //print("%O\n", n->op);
  86. return 1;
  87. }
  88. return 0;
  89. }