aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/ia64/tls-macros.h
blob: 13b216d85dc31221f6cb9d79ed4f0314d0c02853 (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
/* Macros to support TLS testing in times of missing compiler support.  */

extern void *__tls_get_addr (void *);

# define TLS_LE(x) \
  ({ void *__l;								      \
     asm ("mov r2=r13\n\t"						      \
         ";;\n\t"							      \
         "addl %0=@tprel(" #x "),r2\n\t"				      \
         : "=r" (__l) : : "r2"  ); __l; })

# define TLS_IE(x) \
  ({ void *__l;								      \
     register long __gp asm ("gp");					      \
     asm (";;\n\t"							      \
	 "addl r16=@ltoff(@tprel(" #x ")),gp\n\t"			      \
         ";;\n\t"							      \
         "ld8 r17=[r16]\n\t"						      \
         ";;\n\t"							      \
         "add %0=r13,r17\n\t"						      \
         ";;\n\t"							      \
         : "=r" (__l) : "r" (__gp) : "r16", "r17" ); __l; })

# define __TLS_CALL_CLOBBERS \
  "r2", "r3", "r8", "r9", "r10", "r11", "r14", "r15", "r16", "r17",	      \
  "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",	      \
  "r27", "r28", "r29", "r30", "r31",					      \
  "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15",	      \
  "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",	      \
  "b6", "b7",								      \
  "out0", "out1", "out2", "out3", "out4", "out5", "out6", "out7"

# define TLS_LD(x) \
  ({ void *__l;								      \
     register long __gp asm ("gp");					      \
     asm (";;\n\t"							      \
	 "mov loc0=gp\n\t"						      \
         "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t"			      \
         "addl out1=@dtprel(" #x "),r0\n\t"				      \
         ";;\n\t"							      \
         "ld8 out0=[r16]\n\t"						      \
         "br.call.sptk.many b0=__tls_get_addr"				      \
         ";;\n\t"							      \
         "mov gp=loc0\n\t"						      \
         "mov %0=r8\n\t"						      \
         ";;\n\t"							      \
         : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS);	      \
     __l; })

# define TLS_GD(x) \
  ({ void *__l;								      \
     register long __gp asm ("gp");					      \
     asm (";;\n\t"							      \
	 "mov loc0=gp\n\t"						      \
         "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t"			      \
         "addl r17=@ltoff(@dtprel(" #x ")),gp\n\t"			      \
         ";;\n\t"							      \
         "ld8 out0=[r16]\n\t"						      \
         "ld8 out1=[r17]\n\t"						      \
         "br.call.sptk.many b0=__tls_get_addr"				      \
         ";;\n\t"							      \
         "mov gp=loc0\n\t"						      \
         "mov %0=r8\n\t"						      \
         ";;\n\t"							      \
          : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS);	      \
     __l; })