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

# Count leading
0x11 0xc0 0x54 0x88
# CHECK: r17 = clb(r21:20)
0x51 0xc0 0x54 0x88
# CHECK: r17 = cl0(r21:20)
0x91 0xc0 0x54 0x88
# CHECK: r17 = cl1(r21:20)
0x11 0xc0 0x74 0x88
# CHECK: r17 = normamt(r21:20)
0x51 0xd7 0x74 0x88
# CHECK: r17 = add(clb(r21:20),#23)
0x11 0xd7 0x35 0x8c
# CHECK: r17 = add(clb(r21),#23)
0x91 0xc0 0x15 0x8c
# CHECK: r17 = clb(r21)
0xb1 0xc0 0x15 0x8c
# CHECK: r17 = cl0(r21)
0xd1 0xc0 0x15 0x8c
# CHECK: r17 = cl1(r21)
0xf1 0xc0 0x15 0x8c
# CHECK: r17 = normamt(r21)

# Count population
0x71 0xc0 0x74 0x88
# CHECK: r17 = popcount(r21:20)

# Count trailing
0x51 0xc0 0xf4 0x88
# CHECK: r17 = ct0(r21:20)
0x91 0xc0 0xf4 0x88
# CHECK: r17 = ct1(r21:20)
0x91 0xc0 0x55 0x8c
# CHECK: r17 = ct0(r21)
0xb1 0xc0 0x55 0x8c
# CHECK: r17 = ct1(r21)

# Extract bitfield
0xf0 0xdf 0x54 0x81
# CHECK: r17:16 = extractu(r21:20,#31,#23)
0xf0 0xdf 0x54 0x8a
# CHECK: r17:16 = extract(r21:20,#31,#23)
0xf1 0xdf 0x55 0x8d
# CHECK: r17 = extractu(r21,#31,#23)
0xf1 0xdf 0xd5 0x8d
# CHECK: r17 = extract(r21,#31,#23)
0x10 0xde 0x14 0xc1
# CHECK: r17:16 = extractu(r21:20,r31:30)
0x90 0xde 0xd4 0xc1
# CHECK: r17:16 = extract(r21:20,r31:30)
0x11 0xde 0x15 0xc9
# CHECK: r17 = extractu(r21,r31:30)
0x51 0xde 0x15 0xc9
# CHECK: r17 = extract(r21,r31:30)

# Insert bitfield
0xf0 0xdf 0x54 0x83
# CHECK: r17:16 = insert(r21:20,#31,#23)
0xf1 0xdf 0x55 0x8f
# CHECK: r17 = insert(r21,#31,#23)
0x11 0xde 0x15 0xc8
# CHECK: r17 = insert(r21,r31:30)
0x10 0xde 0x14 0xca
# CHECK: r17:16 = insert(r21:20,r31:30)

# Interleave/deinterleave
0x90 0xc0 0xd4 0x80
# CHECK: r17:16 = deinterleave(r21:20)
0xb0 0xc0 0xd4 0x80
# CHECK: r17:16 = interleave(r21:20)

# Linear feedback-shift iteration
0xd0 0xde 0x94 0xc1
# CHECK: r17:16 = lfs(r21:20,r31:30)

# Masked parity
0x11 0xde 0x14 0xd0
# CHECK: r17 = parity(r21:20,r31:30)
0x11 0xdf 0xf5 0xd5
# CHECK: r17 = parity(r21,r31)

# Bit reverse
0xd0 0xc0 0xd4 0x80
# CHECK: r17:16 = brev(r21:20)
0xd1 0xc0 0x55 0x8c
# CHECK: r17 = brev(r21)

# Set/clear/toggle bit
0x11 0xdf 0xd5 0x8c
# CHECK: r17 = setbit(r21,#31)
0x31 0xdf 0xd5 0x8c
# CHECK: r17 = clrbit(r21,#31)
0x51 0xdf 0xd5 0x8c
# CHECK: r17 = togglebit(r21,#31)
0x11 0xdf 0x95 0xc6
# CHECK: r17 = setbit(r21,r31)
0x51 0xdf 0x95 0xc6
# CHECK: r17 = clrbit(r21,r31)
0x91 0xdf 0x95 0xc6
# CHECK: r17 = togglebit(r21,r31)

# Split bitfield
0x90 0xdf 0xd5 0x88
# CHECK: r17:16 = bitsplit(r21,#31)
0x10 0xdf 0x35 0xd4
# CHECK: r17:16 = bitsplit(r21,r31)

# Table index
0xf1 0xcd 0x15 0x87
# CHECK: r17 = tableidxb(r21,#7,#13):raw
0xf1 0xcd 0x55 0x87
# CHECK: r17 = tableidxh(r21,#7,#13):raw
0xf1 0xcd 0x95 0x87
# CHECK: r17 = tableidxw(r21,#7,#13):raw
0xf1 0xcd 0xd5 0x87
# CHECK: r17 = tableidxd(r21,#7,#13):raw
