Home | History | Annotate | Download | only in Mips
      1 # RUN: llvm-mc %s -triple=mips64el-unknown-linux -show-encoding -mcpu=mips64r2 | FileCheck %s
      2 
      3 # Check that signed negative 32-bit immediates are loaded correctly:
      4   li $10, ~(0x101010)
      5 # CHECK: lui $10, 65519        # encoding: [0xef,0xff,0x0a,0x3c]
      6 # CHECK: ori $10, $10, 61423   # encoding: [0xef,0xef,0x4a,0x35]
      7 # CHECK-NOT: dsll
      8 
      9 # Test bne with an immediate as the 2nd operand.
     10   bne $2, 0x100010001, 1332
     11 # CHECK: addiu $1, $zero, 1         # encoding: [0x01,0x00,0x01,0x24]
     12 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     13 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     14 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     15 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     16 # CHECK: bne  $2, $1, 1332          # encoding: [0x4d,0x01,0x41,0x14]
     17 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
     18 
     19   bne $2, 0x1000100010001, 1332
     20 # CHECK: lui  $1, 1                 # encoding: [0x01,0x00,0x01,0x3c]
     21 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     22 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     23 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     24 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     25 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     26 # CHECK: bne  $2, $1, 1332          # encoding: [0x4d,0x01,0x41,0x14]
     27 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
     28 
     29   bne $2, -0x100010001, 1332
     30 # CHECK: addiu $1, $zero, -2        # encoding: [0xfe,0xff,0x01,0x24]
     31 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     32 # CHECK: ori  $1, $1, 65534         # encoding: [0xfe,0xff,0x21,0x34]
     33 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     34 # CHECK: ori  $1, $1, 65535         # encoding: [0xff,0xff,0x21,0x34]
     35 # CHECK: bne  $2, $1, 1332          # encoding: [0x4d,0x01,0x41,0x14]
     36 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
     37 
     38   bne $2, -0x1000100010001, 1332
     39 # CHECK: lui  $1, 65534             # encoding: [0xfe,0xff,0x01,0x3c]
     40 # CHECK: ori  $1, $1, 65534         # encoding: [0xfe,0xff,0x21,0x34]
     41 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     42 # CHECK: ori  $1, $1, 65534         # encoding: [0xfe,0xff,0x21,0x34]
     43 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     44 # CHECK: ori  $1, $1, 65535         # encoding: [0xff,0xff,0x21,0x34]
     45 # CHECK: bne  $2, $1, 1332          # encoding: [0x4d,0x01,0x41,0x14]
     46 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
     47 
     48 # Test beq with an immediate as the 2nd operand.
     49   beq $2, 0x100010001, 1332
     50 # CHECK: addiu $1, $zero, 1         # encoding: [0x01,0x00,0x01,0x24]
     51 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     52 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     53 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     54 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     55 # CHECK: beq  $2, $1, 1332          # encoding: [0x4d,0x01,0x41,0x10]
     56 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
     57 
     58   beq $2, 0x1000100010001, 1332
     59 # CHECK: lui  $1, 1                 # encoding: [0x01,0x00,0x01,0x3c]
     60 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     61 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     62 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     63 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     64 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     65 # CHECK: beq  $2, $1, 1332          # encoding: [0x4d,0x01,0x41,0x10]
     66 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
     67 
     68   beq $2, -0x100010001, 1332
     69 # CHECK: addiu $1, $zero, -2        # encoding: [0xfe,0xff,0x01,0x24]
     70 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     71 # CHECK: ori  $1, $1, 65534         # encoding: [0xfe,0xff,0x21,0x34]
     72 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     73 # CHECK: ori  $1, $1, 65535         # encoding: [0xff,0xff,0x21,0x34]
     74 # CHECK: beq  $2, $1, 1332          # encoding: [0x4d,0x01,0x41,0x10]
     75 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
     76 
     77   beq $2, -0x1000100010001, 1332
     78 # CHECK: lui  $1, 65534             # encoding: [0xfe,0xff,0x01,0x3c]
     79 # CHECK: ori  $1, $1, 65534         # encoding: [0xfe,0xff,0x21,0x34]
     80 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     81 # CHECK: ori  $1, $1, 65534         # encoding: [0xfe,0xff,0x21,0x34]
     82 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     83 # CHECK: ori  $1, $1, 65535         # encoding: [0xff,0xff,0x21,0x34]
     84 # CHECK: beq  $2, $1, 1332          # encoding: [0x4d,0x01,0x41,0x10]
     85 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
     86 
     87 # Test one with a symbol in the third operand.
     88 sym:
     89   bne $2, 0x100010001, sym
     90 # CHECK: addiu $1, $zero, 1         # encoding: [0x01,0x00,0x01,0x24]
     91 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     92 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     93 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
     94 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
     95 # CHECK: bne  $2, $1, sym           # encoding: [A,A,0x41,0x14]
     96 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
     97 
     98 # Test ulhu with 64-bit immediate addresses.
     99   ulhu $8, 0x100010001
    100 # CHECK: addiu $1, $zero, 1    # encoding: [0x01,0x00,0x01,0x24]
    101 # CHECK: ori  $1, $1, 1        # encoding: [0x01,0x00,0x21,0x34]
    102 # CHECK: dsll $1, $1, 16       # encoding: [0x38,0x0c,0x01,0x00]
    103 # CHECK: ori  $1, $1, 1        # encoding: [0x01,0x00,0x21,0x34]
    104 # CHECK: lbu  $8, 1($1)        # encoding: [0x01,0x00,0x28,0x90]
    105 # CHECK: lbu  $1, 0($1)        # encoding: [0x00,0x00,0x21,0x90]
    106 # CHECK: sll  $8, $8, 8        # encoding: [0x00,0x42,0x08,0x00]
    107 # CHECK: or   $8, $8, $1       # encoding: [0x25,0x40,0x01,0x01]
    108 
    109   ulhu $8, 0x1000100010001
    110 # CHECK: lui  $1, 1            # encoding: [0x01,0x00,0x01,0x3c]
    111 # CHECK: ori  $1, $1, 1        # encoding: [0x01,0x00,0x21,0x34]
    112 # CHECK: dsll $1, $1, 16       # encoding: [0x38,0x0c,0x01,0x00]
    113 # CHECK: ori  $1, $1, 1        # encoding: [0x01,0x00,0x21,0x34]
    114 # CHECK: dsll $1, $1, 16       # encoding: [0x38,0x0c,0x01,0x00]
    115 # CHECK: ori  $1, $1, 1        # encoding: [0x01,0x00,0x21,0x34]
    116 # CHECK: lbu  $8, 1($1)        # encoding: [0x01,0x00,0x28,0x90]
    117 # CHECK: lbu  $1, 0($1)        # encoding: [0x00,0x00,0x21,0x90]
    118 # CHECK: sll  $8, $8, 8        # encoding: [0x00,0x42,0x08,0x00]
    119 # CHECK: or   $8, $8, $1       # encoding: [0x25,0x40,0x01,0x01]
    120 
    121   ulhu $8, -0x100010001
    122 # CHECK: addiu $1, $zero, -2   # encoding: [0xfe,0xff,0x01,0x24]
    123 # CHECK: dsll $1, $1, 16       # encoding: [0x38,0x0c,0x01,0x00]
    124 # CHECK: ori  $1, $1, 65534    # encoding: [0xfe,0xff,0x21,0x34]
    125 # CHECK: dsll $1, $1, 16       # encoding: [0x38,0x0c,0x01,0x00]
    126 # CHECK: ori  $1, $1, 65535    # encoding: [0xff,0xff,0x21,0x34]
    127 # CHECK: lbu  $8, 1($1)        # encoding: [0x01,0x00,0x28,0x90]
    128 # CHECK: lbu  $1, 0($1)        # encoding: [0x00,0x00,0x21,0x90]
    129 # CHECK: sll  $8, $8, 8        # encoding: [0x00,0x42,0x08,0x00]
    130 # CHECK: or   $8, $8, $1       # encoding: [0x25,0x40,0x01,0x01]
    131 
    132   ulhu $8, -0x1000100010001
    133 # CHECK: lui  $1, 65534        # encoding: [0xfe,0xff,0x01,0x3c]
    134 # CHECK: ori  $1, $1, 65534    # encoding: [0xfe,0xff,0x21,0x34]
    135 # CHECK: dsll $1, $1, 16       # encoding: [0x38,0x0c,0x01,0x00]
    136 # CHECK: ori  $1, $1, 65534    # encoding: [0xfe,0xff,0x21,0x34]
    137 # CHECK: dsll $1, $1, 16       # encoding: [0x38,0x0c,0x01,0x00]
    138 # CHECK: ori  $1, $1, 65535    # encoding: [0xff,0xff,0x21,0x34]
    139 # CHECK: lbu  $8, 1($1)        # encoding: [0x01,0x00,0x28,0x90]
    140 # CHECK: lbu  $1, 0($1)        # encoding: [0x00,0x00,0x21,0x90]
    141 # CHECK: sll  $8, $8, 8        # encoding: [0x00,0x42,0x08,0x00]
    142 # CHECK: or   $8, $8, $1       # encoding: [0x25,0x40,0x01,0x01]
    143 
    144 # Test ulhu with source register and 64-bit immediate offset.
    145   ulhu $8, 0x100010001($9)
    146 # CHECK: addiu $1, $zero, 1    # encoding: [0x01,0x00,0x01,0x24]
    147 # CHECK: ori   $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
    148 # CHECK: dsll  $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    149 # CHECK: ori   $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
    150 # CHECK: daddu $1, $1, $9      # encoding: [0x2d,0x08,0x29,0x00]
    151 # CHECK: lbu   $8, 1($1)       # encoding: [0x01,0x00,0x28,0x90]
    152 # CHECK: lbu   $1, 0($1)       # encoding: [0x00,0x00,0x21,0x90]
    153 # CHECK: sll   $8, $8, 8       # encoding: [0x00,0x42,0x08,0x00]
    154 # CHECK: or    $8, $8, $1      # encoding: [0x25,0x40,0x01,0x01]
    155 
    156   ulhu $8, 0x1000100010001($9)
    157 # CHECK: lui   $1, 1           # encoding: [0x01,0x00,0x01,0x3c]
    158 # CHECK: ori   $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
    159 # CHECK: dsll  $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    160 # CHECK: ori   $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
    161 # CHECK: dsll  $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    162 # CHECK: ori   $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
    163 # CHECK: daddu $1, $1, $9      # encoding: [0x2d,0x08,0x29,0x00]
    164 # CHECK: lbu   $8, 1($1)       # encoding: [0x01,0x00,0x28,0x90]
    165 # CHECK: lbu   $1, 0($1)       # encoding: [0x00,0x00,0x21,0x90]
    166 # CHECK: sll   $8, $8, 8       # encoding: [0x00,0x42,0x08,0x00]
    167 # CHECK: or    $8, $8, $1      # encoding: [0x25,0x40,0x01,0x01]
    168 
    169   ulhu $8, -0x100010001($9)
    170 # CHECK: addiu $1, $zero, -2   # encoding: [0xfe,0xff,0x01,0x24]
    171 # CHECK: dsll  $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    172 # CHECK: ori   $1, $1, 65534   # encoding: [0xfe,0xff,0x21,0x34]
    173 # CHECK: dsll  $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    174 # CHECK: daddu $1, $1, $9      # encoding: [0x2d,0x08,0x29,0x00]
    175 # CHECK: lbu   $8, 1($1)       # encoding: [0x01,0x00,0x28,0x90]
    176 # CHECK: lbu   $1, 0($1)       # encoding: [0x00,0x00,0x21,0x90]
    177 # CHECK: sll   $8, $8, 8       # encoding: [0x00,0x42,0x08,0x00]
    178 # CHECK: or    $8, $8, $1      # encoding: [0x25,0x40,0x01,0x01]
    179 
    180   ulhu $8, -0x1000100010001($9)
    181 # CHECK: lui   $1, 65534       # encoding: [0xfe,0xff,0x01,0x3c]
    182 # CHECK: ori   $1, $1, 65534   # encoding: [0xfe,0xff,0x21,0x34]
    183 # CHECK: dsll  $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    184 # CHECK: ori   $1, $1, 65534   # encoding: [0xfe,0xff,0x21,0x34]
    185 # CHECK: dsll  $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    186 # CHECK: ori   $1, $1, 65535   # encoding: [0xff,0xff,0x21,0x34]
    187 # CHECK: daddu $1, $1, $9      # encoding: [0x2d,0x08,0x29,0x00]
    188 # CHECK: lbu   $8, 1($1)       # encoding: [0x01,0x00,0x28,0x90]
    189 # CHECK: lbu   $1, 0($1)       # encoding: [0x00,0x00,0x21,0x90]
    190 # CHECK: sll   $8, $8, 8       # encoding: [0x00,0x42,0x08,0x00]
    191 # CHECK: or    $8, $8, $1      # encoding: [0x25,0x40,0x01,0x01]
    192 
    193 # Test ulw with 64-bit immediate addresses.
    194   ulw $8, 0x100010001
    195 # CHECK: addiu $1, $zero, 1   # encoding: [0x01,0x00,0x01,0x24]
    196 # CHECK: ori  $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
    197 # CHECK: dsll $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    198 # CHECK: ori  $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
    199 # CHECK: lwl  $8, 3($1)       # encoding: [0x03,0x00,0x28,0x88]
    200 # CHECK: lwr  $8, 0($1)       # encoding: [0x00,0x00,0x28,0x98]
    201 
    202   ulw $8, 0x1000100010001
    203 # CHECK: lui  $1, 1           # encoding: [0x01,0x00,0x01,0x3c]
    204 # CHECK: ori  $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
    205 # CHECK: dsll $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    206 # CHECK: ori  $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
    207 # CHECK: dsll $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    208 # CHECK: ori  $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
    209 # CHECK: lwl  $8, 3($1)       # encoding: [0x03,0x00,0x28,0x88]
    210 # CHECK: lwr  $8, 0($1)       # encoding: [0x00,0x00,0x28,0x98]
    211 
    212   ulw $8, -0x100010001
    213 # CHECK: addiu $1, $zero, -2  # encoding: [0xfe,0xff,0x01,0x24]
    214 # CHECK: dsll $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    215 # CHECK: ori  $1, $1, 65534   # encoding: [0xfe,0xff,0x21,0x34]
    216 # CHECK: dsll $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    217 # CHECK: ori  $1, $1, 65535   # encoding: [0xff,0xff,0x21,0x34]
    218 # CHECK: lwl  $8, 3($1)       # encoding: [0x03,0x00,0x28,0x88]
    219 # CHECK: lwr  $8, 0($1)       # encoding: [0x00,0x00,0x28,0x98]
    220 
    221   ulw $8, -0x1000100010001
    222 # CHECK: lui  $1, 65534       # encoding: [0xfe,0xff,0x01,0x3c]
    223 # CHECK: ori  $1, $1, 65534   # encoding: [0xfe,0xff,0x21,0x34]
    224 # CHECK: dsll $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    225 # CHECK: ori  $1, $1, 65534   # encoding: [0xfe,0xff,0x21,0x34]
    226 # CHECK: dsll $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
    227 # CHECK: ori  $1, $1, 65535   # encoding: [0xff,0xff,0x21,0x34]
    228 # CHECK: lwl  $8, 3($1)       # encoding: [0x03,0x00,0x28,0x88]
    229 # CHECK: lwr  $8, 0($1)       # encoding: [0x00,0x00,0x28,0x98]
    230 
    231 # Test ulw with source register and 64-bit immediate offset.
    232   ulw $8, 0x100010001($9)
    233 # CHECK: addiu $1, $zero, 1   # encoding: [0x01,0x00,0x01,0x24]
    234 # CHECK: ori   $1, $1, 1      # encoding: [0x01,0x00,0x21,0x34]
    235 # CHECK: dsll  $1, $1, 16     # encoding: [0x38,0x0c,0x01,0x00]
    236 # CHECK: ori   $1, $1, 1      # encoding: [0x01,0x00,0x21,0x34]
    237 # CHECK: daddu $1, $1, $9     # encoding: [0x2d,0x08,0x29,0x00]
    238 # CHECK: lwl   $8, 3($1)      # encoding: [0x03,0x00,0x28,0x88]
    239 # CHECK: lwr   $8, 0($1)      # encoding: [0x00,0x00,0x28,0x98]
    240 
    241   ulw $8, 0x1000100010001($9)
    242 # CHECK: lui   $1, 1          # encoding: [0x01,0x00,0x01,0x3c]
    243 # CHECK: ori   $1, $1, 1      # encoding: [0x01,0x00,0x21,0x34]
    244 # CHECK: dsll  $1, $1, 16     # encoding: [0x38,0x0c,0x01,0x00]
    245 # CHECK: ori   $1, $1, 1      # encoding: [0x01,0x00,0x21,0x34]
    246 # CHECK: dsll  $1, $1, 16     # encoding: [0x38,0x0c,0x01,0x00]
    247 # CHECK: ori   $1, $1, 1      # encoding: [0x01,0x00,0x21,0x34]
    248 # CHECK: daddu $1, $1, $9     # encoding: [0x2d,0x08,0x29,0x00]
    249 # CHECK: lwl   $8, 3($1)      # encoding: [0x03,0x00,0x28,0x88]
    250 # CHECK: lwr   $8, 0($1)      # encoding: [0x00,0x00,0x28,0x98]
    251 
    252   ulw $8, -0x100010001($9)
    253 # CHECK: addiu $1, $zero, -2  # encoding: [0xfe,0xff,0x01,0x24]
    254 # CHECK: dsll  $1, $1, 16     # encoding: [0x38,0x0c,0x01,0x00]
    255 # CHECK: ori   $1, $1, 65534  # encoding: [0xfe,0xff,0x21,0x34]
    256 # CHECK: dsll  $1, $1, 16     # encoding: [0x38,0x0c,0x01,0x00]
    257 # CHECK: ori   $1, $1, 65535  # encoding: [0xff,0xff,0x21,0x34]
    258 # CHECK: daddu $1, $1, $9     # encoding: [0x2d,0x08,0x29,0x00]
    259 # CHECK: lwl   $8, 3($1)      # encoding: [0x03,0x00,0x28,0x88]
    260 # CHECK: lwr   $8, 0($1)      # encoding: [0x00,0x00,0x28,0x98]
    261 
    262   ulw $8, -0x1000100010001($9)
    263 # CHECK: lui   $1, 65534      # encoding: [0xfe,0xff,0x01,0x3c]
    264 # CHECK: ori   $1, $1, 65534  # encoding: [0xfe,0xff,0x21,0x34]
    265 # CHECK: dsll  $1, $1, 16     # encoding: [0x38,0x0c,0x01,0x00]
    266 # CHECK: ori   $1, $1, 65534  # encoding: [0xfe,0xff,0x21,0x34]
    267 # CHECK: dsll  $1, $1, 16     # encoding: [0x38,0x0c,0x01,0x00]
    268 # CHECK: ori   $1, $1, 65535  # encoding: [0xff,0xff,0x21,0x34]
    269 # CHECK: daddu $1, $1, $9     # encoding: [0x2d,0x08,0x29,0x00]
    270 # CHECK: lwl   $8, 3($1)      # encoding: [0x03,0x00,0x28,0x88]
    271 # CHECK: lwr   $8, 0($1)      # encoding: [0x00,0x00,0x28,0x98]
    272