| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-mmicromips" } */ |
| 3 |
|
| 4 |
int __attribute__ ((noinline)) |
| 5 |
frob (int i) |
| 6 |
{ |
| 7 |
switch (i) |
| 8 |
{ |
| 9 |
case -5: |
| 10 |
return -2; |
| 11 |
case -3: |
| 12 |
return -1; |
| 13 |
case 0: |
| 14 |
return 0; |
| 15 |
case 3: |
| 16 |
return 1; |
| 17 |
case 5: |
| 18 |
break; |
| 19 |
default: |
| 20 |
__builtin_unreachable (); |
| 21 |
} |
| 22 |
return i; |
| 23 |
} |
| 24 |
|
| 25 |
int |
| 26 |
main (int argc, char **argv) |
| 27 |
{ |
| 28 |
asm ("" : "+r" (argc)); |
| 29 |
argc = frob ((argc & 10) - 5); |
| 30 |
asm ("" : "+r" (argc)); |
| 31 |
return !argc; |
| 32 |
} |
| 33 |
|
| 34 |
/* This will result in assembly like: |
| 35 |
|
| 36 |
.text |
| 37 |
.align 2 |
| 38 |
.globl frob |
| 39 |
.set nomips16 |
| 40 |
.set micromips |
| 41 |
.ent frob |
| 42 |
.type frob, @function |
| 43 |
frob: |
| 44 |
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0 |
| 45 |
.mask 0x00000000,0 |
| 46 |
.fmask 0x00000000,0 |
| 47 |
.set noreorder |
| 48 |
.set nomacro |
| 49 |
addiu $3,$4,5 |
| 50 |
sltu $2,$3,11 |
| 51 |
beqzc $2,$L2 |
| 52 |
lui $2,%hi($L4) |
| 53 |
addiu $2,$2,%lo($L4) |
| 54 |
lwxs $3,$3($2) |
| 55 |
jrc $3 |
| 56 |
.rdata |
| 57 |
.align 2 |
| 58 |
.align 2 |
| 59 |
$L4: |
| 60 |
.word $L3 |
| 61 |
.word $L2 |
| 62 |
.word $L9 |
| 63 |
.word $L2 |
| 64 |
.word $L2 |
| 65 |
.word $L8 |
| 66 |
.word $L2 |
| 67 |
.word $L2 |
| 68 |
.word $L7 |
| 69 |
.word $L2 |
| 70 |
.word $L8 |
| 71 |
.text |
| 72 |
$L8: |
| 73 |
jr $31 |
| 74 |
move $2,$4 |
| 75 |
|
| 76 |
$L9: |
| 77 |
jr $31 |
| 78 |
li $2,-1 # 0xffffffffffffffff |
| 79 |
|
| 80 |
$L3: |
| 81 |
jr $31 |
| 82 |
li $2,-2 # 0xfffffffffffffffe |
| 83 |
|
| 84 |
$L7: |
| 85 |
jr $31 |
| 86 |
li $2,1 # 0x1 |
| 87 |
|
| 88 |
$L2: |
| 89 |
.insn |
| 90 |
.set macro |
| 91 |
.set reorder |
| 92 |
.end frob |
| 93 |
.size frob, .-frob |
| 94 |
|
| 95 |
for `frob' and we want to make sure it links correctly owing to the |
| 96 |
`.insn' pseudo-op which needs to be there at `$L2' as there's no |
| 97 |
code following and the label is a microMIPS branch target (even though |
| 98 |
the branch is never taken. See also insn-casesi.c. */ |