compiler.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef __ALPHA_COMPILER_H
  2. #define __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. # define __kernel_cttz(x) __builtin_ctzl(x)
  19. # define __kernel_ctlz(x) __builtin_clzl(x)
  20. # define __kernel_ctpop(x) __builtin_popcountl(x)
  21. #else
  22. # define __kernel_insbl(val, shift) \
  23. ({ unsigned long __kir; \
  24. __asm__("insbl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  25. __kir; })
  26. # define __kernel_inswl(val, shift) \
  27. ({ unsigned long __kir; \
  28. __asm__("inswl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  29. __kir; })
  30. # define __kernel_insql(val, shift) \
  31. ({ unsigned long __kir; \
  32. __asm__("insql %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  33. __kir; })
  34. # define __kernel_inslh(val, shift) \
  35. ({ unsigned long __kir; \
  36. __asm__("inslh %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  37. __kir; })
  38. # define __kernel_extbl(val, shift) \
  39. ({ unsigned long __kir; \
  40. __asm__("extbl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  41. __kir; })
  42. # define __kernel_extwl(val, shift) \
  43. ({ unsigned long __kir; \
  44. __asm__("extwl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
  45. __kir; })
  46. # define __kernel_cmpbge(a, b) \
  47. ({ unsigned long __kir; \
  48. __asm__("cmpbge %r2,%1,%0" : "=r"(__kir) : "rI"(b), "rJ"(a)); \
  49. __kir; })
  50. # define __kernel_cttz(x) \
  51. ({ unsigned long __kir; \
  52. __asm__("cttz %1,%0" : "=r"(__kir) : "r"(x)); \
  53. __kir; })
  54. # define __kernel_ctlz(x) \
  55. ({ unsigned long __kir; \
  56. __asm__("ctlz %1,%0" : "=r"(__kir) : "r"(x)); \
  57. __kir; })
  58. # define __kernel_ctpop(x) \
  59. ({ unsigned long __kir; \
  60. __asm__("ctpop %1,%0" : "=r"(__kir) : "r"(x)); \
  61. __kir; })
  62. #endif
  63. /*
  64. * Beginning with EGCS 1.1, GCC defines __alpha_bwx__ when the BWX
  65. * extension is enabled. Previous versions did not define anything
  66. * we could test during compilation -- too bad, so sad.
  67. */
  68. #if defined(__alpha_bwx__)
  69. #define __kernel_ldbu(mem) (mem)
  70. #define __kernel_ldwu(mem) (mem)
  71. #define __kernel_stb(val,mem) ((mem) = (val))
  72. #define __kernel_stw(val,mem) ((mem) = (val))
  73. #else
  74. #define __kernel_ldbu(mem) \
  75. ({ unsigned char __kir; \
  76. __asm__("ldbu %0,%1" : "=r"(__kir) : "m"(mem)); \
  77. __kir; })
  78. #define __kernel_ldwu(mem) \
  79. ({ unsigned short __kir; \
  80. __asm__("ldwu %0,%1" : "=r"(__kir) : "m"(mem)); \
  81. __kir; })
  82. #define __kernel_stb(val,mem) \
  83. __asm__("stb %1,%0" : "=m"(mem) : "r"(val))
  84. #define __kernel_stw(val,mem) \
  85. __asm__("stw %1,%0" : "=m"(mem) : "r"(val))
  86. #endif
  87. /* Some idiots over in <linux/compiler.h> thought inline should imply
  88. always_inline. This breaks stuff. We'll include this file whenever
  89. we run into such problems. */
  90. #include <linux/compiler.h>
  91. #undef inline
  92. #undef __inline__
  93. #undef __inline
  94. #undef __always_inline
  95. #define __always_inline inline __attribute__((always_inline))
  96. #endif /* __ALPHA_COMPILER_H */