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