tls-macros-xtensa.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #if defined(__XTENSA_WINDOWED_ABI__)
  2. #define TLS_GD(x) \
  3. ({ int *__l; \
  4. __asm__ ("movi a8, " #x "@TLSFUNC\n\t" \
  5. "movi a10, " #x "@TLSARG\n\t" \
  6. "callx8.tls a8, " #x "@TLSCALL\n\t" \
  7. "mov %0, a10\n\t" \
  8. : "=r" (__l) \
  9. : \
  10. : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
  11. __l; })
  12. #define TLS_LD(x) \
  13. ({ int *__l; \
  14. __asm__ ("movi a8, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
  15. "movi a10, _TLS_MODULE_BASE_@TLSARG\n\t" \
  16. "callx8.tls a8, _TLS_MODULE_BASE_@TLSCALL\n\t" \
  17. "movi %0, " #x "@TPOFF\n\t" \
  18. "add %0, %0, a10\n\t" \
  19. : "=r" (__l) \
  20. : \
  21. : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
  22. __l; })
  23. #elif defined(__XTENSA_CALL0_ABI__)
  24. #define TLS_GD(x) \
  25. ({ int *__l; \
  26. __asm__ ("movi a0, " #x "@TLSFUNC\n\t" \
  27. "movi a2, " #x "@TLSARG\n\t" \
  28. "callx0.tls a0, " #x "@TLSCALL\n\t" \
  29. "mov %0, a2\n\t" \
  30. : "=r" (__l) \
  31. : \
  32. : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
  33. __l; })
  34. #define TLS_LD(x) \
  35. ({ int *__l; \
  36. __asm__ ("movi a0, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
  37. "movi a2, _TLS_MODULE_BASE_@TLSARG\n\t" \
  38. "callx0.tls a0, _TLS_MODULE_BASE_@TLSCALL\n\t" \
  39. "movi %0, " #x "@TPOFF\n\t" \
  40. "add %0, %0, a2\n\t" \
  41. : "=r" (__l) \
  42. : \
  43. : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
  44. __l; })
  45. #else
  46. #error Unsupported Xtensa ABI
  47. #endif
  48. #define TLS_IE(x) TLS_LE(x)
  49. #define TLS_LE(x) \
  50. ({ int *__l; \
  51. int __t; \
  52. __asm__ ("rur %0, threadptr\n\t" \
  53. "movi %1, " #x "@TPOFF\n\t" \
  54. "add %0, %0, %1\n\t" \
  55. : "=r" (__l), "=r" (__t) ); \
  56. __l; }); \