aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/hppa/tls-macros.h
blob: f5a1cd8f3d4b189c4c6061b03475ead83e298f52 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* TLS Access Macros for HP PARISC Linux */

/* HPPA Local Exec TLS access.  */
#define TLS_LE(x) \
  ({  int * __result;  \
      unsigned long __tmp; \
      asm ( \
	"  mfctl %%cr27, %1\n" \
	"  addil LR'" #x "-$tls_leoff$, %1\n" \
	"  ldo RR'" #x "-$tls_leoff$(%%r1), %0\n" \
        : "=r" (__result), "=r" (__tmp) \
	: \
	: "r1" );  \
      __result;  \
  })

/* HPPA Initial Exec TLS access.  */
#ifdef PIC
#  define TLS_IE(x) \
  ({  int * __result;  \
      unsigned long __tmp, __tmp2; \
      asm ( \
	"  mfctl %%cr27, %1\n" \
	"  addil LT'" #x "-$tls_ieoff$, %%r19\n" \
	"  ldw RT'" #x "-$tls_ieoff$(%%r1), %2\n" \
	"  add %1, %2, %0\n" \
	: "=r" (__result), "=r" (__tmp), "=r" (__tmp2) \
	: \
	: "r1" ); \
      __result;  \
  })
#else
#  define TLS_IE(x) \
  ({  int * __result;  \
      unsigned long __tmp, __tmp2; \
      asm ( \
	"  mfctl %%cr27, %1\n" \
	"  addil LR'" #x "-$tls_ieoff$, %%r27\n" \
	"  ldw RR'" #x "-$tls_ieoff$(%%r1), %2\n" \
	"  add %1, %2, %0\n" \
	: "=r" (__result), "=r" (__tmp), "=r" (__tmp2) \
	: \
	: "r1" ); \
      __result;  \
  })
#endif

#ifdef PIC
/* HPPA Local Dynamic TLS access.  */
#  define TLS_LD(x) \
  ({  int * __result;  \
      asm (  \
	"  copy %%r19, %%r4\n" \
	"  addil LT'" #x "-$tls_ldidx$, %%r19\n" \
	"  bl __tls_get_addr, %%r2\n" \
	"  ldo RT'" #x "-$tls_ldidx$(%%r1), %%r26\n" \
	"  addil LR'" #x "-$tls_dtpoff$, %%r28\n" \
	"  ldo RR'" #x "-$tls_dtpoff$(%%r1), %0\n" \
	"  copy %%r4, %%r19\n" \
	: "=r" (__result) \
	: \
	: "r1", "r2", "r4", "r20", "r21", "r22", "r23", "r24", \
	  "r25", "r26", "r28", "r29", "r31" ); \
      __result;  \
  })
#else
#  define TLS_LD(x) \
  ({  int * __result;  \
      asm (  \
	"  addil LR'" #x "-$tls_ldidx$, %%r27\n" \
	"  bl __tls_get_addr, %%r2\n" \
	"  ldo RR'" #x "-$tls_ldidx$(%%r1), %%r26\n" \
	"  addil LR'" #x "-$tls_dtpoff$, %%r28\n" \
	"  ldo RR'" #x "-$tls_dtpoff$(%%r1), %0\n" \
	: "=r" (__result) \
	: \
	: "r1", "r2", "r20", "r21", "r22", "r23", "r24", \
	  "r25", "r26", "r28", "r29", "r31" ); \
      __result;  \
  })
#endif

/* HPPA General Dynamic TLS access.  */
#ifdef PIC
#  define TLS_GD(x) \
  ({  int * __result;  \
      asm (  \
	"  copy %%r19, %%r4\n" \
        "  addil LT'" #x "-$tls_gdidx$, %%r19\n" \
	"  bl __tls_get_addr, %%r2\n" \
	"  ldo RT'" #x "-$tls_gdidx$(%%r1), %%r26\n" \
	"  copy %%r28, %0\n" \
	"  copy %%r4, %%r19\n" \
	: "=r" (__result) \
	: \
	: "r1", "r2", "r4", "r20", "r21", "r22", "r23", "r24", \
	  "r25", "r26", "r28", "r29", "r31" ); \
      __result;  \
  })
#else
#  define TLS_GD(x) \
  ({  int * __result;  \
      asm (  \
        "  addil LR'" #x "-$tls_gdidx$, %%r27\n" \
	"  bl __tls_get_addr, %%r2\n" \
	"  ldo RR'" #x "-$tls_gdidx$(%%r1), %%r26\n" \
	"  copy %%r28, %0\n" \
	: "=r" (__result) \
	: \
	: "r1", "r2", "r20", "r21", "r22", "r23", "r24", \
	  "r25", "r26", "r28", "r29", "r31" ); \
      __result;  \
  })
#endif