Home | History | Annotate | Download | only in Mips
      1 # RUN: llvm-mc %s -triple=mipsel-unknown-linux -show-encoding -mcpu=mips32r2 | \
      2 # RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LE
      3 # RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips32r2 | \
      4 # RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BE
      5 
      6 # Check that the IAS expands macro instructions in the same way as GAS.
      7 
      8 # Load address, done by MipsAsmParser::expandLoadAddressReg()
      9 # and MipsAsmParser::expandLoadAddressImm():
     10   la $8, 1f
     11 # CHECK-LE: lui     $8, %hi(($tmp0))      # encoding: [A,A,0x08,0x3c]
     12 # CHECK-LE:                             #   fixup A - offset: 0, value: %hi(($tmp0)), kind: fixup_Mips_HI16
     13 # CHECK-LE: addiu   $8, $8, %lo(($tmp0))  # encoding: [A,A,0x08,0x25]
     14 # CHECK-LE:                             #   fixup A - offset: 0, value: %lo(($tmp0)), kind: fixup_Mips_LO16
     15 
     16 # LW/SW and LDC1/SDC1 of symbol address, done by MipsAsmParser::expandMemInst():
     17   .set noat
     18   lw $10, symbol($4)
     19 # CHECK-LE: lui     $10, %hi(symbol)        # encoding: [A,A,0x0a,0x3c]
     20 # CHECK-LE:                                 #   fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
     21 # CHECK-LE: addu    $10, $10, $4            # encoding: [0x21,0x50,0x44,0x01]
     22 # CHECK-LE: lw      $10, %lo(symbol)($10)   # encoding: [A,A,0x4a,0x8d]
     23 # CHECK-LE:                                 #   fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
     24   .set at
     25   sw $10, symbol($9)
     26 # CHECK-LE: lui     $1, %hi(symbol)         # encoding: [A,A,0x01,0x3c]
     27 # CHECK-LE:                                 #   fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
     28 # CHECK-LE: addu    $1, $1, $9              # encoding: [0x21,0x08,0x29,0x00]
     29 # CHECK-LE: sw      $10, %lo(symbol)($1)    # encoding: [A,A,0x2a,0xac]
     30 # CHECK-LE:                                 #   fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
     31 
     32   lw $8, 1f
     33 # CHECK-LE: lui $8, %hi($tmp0)              # encoding: [A,A,0x08,0x3c]
     34 # CHECK-LE:                                 #   fixup A - offset: 0, value: ($tmp0)@ABS_HI, kind: fixup_Mips_HI16
     35 # CHECK-LE: lw  $8, %lo($tmp0)($8)          # encoding: [A,A,0x08,0x8d]
     36 # CHECK-LE:                                 #   fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_Mips_LO16
     37   sw $8, 1f
     38 # CHECK-LE: lui $1, %hi($tmp0)              # encoding: [A,A,0x01,0x3c]
     39 # CHECK-LE:                                 #   fixup A - offset: 0, value: ($tmp0)@ABS_HI, kind: fixup_Mips_HI16
     40 # CHECK-LE: sw  $8, %lo($tmp0)($1)          # encoding: [A,A,0x28,0xac]
     41 # CHECK-LE:                                 #   fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_Mips_LO16
     42 
     43   lw $10, 655483($4)
     44 # CHECK-LE: lui     $10, 10                 # encoding: [0x0a,0x00,0x0a,0x3c]
     45 # CHECK-LE: addu    $10, $10, $4            # encoding: [0x21,0x50,0x44,0x01]
     46 # CHECK-LE: lw      $10, 123($10)           # encoding: [0x7b,0x00,0x4a,0x8d]
     47   sw $10, 123456($9)
     48 # CHECK-LE: lui     $1, 2                   # encoding: [0x02,0x00,0x01,0x3c]
     49 # CHECK-LE: addu    $1, $1, $9              # encoding: [0x21,0x08,0x29,0x00]
     50 # CHECK-LE: sw      $10, 57920($1)          # encoding: [0x40,0xe2,0x2a,0xac]
     51 
     52   lw $8, symbol
     53 # CHECK-LE:     lui     $8, %hi(symbol)     # encoding: [A,A,0x08,0x3c]
     54 # CHECK-LE:                                 #   fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
     55 # CHECK-LE-NOT: move    $8, $8              # encoding: [0x21,0x40,0x00,0x01]
     56 # CHECK-LE:     lw      $8, %lo(symbol)($8) # encoding: [A,A,0x08,0x8d]
     57 # CHECK-LE:                                 #   fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
     58   sw $8, symbol
     59 # CHECK-LE:     lui     $1, %hi(symbol)     # encoding: [A,A,0x01,0x3c]
     60 # CHECK-LE:                                 #   fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
     61 # CHECK-LE-NOT: move    $1, $1              # encoding: [0x21,0x08,0x20,0x00]
     62 # CHECK-LE:     sw      $8, %lo(symbol)($1) # encoding: [A,A,0x28,0xac]
     63 # CHECK-LE:                                 #   fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
     64 
     65   ldc1 $f0, symbol
     66 # CHECK-LE: lui     $1, %hi(symbol)
     67 # CHECK-LE: ldc1    $f0, %lo(symbol)($1)
     68   sdc1 $f0, symbol
     69 # CHECK-LE: lui     $1, %hi(symbol)
     70 # CHECK-LE: sdc1    $f0, %lo(symbol)($1)
     71 
     72 # Test BNE with an immediate as the 2nd operand.
     73   bne $2, 0, 1332
     74 # CHECK-LE: bnez  $2, 1332          # encoding: [0x4d,0x01,0x40,0x14]
     75 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
     76 
     77   bne $2, 123, 1332
     78 # CHECK-LE: addiu $1, $zero, 123    # encoding: [0x7b,0x00,0x01,0x24]
     79 # CHECK-LE: bne   $2, $1, 1332      # encoding: [0x4d,0x01,0x41,0x14]
     80 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
     81 
     82   bne $2, -2345, 1332
     83 # CHECK-LE: addiu $1, $zero, -2345  # encoding: [0xd7,0xf6,0x01,0x24]
     84 # CHECK-LE: bne   $2, $1, 1332      # encoding: [0x4d,0x01,0x41,0x14]
     85 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
     86 
     87   bne $2, 65538, 1332
     88 # CHECK-LE: lui   $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
     89 # CHECK-LE: ori   $1, $1, 2         # encoding: [0x02,0x00,0x21,0x34]
     90 # CHECK-LE: bne   $2, $1, 1332      # encoding: [0x4d,0x01,0x41,0x14]
     91 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
     92 
     93   bne $2, ~7, 1332
     94 # CHECK-LE: addiu $1, $zero, -8     # encoding: [0xf8,0xff,0x01,0x24]
     95 # CHECK-LE: bne   $2, $1, 1332      # encoding: [0x4d,0x01,0x41,0x14]
     96 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
     97 
     98   bne $2, 0x10000, 1332
     99 # CHECK-LE: lui   $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    100 # CHECK-LE: bne   $2, $1, 1332      # encoding: [0x4d,0x01,0x41,0x14]
    101 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
    102 
    103 # Test BEQ with an immediate as the 2nd operand.
    104   beq $2, 0, 1332
    105 # CHECK-LE: beqz  $2, 1332          # encoding: [0x4d,0x01,0x40,0x10]
    106 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
    107 
    108   beq $2, 123, 1332
    109 # CHECK-LE: addiu $1, $zero, 123    # encoding: [0x7b,0x00,0x01,0x24]
    110 # CHECK-LE: beq   $2, $1, 1332      # encoding: [0x4d,0x01,0x41,0x10]
    111 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
    112 
    113   beq $2, -2345, 1332
    114 # CHECK-LE: addiu $1, $zero, -2345  # encoding: [0xd7,0xf6,0x01,0x24]
    115 # CHECK-LE: beq   $2, $1, 1332      # encoding: [0x4d,0x01,0x41,0x10]
    116 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
    117 
    118   beq $2, 65538, 1332
    119 # CHECK-LE: lui   $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    120 # CHECK-LE: ori   $1, $1, 2         # encoding: [0x02,0x00,0x21,0x34]
    121 # CHECK-LE: beq   $2, $1, 1332      # encoding: [0x4d,0x01,0x41,0x10]
    122 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
    123 
    124   beq $2, ~7, 1332
    125 # CHECK-LE: addiu $1, $zero, -8     # encoding: [0xf8,0xff,0x01,0x24]
    126 # CHECK-LE: beq   $2, $1, 1332      # encoding: [0x4d,0x01,0x41,0x10]
    127 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
    128 
    129   beq $2, 0x10000, 1332
    130 # CHECK-LE: lui   $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    131 # CHECK-LE: beq   $2, $1, 1332      # encoding: [0x4d,0x01,0x41,0x10]
    132 # CHECK-LE: nop                     # encoding: [0x00,0x00,0x00,0x00]
    133 
    134 # Test ULH with immediate operand.
    135 ulh_imm: # CHECK-LABEL: ulh_imm:
    136   ulh $8, 0
    137 # CHECK-BE: lb   $1, 0($zero)      # encoding: [0x80,0x01,0x00,0x00]
    138 # CHECK-BE: lbu  $8, 1($zero)      # encoding: [0x90,0x08,0x00,0x01]
    139 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    140 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    141 # CHECK-LE: lb   $1, 1($zero)      # encoding: [0x01,0x00,0x01,0x80]
    142 # CHECK-LE: lbu  $8, 0($zero)      # encoding: [0x00,0x00,0x08,0x90]
    143 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    144 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    145 
    146   ulh $8, 2
    147 # CHECK-BE: lb   $1, 2($zero)      # encoding: [0x80,0x01,0x00,0x02]
    148 # CHECK-BE: lbu  $8, 3($zero)      # encoding: [0x90,0x08,0x00,0x03]
    149 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    150 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    151 # CHECK-LE: lb   $1, 3($zero)      # encoding: [0x03,0x00,0x01,0x80]
    152 # CHECK-LE: lbu  $8, 2($zero)      # encoding: [0x02,0x00,0x08,0x90]
    153 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    154 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    155 
    156   ulh $8, 0x8000
    157 # CHECK-BE: ori  $1, $zero, 32768  # encoding: [0x34,0x01,0x80,0x00]
    158 # CHECK-BE: lb   $8, 0($1)         # encoding: [0x80,0x28,0x00,0x00]
    159 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    160 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    161 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    162 # CHECK-LE: ori  $1, $zero, 32768  # encoding: [0x00,0x80,0x01,0x34]
    163 # CHECK-LE: lb   $8, 1($1)         # encoding: [0x01,0x00,0x28,0x80]
    164 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    165 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    166 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    167 
    168   ulh $8, -0x8000
    169 # CHECK-BE: lb   $1, -32768($zero) # encoding: [0x80,0x01,0x80,0x00]
    170 # CHECK-BE: lbu  $8, -32767($zero) # encoding: [0x90,0x08,0x80,0x01]
    171 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    172 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    173 # CHECK-LE: lb   $1, -32767($zero) # encoding: [0x01,0x80,0x01,0x80]
    174 # CHECK-LE: lbu  $8, -32768($zero) # encoding: [0x00,0x80,0x08,0x90]
    175 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    176 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    177 
    178   ulh $8, 0x10000
    179 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    180 # CHECK-BE: lb   $8, 0($1)         # encoding: [0x80,0x28,0x00,0x00]
    181 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    182 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    183 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    184 # CHECK-LE: lui  $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    185 # CHECK-LE: lb   $8, 1($1)         # encoding: [0x01,0x00,0x28,0x80]
    186 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    187 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    188 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    189 
    190   ulh $8, 0x18888
    191 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    192 # CHECK-BE: ori  $1, $1, 34952     # encoding: [0x34,0x21,0x88,0x88]
    193 # CHECK-BE: lb   $8, 0($1)         # encoding: [0x80,0x28,0x00,0x00]
    194 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    195 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    196 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    197 # CHECK-LE: lui  $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    198 # CHECK-LE: ori  $1, $1, 34952     # encoding: [0x88,0x88,0x21,0x34]
    199 # CHECK-LE: lb   $8, 1($1)         # encoding: [0x01,0x00,0x28,0x80]
    200 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    201 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    202 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    203 
    204   ulh $8, -32769
    205 # CHECK-BE: lui  $1, 65535         # encoding: [0x3c,0x01,0xff,0xff]
    206 # CHECK-BE: ori  $1, $1, 32767     # encoding: [0x34,0x21,0x7f,0xff]
    207 # CHECK-BE: lb   $8, 0($1)         # encoding: [0x80,0x28,0x00,0x00]
    208 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    209 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    210 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    211 # CHECK-LE: lui  $1, 65535         # encoding: [0xff,0xff,0x01,0x3c]
    212 # CHECK-LE: ori  $1, $1, 32767     # encoding: [0xff,0x7f,0x21,0x34]
    213 # CHECK-LE: lb   $8, 1($1)         # encoding: [0x01,0x00,0x28,0x80]
    214 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    215 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    216 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    217 
    218   ulh $8, 32767
    219 # CHECK-BE: addiu $1, $zero, 32767  # encoding: [0x24,0x01,0x7f,0xff]
    220 # CHECK-BE: lb   $8, 0($1)          # encoding: [0x80,0x28,0x00,0x00]
    221 # CHECK-BE: lbu  $1, 1($1)          # encoding: [0x90,0x21,0x00,0x01]
    222 # CHECK-BE: sll  $8, $8, 8          # encoding: [0x00,0x08,0x42,0x00]
    223 # CHECK-BE: or   $8, $8, $1         # encoding: [0x01,0x01,0x40,0x25]
    224 # CHECK-LE: addiu $1, $zero, 32767  # encoding: [0xff,0x7f,0x01,0x24]
    225 # CHECK-LE: lb   $8, 1($1)          # encoding: [0x01,0x00,0x28,0x80]
    226 # CHECK-LE: lbu  $1, 0($1)          # encoding: [0x00,0x00,0x21,0x90]
    227 # CHECK-LE: sll  $8, $8, 8          # encoding: [0x00,0x42,0x08,0x00]
    228 # CHECK-LE: or   $8, $8, $1         # encoding: [0x25,0x40,0x01,0x01]
    229 
    230 # Test ULH with immediate offset and a source register operand.
    231 ulh_reg: # CHECK-LABEL: ulh_reg:
    232   ulh $8, 0($9)
    233 # CHECK-BE: lb   $1, 0($9)         # encoding: [0x81,0x21,0x00,0x00]
    234 # CHECK-BE: lbu  $8, 1($9)         # encoding: [0x91,0x28,0x00,0x01]
    235 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    236 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    237 # CHECK-LE: lb   $1, 1($9)         # encoding: [0x01,0x00,0x21,0x81]
    238 # CHECK-LE: lbu  $8, 0($9)         # encoding: [0x00,0x00,0x28,0x91]
    239 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    240 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    241 
    242   ulh $8, 2($9)
    243 # CHECK-BE: lb   $1, 2($9)         # encoding: [0x81,0x21,0x00,0x02]
    244 # CHECK-BE: lbu  $8, 3($9)         # encoding: [0x91,0x28,0x00,0x03]
    245 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    246 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    247 # CHECK-LE: lb   $1, 3($9)         # encoding: [0x03,0x00,0x21,0x81]
    248 # CHECK-LE: lbu  $8, 2($9)         # encoding: [0x02,0x00,0x28,0x91]
    249 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    250 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    251 
    252   ulh $8, 0x8000($9)
    253 # CHECK-BE: ori  $1, $zero, 32768  # encoding: [0x34,0x01,0x80,0x00]
    254 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    255 # CHECK-BE: lb   $8, 0($1)         # encoding: [0x80,0x28,0x00,0x00]
    256 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    257 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    258 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    259 # CHECK-LE: ori  $1, $zero, 32768  # encoding: [0x00,0x80,0x01,0x34]
    260 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    261 # CHECK-LE: lb   $8, 1($1)         # encoding: [0x01,0x00,0x28,0x80]
    262 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    263 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    264 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    265 
    266   ulh $8, -0x8000($9)
    267 # CHECK-BE: lb   $1, -32768($9)    # encoding: [0x81,0x21,0x80,0x00]
    268 # CHECK-BE: lbu  $8, -32767($9)    # encoding: [0x91,0x28,0x80,0x01]
    269 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    270 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    271 # CHECK-LE: lb   $1, -32767($9)    # encoding: [0x01,0x80,0x21,0x81]
    272 # CHECK-LE: lbu  $8, -32768($9)    # encoding: [0x00,0x80,0x28,0x91]
    273 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    274 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    275 
    276   ulh $8, 0x10000($9)
    277 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    278 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    279 # CHECK-BE: lb   $8, 0($1)         # encoding: [0x80,0x28,0x00,0x00]
    280 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    281 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    282 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    283 # CHECK-LE: lui  $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    284 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    285 # CHECK-LE: lb   $8, 1($1)         # encoding: [0x01,0x00,0x28,0x80]
    286 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    287 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    288 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    289 
    290   ulh $8, 0x18888($9)
    291 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    292 # CHECK-BE: ori  $1, $1, 34952     # encoding: [0x34,0x21,0x88,0x88]
    293 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    294 # CHECK-BE: lb   $8, 0($1)         # encoding: [0x80,0x28,0x00,0x00]
    295 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    296 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    297 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    298 # CHECK-LE: lui  $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    299 # CHECK-LE: ori  $1, $1, 34952     # encoding: [0x88,0x88,0x21,0x34]
    300 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    301 # CHECK-LE: lb   $8, 1($1)         # encoding: [0x01,0x00,0x28,0x80]
    302 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    303 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    304 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    305 
    306   ulh $8, -32769($9)
    307 # CHECK-BE: lui  $1, 65535         # encoding: [0x3c,0x01,0xff,0xff]
    308 # CHECK-BE: ori  $1, $1, 32767     # encoding: [0x34,0x21,0x7f,0xff]
    309 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    310 # CHECK-BE: lb   $8, 0($1)         # encoding: [0x80,0x28,0x00,0x00]
    311 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    312 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    313 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    314 # CHECK-LE: lui  $1, 65535         # encoding: [0xff,0xff,0x01,0x3c]
    315 # CHECK-LE: ori  $1, $1, 32767     # encoding: [0xff,0x7f,0x21,0x34]
    316 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    317 # CHECK-LE: lb   $8, 1($1)         # encoding: [0x01,0x00,0x28,0x80]
    318 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    319 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    320 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    321 
    322   ulh $8, 32767($9)
    323 # CHECK-BE: addiu $1, $zero, 32767 # encoding: [0x24,0x01,0x7f,0xff]
    324 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    325 # CHECK-BE: lb   $8, 0($1)         # encoding: [0x80,0x28,0x00,0x00]
    326 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    327 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    328 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    329 # CHECK-LE: addiu $1, $zero, 32767 # encoding: [0xff,0x7f,0x01,0x24]
    330 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    331 # CHECK-LE: lb   $8, 1($1)         # encoding: [0x01,0x00,0x28,0x80]
    332 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    333 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    334 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    335 
    336 # Test ULHU with immediate operand.
    337 ulhu_imm: # CHECK-LABEL: ulhu_imm:
    338   ulhu $8, 0
    339 # CHECK-BE: lbu  $1, 0($zero)      # encoding: [0x90,0x01,0x00,0x00]
    340 # CHECK-BE: lbu  $8, 1($zero)      # encoding: [0x90,0x08,0x00,0x01]
    341 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    342 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    343 # CHECK-LE: lbu  $1, 1($zero)      # encoding: [0x01,0x00,0x01,0x90]
    344 # CHECK-LE: lbu  $8, 0($zero)      # encoding: [0x00,0x00,0x08,0x90]
    345 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    346 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    347 
    348   ulhu $8, 2
    349 # CHECK-BE: lbu  $1, 2($zero)      # encoding: [0x90,0x01,0x00,0x02]
    350 # CHECK-BE: lbu  $8, 3($zero)      # encoding: [0x90,0x08,0x00,0x03]
    351 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    352 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    353 # CHECK-LE: lbu  $1, 3($zero)      # encoding: [0x03,0x00,0x01,0x90]
    354 # CHECK-LE: lbu  $8, 2($zero)      # encoding: [0x02,0x00,0x08,0x90]
    355 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    356 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    357 
    358   ulhu $8, 0x8000
    359 # CHECK-BE: ori  $1, $zero, 32768  # encoding: [0x34,0x01,0x80,0x00]
    360 # CHECK-BE: lbu  $8, 0($1)         # encoding: [0x90,0x28,0x00,0x00]
    361 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    362 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    363 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    364 # CHECK-LE: ori  $1, $zero, 32768  # encoding: [0x00,0x80,0x01,0x34]
    365 # CHECK-LE: lbu  $8, 1($1)         # encoding: [0x01,0x00,0x28,0x90]
    366 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    367 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    368 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    369 
    370   ulhu $8, -0x8000
    371 # CHECK-BE: lbu  $1, -32768($zero) # encoding: [0x90,0x01,0x80,0x00]
    372 # CHECK-BE: lbu  $8, -32767($zero) # encoding: [0x90,0x08,0x80,0x01]
    373 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    374 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    375 # CHECK-LE: lbu  $1, -32767($zero) # encoding: [0x01,0x80,0x01,0x90]
    376 # CHECK-LE: lbu  $8, -32768($zero) # encoding: [0x00,0x80,0x08,0x90]
    377 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    378 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    379 
    380   ulhu $8, 0x10000
    381 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    382 # CHECK-BE: lbu  $8, 0($1)         # encoding: [0x90,0x28,0x00,0x00]
    383 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    384 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    385 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    386 # CHECK-LE: lui  $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    387 # CHECK-LE: lbu  $8, 1($1)         # encoding: [0x01,0x00,0x28,0x90]
    388 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    389 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    390 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    391 
    392   ulhu $8, 0x18888
    393 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    394 # CHECK-BE: ori  $1, $1, 34952     # encoding: [0x34,0x21,0x88,0x88]
    395 # CHECK-BE: lbu  $8, 0($1)         # encoding: [0x90,0x28,0x00,0x00]
    396 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    397 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    398 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    399 # CHECK-LE: lui  $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    400 # CHECK-LE: ori  $1, $1, 34952     # encoding: [0x88,0x88,0x21,0x34]
    401 # CHECK-LE: lbu  $8, 1($1)         # encoding: [0x01,0x00,0x28,0x90]
    402 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    403 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    404 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    405 
    406   ulhu $8, -32769
    407 # CHECK-BE: lui  $1, 65535         # encoding: [0x3c,0x01,0xff,0xff]
    408 # CHECK-BE: ori  $1, $1, 32767     # encoding: [0x34,0x21,0x7f,0xff]
    409 # CHECK-BE: lbu  $8, 0($1)         # encoding: [0x90,0x28,0x00,0x00]
    410 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    411 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    412 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    413 # CHECK-LE: lui  $1, 65535         # encoding: [0xff,0xff,0x01,0x3c]
    414 # CHECK-LE: ori  $1, $1, 32767     # encoding: [0xff,0x7f,0x21,0x34]
    415 # CHECK-LE: lbu  $8, 1($1)         # encoding: [0x01,0x00,0x28,0x90]
    416 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    417 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    418 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    419 
    420   ulhu $8, 32767
    421 # CHECK-BE: addiu $1, $zero, 32767  # encoding: [0x24,0x01,0x7f,0xff]
    422 # CHECK-BE: lbu  $8, 0($1)          # encoding: [0x90,0x28,0x00,0x00]
    423 # CHECK-BE: lbu  $1, 1($1)          # encoding: [0x90,0x21,0x00,0x01]
    424 # CHECK-BE: sll  $8, $8, 8          # encoding: [0x00,0x08,0x42,0x00]
    425 # CHECK-BE: or   $8, $8, $1         # encoding: [0x01,0x01,0x40,0x25]
    426 # CHECK-LE: addiu $1, $zero, 32767  # encoding: [0xff,0x7f,0x01,0x24]
    427 # CHECK-LE: lbu  $8, 1($1)          # encoding: [0x01,0x00,0x28,0x90]
    428 # CHECK-LE: lbu  $1, 0($1)          # encoding: [0x00,0x00,0x21,0x90]
    429 # CHECK-LE: sll  $8, $8, 8          # encoding: [0x00,0x42,0x08,0x00]
    430 # CHECK-LE: or   $8, $8, $1         # encoding: [0x25,0x40,0x01,0x01]
    431 
    432 # Test ULHU with immediate offset and a source register operand.
    433   ulhu $8, 0($9)
    434 # CHECK-BE: lbu  $1, 0($9)         # encoding: [0x91,0x21,0x00,0x00]
    435 # CHECK-BE: lbu  $8, 1($9)         # encoding: [0x91,0x28,0x00,0x01]
    436 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    437 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    438 # CHECK-LE: lbu  $1, 1($9)         # encoding: [0x01,0x00,0x21,0x91]
    439 # CHECK-LE: lbu  $8, 0($9)         # encoding: [0x00,0x00,0x28,0x91]
    440 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    441 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    442 
    443   ulhu $8, 2($9)
    444 # CHECK-BE: lbu  $1, 2($9)         # encoding: [0x91,0x21,0x00,0x02]
    445 # CHECK-BE: lbu  $8, 3($9)         # encoding: [0x91,0x28,0x00,0x03]
    446 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    447 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    448 # CHECK-LE: lbu  $1, 3($9)         # encoding: [0x03,0x00,0x21,0x91]
    449 # CHECK-LE: lbu  $8, 2($9)         # encoding: [0x02,0x00,0x28,0x91]
    450 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    451 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    452 
    453   ulhu $8, 0x8000($9)
    454 # CHECK-BE: ori  $1, $zero, 32768  # encoding: [0x34,0x01,0x80,0x00]
    455 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    456 # CHECK-BE: lbu  $8, 0($1)         # encoding: [0x90,0x28,0x00,0x00]
    457 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    458 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    459 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    460 # CHECK-LE: ori  $1, $zero, 32768  # encoding: [0x00,0x80,0x01,0x34]
    461 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    462 # CHECK-LE: lbu  $8, 1($1)         # encoding: [0x01,0x00,0x28,0x90]
    463 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    464 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    465 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    466 
    467   ulhu $8, -0x8000($9)
    468 # CHECK-BE: lbu  $1, -32768($9)    # encoding: [0x91,0x21,0x80,0x00]
    469 # CHECK-BE: lbu  $8, -32767($9)    # encoding: [0x91,0x28,0x80,0x01]
    470 # CHECK-BE: sll  $1, $1, 8         # encoding: [0x00,0x01,0x0a,0x00]
    471 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    472 # CHECK-LE: lbu  $1, -32767($9)    # encoding: [0x01,0x80,0x21,0x91]
    473 # CHECK-LE: lbu  $8, -32768($9)    # encoding: [0x00,0x80,0x28,0x91]
    474 # CHECK-LE: sll  $1, $1, 8         # encoding: [0x00,0x0a,0x01,0x00]
    475 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    476 
    477   ulhu $8, 0x10000($9)
    478 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    479 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    480 # CHECK-BE: lbu  $8, 0($1)         # encoding: [0x90,0x28,0x00,0x00]
    481 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    482 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    483 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    484 # CHECK-LE: lui  $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    485 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    486 # CHECK-LE: lbu  $8, 1($1)         # encoding: [0x01,0x00,0x28,0x90]
    487 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    488 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    489 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    490 
    491   ulhu $8, 0x18888($9)
    492 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    493 # CHECK-BE: ori  $1, $1, 34952     # encoding: [0x34,0x21,0x88,0x88]
    494 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    495 # CHECK-BE: lbu  $8, 0($1)         # encoding: [0x90,0x28,0x00,0x00]
    496 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    497 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    498 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    499 # CHECK-LE: lui  $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    500 # CHECK-LE: ori  $1, $1, 34952     # encoding: [0x88,0x88,0x21,0x34]
    501 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    502 # CHECK-LE: lbu  $8, 1($1)         # encoding: [0x01,0x00,0x28,0x90]
    503 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    504 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    505 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    506 
    507   ulhu $8, -32769($9)
    508 # CHECK-BE: lui  $1, 65535         # encoding: [0x3c,0x01,0xff,0xff]
    509 # CHECK-BE: ori  $1, $1, 32767     # encoding: [0x34,0x21,0x7f,0xff]
    510 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    511 # CHECK-BE: lbu  $8, 0($1)         # encoding: [0x90,0x28,0x00,0x00]
    512 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    513 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    514 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    515 # CHECK-LE: lui  $1, 65535         # encoding: [0xff,0xff,0x01,0x3c]
    516 # CHECK-LE: ori  $1, $1, 32767     # encoding: [0xff,0x7f,0x21,0x34]
    517 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    518 # CHECK-LE: lbu  $8, 1($1)         # encoding: [0x01,0x00,0x28,0x90]
    519 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    520 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    521 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    522 
    523   ulhu $8, 32767($9)
    524 # CHECK-BE: addiu $1, $zero, 32767 # encoding: [0x24,0x01,0x7f,0xff]
    525 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    526 # CHECK-BE: lbu  $8, 0($1)         # encoding: [0x90,0x28,0x00,0x00]
    527 # CHECK-BE: lbu  $1, 1($1)         # encoding: [0x90,0x21,0x00,0x01]
    528 # CHECK-BE: sll  $8, $8, 8         # encoding: [0x00,0x08,0x42,0x00]
    529 # CHECK-BE: or   $8, $8, $1        # encoding: [0x01,0x01,0x40,0x25]
    530 # CHECK-LE: addiu $1, $zero, 32767 # encoding: [0xff,0x7f,0x01,0x24]
    531 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    532 # CHECK-LE: lbu  $8, 1($1)         # encoding: [0x01,0x00,0x28,0x90]
    533 # CHECK-LE: lbu  $1, 0($1)         # encoding: [0x00,0x00,0x21,0x90]
    534 # CHECK-LE: sll  $8, $8, 8         # encoding: [0x00,0x42,0x08,0x00]
    535 # CHECK-LE: or   $8, $8, $1        # encoding: [0x25,0x40,0x01,0x01]
    536 
    537 # Test ULW with immediate operand.
    538   ulw $8, 0
    539 # CHECK-BE: lwl  $8, 0($zero)      # encoding: [0x88,0x08,0x00,0x00]
    540 # CHECK-BE: lwr  $8, 3($zero)      # encoding: [0x98,0x08,0x00,0x03]
    541 # CHECK-LE: lwl $8, 3($zero)       # encoding: [0x03,0x00,0x08,0x88]
    542 # CHECK-LE: lwr $8, 0($zero)       # encoding: [0x00,0x00,0x08,0x98]
    543 
    544   ulw $8, 2
    545 # CHECK-BE: lwl  $8, 2($zero)      # encoding: [0x88,0x08,0x00,0x02]
    546 # CHECK-BE: lwr  $8, 5($zero)      # encoding: [0x98,0x08,0x00,0x05]
    547 # CHECK-LE: lwl $8, 5($zero)       # encoding: [0x05,0x00,0x08,0x88]
    548 # CHECK-LE: lwr $8, 2($zero)       # encoding: [0x02,0x00,0x08,0x98]
    549 
    550   ulw $8, 0x8000
    551 # CHECK-BE: ori  $1, $zero, 32768  # encoding: [0x34,0x01,0x80,0x00]
    552 # CHECK-BE: lwl  $8, 0($1)         # encoding: [0x88,0x28,0x00,0x00]
    553 # CHECK-BE: lwr  $8, 3($1)         # encoding: [0x98,0x28,0x00,0x03]
    554 # CHECK-LE: ori $1, $zero, 32768   # encoding: [0x00,0x80,0x01,0x34]
    555 # CHECK-LE: lwl $8, 3($1)          # encoding: [0x03,0x00,0x28,0x88]
    556 # CHECK-LE: lwr $8, 0($1)          # encoding: [0x00,0x00,0x28,0x98]
    557 
    558   ulw $8, -0x8000
    559 # CHECK-BE: lwl  $8, -32768($zero) # encoding: [0x88,0x08,0x80,0x00]
    560 # CHECK-BE: lwr  $8, -32765($zero) # encoding: [0x98,0x08,0x80,0x03]
    561 # CHECK-LE: lwl $8, -32765($zero)  # encoding: [0x03,0x80,0x08,0x88]
    562 # CHECK-LE: lwr $8, -32768($zero)  # encoding: [0x00,0x80,0x08,0x98]
    563 
    564   ulw $8, 0x10000
    565 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    566 # CHECK-BE: lwl  $8, 0($1)         # encoding: [0x88,0x28,0x00,0x00]
    567 # CHECK-BE: lwr  $8, 3($1)         # encoding: [0x98,0x28,0x00,0x03]
    568 # CHECK-LE: lui $1, 1              # encoding: [0x01,0x00,0x01,0x3c]
    569 # CHECK-LE: lwl $8, 3($1)          # encoding: [0x03,0x00,0x28,0x88]
    570 # CHECK-LE: lwr $8, 0($1)          # encoding: [0x00,0x00,0x28,0x98]
    571 
    572   ulw $8, 0x18888
    573 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    574 # CHECK-BE: ori  $1, $1, 34952     # encoding: [0x34,0x21,0x88,0x88]
    575 # CHECK-BE: lwl  $8, 0($1)         # encoding: [0x88,0x28,0x00,0x00]
    576 # CHECK-BE: lwr  $8, 3($1)         # encoding: [0x98,0x28,0x00,0x03]
    577 # CHECK-LE: lui $1, 1              # encoding: [0x01,0x00,0x01,0x3c]
    578 # CHECK-LE: ori $1, $1, 34952      # encoding: [0x88,0x88,0x21,0x34]
    579 # CHECK-LE: lwl $8, 3($1)          # encoding: [0x03,0x00,0x28,0x88]
    580 # CHECK-LE: lwr $8, 0($1)          # encoding: [0x00,0x00,0x28,0x98]
    581 
    582   ulw $8, -32771
    583 # CHECK-BE: lui  $1, 65535         # encoding: [0x3c,0x01,0xff,0xff]
    584 # CHECK-BE: ori  $1, $1, 32765     # encoding: [0x34,0x21,0x7f,0xfd]
    585 # CHECK-BE: lwl  $8, 0($1)         # encoding: [0x88,0x28,0x00,0x00]
    586 # CHECK-BE: lwr  $8, 3($1)         # encoding: [0x98,0x28,0x00,0x03]
    587 # CHECK-LE: lui $1, 65535          # encoding: [0xff,0xff,0x01,0x3c]
    588 # CHECK-LE: ori $1, $1, 32765      # encoding: [0xfd,0x7f,0x21,0x34]
    589 # CHECK-LE: lwl $8, 3($1)          # encoding: [0x03,0x00,0x28,0x88]
    590 # CHECK-LE: lwr $8, 0($1)          # encoding: [0x00,0x00,0x28,0x98]
    591 
    592   ulw $8, 32765
    593 # CHECK-BE: addiu $1, $zero, 32765 # encoding: [0x24,0x01,0x7f,0xfd]
    594 # CHECK-BE: lwl  $8, 0($1)         # encoding: [0x88,0x28,0x00,0x00]
    595 # CHECK-BE: lwr  $8, 3($1)         # encoding: [0x98,0x28,0x00,0x03]
    596 # CHECK-LE: addiu $1, $zero, 32765 # encoding: [0xfd,0x7f,0x01,0x24]
    597 # CHECK-LE: lwl $8, 3($1)          # encoding: [0x03,0x00,0x28,0x88]
    598 # CHECK-LE: lwr $8, 0($1)          # encoding: [0x00,0x00,0x28,0x98]
    599 
    600 # Test ULW with immediate offset and a source register operand.
    601   ulw $8, 0($9)
    602 # CHECK-BE: lwl  $8, 0($9)         # encoding: [0x89,0x28,0x00,0x00]
    603 # CHECK-BE: lwr  $8, 3($9)         # encoding: [0x99,0x28,0x00,0x03]
    604 # CHECK-LE: lwl  $8, 3($9)         # encoding: [0x03,0x00,0x28,0x89]
    605 # CHECK-LE: lwr  $8, 0($9)         # encoding: [0x00,0x00,0x28,0x99]
    606 
    607   ulw $8, 2($9)
    608 # CHECK-BE: lwl  $8, 2($9)         # encoding: [0x89,0x28,0x00,0x02]
    609 # CHECK-BE: lwr  $8, 5($9)         # encoding: [0x99,0x28,0x00,0x05]
    610 # CHECK-LE: lwl  $8, 5($9)         # encoding: [0x05,0x00,0x28,0x89]
    611 # CHECK-LE: lwr  $8, 2($9)         # encoding: [0x02,0x00,0x28,0x99]
    612 
    613   ulw $8, 0x8000($9)
    614 # CHECK-BE: ori  $1, $zero, 32768  # encoding: [0x34,0x01,0x80,0x00]
    615 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    616 # CHECK-BE: lwl  $8, 0($1)         # encoding: [0x88,0x28,0x00,0x00]
    617 # CHECK-BE: lwr  $8, 3($1)         # encoding: [0x98,0x28,0x00,0x03]
    618 # CHECK-LE: ori  $1, $zero, 32768  # encoding: [0x00,0x80,0x01,0x34]
    619 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    620 # CHECK-LE: lwl  $8, 3($1)         # encoding: [0x03,0x00,0x28,0x88]
    621 # CHECK-LE: lwr  $8, 0($1)         # encoding: [0x00,0x00,0x28,0x98]
    622 
    623   ulw $8, -0x8000($9)
    624 # CHECK-BE: lwl  $8, -32768($9)    # encoding: [0x89,0x28,0x80,0x00]
    625 # CHECK-BE: lwr  $8, -32765($9)    # encoding: [0x99,0x28,0x80,0x03]
    626 # CHECK-LE: lwl  $8, -32765($9)    # encoding: [0x03,0x80,0x28,0x89]
    627 # CHECK-LE: lwr  $8, -32768($9)    # encoding: [0x00,0x80,0x28,0x99]
    628 
    629   ulw $8, 0x10000($9)
    630 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    631 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    632 # CHECK-BE: lwl  $8, 0($1)         # encoding: [0x88,0x28,0x00,0x00]
    633 # CHECK-BE: lwr  $8, 3($1)         # encoding: [0x98,0x28,0x00,0x03]
    634 # CHECK-LE: lui  $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    635 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    636 # CHECK-LE: lwl  $8, 3($1)         # encoding: [0x03,0x00,0x28,0x88]
    637 # CHECK-LE: lwr  $8, 0($1)         # encoding: [0x00,0x00,0x28,0x98]
    638 
    639   ulw $8, 0x18888($9)
    640 # CHECK-BE: lui  $1, 1             # encoding: [0x3c,0x01,0x00,0x01]
    641 # CHECK-BE: ori  $1, $1, 34952     # encoding: [0x34,0x21,0x88,0x88]
    642 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    643 # CHECK-BE: lwl  $8, 0($1)         # encoding: [0x88,0x28,0x00,0x00]
    644 # CHECK-BE: lwr  $8, 3($1)         # encoding: [0x98,0x28,0x00,0x03]
    645 # CHECK-LE: lui  $1, 1             # encoding: [0x01,0x00,0x01,0x3c]
    646 # CHECK-LE: ori  $1, $1, 34952     # encoding: [0x88,0x88,0x21,0x34]
    647 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    648 # CHECK-LE: lwl  $8, 3($1)         # encoding: [0x03,0x00,0x28,0x88]
    649 # CHECK-LE: lwr  $8, 0($1)         # encoding: [0x00,0x00,0x28,0x98]
    650 
    651   ulw $8, -32771($9)
    652 # CHECK-BE: lui  $1, 65535         # encoding: [0x3c,0x01,0xff,0xff]
    653 # CHECK-BE: ori  $1, $1, 32765     # encoding: [0x34,0x21,0x7f,0xfd]
    654 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    655 # CHECK-BE: lwl  $8, 0($1)         # encoding: [0x88,0x28,0x00,0x00]
    656 # CHECK-BE: lwr  $8, 3($1)         # encoding: [0x98,0x28,0x00,0x03]
    657 # CHECK-LE: lui  $1, 65535         # encoding: [0xff,0xff,0x01,0x3c]
    658 # CHECK-LE: ori  $1, $1, 32765     # encoding: [0xfd,0x7f,0x21,0x34]
    659 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    660 # CHECK-LE: lwl  $8, 3($1)         # encoding: [0x03,0x00,0x28,0x88]
    661 # CHECK-LE: lwr  $8, 0($1)         # encoding: [0x00,0x00,0x28,0x98]
    662 
    663   ulw $8, 32765($9)
    664 # CHECK-BE: addiu $1, $zero, 32765 # encoding: [0x24,0x01,0x7f,0xfd]
    665 # CHECK-BE: addu $1, $1, $9        # encoding: [0x00,0x29,0x08,0x21]
    666 # CHECK-BE: lwl  $8, 0($1)         # encoding: [0x88,0x28,0x00,0x00]
    667 # CHECK-BE: lwr  $8, 3($1)         # encoding: [0x98,0x28,0x00,0x03]
    668 # CHECK-LE: addiu $1, $zero, 32765 # encoding: [0xfd,0x7f,0x01,0x24]
    669 # CHECK-LE: addu $1, $1, $9        # encoding: [0x21,0x08,0x29,0x00]
    670 # CHECK-LE: lwl  $8, 3($1)         # encoding: [0x03,0x00,0x28,0x88]
    671 # CHECK-LE: lwr  $8, 0($1)         # encoding: [0x00,0x00,0x28,0x98]
    672 
    673 1:
    674   add $4, $4, $4
    675