OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.target/] [x86_64/] [abi/] [test_passing_structs.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* This tests passing of structs. Only integers are tested.  */
2
 
3
#include "defines.h"
4
#include "args.h"
5
 
6
struct IntegerRegisters iregs;
7
struct FloatRegisters fregs;
8
unsigned int num_iregs, num_fregs;
9
 
10
struct int_struct
11
{
12
  int i;
13
};
14
 
15
struct long_struct
16
{
17
  long l;
18
};
19
 
20
struct long2_struct
21
{
22
  long l1, l2;
23
};
24
 
25
struct long3_struct
26
{
27
  long l1, l2, l3;
28
};
29
 
30
 
31
/* Check that the struct is passed as the individual members in iregs.  */
32
void
33
check_struct_passing1 (struct int_struct is ATTRIBUTE_UNUSED)
34
{
35
  check_int_arguments;
36
}
37
 
38
void
39
check_struct_passing2 (struct long_struct ls ATTRIBUTE_UNUSED)
40
{
41
  check_int_arguments;
42
}
43
 
44
void
45
check_struct_passing3 (struct long2_struct ls ATTRIBUTE_UNUSED)
46
{
47
  check_int_arguments;
48
}
49
 
50
void
51
check_struct_passing4 (struct long3_struct ls ATTRIBUTE_UNUSED)
52
{
53
  /* Check the passing on the stack by comparing the address of the
54
     stack elements to the expected place on the stack.  */
55
  assert ((unsigned long)&ls.l1 == rsp+8);
56
  assert ((unsigned long)&ls.l2 == rsp+16);
57
  assert ((unsigned long)&ls.l3 == rsp+24);
58
}
59
 
60
 
61
int
62
main (void)
63
{
64
  struct int_struct is = { 48 };
65
  struct long_struct ls = { 49 };
66
#ifdef CHECK_LARGER_STRUCTS
67
  struct long2_struct l2s = { 50, 51 };
68
  struct long3_struct l3s = { 52, 53, 54 };
69
#endif
70
 
71
  clear_struct_registers;
72
  iregs.I0 = is.i;
73
  num_iregs = 1;
74
  clear_int_hardware_registers;
75
  WRAP_CALL (check_struct_passing1)(is);
76
 
77
  clear_struct_registers;
78
  iregs.I0 = ls.l;
79
  num_iregs = 1;
80
  clear_int_hardware_registers;
81
  WRAP_CALL (check_struct_passing2)(ls);
82
 
83
#ifdef CHECK_LARGER_STRUCTS
84
  clear_struct_registers;
85
  iregs.I0 = l2s.l1;
86
  iregs.I1 = l2s.l2;
87
  num_iregs = 2;
88
  clear_int_hardware_registers;
89
  WRAP_CALL (check_struct_passing3)(l2s);
90
  WRAP_CALL (check_struct_passing4)(l3s);
91
#endif
92
 
93
  return 0;
94
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.