1 /* Macros to support TLS testing in times of missing compiler support. */
3 #define COMMON_INT_DEF(x) \
4 __asm__ (".tls_common " #x ",4,4")
5 /* XXX Until we get compiler support we don't need declarations. */
6 #define COMMON_INT_DECL(x)
8 /* XXX This definition will probably be machine specific, too. */
9 #define VAR_INT_DEF(x) \
10 __asm__ (".section .tdata\n\t" \
14 ".size " #x ",4\n\t" \
16 /* XXX Until we get compiler support we don't need declarations. */
17 #define VAR_INT_DECL(x)
20 #include <tls-macros-mips.h>
25 #include <tls-macros-thumb.h>
27 #include <tls-macros-arm.h>
31 /* XXX Each architecture must have its own asm for now. */
35 __asm__ ("movl %%gs:0,%0\n\t" \
36 "subl $" #x "@tpoff,%0" \
43 __asm__ ("movl %%gs:0,%0\n\t" \
44 "subl " #x "@gottpoff(%%ebx),%0" \
50 __asm__ ("call 1f\n\t" \
52 "1:\tmovl (%%esp), %%ebx\n\t" \
55 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
56 "movl %%gs:0,%0\n\t" \
57 "subl " #x "@gottpoff(%%ebx),%0" \
64 ({ int *__l, __c, __d; \
65 __asm__ ("leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
66 "call ___tls_get_addr@plt\n\t" \
67 "leal " #x "@dtpoff(%%eax), %%eax" \
68 : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
72 ({ int *__l, __b, __c, __d; \
73 __asm__ ("call 1f\n\t" \
75 "1:\tmovl (%%esp), %%ebx\n\t" \
78 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
79 "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
80 "call ___tls_get_addr@plt\n\t" \
81 "leal " #x "@dtpoff(%%eax), %%eax" \
82 : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
88 ({ int *__l, __c, __d; \
89 __asm__ ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
90 "call ___tls_get_addr@plt\n\t" \
92 : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
96 ({ int *__l, __c, __d; \
97 __asm__ ("call 1f\n\t" \
99 "1:\tmovl (%%esp), %%ebx\n\t" \
102 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
103 "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
104 "call ___tls_get_addr@plt\n\t" \
106 : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
110 #elif defined __x86_64__
114 __asm__ ("movq %%fs:0,%0\n\t" \
115 "leaq " #x "@tpoff(%0), %0" \
121 __asm__ ("movq %%fs:0,%0\n\t" \
122 "addq " #x "@gottpoff(%%rip),%0" \
127 ({ int *__l, __c, __d; \
128 __asm__ ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \
129 "call __tls_get_addr@plt\n\t" \
130 "leaq " #x "@dtpoff(%%rax), %%rax" \
131 : "=a" (__l), "=&c" (__c), "=&d" (__d) \
132 : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
136 ({ int *__l, __c, __d; \
137 __asm__ (".byte 0x66\n\t" \
138 "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \
141 "call __tls_get_addr@plt" \
142 : "=a" (__l), "=&c" (__c), "=&d" (__d) \
143 : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
149 ({ int *__l; void *__tp; \
150 __asm__ ("stc gbr,%1\n\t" \
155 "1: .long " #x "@tpoff\n\t" \
157 : "=r" (__l), "=r" (__tp)); \
162 ({ int *__l; void *__tp; \
163 register void *__gp __asm__("r12"); \
164 __asm__ ("mov.l 1f,r0\n\t" \
166 "mov.l @(r0,r12),%0\n\t" \
170 "1: .long " #x "@gottpoff\n\t" \
172 : "=r" (__l), "=r" (__tp) : "r" (__gp) : "r0"); \
176 ({ int *__l; void *__tp; \
177 __asm__ ("mov.l r12,@-r15\n\t" \
183 "mov.l @(r0,r12),%0\n\t" \
187 "1: .long " #x "@gottpoff\n\t" \
188 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
189 "2: mov.l @r15+,r12" \
190 : "=r" (__l), "=r" (__tp) : : "r0"); \
197 register void *__gp __asm__("r12"); \
198 __asm__ ("mov.l 1f,r4\n\t" \
207 "1: .long " #x "@tlsldm\n\t" \
208 "2: .long __tls_get_addr@plt\n\t" \
209 "4: mov.l 3f,%0\n\t" \
213 "3: .long " #x "@dtpoff\n\t" \
215 : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
216 "r6", "r7", "pr", "t"); \
221 __asm__ ("mov.l r12,@-r15\n\t" \
234 "1: .long " #x "@tlsldm\n\t" \
235 "2: .long __tls_get_addr@plt\n\t" \
236 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
237 "4: mov.l 3f,%0\n\t" \
241 "3: .long " #x "@dtpoff\n\t" \
242 "5: mov.l @r15+,r12" \
243 : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
251 register void *__gp __asm__("r12"); \
252 __asm__ ("mov.l 1f,r4\n\t" \
261 "1: .long " #x "@tlsgd\n\t" \
262 "2: .long __tls_get_addr@plt\n\t" \
264 : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
265 "r6", "r7", "pr", "t"); \
270 __asm__ ("mov.l r12,@-r15\n\t" \
283 "1: .long " #x "@tlsgd\n\t" \
284 "2: .long __tls_get_addr@plt\n\t" \
285 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
286 "3: mov.l @r15+,r12" \
287 : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
292 #elif defined __alpha__
294 register void *__gp
__asm__("$29");
298 __asm__ ("call_pal 158\n\tlda $0," #x "($0)\t\t!tprel" : "=v"(__l)); \
302 ({ char *__tp; unsigned long __o; \
303 __asm__ ("call_pal 158\n\tldq %1," #x "($gp)\t\t!gottprel" \
304 : "=v"(__tp), "=r"(__o) : "r"(__gp)); \
305 (int *)(__tp + __o); })
308 ({ extern void *__tls_get_addr(void *); int *__l; void *__i; \
309 __asm__ ("lda %0," #x "($gp)\t\t!tlsldm" : "=r" (__i) : "r"(__gp)); \
310 __i = __tls_get_addr(__i); \
311 __asm__ ("lda %0, " #x "(%1)\t\t!dtprel" : "=r"(__l) : "r"(__i)); \
315 ({ extern void *__tls_get_addr(void *); void *__i; \
316 __asm__ ("lda %0," #x "($gp)\t\t!tlsgd" : "=r" (__i) : "r"(__gp)); \
317 (int *) __tls_get_addr(__i); })
320 #elif defined __ia64__
324 __asm__ ("mov r2=r13\n\t" \
326 "addl %0=@tprel(" #x "),r2\n\t" \
327 : "=r" (__l) : : "r2" ); __l; })
331 register long __gp __asm__ ("gp"); \
333 "addl r16=@ltoff(@tprel(" #x ")),gp\n\t" \
335 "ld8 r17=[r16]\n\t" \
337 "add %0=r13,r17\n\t" \
339 : "=r" (__l) : "r" (__gp) : "r16", "r17" ); __l; })
341 # define __TLS_CALL_CLOBBERS \
342 "r2", "r3", "r8", "r9", "r10", "r11", "r14", "r15", "r16", "r17", \
343 "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", \
344 "r27", "r28", "r29", "r30", "r31", \
345 "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
346 "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
348 "out0", "out1", "out2", "out3", "out4", "out5", "out6", "out7"
352 register long __gp __asm__ ("gp"); \
355 "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
356 "addl out1=@dtprel(" #x "),r0\n\t" \
358 "ld8 out0=[r16]\n\t" \
359 "br.call.sptk.many b0=__tls_get_addr" \
364 : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
369 register long __gp __asm__ ("gp"); \
372 "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
373 "addl r17=@ltoff(@dtprel(" #x ")),gp\n\t" \
375 "ld8 out0=[r16]\n\t" \
376 "ld8 out1=[r17]\n\t" \
377 "br.call.sptk.many b0=__tls_get_addr" \
382 : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
385 #elif defined __sparc__ && !defined __arch64__
389 __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
390 __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
391 __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
395 # define TLS_LOAD_PIC \
396 ({ register long pc __asm__ ("%o7"); \
398 __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
400 "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
401 "add %1, %0, %1\n\t" \
402 : "=r" (pc), "=r" (got)); \
405 # define TLS_LOAD_PIC \
407 __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
408 "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
409 "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
416 __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
417 __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
418 __asm__ ("ld [%1 + %2], %0, %%tie_ld(" #x ")" \
419 : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
420 __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
424 ({ int *__l; register void *__o0 __asm__ ("%o0"); \
426 __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
427 __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
428 __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
429 : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
430 __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
432 : "=r" (__o0) : "0" (__o0) \
433 : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
435 __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
436 __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
437 __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
438 : "r" (__o0), "r" (__o)); \
442 ({ int *__l; register void *__o0 __asm__ ("%o0"); \
443 __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
444 __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
445 __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
446 : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
447 __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
449 : "=r" (__o0) : "0" (__o0) \
450 : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
454 #elif defined __sparc__ && defined __arch64__
458 __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
459 __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
460 __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
464 # define TLS_LOAD_PIC \
466 __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
468 "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
469 "add %1, %0, %1\n\t" \
470 : "=r" (pc), "=r" (got)); \
473 # define TLS_LOAD_PIC \
475 __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
476 "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
477 "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
484 __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
485 __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
486 __asm__ ("ldx [%1 + %2], %0, %%tie_ldx(" #x ")" \
487 : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
488 __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
492 ({ int *__l; register void *__o0 __asm__ ("%o0"); \
494 __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
495 __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
496 __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
497 : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
498 __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
500 : "=r" (__o0) : "0" (__o0) \
501 : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
503 __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
504 __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
505 __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
506 : "r" (__o0), "r" (__o)); \
510 ({ int *__l; register void *__o0 __asm__ ("%o0"); \
511 __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
512 __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
513 __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
514 : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
515 __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
517 : "=r" (__o0) : "0" (__o0) \
518 : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
522 #elif defined __s390x__
525 ({ unsigned long __offset; \
526 __asm__ ("bras %0,1f\n" \
527 "0:\t.quad " #x "@ntpoff\n" \
529 : "=a" (__offset) : : "cc" ); \
530 (int *) (__builtin_thread_pointer() + __offset); })
534 ({ unsigned long __offset; \
535 __asm__ ("bras %0,1f\n" \
536 "0:\t.quad " #x "@gotntpoff\n" \
537 "1:\tlg %0,0(%0)\n\t" \
538 "lg %0,0(%0,%%r12):tls_load:" #x \
539 : "=&a" (__offset) : : "cc" ); \
540 (int *) (__builtin_thread_pointer() + __offset); })
543 ({ unsigned long __offset; \
544 __asm__ ("bras %0,1f\n" \
545 "0:\t.quad " #x "@indntpoff\n" \
546 "1:\t lg %0,0(%0)\n\t" \
547 "lg %0,0(%0):tls_load:" #x \
548 : "=&a" (__offset) : : "cc" ); \
549 (int *) (__builtin_thread_pointer() + __offset); })
554 ({ unsigned long __offset, __save12; \
555 __asm__ ("bras %0,1f\n" \
556 "0:\t.quad " #x "@tlsldm\n\t" \
557 ".quad " #x "@dtpoff\n" \
558 "1:\tlgr %1,%%r12\n\t" \
559 "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
560 "lg %%r2,0(%0)\n\t" \
561 "brasl %%r14,__tls_get_offset@plt:tls_ldcall:" #x "\n\t" \
565 : "=&a" (__offset), "=&a" (__save12) \
566 : : "cc", "0", "1", "2", "3", "4", "5", "14" ); \
567 (int *) (__builtin_thread_pointer() + __offset); })
570 ({ unsigned long __offset; \
571 __asm__ ("bras %0,1f\n" \
572 "0:\t.quad " #x "@tlsldm\n\t" \
573 ".quad " #x "@dtpoff\n" \
574 "1:\tlarl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
575 "lg %%r2,0(%0)\n\t" \
576 "brasl %%r14,__tls_get_offset@plt:tls_ldcall:" #x "\n\t" \
580 : : "cc", "0", "1", "2", "3", "4", "5", "12", "14" ); \
581 (int *) (__builtin_thread_pointer() + __offset); })
586 ({ unsigned long __offset, __save12; \
587 __asm__ ("bras %0,1f\n" \
588 "0:\t.quad " #x "@tlsgd\n" \
589 "1:\tlgr %1,%%r12\n\t" \
590 "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
591 "lg %%r2,0(%0)\n\t" \
592 "brasl %%r14,__tls_get_offset@plt:tls_gdcall:" #x "\n\t" \
595 : "=&a" (__offset), "=&a" (__save12) \
596 : : "cc", "0", "1", "2", "3", "4", "5", "14" ); \
597 (int *) (__builtin_thread_pointer() + __offset); })
600 ({ unsigned long __offset; \
601 __asm__ ("bras %0,1f\n" \
602 "0:\t.quad " #x "@tlsgd\n" \
603 "1:\tlarl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
604 "lg %%r2,0(%0)\n\t" \
605 "brasl %%r14,__tls_get_offset@plt:tls_gdcall:" #x "\n\t" \
608 : : "cc", "0", "1", "2", "3", "4", "5", "12", "14" ); \
609 (int *) (__builtin_thread_pointer() + __offset); })
612 #elif defined __s390__
615 ({ unsigned long __offset; \
616 __asm__ ("bras %0,1f\n" \
617 "0:\t.long " #x "@ntpoff\n" \
619 : "=a" (__offset) : : "cc" ); \
620 (int *) (__builtin_thread_pointer() + __offset); })
624 ({ unsigned long __offset; \
625 __asm__ ("bras %0,1f\n" \
626 "0:\t.long " #x "@gotntpoff\n" \
627 "1:\tl %0,0(%0)\n\t" \
628 "l %0,0(%0,%%r12):tls_load:" #x \
629 : "=&a" (__offset) : : "cc" ); \
630 (int *) (__builtin_thread_pointer() + __offset); })
633 ({ unsigned long __offset; \
634 __asm__ ("bras %0,1f\n" \
635 "0:\t.long " #x "@indntpoff\n" \
636 "1:\t l %0,0(%0)\n\t" \
637 "l %0,0(%0):tls_load:" #x \
638 : "=&a" (__offset) : : "cc" ); \
639 (int *) (__builtin_thread_pointer() + __offset); })
644 ({ unsigned long __offset, __save12; \
645 __asm__ ("bras %0,1f\n" \
646 "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
647 ".long __tls_get_offset@plt-0b\n\t" \
648 ".long " #x "@tlsldm\n\t" \
649 ".long " #x "@dtpoff\n" \
650 "1:\tlr %1,%%r12\n\t" \
651 "l %%r12,0(%0)\n\t" \
652 "la %%r12,0(%%r12,%0)\n\t" \
655 "bas %%r14,0(%%r1,%0):tls_ldcall:" #x "\n\t" \
659 : "=&a" (__offset), "=&a" (__save12) \
660 : : "cc", "0", "1", "2", "3", "4", "5" ); \
661 (int *) (__builtin_thread_pointer() + __offset); })
664 ({ unsigned long __offset; \
665 __asm__ ("bras %0,1f\n" \
666 "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \
667 ".long __tls_get_offset@plt\n\t" \
668 ".long " #x "@tlsldm\n\t" \
669 ".long " #x "@dtpoff\n" \
670 "1:\tl %%r12,0(%0)\n\t" \
673 "bas %%r14,0(%%r1):tls_ldcall:" #x "\n\t" \
676 : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" ); \
677 (int *) (__builtin_thread_pointer() + __offset); })
682 ({ unsigned long __offset, __save12; \
683 __asm__ ("bras %0,1f\n" \
684 "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
685 ".long __tls_get_offset@plt-0b\n\t" \
686 ".long " #x "@tlsgd\n" \
687 "1:\tlr %1,%%r12\n\t" \
688 "l %%r12,0(%0)\n\t" \
689 "la %%r12,0(%%r12,%0)\n\t" \
692 "bas %%r14,0(%%r1,%0):tls_gdcall:" #x "\n\t" \
695 : "=&a" (__offset), "=&a" (__save12) \
696 : : "cc", "0", "1", "2", "3", "4", "5" ); \
697 (int *) (__builtin_thread_pointer() + __offset); })
700 ({ unsigned long __offset; \
701 __asm__ ("bras %0,1f\n" \
702 "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \
703 ".long __tls_get_offset@plt\n\t" \
704 ".long " #x "@tlsgd\n" \
705 "1:\tl %%r12,0(%0)\n\t" \
708 "bas %%r14,0(%%r1):tls_gdcall:" #x "\n\t" \
710 : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" ); \
711 (int *) (__builtin_thread_pointer() + __offset); })
714 #elif defined __powerpc__ && !defined __powerpc64__
716 /*#include "config.h"*/
718 # define __TLS_CALL_CLOBBERS \
719 "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", \
720 "lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"
722 /* PowerPC32 Local Exec TLS access. */
725 __asm__ ("addi %0,2," #x "@tprel" \
726 : "=r" (__result)); \
729 /* PowerPC32 Initial Exec TLS access. */
730 # ifdef HAVE_ASM_PPC_REL16
733 __asm__ ("bcl 20,31,1f\n1:\t" \
735 "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
736 "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
737 "lwz %0," #x "@got@tprel(%0)\n\t" \
738 "add %0,%0," #x "@tls" \
739 : "=b" (__result) : \
745 __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
747 "lwz %0," #x "@got@tprel(%0)\n\t" \
748 "add %0,%0," #x "@tls" \
749 : "=b" (__result) : \
754 /* PowerPC32 Local Dynamic TLS access. */
755 # ifdef HAVE_ASM_PPC_REL16
758 __asm__ ("bcl 20,31,1f\n1:\t" \
760 "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
761 "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
762 "addi 3,3," #x "@got@tlsld\n\t" \
763 "bl __tls_get_addr@plt\n\t" \
764 "addi %0,3," #x "@dtprel" \
765 : "=r" (__result) : \
766 : __TLS_CALL_CLOBBERS); \
771 __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
773 "addi 3,3," #x "@got@tlsld\n\t" \
774 "bl __tls_get_addr@plt\n\t" \
775 "addi %0,3," #x "@dtprel" \
776 : "=r" (__result) : \
777 : __TLS_CALL_CLOBBERS); \
781 /* PowerPC32 General Dynamic TLS access. */
782 # ifdef HAVE_ASM_PPC_REL16
784 ({ register int *__result __asm__ ("r3"); \
785 __asm__ ("bcl 20,31,1f\n1:\t" \
787 "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
788 "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
789 "addi 3,3," #x "@got@tlsgd\n\t" \
790 "bl __tls_get_addr@plt" \
792 : __TLS_CALL_CLOBBERS); \
796 ({ register int *__result __asm__ ("r3"); \
797 __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
799 "addi 3,3," #x "@got@tlsgd\n\t" \
800 "bl __tls_get_addr@plt" \
802 : __TLS_CALL_CLOBBERS); \
806 #elif defined __powerpc__ && defined __powerpc64__
808 /* PowerPC64 Local Exec TLS access. */
812 " addis %0,13," #x "@tprel@ha\n" \
813 " addi %0,%0," #x "@tprel@l\n" \
814 : "=b" (__result) ); \
817 /* PowerPC64 Initial Exec TLS access. */
821 " ld %0," #x "@got@tprel(2)\n" \
822 " add %0,%0," #x "@tls\n" \
823 : "=b" (__result) ); \
826 /* PowerPC64 Local Dynamic TLS access. */
830 " addi 3,2," #x "@got@tlsld\n" \
831 " bl .__tls_get_addr\n" \
833 " addis %0,3," #x "@dtprel@ha\n" \
834 " addi %0,%0," #x "@dtprel@l\n" \
835 : "=b" (__result) : \
836 : "0", "3", "4", "5", "6", "7", \
837 "8", "9", "10", "11", "12", \
839 "cr0", "cr1", "cr5", "cr6", "cr7"); \
842 /* PowerPC64 General Dynamic TLS access. */
846 " addi 3,2," #x "@got@tlsgd\n" \
847 " bl .__tls_get_addr\n" \
850 : "=b" (__result) : \
851 : "0", "3", "4", "5", "6", "7", \
852 "8", "9", "10", "11", "12", \
854 "cr0", "cr1", "cr5", "cr6", "cr7"); \
858 #elif defined __arc__
861 #define TLS_LD(x) TLS_IE(x)
865 __asm__ ("add r0, pcl, @" #x "@tlsgd \n" \
866 ".tls_gd_ld " #x "`bl __tls_get_addr@plt \n" \
869 ::"r0","r1","r2","r3","r4","r5","r6","r7", \
870 "r8","r9","r10","r11","r12"); \
875 void *tp = __builtin_thread_pointer(); \
876 __asm__ ("add %0, %1, @" #x "@tpoff \n" \
877 : "=r" (__result) : "r"(tp)); \
882 void *tp = __builtin_thread_pointer(); \
883 __asm__ ("ld %0, [pcl, @" #x "@tlsie] \n" \
884 "add %0, %1, %0 \n" \
885 : "=&r" (__result) : "r" (tp)); \
888 #elif defined __xtensa__
892 asm ("movi a8, " #x "@TLSFUNC\n\t" \
893 "movi a10, " #x "@TLSARG\n\t" \
894 "callx8.tls a8, " #x "@TLSCALL\n\t" \
898 : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
903 asm ("movi a8, " #x "@TLSFUNC\n\t" \
904 "movi a10, " #x "@TLSARG\n\t" \
905 "callx8.tls a8, " #x "@TLSCALL\n\t" \
906 "movi %0, " #x "@TPOFF\n\t" \
907 "add %0, %0, a10\n\t" \
910 : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
913 #define TLS_IE(x) TLS_LE(x)
918 asm ("rur %0, threadptr\n\t" \
919 "movi %1, " #x "@TPOFF\n\t" \
920 "add %0, %0, %1\n\t" \
921 : "=r" (__l), "=r" (__t) ); \
925 #elif !defined TLS_LE || !defined TLS_IE \
926 || !defined TLS_LD || !defined TLS_GD
927 # error "No support for this architecture so far."