aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/pcrel-opt-di2.c
blob: 19204e2a332d1dc79e18a3bf0cb204756873e067 (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
/* { dg-do compile } */
/* { dg-require-effective-target powerpc_elfv2 } */
/* { dg-require-effective-target powerpc_future_ok } */
/* { dg-options "-mdejagnu-cpu=future -O2" } */

/* Determine if the pc-relative optimization using the R_PPC64_PCREL_OPT
   optimization is supported.  */

#ifndef TYPE
#define TYPE long
#endif

#ifndef OFFSET
#define OFFSET 10
#endif

extern TYPE ext[];

/* This should generate:
		PLD 9,ext@got@pcrel
	.Label:
		.reloc .Label-8,R_PPC64_PCREL_OPT,0
		LD 3,80(9)  */
TYPE
get_ext (void)
{
  return ext[OFFSET];
}

/* This should generate:
		PLD 9,ext@got@pcrel
	.Label:
		.reloc .Label-8,R_PPC64_PCREL_OPT,0
		STD 3,80(9)  */

void
set_ext (TYPE a)
{
  ext[OFFSET] = a;
}

/* Because it has two references to 'ext', this should not generate a
   R_PPC64_PCREL_OPT relocation.  Instead it should generate:
		PLD 10,ext@got@pcrel
		LD 9,80(10)
		ADDI 9,9,1
		STD 9,80(10)  */

void
inc_ext (void)
{
  (ext[OFFSET])++;
}

/* { dg-final { scan-assembler-times "ext@got@pcrel"     3 } } */
/* { dg-final { scan-assembler-times "R_PPC64_PCREL_OPT" 2 } } */