예제 #1
0
파일: tattr-2.c 프로젝트: MaxKellermann/gcc
void p1(void)
{
#ifndef __HTM__
#error __HTM__ is not defined
#endif
  __builtin_tend ();
}
예제 #2
0
파일: tattr-2.c 프로젝트: MaxKellermann/gcc
void a1(void)
{
#ifdef __HTM__
#error __HTM__ is defined
#endif
  __builtin_tend ();
}
예제 #3
0
파일: tattr-2.c 프로젝트: MaxKellermann/gcc
void htmd(void)
{
#ifdef __HTM__
#error __HTM__ is defined
#endif
  __builtin_tend (); /* { dg-error "is not supported without -mhtm" } */
}
예제 #4
0
int __attribute__ ((noinline)) htm_begin (int r3, int r4)
{
   int ret;

   if (__builtin_tbegin (0)) {
      ret = r3;
      __builtin_tend (0);
   } else {
      ret = r4;
   } return ret;
}
예제 #5
0
foo (v4si a)
{
  a += (v4si){ 1, 1, 1, 1 };
  if (__builtin_tbegin (0) == 0)
    {
      a += (v4si){ 1, 1, 1, 1 };
      __builtin_tabort (256);
      __builtin_tend ();
    }
  else
    a -= (v4si){ 1, 1, 1, 1 };

  return a;
}
예제 #6
0
int
__lll_unlock_elision (int *lock, short *adapt_count, int pshared)
{
  /* When the lock was free we're in a transaction.  */
  if (*lock == 0)
    __builtin_tend (0);
  else
    {
      lll_unlock ((*lock), pshared);

      /* Update the adapt count AFTER completing the critical section.
         Doing this here prevents unneeded stalling when entering
         a critical section.  Saving about 8% runtime on P8.  */
      if (*adapt_count > 0)
	(*adapt_count)--;
    }
  return 0;
}
예제 #7
0
int main (void) {
#ifdef HAS_ISA_2_07
   /* Just get the compiler to generate each of the TM instructions
    * so we can verify that valgrind recognizes them.
    * For now, only the tbegin instruction does anything in valgrind.
    * The rest are just treated as NOPS.
    */
   __builtin_tabort (0);
   __builtin_tabortdc (0,0,0);
   __builtin_tabortdci (0,0,0);
   __builtin_tabortwc (0,0,0);
   __builtin_tabortwci (0,0,0);
   __builtin_tbegin (0);
   __builtin_tend (0);
   //   __builtin_tcheck (0);  tcheck not recognized by compiler
   __builtin_trechkpt ();  // not recognized by early HW
   __builtin_treclaim (0); // not recognized by early HW
   __builtin_tsr (0);
#endif
   return 0;
}
예제 #8
0
int
__lll_trylock_elision (int *futex, short *adapt_count)
{
  __asm__ volatile (".machinemode \"zarch_nohighgprs\"\n\t"
		    ".machine \"all\""
		    : : : "memory");

  /* Implement POSIX semantics by forbiding nesting elided trylocks.
     Sorry.  After the abort the code is re-executed
     non transactional and if the lock was already locked
     return an error.  */
  if (__builtin_tx_nesting_depth () > 0)
    {
      /* Note that this abort may terminate an outermost transaction that
	 was created outside glibc.
	 This persistently aborts the current transactions to force
	 them to use the default lock instead of retrying transactions
	 until their try_tbegin is zero.
      */
      __builtin_tabort (_HTM_FIRST_USER_ABORT_CODE | 1);
    }

  /* Only try a transaction if it's worth it.  */
  if (*adapt_count <= 0)
    {
      unsigned status;

      if (__builtin_expect
	  ((status = __builtin_tbegin ((void *)0)) == _HTM_TBEGIN_STARTED, 1))
	{
	  if (*futex == 0)
	    return 0;
	  /* Lock was busy.  Fall back to normal locking.  */
	  /* Since we are in a non-nested transaction there is no need to abort,
	     which is expensive.  */
	  __builtin_tend ();
	  /* Note: Changing the adapt_count here might abort a transaction on a
	     different cpu, but that could happen anyway when the futex is
	     acquired, so there's no need to check the nesting depth here.  */
	  if (aconf.skip_lock_busy > 0)
	    *adapt_count = aconf.skip_lock_busy;
	}
      else
	{
	  if (status != _HTM_TBEGIN_TRANSIENT)
	    {
	      /* A persistent abort (cc 1 or 3) indicates that a retry is
		 probably futile.  Use the normal locking now and for the
		 next couple of calls.
		 Be careful to avoid writing to the lock.  */
	      if (aconf.skip_trylock_internal_abort > 0)
		*adapt_count = aconf.skip_trylock_internal_abort;
	    }
	}
      /* Could do some retries here.  */
    }
  else
    {
      /* Lost updates are possible, but harmless.  Due to races this might lead
	 to *adapt_count becoming less than zero.  */
      (*adapt_count)--;
    }

  return lll_trylock (*futex);
}
예제 #9
0
int
foo (struct __htm_tdb* tdb, int reg, int *mem, uint64_t *mem64)
{

  int cc;
  int n;

  __builtin_tbegin ((void *)0);
  __builtin_tbegin ((void *)-99999);
  __builtin_tbegin ((void *)99999);
  while (__builtin_tbegin ((void *)0) != 0)
  {
  }
  cc = __builtin_tbegin ((void *)0x12345678);
  cc = __builtin_tbegin (tdb);
  cc = __builtin_tbegin (&global_tdb);
  cc = __builtin_tbegin ((void *)(long long)(reg + 0x12345678));
  cc = __builtin_tbegin ((void *)(long long)(reg));

  __builtin_tbegin_nofloat ((void *)0);
  __builtin_tbegin_nofloat ((void *)-99999);
  __builtin_tbegin_nofloat ((void *)99999);
  cc = __builtin_tbegin_nofloat ((void *)0x12345678);
  cc = __builtin_tbegin_nofloat (tdb);
  cc = __builtin_tbegin_nofloat (&global_tdb);
  cc = __builtin_tbegin_nofloat ((void *)(long long)(reg + 0x12345678));
  cc = __builtin_tbegin_nofloat ((void *)(long long)(reg));

  __builtin_tbegin_retry ((void *)0, 0);
  cc = __builtin_tbegin_retry ((void *)0, 1);
  cc = __builtin_tbegin_retry ((void *)0, -1);
  cc = __builtin_tbegin_retry ((void *)0, 42);
  cc = __builtin_tbegin_retry ((void *)0, reg);
  cc = __builtin_tbegin_retry ((void *)0, *mem);
  cc = __builtin_tbegin_retry ((void *)0, global);
  cc = __builtin_tbegin_retry (tdb, 42);
  cc = __builtin_tbegin_retry (&global_tdb, 42);
  cc = __builtin_tbegin_retry ((void *)0x12345678, global);
  cc = __builtin_tbegin_retry (
	  (void *)(long long) (reg + 0x12345678), global + 1);
  cc = __builtin_tbegin_retry (
	  (void *)(long long)(reg), global - 1);

  __builtin_tbegin_retry_nofloat ((void *)0, 0);
  cc = __builtin_tbegin_retry_nofloat ((void *)0, 1);
  cc = __builtin_tbegin_retry_nofloat ((void *)0, -1);
  cc = __builtin_tbegin_retry_nofloat ((void *)0, 42);
  cc = __builtin_tbegin_retry_nofloat ((void *)0, reg);
  cc = __builtin_tbegin_retry_nofloat ((void *)0, *mem);
  cc = __builtin_tbegin_retry_nofloat ((void *)0, global);
  cc = __builtin_tbegin_retry_nofloat (tdb, 42);
  cc = __builtin_tbegin_retry_nofloat (&global_tdb, 42);
  cc = __builtin_tbegin_retry_nofloat ((void *)0x12345678, global);
  cc = __builtin_tbegin_retry_nofloat (
	  (void *)(long long) (reg + 0x12345678), global + 1);
  cc = __builtin_tbegin_retry_nofloat (
	  (void *)(long long)(reg), global - 1);

  __builtin_tbeginc ();

  __builtin_tx_nesting_depth ();
  n = __builtin_tx_nesting_depth ();

  __builtin_non_tx_store (mem64, 0);
  {
	  const uint64_t val_var = 0x1122334455667788;

	  __builtin_non_tx_store (mem64, val_var);
  }
  __builtin_non_tx_store (mem64, (uint64_t)reg);
  __builtin_non_tx_store (mem64, g);
  __builtin_non_tx_store ((uint64_t *)0, 0);
  __builtin_non_tx_store ((uint64_t *)0x12345678, 0);
  __builtin_non_tx_store (&g, 23);
  __builtin_non_tx_store (&g, reg);
  __builtin_non_tx_store (&g, *mem);
  __builtin_non_tx_store (&g, global);

  __builtin_tend();

  __builtin_tx_assist (0);
  __builtin_tx_assist (1);
  __builtin_tx_assist (reg);
  __builtin_tx_assist (*mem);
  __builtin_tx_assist (global);
}
예제 #10
0
파일: tattr-1.c 프로젝트: 0day-ci/gcc
void htm1(void)
{
  __builtin_tend();
}
예제 #11
0
파일: tattr-1.c 프로젝트: 0day-ci/gcc
void htm0(void)
{
  __builtin_tend(); /* { dg-error "is not supported without -mhtm" } */
}
예제 #12
0
파일: htm-nofloat-1.c 프로젝트: 0day-ci/gcc
foo (int a)
{
  if (__builtin_tbegin (0) == 0)
    __builtin_tend ();
}