PAPI 7.1.0.0
Loading...
Searching...
No Matches
gcc/arm.h File Reference
Include dependency graph for gcc/arm.h:

Go to the source code of this file.

Macros

#define AO_MASK_PTR(reg)   /* empty */
 
#define AO_BR_ALIGN   /* empty */
 
#define AO_THUMB_GO_ARM   /* empty */
 
#define AO_THUMB_RESTORE_MODE   /* empty */
 
#define AO_THUMB_SWITCH_CLOBBERS   /* empty */
 
#define AO_ARM_HAVE_LDREX
 
#define AO_ARM_HAVE_LDREXBH
 
#define AO_ARM_HAVE_DMB
 
#define AO_ARM_HAVE_LDREXD
 
#define AO_ARM_HAVE_SWP
 
#define AO_HAVE_nop_write
 
#define AO_HAVE_nop_full
 
#define AO_ACCESS_CHECK_ALIGNED
 
#define AO_ACCESS_short_CHECK_ALIGNED
 
#define AO_ACCESS_int_CHECK_ALIGNED
 
#define AO_HAVE_test_and_set
 
#define AO_HAVE_fetch_and_add
 
#define AO_HAVE_fetch_and_add1
 
#define AO_HAVE_fetch_and_sub1
 
#define AO_HAVE_and
 
#define AO_HAVE_or
 
#define AO_HAVE_xor
 
#define AO_HAVE_char_fetch_and_add
 
#define AO_HAVE_short_fetch_and_add
 
#define AO_HAVE_compare_and_swap
 
#define AO_HAVE_fetch_compare_and_swap
 
#define AO_HAVE_double_load
 
#define AO_HAVE_double_store
 
#define AO_HAVE_double_compare_and_swap
 
#define AO_T_IS_INT
 

Functions

AO_INLINE void AO_nop_write (void)
 
AO_INLINE void AO_nop_full (void)
 
AO_INLINE AO_TS_VAL_t AO_test_and_set (volatile AO_TS_t *addr)
 
AO_INLINE AO_t AO_fetch_and_add (volatile AO_t *p, AO_t incr)
 
AO_INLINE AO_t AO_fetch_and_add1 (volatile AO_t *p)
 
AO_INLINE AO_t AO_fetch_and_sub1 (volatile AO_t *p)
 
AO_INLINE void AO_and (volatile AO_t *p, AO_t value)
 
AO_INLINE void AO_or (volatile AO_t *p, AO_t value)
 
AO_INLINE void AO_xor (volatile AO_t *p, AO_t value)
 
AO_INLINE unsigned char AO_char_fetch_and_add (volatile unsigned char *p, unsigned char incr)
 
AO_INLINE unsigned short AO_short_fetch_and_add (volatile unsigned short *p, unsigned short incr)
 
AO_INLINE int AO_compare_and_swap (volatile AO_t *addr, AO_t old_val, AO_t new_val)
 
AO_INLINE AO_t AO_fetch_compare_and_swap (volatile AO_t *addr, AO_t old_val, AO_t new_val)
 
AO_INLINE AO_double_t AO_double_load (const volatile AO_double_t *addr)
 
AO_INLINE void AO_double_store (volatile AO_double_t *addr, AO_double_t new_val)
 
AO_INLINE int AO_double_compare_and_swap (volatile AO_double_t *addr, AO_double_t old_val, AO_double_t new_val)
 

Macro Definition Documentation

◆ AO_ACCESS_CHECK_ALIGNED

#define AO_ACCESS_CHECK_ALIGNED

Definition at line 285 of file gcc/arm.h.

◆ AO_ACCESS_int_CHECK_ALIGNED

#define AO_ACCESS_int_CHECK_ALIGNED

Definition at line 287 of file gcc/arm.h.

◆ AO_ACCESS_short_CHECK_ALIGNED

#define AO_ACCESS_short_CHECK_ALIGNED

Definition at line 286 of file gcc/arm.h.

◆ AO_ARM_HAVE_DMB

#define AO_ARM_HAVE_DMB

Definition at line 79 of file gcc/arm.h.

◆ AO_ARM_HAVE_LDREX

#define AO_ARM_HAVE_LDREX

Definition at line 67 of file gcc/arm.h.

◆ AO_ARM_HAVE_LDREXBH

#define AO_ARM_HAVE_LDREXBH

Definition at line 71 of file gcc/arm.h.

◆ AO_ARM_HAVE_LDREXD

#define AO_ARM_HAVE_LDREXD

Definition at line 90 of file gcc/arm.h.

◆ AO_ARM_HAVE_SWP

#define AO_ARM_HAVE_SWP

Definition at line 97 of file gcc/arm.h.

◆ AO_BR_ALIGN

#define AO_BR_ALIGN   /* empty */

Definition at line 30 of file gcc/arm.h.

◆ AO_HAVE_and

#define AO_HAVE_and

Definition at line 429 of file gcc/arm.h.

◆ AO_HAVE_char_fetch_and_add

#define AO_HAVE_char_fetch_and_add

Definition at line 499 of file gcc/arm.h.

◆ AO_HAVE_compare_and_swap

#define AO_HAVE_compare_and_swap

Definition at line 555 of file gcc/arm.h.

◆ AO_HAVE_double_compare_and_swap

#define AO_HAVE_double_compare_and_swap

Definition at line 657 of file gcc/arm.h.

◆ AO_HAVE_double_load

#define AO_HAVE_double_load

Definition at line 609 of file gcc/arm.h.

◆ AO_HAVE_double_store

#define AO_HAVE_double_store

Definition at line 629 of file gcc/arm.h.

◆ AO_HAVE_fetch_and_add

#define AO_HAVE_fetch_and_add

Definition at line 359 of file gcc/arm.h.

◆ AO_HAVE_fetch_and_add1

#define AO_HAVE_fetch_and_add1

Definition at line 383 of file gcc/arm.h.

◆ AO_HAVE_fetch_and_sub1

#define AO_HAVE_fetch_and_sub1

Definition at line 407 of file gcc/arm.h.

◆ AO_HAVE_fetch_compare_and_swap

#define AO_HAVE_fetch_compare_and_swap

Definition at line 584 of file gcc/arm.h.

◆ AO_HAVE_nop_full

#define AO_HAVE_nop_full

Definition at line 146 of file gcc/arm.h.

◆ AO_HAVE_nop_write

#define AO_HAVE_nop_write

Definition at line 120 of file gcc/arm.h.

◆ AO_HAVE_or

#define AO_HAVE_or

Definition at line 451 of file gcc/arm.h.

◆ AO_HAVE_short_fetch_and_add

#define AO_HAVE_short_fetch_and_add

Definition at line 523 of file gcc/arm.h.

◆ AO_HAVE_test_and_set

#define AO_HAVE_test_and_set

Definition at line 334 of file gcc/arm.h.

◆ AO_HAVE_xor

#define AO_HAVE_xor

Definition at line 473 of file gcc/arm.h.

◆ AO_MASK_PTR

#define AO_MASK_PTR (   reg)    /* empty */

Definition at line 29 of file gcc/arm.h.

◆ AO_T_IS_INT

#define AO_T_IS_INT

Definition at line 703 of file gcc/arm.h.

◆ AO_THUMB_GO_ARM

#define AO_THUMB_GO_ARM   /* empty */

Definition at line 52 of file gcc/arm.h.

◆ AO_THUMB_RESTORE_MODE

#define AO_THUMB_RESTORE_MODE   /* empty */

Definition at line 53 of file gcc/arm.h.

◆ AO_THUMB_SWITCH_CLOBBERS

#define AO_THUMB_SWITCH_CLOBBERS   /* empty */

Definition at line 54 of file gcc/arm.h.

Function Documentation

◆ AO_and()

AO_INLINE void AO_and ( volatile AO_t p,
AO_t  value 
)

Definition at line 410 of file gcc/arm.h.

411{
412 AO_t tmp, result;
413
414 __asm__ __volatile__("@AO_and\n"
417 "1: " AO_MASK_PTR("%4")
418 " ldrex %0, [%4]\n"
419 " and %1, %0, %3\n"
420 AO_MASK_PTR("%4")
421 " strex %0, %1, [%4]\n"
422 " teq %0, #0\n"
423 " bne 1b\n"
425 : "=&r" (tmp), "=&r" (result), "+m" (*p)
426 : "r" (value), "r" (p)
428}
volatile int result
double tmp
#define AO_t
Definition: atomic_ops.h:156
#define AO_THUMB_RESTORE_MODE
Definition: gcc/arm.h:53
#define AO_THUMB_GO_ARM
Definition: gcc/arm.h:52
#define AO_MASK_PTR(reg)
Definition: gcc/arm.h:29
#define AO_THUMB_SWITCH_CLOBBERS
Definition: gcc/arm.h:54
#define AO_BR_ALIGN
Definition: gcc/arm.h:30

◆ AO_char_fetch_and_add()

AO_INLINE unsigned char AO_char_fetch_and_add ( volatile unsigned char *  p,
unsigned char  incr 
)

Definition at line 478 of file gcc/arm.h.

479 {
480 unsigned result, tmp;
481 int flag;
482
483 __asm__ __volatile__("@AO_char_fetch_and_add\n"
486 "1: " AO_MASK_PTR("%5")
487 " ldrexb %0, [%5]\n"
488 " add %2, %0, %4\n"
489 AO_MASK_PTR("%5")
490 " strexb %1, %2, [%5]\n"
491 " teq %1, #0\n"
492 " bne 1b\n"
494 : "=&r" (result), "=&r" (flag), "=&r" (tmp), "+m" (*p)
495 : "r" ((unsigned)incr), "r" (p)
497 return (unsigned char)result;
498 }

◆ AO_compare_and_swap()

AO_INLINE int AO_compare_and_swap ( volatile AO_t addr,
AO_t  old_val,
AO_t  new_val 
)

Definition at line 529 of file gcc/arm.h.

530 {
531 AO_t result, tmp;
532
533 __asm__ __volatile__("@AO_compare_and_swap\n"
536 "1: mov %0, #2\n" /* store a flag */
537 AO_MASK_PTR("%3")
538 " ldrex %1, [%3]\n" /* get original */
539 " teq %1, %4\n" /* see if match */
540 AO_MASK_PTR("%3")
541# ifdef __thumb2__
542 /* TODO: Eliminate warning: it blocks containing wide Thumb */
543 /* instructions are deprecated in ARMv8. */
544 " it eq\n"
545# endif
546 " strexeq %0, %5, [%3]\n" /* store new one if matched */
547 " teq %0, #1\n"
548 " beq 1b\n" /* if update failed, repeat */
550 : "=&r"(result), "=&r"(tmp), "+m"(*addr)
551 : "r"(addr), "r"(old_val), "r"(new_val)
553 return !(result&2); /* if succeeded then return 1 else 0 */
554 }

◆ AO_double_compare_and_swap()

AO_INLINE int AO_double_compare_and_swap ( volatile AO_double_t addr,
AO_double_t  old_val,
AO_double_t  new_val 
)

Definition at line 632 of file gcc/arm.h.

634 {
636 int result = 1;
637
638 do {
639 /* AO_THUMB_GO_ARM is empty. */
640 __asm__ __volatile__("@AO_double_compare_and_swap\n"
641 AO_MASK_PTR("%1")
642 " ldrexd %0, %H0, [%1]\n" /* get original to r1 & r2 */
643 : "=&r"(tmp)
644 : "r"(addr)
645 /* : no clobber */);
646 if (tmp != old_val.AO_whole)
647 break;
648 __asm__ __volatile__(
649 AO_MASK_PTR("%2")
650 " strexd %0, %3, %H3, [%2]\n" /* store new one if matched */
651 : "=&r"(result), "+m"(*addr)
652 : "r" (addr), "r" (new_val.AO_whole)
653 : "cc");
654 } while (AO_EXPECT_FALSE(result));
655 return !result; /* if succeeded then return 1 else 0 */
656 }
#define AO_EXPECT_FALSE(expr)
Definition: atomic_ops.h:193
unsigned long long double_ptr_storage
double_ptr_storage AO_whole

◆ AO_double_load()

AO_INLINE AO_double_t AO_double_load ( const volatile AO_double_t addr)

Definition at line 596 of file gcc/arm.h.

597 {
599
600 /* AO_THUMB_GO_ARM is empty. */
601 __asm__ __volatile__("@AO_double_load\n"
602 AO_MASK_PTR("%1")
603 " ldrexd %0, %H0, [%1]"
604 : "=&r" (result.AO_whole)
605 : "r" (addr)
606 /* : no clobber */);
607 return result;
608 }

◆ AO_double_store()

AO_INLINE void AO_double_store ( volatile AO_double_t addr,
AO_double_t  new_val 
)

Definition at line 612 of file gcc/arm.h.

613 {
614 AO_double_t old_val;
615 int status;
616
617 do {
618 /* AO_THUMB_GO_ARM is empty. */
619 __asm__ __volatile__("@AO_double_store\n"
620 AO_MASK_PTR("%3")
621 " ldrexd %0, %H0, [%3]\n"
622 AO_MASK_PTR("%3")
623 " strexd %1, %4, %H4, [%3]"
624 : "=&r" (old_val.AO_whole), "=&r" (status), "+m" (*addr)
625 : "r" (addr), "r" (new_val.AO_whole)
626 : "cc");
627 } while (AO_EXPECT_FALSE(status));
628 }

◆ AO_fetch_and_add()

AO_INLINE AO_t AO_fetch_and_add ( volatile AO_t p,
AO_t  incr 
)

Definition at line 338 of file gcc/arm.h.

339{
340 AO_t result, tmp;
341 int flag;
342
343 __asm__ __volatile__("@AO_fetch_and_add\n"
346 "1: " AO_MASK_PTR("%5")
347 " ldrex %0, [%5]\n" /* get original */
348 " add %2, %0, %4\n" /* sum up in incr */
349 AO_MASK_PTR("%5")
350 " strex %1, %2, [%5]\n" /* store them */
351 " teq %1, #0\n"
352 " bne 1b\n"
354 : "=&r"(result), "=&r"(flag), "=&r"(tmp), "+m"(*p) /* 0..3 */
355 : "r"(incr), "r"(p) /* 4..5 */
357 return result;
358}

◆ AO_fetch_and_add1()

AO_INLINE AO_t AO_fetch_and_add1 ( volatile AO_t p)

Definition at line 362 of file gcc/arm.h.

363{
364 AO_t result, tmp;
365 int flag;
366
367 __asm__ __volatile__("@AO_fetch_and_add1\n"
370 "1: " AO_MASK_PTR("%4")
371 " ldrex %0, [%4]\n" /* get original */
372 " add %1, %0, #1\n" /* increment */
373 AO_MASK_PTR("%4")
374 " strex %2, %1, [%4]\n" /* store them */
375 " teq %2, #0\n"
376 " bne 1b\n"
378 : "=&r"(result), "=&r"(tmp), "=&r"(flag), "+m"(*p)
379 : "r"(p)
381 return result;
382}

◆ AO_fetch_and_sub1()

AO_INLINE AO_t AO_fetch_and_sub1 ( volatile AO_t p)

Definition at line 386 of file gcc/arm.h.

387{
388 AO_t result, tmp;
389 int flag;
390
391 __asm__ __volatile__("@AO_fetch_and_sub1\n"
394 "1: " AO_MASK_PTR("%4")
395 " ldrex %0, [%4]\n" /* get original */
396 " sub %1, %0, #1\n" /* decrement */
397 AO_MASK_PTR("%4")
398 " strex %2, %1, [%4]\n" /* store them */
399 " teq %2, #0\n"
400 " bne 1b\n"
402 : "=&r"(result), "=&r"(tmp), "=&r"(flag), "+m"(*p)
403 : "r"(p)
405 return result;
406}

◆ AO_fetch_compare_and_swap()

AO_INLINE AO_t AO_fetch_compare_and_swap ( volatile AO_t addr,
AO_t  old_val,
AO_t  new_val 
)

Definition at line 559 of file gcc/arm.h.

560{
561 AO_t fetched_val;
562 int flag;
563
564 __asm__ __volatile__("@AO_fetch_compare_and_swap\n"
567 "1: mov %0, #2\n" /* store a flag */
568 AO_MASK_PTR("%3")
569 " ldrex %1, [%3]\n" /* get original */
570 " teq %1, %4\n" /* see if match */
571 AO_MASK_PTR("%3")
572# ifdef __thumb2__
573 " it eq\n"
574# endif
575 " strexeq %0, %5, [%3]\n" /* store new one if matched */
576 " teq %0, #1\n"
577 " beq 1b\n" /* if update failed, repeat */
579 : "=&r"(flag), "=&r"(fetched_val), "+m"(*addr)
580 : "r"(addr), "r"(old_val), "r"(new_val)
582 return fetched_val;
583}

◆ AO_nop_full()

AO_INLINE void AO_nop_full ( void  )

Definition at line 141 of file gcc/arm.h.

142 {
143 /* AO_THUMB_GO_ARM is empty. */
144 __asm__ __volatile__("dmb" : : : "memory");
145 }

◆ AO_nop_write()

AO_INLINE void AO_nop_write ( void  )

Definition at line 105 of file gcc/arm.h.

106 {
107 /* AO_THUMB_GO_ARM is empty. */
108 /* This will target the system domain and thus be overly */
109 /* conservative as the CPUs (even in case of big.LITTLE SoC) will */
110 /* occupy the inner shareable domain. */
111 /* The plain variant (dmb st) is theoretically slower, and should */
112 /* not be needed. That said, with limited experimentation, a CPU */
113 /* implementation for which it actually matters has not been found */
114 /* yet, though they should already exist. */
115 /* Anyway, note that the "st" and "ishst" barriers are actually */
116 /* quite weak and, as the libatomic_ops documentation states, */
117 /* usually not what you really want. */
118 __asm__ __volatile__("dmb ishst" : : : "memory");
119 }

◆ AO_or()

AO_INLINE void AO_or ( volatile AO_t p,
AO_t  value 
)

Definition at line 432 of file gcc/arm.h.

433{
434 AO_t tmp, result;
435
436 __asm__ __volatile__("@AO_or\n"
439 "1: " AO_MASK_PTR("%4")
440 " ldrex %0, [%4]\n"
441 " orr %1, %0, %3\n"
442 AO_MASK_PTR("%4")
443 " strex %0, %1, [%4]\n"
444 " teq %0, #0\n"
445 " bne 1b\n"
447 : "=&r" (tmp), "=&r" (result), "+m" (*p)
448 : "r" (value), "r" (p)
450}

◆ AO_short_fetch_and_add()

AO_INLINE unsigned short AO_short_fetch_and_add ( volatile unsigned short *  p,
unsigned short  incr 
)

Definition at line 502 of file gcc/arm.h.

503 {
504 unsigned result, tmp;
505 int flag;
506
507 __asm__ __volatile__("@AO_short_fetch_and_add\n"
510 "1: " AO_MASK_PTR("%5")
511 " ldrexh %0, [%5]\n"
512 " add %2, %0, %4\n"
513 AO_MASK_PTR("%5")
514 " strexh %1, %2, [%5]\n"
515 " teq %1, #0\n"
516 " bne 1b\n"
518 : "=&r" (result), "=&r" (flag), "=&r" (tmp), "+m" (*p)
519 : "r" ((unsigned)incr), "r" (p)
521 return (unsigned short)result;
522 }

◆ AO_test_and_set()

AO_INLINE AO_TS_VAL_t AO_test_and_set ( volatile AO_TS_t addr)

Definition at line 314 of file gcc/arm.h.

315 {
316 AO_TS_VAL_t oldval;
317 int flag;
318
319 __asm__ __volatile__("@AO_test_and_set\n"
322 "1: " AO_MASK_PTR("%3")
323 " ldrex %0, [%3]\n"
324 AO_MASK_PTR("%3")
325 " strex %1, %4, [%3]\n"
326 " teq %1, #0\n"
327 " bne 1b\n"
329 : "=&r"(oldval), "=&r"(flag), "+m"(*addr)
330 : "r"(addr), "r"(1)
332 return oldval;
333 }
#define AO_TS_VAL_t
Definition: gcc/hppa.h:44

◆ AO_xor()

AO_INLINE void AO_xor ( volatile AO_t p,
AO_t  value 
)

Definition at line 454 of file gcc/arm.h.

455{
456 AO_t tmp, result;
457
458 __asm__ __volatile__("@AO_xor\n"
461 "1: " AO_MASK_PTR("%4")
462 " ldrex %0, [%4]\n"
463 " eor %1, %0, %3\n"
464 AO_MASK_PTR("%4")
465 " strex %0, %1, [%4]\n"
466 " teq %0, #0\n"
467 " bne 1b\n"
469 : "=&r" (tmp), "=&r" (result), "+m" (*p)
470 : "r" (value), "r" (p)
472}