1*9880d681SAndroid Build Coastguard Worker# RUN: llvm-mc %s -triple=mipsel-unknown-linux -show-encoding -mcpu=mips32r2 | \ 2*9880d681SAndroid Build Coastguard Worker# RUN: FileCheck -check-prefix=CHECK32 %s 3*9880d681SAndroid Build Coastguard Worker# RUN: llvm-mc %s -triple=mips64el-unknown-linux -show-encoding -mcpu=mips64r2 | \ 4*9880d681SAndroid Build Coastguard Worker# RUN: FileCheck -check-prefix=CHECK64 %s 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker# Check that the assembler can handle the documented syntax 7*9880d681SAndroid Build Coastguard Worker# for jumps and branches. 8*9880d681SAndroid Build Coastguard Worker#------------------------------------------------------------------------------ 9*9880d681SAndroid Build Coastguard Worker# Branch instructions 10*9880d681SAndroid Build Coastguard Worker#------------------------------------------------------------------------------ 11*9880d681SAndroid Build Coastguard Worker# CHECK32: b 1332 # encoding: [0x4d,0x01,0x00,0x10] 12*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 13*9880d681SAndroid Build Coastguard Worker# CHECK32: bc1f 1332 # encoding: [0x4d,0x01,0x00,0x45] 14*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 15*9880d681SAndroid Build Coastguard Worker# CHECK32: bc1t 1332 # encoding: [0x4d,0x01,0x01,0x45] 16*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 17*9880d681SAndroid Build Coastguard Worker# CHECK32: beq $9, $6, 1332 # encoding: [0x4d,0x01,0x26,0x11] 18*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 19*9880d681SAndroid Build Coastguard Worker# CHECK32: bgez $6, 1332 # encoding: [0x4d,0x01,0xc1,0x04] 20*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 21*9880d681SAndroid Build Coastguard Worker# CHECK32: bgezal $6, 1332 # encoding: [0x4d,0x01,0xd1,0x04] 22*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 23*9880d681SAndroid Build Coastguard Worker# CHECK32: bgtz $6, 1332 # encoding: [0x4d,0x01,0xc0,0x1c] 24*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 25*9880d681SAndroid Build Coastguard Worker# CHECK32: blez $6, 1332 # encoding: [0x4d,0x01,0xc0,0x18] 26*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 27*9880d681SAndroid Build Coastguard Worker# CHECK32: bne $9, $6, 1332 # encoding: [0x4d,0x01,0x26,0x15] 28*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 29*9880d681SAndroid Build Coastguard Worker# CHECK32: bal 1332 # encoding: [0x4d,0x01,0x11,0x04] 30*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 31*9880d681SAndroid Build Coastguard Worker# CHECK32: bnez $11, 1332 # encoding: [0x4d,0x01,0x60,0x15] 32*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 33*9880d681SAndroid Build Coastguard Worker# CHECK32: beqz $11, 1332 # encoding: [0x4d,0x01,0x60,0x11] 34*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker# CHECK64: b 1332 # encoding: [0x4d,0x01,0x00,0x10] 37*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 38*9880d681SAndroid Build Coastguard Worker# CHECK64: bc1f 1332 # encoding: [0x4d,0x01,0x00,0x45] 39*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 40*9880d681SAndroid Build Coastguard Worker# CHECK64: bc1t 1332 # encoding: [0x4d,0x01,0x01,0x45] 41*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 42*9880d681SAndroid Build Coastguard Worker# CHECK64: beq $9, $6, 1332 # encoding: [0x4d,0x01,0x26,0x11] 43*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 44*9880d681SAndroid Build Coastguard Worker# CHECK64: bgez $6, 1332 # encoding: [0x4d,0x01,0xc1,0x04] 45*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 46*9880d681SAndroid Build Coastguard Worker# CHECK64: bgezal $6, 1332 # encoding: [0x4d,0x01,0xd1,0x04] 47*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 48*9880d681SAndroid Build Coastguard Worker# CHECK64: bgtz $6, 1332 # encoding: [0x4d,0x01,0xc0,0x1c] 49*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 50*9880d681SAndroid Build Coastguard Worker# CHECK64: blez $6, 1332 # encoding: [0x4d,0x01,0xc0,0x18] 51*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 52*9880d681SAndroid Build Coastguard Worker# CHECK64: bne $9, $6, 1332 # encoding: [0x4d,0x01,0x26,0x15] 53*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 54*9880d681SAndroid Build Coastguard Worker# CHECK64: bal 1332 # encoding: [0x4d,0x01,0x11,0x04] 55*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 56*9880d681SAndroid Build Coastguard Worker# CHECK64: bnez $11, 1332 # encoding: [0x4d,0x01,0x60,0x15] 57*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 58*9880d681SAndroid Build Coastguard Worker# CHECK64: beqz $11, 1332 # encoding: [0x4d,0x01,0x60,0x11] 59*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Worker.set noreorder 62*9880d681SAndroid Build Coastguard Worker 63*9880d681SAndroid Build Coastguard Worker b 1332 64*9880d681SAndroid Build Coastguard Worker nop 65*9880d681SAndroid Build Coastguard Worker bc1f 1332 66*9880d681SAndroid Build Coastguard Worker nop 67*9880d681SAndroid Build Coastguard Worker bc1t 1332 68*9880d681SAndroid Build Coastguard Worker nop 69*9880d681SAndroid Build Coastguard Worker beq $9,$6,1332 70*9880d681SAndroid Build Coastguard Worker nop 71*9880d681SAndroid Build Coastguard Worker bgez $6,1332 72*9880d681SAndroid Build Coastguard Worker nop 73*9880d681SAndroid Build Coastguard Worker bgezal $6,1332 74*9880d681SAndroid Build Coastguard Worker nop 75*9880d681SAndroid Build Coastguard Worker bgtz $6,1332 76*9880d681SAndroid Build Coastguard Worker nop 77*9880d681SAndroid Build Coastguard Worker blez $6,1332 78*9880d681SAndroid Build Coastguard Worker nop 79*9880d681SAndroid Build Coastguard Worker bne $9,$6,1332 80*9880d681SAndroid Build Coastguard Worker nop 81*9880d681SAndroid Build Coastguard Worker bal 1332 82*9880d681SAndroid Build Coastguard Worker nop 83*9880d681SAndroid Build Coastguard Worker bnez $11,1332 84*9880d681SAndroid Build Coastguard Worker nop 85*9880d681SAndroid Build Coastguard Worker beqz $11,1332 86*9880d681SAndroid Build Coastguard Worker nop 87*9880d681SAndroid Build Coastguard Worker 88*9880d681SAndroid Build Coastguard Workerend_of_code: 89*9880d681SAndroid Build Coastguard Worker#------------------------------------------------------------------------------ 90*9880d681SAndroid Build Coastguard Worker# Jump instructions 91*9880d681SAndroid Build Coastguard Worker#------------------------------------------------------------------------------ 92*9880d681SAndroid Build Coastguard Worker# CHECK32: j 1328 # encoding: [0x4c,0x01,0x00,0x08] 93*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 94*9880d681SAndroid Build Coastguard Worker# CHECK32: jal 1328 # encoding: [0x4c,0x01,0x00,0x0c] 95*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 96*9880d681SAndroid Build Coastguard Worker# CHECK32: jalr $6 # encoding: [0x09,0xf8,0xc0,0x00] 97*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 98*9880d681SAndroid Build Coastguard Worker# CHECK32: jalr $25 # encoding: [0x09,0xf8,0x20,0x03] 99*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 100*9880d681SAndroid Build Coastguard Worker# CHECK32: jalr $10, $11 # encoding: [0x09,0x50,0x60,0x01] 101*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 102*9880d681SAndroid Build Coastguard Worker# CHECK32: jr $7 # encoding: [0x08,0x00,0xe0,0x00] 103*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 104*9880d681SAndroid Build Coastguard Worker# CHECK32:lab: 105*9880d681SAndroid Build Coastguard Worker# CHECK32: jr $7 # encoding: [0x08,0x00,0xe0,0x00] 106*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 107*9880d681SAndroid Build Coastguard Worker# CHECK32: jalr $25 # encoding: [0x09,0xf8,0x20,0x03] 108*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 109*9880d681SAndroid Build Coastguard Worker# CHECK32: jalr $4, $25 # encoding: [0x09,0x20,0x20,0x03] 110*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 111*9880d681SAndroid Build Coastguard Worker# CHECK32: jalx lab # encoding: [A,A,A,0b011101AA] 112*9880d681SAndroid Build Coastguard Worker# CHECK32: # fixup A - offset: 0, value: lab, kind: fixup_Mips_26 113*9880d681SAndroid Build Coastguard Worker# CHECK32: nop # encoding: [0x00,0x00,0x00,0x00] 114*9880d681SAndroid Build Coastguard Worker 115*9880d681SAndroid Build Coastguard Worker# CHECK64: j 1328 # encoding: [0x4c,0x01,0x00,0x08] 116*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 117*9880d681SAndroid Build Coastguard Worker# CHECK64: jal 1328 # encoding: [0x4c,0x01,0x00,0x0c] 118*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 119*9880d681SAndroid Build Coastguard Worker# CHECK64: jalr $6 # encoding: [0x09,0xf8,0xc0,0x00] 120*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 121*9880d681SAndroid Build Coastguard Worker# CHECK64: jalr $25 # encoding: [0x09,0xf8,0x20,0x03] 122*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 123*9880d681SAndroid Build Coastguard Worker# CHECK64: jalr $10, $11 # encoding: [0x09,0x50,0x60,0x01] 124*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 125*9880d681SAndroid Build Coastguard Worker# CHECK64: jr $7 # encoding: [0x08,0x00,0xe0,0x00] 126*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 127*9880d681SAndroid Build Coastguard Worker# CHECK64:lab: 128*9880d681SAndroid Build Coastguard Worker# CHECK64: jr $7 # encoding: [0x08,0x00,0xe0,0x00] 129*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 130*9880d681SAndroid Build Coastguard Worker# CHECK64: jalr $25 # encoding: [0x09,0xf8,0x20,0x03] 131*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 132*9880d681SAndroid Build Coastguard Worker# CHECK64: jalr $4, $25 # encoding: [0x09,0x20,0x20,0x03] 133*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 134*9880d681SAndroid Build Coastguard Worker# CHECK64: jalx lab # encoding: [A,A,A,0b011101AA] 135*9880d681SAndroid Build Coastguard Worker# CHECK64: # fixup A - offset: 0, value: lab, kind: fixup_Mips_26 136*9880d681SAndroid Build Coastguard Worker# CHECK64: nop # encoding: [0x00,0x00,0x00,0x00] 137*9880d681SAndroid Build Coastguard Worker 138*9880d681SAndroid Build Coastguard Worker j 1328 139*9880d681SAndroid Build Coastguard Worker nop 140*9880d681SAndroid Build Coastguard Worker jal 1328 141*9880d681SAndroid Build Coastguard Worker nop 142*9880d681SAndroid Build Coastguard Worker jalr $6 143*9880d681SAndroid Build Coastguard Worker nop 144*9880d681SAndroid Build Coastguard Worker jalr $31, $25 145*9880d681SAndroid Build Coastguard Worker nop 146*9880d681SAndroid Build Coastguard Worker jalr $10, $11 147*9880d681SAndroid Build Coastguard Worker nop 148*9880d681SAndroid Build Coastguard Worker jr $7 149*9880d681SAndroid Build Coastguard Worker nop 150*9880d681SAndroid Build Coastguard Workerlab: 151*9880d681SAndroid Build Coastguard Worker j $7 152*9880d681SAndroid Build Coastguard Worker nop 153*9880d681SAndroid Build Coastguard Worker jal $25 154*9880d681SAndroid Build Coastguard Worker nop 155*9880d681SAndroid Build Coastguard Worker jal $4,$25 156*9880d681SAndroid Build Coastguard Worker nop 157*9880d681SAndroid Build Coastguard Worker jalx lab 158*9880d681SAndroid Build Coastguard Worker nop 159