| 1 |
/* { dg-do compile { target { powerpc*-*-* } } } */ |
| 2 |
/* { dg-options "-O2" } */ |
| 3 |
/* We have to lose the default pic codegen on Darwin. */ |
| 4 |
/* { dg-additional-options "-mdynamic-no-pic" { target powerpc*-*-darwin* } } */ |
| 5 |
/* ... and account for the out-of-line GPR restore. */ |
| 6 |
/* { dg-final { scan-assembler-times {\mb[ \t]*restGPR} 1 { target powerpc*-*-darwin* } } } */ |
| 7 |
/* { dg-final { scan-assembler-not {\mb[ \t]L} { target powerpc*-*-darwin* } } } */ |
| 8 |
/* { dg-final { scan-assembler-not {\mb\M} { target { ! powerpc*-*-darwin* } } } } */ |
| 9 |
|
| 10 |
/* Check that all computed gotos in this testcase end up unfactored completely. |
| 11 |
If some is not there will be a unconditional jump left; if all works fine, |
| 12 |
all are gone. */ |
| 13 |
|
| 14 |
typedef enum opcode |
| 15 |
{ |
| 16 |
OP_A, |
| 17 |
OP_B, |
| 18 |
OP_END |
| 19 |
} opcode; |
| 20 |
|
| 21 |
typedef struct op |
| 22 |
{ |
| 23 |
opcode opcode; |
| 24 |
int arg; |
| 25 |
} op; |
| 26 |
|
| 27 |
extern void do_stuff_b(int arg); |
| 28 |
extern void do_stuff_c(int arg); |
| 29 |
|
| 30 |
extern int someglobal; |
| 31 |
|
| 32 |
void |
| 33 |
eval(op *op) |
| 34 |
{ |
| 35 |
static const void *dispatch_table[] = { |
| 36 |
&&CASE_OP_A, |
| 37 |
&&CASE_OP_B, |
| 38 |
&&CASE_OP_C, |
| 39 |
&&CASE_OP_END |
| 40 |
}; |
| 41 |
|
| 42 |
goto *dispatch_table[op->opcode]; |
| 43 |
CASE_OP_A: |
| 44 |
someglobal++; |
| 45 |
op++; |
| 46 |
goto *dispatch_table[op->opcode]; |
| 47 |
CASE_OP_B: |
| 48 |
do_stuff_b(op->arg); |
| 49 |
op++; |
| 50 |
goto *dispatch_table[op->opcode]; |
| 51 |
CASE_OP_C: |
| 52 |
do_stuff_c(op->arg); |
| 53 |
op++; |
| 54 |
goto *dispatch_table[op->opcode]; |
| 55 |
CASE_OP_END: |
| 56 |
return; |
| 57 |
} |