# RUN: llvm-mc %s -triple=riscv32 -mattr=+a -riscv-no-aliases -show-encoding \
# RUN:     | FileCheck -check-prefixes=CHECK,CHECK-INST %s
# RUN: llvm-mc %s -triple=riscv64 -mattr=+a -riscv-no-aliases -show-encoding \
# RUN:     | FileCheck -check-prefixes=CHECK,CHECK-INST %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+a < %s \
# RUN:     | llvm-objdump -mattr=+a -riscv-no-aliases -d - \
# RUN:     | FileCheck -check-prefix=CHECK-INST %s
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+a < %s \
# RUN:     | llvm-objdump -mattr=+a -riscv-no-aliases -d - \
# RUN:     | FileCheck -check-prefix=CHECK-INST %s

# CHECK-INST: lr.w t0, (t1)
# CHECK: encoding: [0xaf,0x22,0x03,0x10]
lr.w t0, (t1)
# CHECK-INST: lr.w.aq t1, (t2)
# CHECK: encoding: [0x2f,0xa3,0x03,0x14]
lr.w.aq t1, (t2)
# CHECK-INST: lr.w.rl t2, (t3)
# CHECK: encoding: [0xaf,0x23,0x0e,0x12]
lr.w.rl t2, (t3)
# CHECK-INST: lr.w.aqrl t3, (t4)
# CHECK: encoding: [0x2f,0xae,0x0e,0x16]
lr.w.aqrl t3, (t4)

# CHECK-INST: sc.w t6, t5, (t4)
# CHECK: encoding: [0xaf,0xaf,0xee,0x19]
sc.w t6, t5, (t4)
# CHECK-INST: sc.w.aq t5, t4, (t3)
# CHECK: encoding: [0x2f,0x2f,0xde,0x1d]
sc.w.aq t5, t4, (t3)
# CHECK-INST: sc.w.rl t4, t3, (t2)
# CHECK: encoding: [0xaf,0xae,0xc3,0x1b]
sc.w.rl t4, t3, (t2)
# CHECK-INST: sc.w.aqrl t3, t2, (t1)
# CHECK: encoding: [0x2f,0x2e,0x73,0x1e]
sc.w.aqrl t3, t2, (t1)

# CHECK-INST: amoswap.w a4, ra, (s0)
# CHECK: encoding: [0x2f,0x27,0x14,0x08]
amoswap.w a4, ra, (s0)
# CHECK-INST: amoadd.w a1, a2, (a3)
# CHECK: encoding: [0xaf,0xa5,0xc6,0x00]
amoadd.w a1, a2, (a3)
# CHECK-INST: amoxor.w a2, a3, (a4)
# CHECK: encoding: [0x2f,0x26,0xd7,0x20]
amoxor.w a2, a3, (a4)
# CHECK-INST: amoand.w a3, a4, (a5)
# CHECK: encoding: [0xaf,0xa6,0xe7,0x60]
amoand.w a3, a4, (a5)
# CHECK-INST: amoor.w a4, a5, (a6)
# CHECK: encoding: [0x2f,0x27,0xf8,0x40]
amoor.w a4, a5, (a6)
# CHECK-INST: amomin.w a5, a6, (a7)
# CHECK: encoding: [0xaf,0xa7,0x08,0x81]
amomin.w a5, a6, (a7)
# CHECK-INST: amomax.w s7, s6, (s5)
# CHECK: encoding: [0xaf,0xab,0x6a,0xa1]
amomax.w s7, s6, (s5)
# CHECK-INST: amominu.w s6, s5, (s4)
# CHECK: encoding: [0x2f,0x2b,0x5a,0xc1]
amominu.w s6, s5, (s4)
# CHECK-INST: amomaxu.w s5, s4, (s3)
# CHECK: encoding: [0xaf,0xaa,0x49,0xe1]
amomaxu.w s5, s4, (s3)

# CHECK-INST: amoswap.w.aq a4, ra, (s0)
# CHECK: encoding: [0x2f,0x27,0x14,0x0c]
amoswap.w.aq a4, ra, (s0)
# CHECK-INST: amoadd.w.aq a1, a2, (a3)
# CHECK: encoding: [0xaf,0xa5,0xc6,0x04]
amoadd.w.aq a1, a2, (a3)
# CHECK-INST: amoxor.w.aq a2, a3, (a4)
# CHECK: encoding: [0x2f,0x26,0xd7,0x24]
amoxor.w.aq a2, a3, (a4)
# CHECK-INST: amoand.w.aq a3, a4, (a5)
# CHECK: encoding: [0xaf,0xa6,0xe7,0x64]
amoand.w.aq a3, a4, (a5)
# CHECK-INST: amoor.w.aq a4, a5, (a6)
# CHECK: encoding: [0x2f,0x27,0xf8,0x44]
amoor.w.aq a4, a5, (a6)
# CHECK-INST: amomin.w.aq a5, a6, (a7)
# CHECK: encoding: [0xaf,0xa7,0x08,0x85]
amomin.w.aq a5, a6, (a7)
# CHECK-INST: amomax.w.aq s7, s6, (s5)
# CHECK: encoding: [0xaf,0xab,0x6a,0xa5]
amomax.w.aq s7, s6, (s5)
# CHECK-INST: amominu.w.aq s6, s5, (s4)
# CHECK: encoding: [0x2f,0x2b,0x5a,0xc5]
amominu.w.aq s6, s5, (s4)
# CHECK-INST: amomaxu.w.aq s5, s4, (s3)
# CHECK: encoding: [0xaf,0xaa,0x49,0xe5]
amomaxu.w.aq s5, s4, (s3)

# CHECK-INST: amoswap.w.rl a4, ra, (s0)
# CHECK: encoding: [0x2f,0x27,0x14,0x0a]
amoswap.w.rl a4, ra, (s0)
# CHECK-INST: amoadd.w.rl a1, a2, (a3)
# CHECK: encoding: [0xaf,0xa5,0xc6,0x02]
amoadd.w.rl a1, a2, (a3)
# CHECK-INST: amoxor.w.rl a2, a3, (a4)
# CHECK: encoding: [0x2f,0x26,0xd7,0x22]
amoxor.w.rl a2, a3, (a4)
# CHECK-INST: amoand.w.rl a3, a4, (a5)
# CHECK: encoding: [0xaf,0xa6,0xe7,0x62]
amoand.w.rl a3, a4, (a5)
# CHECK-INST: amoor.w.rl a4, a5, (a6)
# CHECK: encoding: [0x2f,0x27,0xf8,0x42]
amoor.w.rl a4, a5, (a6)
# CHECK-INST: amomin.w.rl a5, a6, (a7)
# CHECK: encoding: [0xaf,0xa7,0x08,0x83]
amomin.w.rl a5, a6, (a7)
# CHECK-INST: amomax.w.rl s7, s6, (s5)
# CHECK: encoding: [0xaf,0xab,0x6a,0xa3]
amomax.w.rl s7, s6, (s5)
# CHECK-INST: amominu.w.rl s6, s5, (s4)
# CHECK: encoding: [0x2f,0x2b,0x5a,0xc3]
amominu.w.rl s6, s5, (s4)
# CHECK-INST: amomaxu.w.rl s5, s4, (s3)
# CHECK: encoding: [0xaf,0xaa,0x49,0xe3]
amomaxu.w.rl s5, s4, (s3)

# CHECK-INST: amoswap.w.aqrl a4, ra, (s0)
# CHECK: encoding: [0x2f,0x27,0x14,0x0e]
amoswap.w.aqrl a4, ra, (s0)
# CHECK-INST: amoadd.w.aqrl a1, a2, (a3)
# CHECK: encoding: [0xaf,0xa5,0xc6,0x06]
amoadd.w.aqrl a1, a2, (a3)
# CHECK-INST: amoxor.w.aqrl a2, a3, (a4)
# CHECK: encoding: [0x2f,0x26,0xd7,0x26]
amoxor.w.aqrl a2, a3, (a4)
# CHECK-INST: amoand.w.aqrl a3, a4, (a5)
# CHECK: encoding: [0xaf,0xa6,0xe7,0x66]
amoand.w.aqrl a3, a4, (a5)
# CHECK-INST: amoor.w.aqrl a4, a5, (a6)
# CHECK: encoding: [0x2f,0x27,0xf8,0x46]
amoor.w.aqrl a4, a5, (a6)
# CHECK-INST: amomin.w.aqrl a5, a6, (a7)
# CHECK: encoding: [0xaf,0xa7,0x08,0x87]
amomin.w.aqrl a5, a6, (a7)
# CHECK-INST: amomax.w.aqrl s7, s6, (s5)
# CHECK: encoding: [0xaf,0xab,0x6a,0xa7]
amomax.w.aqrl s7, s6, (s5)
# CHECK-INST: amominu.w.aqrl s6, s5, (s4)
# CHECK: encoding: [0x2f,0x2b,0x5a,0xc7]
amominu.w.aqrl s6, s5, (s4)
# CHECK-INST: amomaxu.w.aqrl s5, s4, (s3)
# CHECK: encoding: [0xaf,0xaa,0x49,0xe7]
amomaxu.w.aqrl s5, s4, (s3)
