aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/asm-function-4.C
blob: eb1baa76b832196f8ec3e97658157fab47a0f449 (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
58
59
60
61
62
/* APPLE LOCAL file CW asm blocks */
/* Test asm with macros.  */

/* { dg-do run { target powerpc*-*-darwin* } } */
/* { dg-options "-fasm-blocks -O2" } */

extern "C" void abort(void);

#define mac1 add r3, argx, argy

asm int
foo (register int argx, register int argy)
{
  mac1
}

#define rsltreg r3
#define mac2(x,y) add rsltreg,x,y

asm int
foo1 (register int argx, register int argy)
{
  register int loc1, loc2;
  nop
    li loc1, 100
    li rsltreg,0
    b @a34
    mac2(argx,argy)
@a34
    mac2(rsltreg,loc1)
    blr
}

#define limac li
#define num 48

asm int foo2(int x, float y)
{
#pragma unused(x)
#pragma unused(x,y)
  limac rsltreg, num;
#define mac3(zzz) \
  limac r4, zzz
#pragma unused(y)
  nop
    mac3(num)
#pragma unused(x)
    add r3,r3,r4
}

int
main ()
{
  if (foo (22, 23) != 45)
    abort ();
  if (foo1 (1, 2) != 100)
    abort ();
  if (foo2 (100, 1.2) != 2 * num)
    abort ();
  return 0;
}