aux.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef NORCSID
  2. static char rcsid4[] = "$Id$";
  3. #endif
  4. #include "nopt.h"
  5. arith
  6. OO_rotate(w,amount)
  7. arith w, amount;
  8. {
  9. long highmask, lowmask;
  10. highmask = (long)(-1) << amount;
  11. lowmask = ~highmask;
  12. if(OO_WSIZE!=4)
  13. highmask &= (OO_WSIZE==2)?0xFFFF:0xFF;
  14. return(((w<<amount)&highmask) | ((w >> (8*OO_WSIZE-amount))&lowmask));
  15. }
  16. int
  17. OO_signsame(a,b)
  18. arith a, b;
  19. {
  20. return( (a ^ b) >= 0);
  21. }
  22. int
  23. OO_sfit(val,nbits)
  24. arith val, nbits;
  25. {
  26. register long mask = ~((1L << (nbits - 1)) - 1);
  27. return(((val&mask) == 0) | (val&mask)==mask);
  28. }
  29. int
  30. OO_ufit(val, nbits)
  31. arith val, nbits;
  32. {
  33. return((val&(~((1L << (nbits - 1)) - 1))) == 0);
  34. }
  35. int
  36. OO_extsame(a1,a2)
  37. register p_instr a1, a2;
  38. {
  39. if (a1->em_argtype != a2->em_argtype)
  40. return(0);
  41. switch(a1->em_argtype) {
  42. case cst_ptyp:
  43. return (a1->em_cst == a2->em_cst);
  44. case sof_ptyp:
  45. if(a1->em_off != a2->em_off)
  46. return(0);
  47. return (strcmp(a1->em_dnam,a2->em_dnam)==0);
  48. case nof_ptyp:
  49. if (a1->em_off != a2->em_off)
  50. return(0);
  51. return (a1->em_dlb == a2->em_dlb);
  52. default:
  53. fatal("illegal type (%d) to sameext!",a1->em_argtype);
  54. /*NOTREACHED*/
  55. }
  56. }
  57. int
  58. OO_namsame(a1,a2)
  59. register p_instr a1, a2;
  60. {
  61. if (a1->em_argtype != a2->em_argtype)
  62. return(0);
  63. switch(a1->em_argtype) {
  64. case cst_ptyp:
  65. return 1;
  66. case sof_ptyp:
  67. return (strcmp(a1->em_dnam,a2->em_dnam)==0);
  68. case nof_ptyp:
  69. return (a1->em_dlb == a2->em_dlb);
  70. default:
  71. fatal("illegal type (%d) to samenam!",a1->em_argtype);
  72. /*NOTREACHED*/
  73. }
  74. }
  75. arith
  76. OO_offset(a)
  77. register p_instr a;
  78. {
  79. switch(a->em_argtype) {
  80. case cst_ptyp:
  81. return a->em_cst;
  82. case sof_ptyp:
  83. return a->em_off;
  84. case nof_ptyp:
  85. return a->em_off;
  86. default:
  87. fatal("illegal type (%d) to offset!",a->em_argtype);
  88. /*NOTREACHED*/
  89. }
  90. }