summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/iamcu/test_basic_64bit_returning.c
blob: ecece94b793d0728d3467d0ee1e18a4733b88db0 (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
#include "defines.h"
#include "macros.h"
#include "args.h"

struct IntegerRegisters iregbits = { ~0, ~0, ~0, ~0, ~0, ~0 };
struct IntegerRegisters iregs;
unsigned int num_iregs;

long long
fun_test_returning_long_long (void)
{
  volatile_var++;
  return (long long) 0xabadbeefabadbeefLL;
}

double
fun_test_returning_double (void)
{
  volatile_var++;
  return (double) 12345678.0;
}

union
{
  long long ll;
  double d;
} test_64;

int
main (void)
{
  unsigned failed = 0;
  long long ll;
  double d;

  clear_struct_registers;
  test_64.ll = 0xabadbeefabadbeefLL;

  ll = WRAP_RET (fun_test_returning_long_long)();
  if (ll != test_64.ll
      || (test_64.ll & 0xffffffff) != eax
      || ((test_64.ll >> 32) & 0xffffffff) != edx)
    failed++;

  clear_struct_registers;
  test_64.d = 12345678.0;

  d = WRAP_RET (fun_test_returning_double)();
  if (d != test_64.d
      || (test_64.ll & 0xffffffff) != eax
      || ((test_64.ll >> 32) & 0xffffffff) != edx)
    printf ("fail double\n"), failed++;

  if (failed)
    abort ();
  return 0;
}