compiler.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef _UAPI__ALPHA_COMPILER_H
  2. #define _UAPI__ALPHA_COMPILER_H
  3. /*
  4. * Herein are macros we use when describing various patterns we want to GCC.
  5. * In all cases we can get better schedules out of the compiler if we hide
  6. * as little as possible inside inline assembly. However, we want to be
  7. * able to know what we'll get out before giving up inline assembly. Thus
  8. * these tests and macros.
  9. */
  10. #if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3
  11. # define __kernel_insbl(val, shift) __builtin_alpha_insbl(val, shift)
  12. # define __kernel_inswl(val, shift) __builtin_alpha_inswl(val, shift)
  13. # define __kernel_insql(val, shift) __builtin_alpha_insql(val, shift)
  14. # define __kernel_inslh(val, shift) __builtin_alpha_inslh(val, shift)
  15. # define __kernel_extbl(val, shift) __builtin_alpha_extbl(val, shift)
  16. # define __kernel_extwl(val, shift) __builtin_alpha_extwl(val, shift)
  17. # define __kernel_cmpbge(a, b) __builtin_alpha_cmpbge(a, b)
  18. #else
  19. # define __kernel_insbl(val, shift) \
  20. ({ unsigned long __kir; \
  21. __asm__("insbl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  22. __kir; })
  23. # define __kernel_inswl(val, shift) \
  24. ({ unsigned long __kir; \
  25. __asm__("inswl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  26. __kir; })
  27. # define __kernel_insql(val, shift) \
  28. ({ unsigned long __kir; \
  29. __asm__("insql %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  30. __kir; })
  31. # define __kernel_inslh(val, shift) \
  32. ({ unsigned long __kir; \
  33. __asm__("inslh %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  34. __kir; })
  35. # define __kernel_extbl(val, shift) \
  36. ({ unsigned long __kir; \
  37. __asm__("extbl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  38. __kir; })
  39. # define __kernel_extwl(val, shift) \
  40. ({ unsigned long __kir; \
  41. __asm__("extwl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  42. __kir; })
  43. # define __kernel_cmpbge(a, b) \
  44. ({ unsigned long __kir; \
  45. __asm__("cmpbge %r2,%1,%0" : "=r"(__kir) : "rI"(b), "rJ"(a)); \
  46. __kir; })
  47. #endif
  48. #ifdef __alpha_cix__
  49. # if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3
  50. # define __kernel_cttz(x) __builtin_ctzl(x)
  51. # define __kernel_ctlz(x) __builtin_clzl(x)
  52. # define __kernel_ctpop(x) __builtin_popcountl(x)
  53. # else
  54. # define __kernel_cttz(x) \
  55. ({ unsigned long __kir; \
  56. __asm__("cttz %1,%0" : "=r"(__kir) : "r"(x)); \
  57. __kir; })
  58. # define __kernel_ctlz(x) \
  59. ({ unsigned long __kir; \
  60. __asm__("ctlz %1,%0" : "=r"(__kir) : "r"(x)); \
  61. __kir; })
  62. # define __kernel_ctpop(x) \
  63. ({ unsigned long __kir; \
  64. __asm__("ctpop %1,%0" : "=r"(__kir) : "r"(x)); \
  65. __kir; })
  66. # endif
  67. #else
  68. # define __kernel_cttz(x) \
  69. ({ unsigned long __kir; \
  70. __asm__(".arch ev67; cttz %1,%0" : "=r"(__kir) : "r"(x)); \
  71. __kir; })
  72. # define __kernel_ctlz(x) \
  73. ({ unsigned long __kir; \
  74. __asm__(".arch ev67; ctlz %1,%0" : "=r"(__kir) : "r"(x)); \
  75. __kir; })
  76. # define __kernel_ctpop(x) \
  77. ({ unsigned long __kir; \
  78. __asm__(".arch ev67; ctpop %1,%0" : "=r"(__kir) : "r"(x)); \
  79. __kir; })
  80. #endif
  81. /*
  82. * Beginning with EGCS 1.1, GCC defines __alpha_bwx__ when the BWX
  83. * extension is enabled. Previous versions did not define anything
  84. * we could test during compilation -- too bad, so sad.
  85. */
  86. #if defined(__alpha_bwx__)
  87. #define __kernel_ldbu(mem) (mem)
  88. #define __kernel_ldwu(mem) (mem)
  89. #define __kernel_stb(val,mem) ((mem) = (val))
  90. #define __kernel_stw(val,mem) ((mem) = (val))
  91. #else
  92. #define __kernel_ldbu(mem) \
  93. ({ unsigned char __kir; \
  94. __asm__(".arch ev56; \
  95. ldbu %0,%1" : "=r"(__kir) : "m"(mem)); \
  96. __kir; })
  97. #define __kernel_ldwu(mem) \
  98. ({ unsigned short __kir; \
  99. __asm__(".arch ev56; \
  100. ldwu %0,%1" : "=r"(__kir) : "m"(mem)); \
  101. __kir; })
  102. #define __kernel_stb(val,mem) \
  103. __asm__(".arch ev56; \
  104. stb %1,%0" : "=m"(mem) : "r"(val))
  105. #define __kernel_stw(val,mem) \
  106. __asm__(".arch ev56; \
  107. stw %1,%0" : "=m"(mem) : "r"(val))
  108. #endif
  109. #endif /* _UAPI__ALPHA_COMPILER_H */