aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/asm-block-1.C
blob: 63446417a126d21f76db962bea09b12e095f9d43 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
/* APPLE LOCAL file CW asm blocks */
/* Test asm-syntax blocks within functions.  */

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

extern "C" void abort (void);

int
foo (int argx, int argy)
{
  register int locx = argx, locy = argy, rslt;
  asm {
      add rslt,locx,locy
    }
  return rslt;
}

/* Exercise corners of syntax.  */

int
bar ()
{
  register int rslt = 100;
  asm {
    // Combos of instructions on a line

    nop
     ;
    nop
    nop ;
    ; nop
    nop ; nop
    ; nop ;;; li r3,95 ; nop ;
    // '.' in an opcode
    add. r6,r6,r5
  }
  return rslt;
}

int baz ()
{
  register int rslt = 1;
  asm {
    li r8,29+(2 * 3);
    add rslt,rslt,r8;
    b @192
   @34
    nop
    ble+ @34
    b forward
   abc:
    b abc
   @abc:
    b @abc
   forward: ; @192:
    nop
    ;
  sameline: nop
  x1: @x2 @x3: nop ; @x4 x5:
  }
  return rslt;
}

int
main ()
{
  if (foo (22, 23) != 45)
    abort ();
  if (bar () != 100)
    abort ();
  if (baz () != 36)
    abort ();
  return 0;
}