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