# RUN: llvm-mc -triple=hexagon -disassemble < %s | FileCheck %s
# Hexagon Programmer's Reference Manual 11.10.3 XTYPE/COMPLEX

# Complex add/sub halfwords
0x90 0xde 0x54 0xc1
# CHECK: r17:16 = vxaddsubh(r21:20, r31:30):sat
0xd0 0xde 0x54 0xc1
# CHECK: r17:16 = vxsubaddh(r21:20, r31:30):sat
0x10 0xde 0xd4 0xc1
# CHECK: r17:16 = vxaddsubh(r21:20, r31:30):rnd:>>1:sat
0x50 0xde 0xd4 0xc1
# CHECK: r17:16 = vxsubaddh(r21:20, r31:30):rnd:>>1:sat

# Complex add/sub words
0x10 0xde 0x54 0xc1
# CHECK: r17:16 = vxaddsubw(r21:20, r31:30):sat
0x50 0xde 0x54 0xc1
# CHECK: r17:16 = vxsubaddw(r21:20, r31:30):sat

# Complex multiply
0xd0 0xdf 0x15 0xe5
# CHECK: r17:16 = cmpy(r21, r31):sat
0xd0 0xdf 0x95 0xe5
# CHECK: r17:16 = cmpy(r21, r31):<<1:sat
0xd0 0xdf 0x55 0xe5
# CHECK: r17:16 = cmpy(r21, r31*):sat
0xd0 0xdf 0xd5 0xe5
# CHECK: r17:16 = cmpy(r21, r31*):<<1:sat
0xd0 0xdf 0x15 0xe7
# CHECK: r17:16 += cmpy(r21, r31):sat
0xd0 0xdf 0x95 0xe7
# CHECK: r17:16 += cmpy(r21, r31):<<1:sat
0xf0 0xdf 0x15 0xe7
# CHECK: r17:16 -= cmpy(r21, r31):sat
0xf0 0xdf 0x95 0xe7
# CHECK: r17:16 -= cmpy(r21, r31):<<1:sat
0xd0 0xdf 0x55 0xe7
# CHECK: r17:16 += cmpy(r21, r31*):sat
0xd0 0xdf 0xd5 0xe7
# CHECK: r17:16 += cmpy(r21, r31*):<<1:sat
0xf0 0xdf 0x55 0xe7
# CHECK: r17:16 -= cmpy(r21, r31*):sat
0xf0 0xdf 0xd5 0xe7
# CHECK: r17:16 -= cmpy(r21, r31*):<<1:sat

# Complex multiply real or imaginary
0x30 0xdf 0x15 0xe5
# CHECK: r17:16 = cmpyi(r21, r31)
0x50 0xdf 0x15 0xe5
# CHECK: r17:16 = cmpyr(r21, r31)
0x30 0xdf 0x15 0xe7
# CHECK: r17:16 += cmpyi(r21, r31)
0x50 0xdf 0x15 0xe7
# CHECK: r17:16 += cmpyr(r21, r31)

# Complex multiply with round and pack
0xd1 0xdf 0x35 0xed
# CHECK: r17 = cmpy(r21, r31):rnd:sat
0xd1 0xdf 0xb5 0xed
# CHECK: r17 = cmpy(r21, r31):<<1:rnd:sat
0xd1 0xdf 0x75 0xed
# CHECK: r17 = cmpy(r21, r31*):rnd:sat
0xd1 0xdf 0xf5 0xed
# CHECK: r17 = cmpy(r21, r31*):<<1:rnd:sat

# Complex multiply 32x16
0x91 0xdf 0x14 0xc5
# CHECK: r17 = cmpyiwh(r21:20, r31):<<1:rnd:sat
0xb1 0xdf 0x14 0xc5
# CHECK: r17 = cmpyiwh(r21:20, r31*):<<1:rnd:sat
0xd1 0xdf 0x14 0xc5
# CHECK: r17 = cmpyrwh(r21:20, r31):<<1:rnd:sat
0xf1 0xdf 0x14 0xc5
# CHECK: r17 = cmpyrwh(r21:20, r31*):<<1:rnd:sat

# Vector complex multiply real or imaginary
0xd0 0xde 0x34 0xe8
# CHECK: r17:16 = vcmpyr(r21:20, r31:30):sat
0xd0 0xde 0xb4 0xe8
# CHECK: r17:16 = vcmpyr(r21:20, r31:30):<<1:sat
0xd0 0xde 0x54 0xe8
# CHECK: r17:16 = vcmpyi(r21:20, r31:30):sat
0xd0 0xde 0xd4 0xe8
# CHECK: r17:16 = vcmpyi(r21:20, r31:30):<<1:sat
0x90 0xde 0x34 0xea
# CHECK: r17:16 += vcmpyr(r21:20, r31:30):sat
0x90 0xde 0x54 0xea
# CHECK: r17:16 += vcmpyi(r21:20, r31:30):sat

# Vector complex conjugate
0xf0 0xc0 0x94 0x80
# CHECK: r17:16 = vconj(r21:20):sat

# Vector complex rotate
0x10 0xdf 0xd4 0xc3
# CHECK: r17:16 = vcrotate(r21:20, r31)

# Vector reduce complex multiply real or imaginary
0x10 0xde 0x14 0xe8
# CHECK: r17:16 = vrcmpyi(r21:20, r31:30)
0x30 0xde 0x14 0xe8
# CHECK: r17:16 = vrcmpyr(r21:20, r31:30)
0x10 0xde 0x54 0xe8
# CHECK: r17:16 = vrcmpyi(r21:20, r31:30*)
0x30 0xde 0x74 0xe8
# CHECK: r17:16 = vrcmpyr(r21:20, r31:30*)

# Vector reduce complex multiply by scalar
0x90 0xde 0xb4 0xe8
# CHECK: r17:16 = vrcmpys(r21:20, r31:30):<<1:sat:raw:hi
0x90 0xde 0xf4 0xe8
# CHECK: r17:16 = vrcmpys(r21:20, r31:30):<<1:sat:raw:lo
0x90 0xde 0xb4 0xea
# CHECK: r17:16 += vrcmpys(r21:20, r31:30):<<1:sat:raw:hi
0x90 0xde 0xf4 0xea
# CHECK: r17:16 += vrcmpys(r21:20, r31:30):<<1:sat:raw:lo

# Vector reduce complex multiply by scalar with round and pack
0xd1 0xde 0xb4 0xe9
# CHECK: r17 = vrcmpys(r21:20, r31:30):<<1:rnd:sat:raw:hi
0xf1 0xde 0xb4 0xe9
# CHECK: r17 = vrcmpys(r21:20, r31:30):<<1:rnd:sat:raw:lo

# Vector reduce complex rotate
0xf0 0xff 0xd4 0xc3
# CHECK: r17:16 = vrcrotate(r21:20, r31, #3)
0x30 0xff 0xb4 0xcb
# CHECK: r17:16 += vrcrotate(r21:20, r31, #3)
