summaryrefslogtreecommitdiff
path: root/test/tls/tls-macros-xtensa.h
blob: 90fc726f6f6b65a96ea9e23867c6a222c3ad5c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#if defined(__XTENSA_WINDOWED_ABI__)
#define TLS_GD(x)							\
  ({ int *__l;								\
     __asm__ ("movi  a8, " #x "@TLSFUNC\n\t"				\
	  "movi a10, " #x "@TLSARG\n\t"					\
	  "callx8.tls a8, " #x "@TLSCALL\n\t"				\
	  "mov %0, a10\n\t"						\
	  : "=r" (__l)							\
	  :								\
	  : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15");	\
      __l; })

#define TLS_LD(x)							\
  ({ int *__l;								\
     __asm__ ("movi  a8, _TLS_MODULE_BASE_@TLSFUNC\n\t"			\
	  "movi a10, _TLS_MODULE_BASE_@TLSARG\n\t"			\
	  "callx8.tls a8, _TLS_MODULE_BASE_@TLSCALL\n\t"		\
	  "movi %0, " #x "@DTPOFF\n\t"					\
	  "add %0, %0, a10\n\t"						\
	  : "=r" (__l)							\
	  :								\
	  : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15");	\
      __l; })
#elif defined(__XTENSA_CALL0_ABI__)
#define TLS_GD(x)							\
  ({ int *__l;								\
     __asm__ ("movi  a0, " #x "@TLSFUNC\n\t"				\
	  "movi a2, " #x "@TLSARG\n\t"					\
	  "callx0.tls a0, " #x "@TLSCALL\n\t"				\
	  "mov %0, a2\n\t"						\
	  : "=r" (__l)							\
	  :								\
	  : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
      __l; })

#define TLS_LD(x)							\
  ({ int *__l;								\
     __asm__ ("movi  a0, _TLS_MODULE_BASE_@TLSFUNC\n\t"			\
	  "movi a2, _TLS_MODULE_BASE_@TLSARG\n\t"			\
	  "callx0.tls a0, _TLS_MODULE_BASE_@TLSCALL\n\t"		\
	  "movi %0, " #x "@DTPOFF\n\t"					\
	  "add %0, %0, a2\n\t"						\
	  : "=r" (__l)							\
	  :								\
	  : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
      __l; })
#else
#error Unsupported Xtensa ABI
#endif

#define TLS_IE(x) TLS_LE(x)

#define TLS_LE(x)							\
  ({ int *__l;								\
     int __t;								\
     __asm__ ("rur %0, threadptr\n\t"					\
	  "movi %1, " #x "@TPOFF\n\t"					\
	  "add %0, %0, %1\n\t"						\
	  : "=r" (__l), "=r" (__t) );					\
     __l; });								\