# RUN: llvm-mc %s -triple=mipsel-unknown-linux -show-encoding -mcpu=mips32r2 | \
-# RUN: FileCheck %s --check-prefix=CHECK-LE
+# RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LE
# RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips32r2 | \
-# RUN: FileCheck %s --check-prefix=CHECK-BE
+# RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BE
# Check that the IAS expands macro instructions in the same way as GAS.
# CHECK-LE: beq $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x10]
# CHECK-LE: nop # encoding: [0x00,0x00,0x00,0x00]
+# Test ULH with immediate operand.
+ulh_imm: # CHECK-LABEL: ulh_imm:
+ ulh $8, 0
+# CHECK-BE: lb $1, 0($zero) # encoding: [0x80,0x01,0x00,0x00]
+# CHECK-BE: lbu $8, 1($zero) # encoding: [0x90,0x08,0x00,0x01]
+# CHECK-BE: sll $1, $1, 8 # encoding: [0x00,0x01,0x0a,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lb $1, 1($zero) # encoding: [0x01,0x00,0x01,0x80]
+# CHECK-LE: lbu $8, 0($zero) # encoding: [0x00,0x00,0x08,0x90]
+# CHECK-LE: sll $1, $1, 8 # encoding: [0x00,0x0a,0x01,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, 2
+# CHECK-BE: lb $1, 2($zero) # encoding: [0x80,0x01,0x00,0x02]
+# CHECK-BE: lbu $8, 3($zero) # encoding: [0x90,0x08,0x00,0x03]
+# CHECK-BE: sll $1, $1, 8 # encoding: [0x00,0x01,0x0a,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lb $1, 3($zero) # encoding: [0x03,0x00,0x01,0x80]
+# CHECK-LE: lbu $8, 2($zero) # encoding: [0x02,0x00,0x08,0x90]
+# CHECK-LE: sll $1, $1, 8 # encoding: [0x00,0x0a,0x01,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, 0x8000
+# CHECK-BE: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00]
+# CHECK-BE: lb $8, 0($1) # encoding: [0x80,0x28,0x00,0x00]
+# CHECK-BE: lbu $1, 1($1) # encoding: [0x90,0x21,0x00,0x01]
+# CHECK-BE: sll $8, $8, 8 # encoding: [0x00,0x08,0x42,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: ori $1, $zero, 32768 # encoding: [0x00,0x80,0x01,0x34]
+# CHECK-LE: lb $8, 1($1) # encoding: [0x01,0x00,0x28,0x80]
+# CHECK-LE: lbu $1, 0($1) # encoding: [0x00,0x00,0x21,0x90]
+# CHECK-LE: sll $8, $8, 8 # encoding: [0x00,0x42,0x08,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, -0x8000
+# CHECK-BE: lb $1, -32768($zero) # encoding: [0x80,0x01,0x80,0x00]
+# CHECK-BE: lbu $8, -32767($zero) # encoding: [0x90,0x08,0x80,0x01]
+# CHECK-BE: sll $1, $1, 8 # encoding: [0x00,0x01,0x0a,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lb $1, -32767($zero) # encoding: [0x01,0x80,0x01,0x80]
+# CHECK-LE: lbu $8, -32768($zero) # encoding: [0x00,0x80,0x08,0x90]
+# CHECK-LE: sll $1, $1, 8 # encoding: [0x00,0x0a,0x01,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, 0x10000
+# CHECK-BE: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01]
+# CHECK-BE: lb $8, 0($1) # encoding: [0x80,0x28,0x00,0x00]
+# CHECK-BE: lbu $1, 1($1) # encoding: [0x90,0x21,0x00,0x01]
+# CHECK-BE: sll $8, $8, 8 # encoding: [0x00,0x08,0x42,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lui $1, 1 # encoding: [0x01,0x00,0x01,0x3c]
+# CHECK-LE: lb $8, 1($1) # encoding: [0x01,0x00,0x28,0x80]
+# CHECK-LE: lbu $1, 0($1) # encoding: [0x00,0x00,0x21,0x90]
+# CHECK-LE: sll $8, $8, 8 # encoding: [0x00,0x42,0x08,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, 0x18888
+# CHECK-BE: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01]
+# CHECK-BE: ori $1, $1, 34952 # encoding: [0x34,0x21,0x88,0x88]
+# CHECK-BE: lb $8, 0($1) # encoding: [0x80,0x28,0x00,0x00]
+# CHECK-BE: lbu $1, 1($1) # encoding: [0x90,0x21,0x00,0x01]
+# CHECK-BE: sll $8, $8, 8 # encoding: [0x00,0x08,0x42,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lui $1, 1 # encoding: [0x01,0x00,0x01,0x3c]
+# CHECK-LE: ori $1, $1, 34952 # encoding: [0x88,0x88,0x21,0x34]
+# CHECK-LE: lb $8, 1($1) # encoding: [0x01,0x00,0x28,0x80]
+# CHECK-LE: lbu $1, 0($1) # encoding: [0x00,0x00,0x21,0x90]
+# CHECK-LE: sll $8, $8, 8 # encoding: [0x00,0x42,0x08,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, -32769
+# CHECK-BE: lui $1, 65535 # encoding: [0x3c,0x01,0xff,0xff]
+# CHECK-BE: ori $1, $1, 32767 # encoding: [0x34,0x21,0x7f,0xff]
+# CHECK-BE: lb $8, 0($1) # encoding: [0x80,0x28,0x00,0x00]
+# CHECK-BE: lbu $1, 1($1) # encoding: [0x90,0x21,0x00,0x01]
+# CHECK-BE: sll $8, $8, 8 # encoding: [0x00,0x08,0x42,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lui $1, 65535 # encoding: [0xff,0xff,0x01,0x3c]
+# CHECK-LE: ori $1, $1, 32767 # encoding: [0xff,0x7f,0x21,0x34]
+# CHECK-LE: lb $8, 1($1) # encoding: [0x01,0x00,0x28,0x80]
+# CHECK-LE: lbu $1, 0($1) # encoding: [0x00,0x00,0x21,0x90]
+# CHECK-LE: sll $8, $8, 8 # encoding: [0x00,0x42,0x08,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, 32767
+# CHECK-BE: addiu $1, $zero, 32767 # encoding: [0x24,0x01,0x7f,0xff]
+# CHECK-BE: lb $8, 0($1) # encoding: [0x80,0x28,0x00,0x00]
+# CHECK-BE: lbu $1, 1($1) # encoding: [0x90,0x21,0x00,0x01]
+# CHECK-BE: sll $8, $8, 8 # encoding: [0x00,0x08,0x42,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: addiu $1, $zero, 32767 # encoding: [0xff,0x7f,0x01,0x24]
+# CHECK-LE: lb $8, 1($1) # encoding: [0x01,0x00,0x28,0x80]
+# CHECK-LE: lbu $1, 0($1) # encoding: [0x00,0x00,0x21,0x90]
+# CHECK-LE: sll $8, $8, 8 # encoding: [0x00,0x42,0x08,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+# Test ULH with immediate offset and a source register operand.
+ulh_reg: # CHECK-LABEL: ulh_reg:
+ ulh $8, 0($9)
+# CHECK-BE: lb $1, 0($9) # encoding: [0x81,0x21,0x00,0x00]
+# CHECK-BE: lbu $8, 1($9) # encoding: [0x91,0x28,0x00,0x01]
+# CHECK-BE: sll $1, $1, 8 # encoding: [0x00,0x01,0x0a,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lb $1, 1($9) # encoding: [0x01,0x00,0x21,0x81]
+# CHECK-LE: lbu $8, 0($9) # encoding: [0x00,0x00,0x28,0x91]
+# CHECK-LE: sll $1, $1, 8 # encoding: [0x00,0x0a,0x01,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, 2($9)
+# CHECK-BE: lb $1, 2($9) # encoding: [0x81,0x21,0x00,0x02]
+# CHECK-BE: lbu $8, 3($9) # encoding: [0x91,0x28,0x00,0x03]
+# CHECK-BE: sll $1, $1, 8 # encoding: [0x00,0x01,0x0a,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lb $1, 3($9) # encoding: [0x03,0x00,0x21,0x81]
+# CHECK-LE: lbu $8, 2($9) # encoding: [0x02,0x00,0x28,0x91]
+# CHECK-LE: sll $1, $1, 8 # encoding: [0x00,0x0a,0x01,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, 0x8000($9)
+# CHECK-BE: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00]
+# CHECK-BE: addu $1, $1, $9 # encoding: [0x00,0x29,0x08,0x21]
+# CHECK-BE: lb $8, 0($1) # encoding: [0x80,0x28,0x00,0x00]
+# CHECK-BE: lbu $1, 1($1) # encoding: [0x90,0x21,0x00,0x01]
+# CHECK-BE: sll $8, $8, 8 # encoding: [0x00,0x08,0x42,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: ori $1, $zero, 32768 # encoding: [0x00,0x80,0x01,0x34]
+# CHECK-LE: addu $1, $1, $9 # encoding: [0x21,0x08,0x29,0x00]
+# CHECK-LE: lb $8, 1($1) # encoding: [0x01,0x00,0x28,0x80]
+# CHECK-LE: lbu $1, 0($1) # encoding: [0x00,0x00,0x21,0x90]
+# CHECK-LE: sll $8, $8, 8 # encoding: [0x00,0x42,0x08,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, -0x8000($9)
+# CHECK-BE: lb $1, -32768($9) # encoding: [0x81,0x21,0x80,0x00]
+# CHECK-BE: lbu $8, -32767($9) # encoding: [0x91,0x28,0x80,0x01]
+# CHECK-BE: sll $1, $1, 8 # encoding: [0x00,0x01,0x0a,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lb $1, -32767($9) # encoding: [0x01,0x80,0x21,0x81]
+# CHECK-LE: lbu $8, -32768($9) # encoding: [0x00,0x80,0x28,0x91]
+# CHECK-LE: sll $1, $1, 8 # encoding: [0x00,0x0a,0x01,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, 0x10000($9)
+# CHECK-BE: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01]
+# CHECK-BE: addu $1, $1, $9 # encoding: [0x00,0x29,0x08,0x21]
+# CHECK-BE: lb $8, 0($1) # encoding: [0x80,0x28,0x00,0x00]
+# CHECK-BE: lbu $1, 1($1) # encoding: [0x90,0x21,0x00,0x01]
+# CHECK-BE: sll $8, $8, 8 # encoding: [0x00,0x08,0x42,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lui $1, 1 # encoding: [0x01,0x00,0x01,0x3c]
+# CHECK-LE: addu $1, $1, $9 # encoding: [0x21,0x08,0x29,0x00]
+# CHECK-LE: lb $8, 1($1) # encoding: [0x01,0x00,0x28,0x80]
+# CHECK-LE: lbu $1, 0($1) # encoding: [0x00,0x00,0x21,0x90]
+# CHECK-LE: sll $8, $8, 8 # encoding: [0x00,0x42,0x08,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, 0x18888($9)
+# CHECK-BE: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01]
+# CHECK-BE: ori $1, $1, 34952 # encoding: [0x34,0x21,0x88,0x88]
+# CHECK-BE: addu $1, $1, $9 # encoding: [0x00,0x29,0x08,0x21]
+# CHECK-BE: lb $8, 0($1) # encoding: [0x80,0x28,0x00,0x00]
+# CHECK-BE: lbu $1, 1($1) # encoding: [0x90,0x21,0x00,0x01]
+# CHECK-BE: sll $8, $8, 8 # encoding: [0x00,0x08,0x42,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lui $1, 1 # encoding: [0x01,0x00,0x01,0x3c]
+# CHECK-LE: ori $1, $1, 34952 # encoding: [0x88,0x88,0x21,0x34]
+# CHECK-LE: addu $1, $1, $9 # encoding: [0x21,0x08,0x29,0x00]
+# CHECK-LE: lb $8, 1($1) # encoding: [0x01,0x00,0x28,0x80]
+# CHECK-LE: lbu $1, 0($1) # encoding: [0x00,0x00,0x21,0x90]
+# CHECK-LE: sll $8, $8, 8 # encoding: [0x00,0x42,0x08,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, -32769($9)
+# CHECK-BE: lui $1, 65535 # encoding: [0x3c,0x01,0xff,0xff]
+# CHECK-BE: ori $1, $1, 32767 # encoding: [0x34,0x21,0x7f,0xff]
+# CHECK-BE: addu $1, $1, $9 # encoding: [0x00,0x29,0x08,0x21]
+# CHECK-BE: lb $8, 0($1) # encoding: [0x80,0x28,0x00,0x00]
+# CHECK-BE: lbu $1, 1($1) # encoding: [0x90,0x21,0x00,0x01]
+# CHECK-BE: sll $8, $8, 8 # encoding: [0x00,0x08,0x42,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: lui $1, 65535 # encoding: [0xff,0xff,0x01,0x3c]
+# CHECK-LE: ori $1, $1, 32767 # encoding: [0xff,0x7f,0x21,0x34]
+# CHECK-LE: addu $1, $1, $9 # encoding: [0x21,0x08,0x29,0x00]
+# CHECK-LE: lb $8, 1($1) # encoding: [0x01,0x00,0x28,0x80]
+# CHECK-LE: lbu $1, 0($1) # encoding: [0x00,0x00,0x21,0x90]
+# CHECK-LE: sll $8, $8, 8 # encoding: [0x00,0x42,0x08,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
+ ulh $8, 32767($9)
+# CHECK-BE: addiu $1, $zero, 32767 # encoding: [0x24,0x01,0x7f,0xff]
+# CHECK-BE: addu $1, $1, $9 # encoding: [0x00,0x29,0x08,0x21]
+# CHECK-BE: lb $8, 0($1) # encoding: [0x80,0x28,0x00,0x00]
+# CHECK-BE: lbu $1, 1($1) # encoding: [0x90,0x21,0x00,0x01]
+# CHECK-BE: sll $8, $8, 8 # encoding: [0x00,0x08,0x42,0x00]
+# CHECK-BE: or $8, $8, $1 # encoding: [0x01,0x01,0x40,0x25]
+# CHECK-LE: addiu $1, $zero, 32767 # encoding: [0xff,0x7f,0x01,0x24]
+# CHECK-LE: addu $1, $1, $9 # encoding: [0x21,0x08,0x29,0x00]
+# CHECK-LE: lb $8, 1($1) # encoding: [0x01,0x00,0x28,0x80]
+# CHECK-LE: lbu $1, 0($1) # encoding: [0x00,0x00,0x21,0x90]
+# CHECK-LE: sll $8, $8, 8 # encoding: [0x00,0x42,0x08,0x00]
+# CHECK-LE: or $8, $8, $1 # encoding: [0x25,0x40,0x01,0x01]
+
# Test ULHU with immediate operand.
+ulhu_imm: # CHECK-LABEL: ulhu_imm:
ulhu $8, 0
# CHECK-BE: lbu $1, 0($zero) # encoding: [0x90,0x01,0x00,0x00]
# CHECK-BE: lbu $8, 1($zero) # encoding: [0x90,0x08,0x00,0x01]