Example #1
0
File: arith.c Project: 0day-ci/gcc
int main ()
{
  fract2x16 a, b, c, d;
  fract16 t1, t2;
  a = __builtin_bfin_compose_2x16 (0x3000, 0x2000);
  b = __builtin_bfin_compose_2x16 (0x7000, 0x5000);
  c = __builtin_bfin_compose_2x16 (0x7000, 0xc000);

  d = __builtin_bfin_add_fr2x16 (a, b);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if (t1 != 0x7000 || t2 != 0x7fff)
    abort ();

  d = __builtin_bfin_sub_fr2x16 (a, b);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if (t1 != -0x3000 || t2 != -0x4000)
    abort ();

  d = __builtin_bfin_negate_fr2x16 (c);
  t1 = __builtin_bfin_extract_lo (d);
  t2 = __builtin_bfin_extract_hi (d);
  if (t1 != 0x4000 || t2 != -0x7000)
    abort ();
  
  if (__builtin_bfin_add_fr1x32 (0x7fffffff, 1) != 0x7fffffff)
    abort ();

  if (__builtin_bfin_add_fr1x32 (0x80000000, -1) != 0x80000000)
    abort ();
    
  if (__builtin_bfin_add_fr1x32 (0x80000001, -1) != 0x80000000)
    abort ();
    
  if (__builtin_bfin_add_fr1x32 (0xFEDCBA98, 0x11111111) != 0x0FEDCBA9)
    abort ();
    
  exit (0);
}
Example #2
0
int main ()
{
  fract2x16 a, t;
  fract16 t1, t2;

  a = __builtin_bfin_compose_2x16 (0x1001, 0x0001);
  t = __builtin_bfin_negate_fr2x16 (a);
  t1 = __builtin_bfin_extract_hi (t);
  t2 = __builtin_bfin_extract_lo (t);
  if (t1 != -0x1001 || t2 != -0x1)
    abort ();

  return 0;
}
Example #3
0
int main ()
{
  fract2x16 a, t;
  fract16 t1, t2;

  a = __builtin_bfin_compose_2x16 (0xcfff, 0xffff);

  t = foo (a, 4);
  t1 = __builtin_bfin_extract_hi (t);
  t2 = __builtin_bfin_extract_lo (t);
  if (t1 != 0x0cff || t2 != 0x0fff)
    abort ();

  return 0;
}
Example #4
0
int main ()
{
  fract2x16 a, b, t;
  fract16 t1, t2;

  a = __builtin_bfin_compose_2x16 (0x5000, 0x3000);
  b = __builtin_bfin_compose_2x16 (0x4000, 0x2000);

  t = __builtin_bfin_dspaddsubsat (a, b);
  t1 = __builtin_bfin_extract_hi (t);
  t2 = __builtin_bfin_extract_lo (t);
  if (t1 != 0x7fff || t2 != 0x1000)
    abort ();
  return 0;
}
Example #5
0
int main ()
{
  fract2x16 a, b, t;
  fract16 t1, t2;

  a = __builtin_bfin_compose_2x16 (0x5000, 0xd000);
  b = __builtin_bfin_compose_2x16 (0xc000, 0x2000);

  t = __builtin_bfin_mult_fr2x16 (a, b);
  t1 = __builtin_bfin_extract_hi (t);
  t2 = __builtin_bfin_extract_lo (t);
  if (t1 != 0xffffd800 || t2 != 0xfffff400)
    abort ();

  return 0;
}
Example #6
0
int main ()
{
  fract2x16 a, b, t;
  fract16 t1, t2;

  a = __builtin_bfin_compose_2x16 (0x5fff, 0xffff);
  b = __builtin_bfin_compose_2x16 (0x1001, 0x0001);

  t = __builtin_bfin_multr_fr2x16 (a, b);
  t1 = __builtin_bfin_extract_hi (t);
  t2 = __builtin_bfin_extract_lo (t);
  if (t1 != 0xc01 || t2 != 0x0)
    abort ();

  return 0;
}
Example #7
0
int main ()
{
  fract2x16 a, b, c;
  fract16 t1, t2;
  a = __builtin_bfin_compose_2x16 (0x3000, 0x2000);
  b = __builtin_bfin_compose_2x16 (0x7000, 0x5000);

  c = foo0000 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES1 || t2 != RES1)
    abort ();

  c = foo1000 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES2 || t2 != RES1)
    abort ();

  c = foo0100 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES1 || t2 != RES2)
    abort ();

  c = foo1100 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES2 || t2 != RES2)
    abort ();

  c = foo0010 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES3 || t2 != RES1)
    abort ();

  c = foo1010 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES4 || t2 != RES1)
    abort ();

  c = foo0110 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES3 || t2 != RES2)
    abort ();

  c = foo1110 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES4 || t2 != RES2)
    abort ();

  c = foo0001 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES1 || t2 != RES3)
    abort ();

  c = foo1001 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES2 || t2 != RES3)
    abort ();

  c = foo0101 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES1 || t2 != RES4)
    abort ();

  c = foo1101 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES2 || t2 != RES4)
    abort ();

  c = foo0011 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES3 || t2 != RES3)
    abort ();

  c = foo1011 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES4 || t2 != RES3)
    abort ();

  c = foo0111 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES3 || t2 != RES4)
    abort ();

  c = foo1111 (a, b);
  t1 = __builtin_bfin_extract_lo (c);
  t2 = __builtin_bfin_extract_hi (c);
  if (t1 != RES4 || t2 != RES4)
    abort ();

  exit (0);
}