Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHERI-RISC-V] Allow load/store mnemonics without the c prefix #749

390 changes: 228 additions & 162 deletions llvm/lib/Target/RISCV/RISCVInstrInfoXCheri.td

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions llvm/test/MC/RISCV/cheri/rv32axcheri-cap-mode-invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ camoswap.w a1, a2, c3 # CHECK: :[[@LINE]]:20: error: expected '(' or optional in
camomin.w a1, a2, 1 # CHECK: :[[@LINE]]:21: error: expected '(' after optional integer offset
camomin.w a1, a2, 1(c3) # CHECK: :[[@LINE]]:19: error: optional integer offset must be 0
clr.w a4, c5 # CHECK: :[[@LINE]]:11: error: expected '(' or optional integer offset
clr.w a4, (a5) # CHECK: :[[@LINE]]:12: error: invalid operand for instruction

# Only .aq, .rl, and .aqrl suffixes are valid
camoxor.w.rlqa a2, a3, (c4) # CHECK: :[[@LINE]]:1: error: unrecognized instruction mnemonic
Expand Down
10 changes: 9 additions & 1 deletion llvm/test/MC/RISCV/cheri/rv32axcheri-cap-mode-only-valid.s
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# RUN: llvm-mc %s -triple=riscv32 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding \
# RUN: llvm-mc -triple=riscv32 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %s \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+a,+xcheri,+cap-mode < %s \
# RUN: | llvm-objdump --mattr=+a,+xcheri,+cap-mode -M no-aliases -d -r - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s

## Same test again without the "c" prefix on all lines
# RUN: sed -e 's/^c//' < %s > %t.s
# RUN: llvm-mc -triple=riscv32 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %t.s \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+a,+xcheri,+cap-mode < %t.s \
# RUN: | llvm-objdump --mattr=+a,+xcheri,+cap-mode -M no-aliases -d -r - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s

# CHECK-ASM-AND-OBJ: clr.c ct0, (ct1)
# CHECK-ASM: encoding: [0xaf,0x32,0x03,0x10]
clr.c ct0, (ct1)
Expand Down
17 changes: 15 additions & 2 deletions llvm/test/MC/RISCV/cheri/rv32axcheri-cap-mode-valid.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RUN: llvm-mc %s -triple=riscv32 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding \
# RUN: llvm-mc -triple=riscv32 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %s\
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc %s -triple=riscv64 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding \
# RUN: llvm-mc -triple=riscv64 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %s\
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+a,+xcheri,+cap-mode < %s \
# RUN: | llvm-objdump --mattr=+a,+xcheri,+cap-mode -M no-aliases -d -r - \
Expand All @@ -9,6 +9,19 @@
# RUN: | llvm-objdump --mattr=+a,+xcheri,+cap-mode -M no-aliases -d -r - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s

## Same test again without the "c" prefix on all lines
# RUN: sed -e 's/^c//' < %s > %t.s
# RUN: llvm-mc %t.s -triple=riscv32 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc %t.s -triple=riscv64 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+a,+xcheri,+cap-mode < %t.s \
# RUN: | llvm-objdump --mattr=+a,+xcheri,+cap-mode -M no-aliases -d -r - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+a,+xcheri,+cap-mode < %t.s \
# RUN: | llvm-objdump --mattr=+a,+xcheri,+cap-mode -M no-aliases -d -r - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s

# CHECK-ASM-AND-OBJ: clr.b t0, (ct1)
# CHECK-ASM: encoding: [0xaf,0x02,0x03,0x10]
clr.b t0, (ct1)
Expand Down
8 changes: 8 additions & 0 deletions llvm/test/MC/RISCV/cheri/rv32cxcheri-cap-mode-invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ c.csw a5, 1(ca3)
# TODO-RV64-NO-C: <stdin>:[[#@LINE-5]]:11: error: instruction requires the following: 'C' (Compressed Instructions){{$}}
# CHECK-RV64-NO-C: <stdin>:[[#@LINE-6]]:11: error: invalid operand for instruction

c.csw a5, 4(a3)
# CHECK: <stdin>:[[#@LINE-1]]:13: error: invalid operand for instruction
c.sw a5, 4(a3)
# CHECK-RV32-NO-C: <stdin>:[[#@LINE-1]]:1: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores), Not Capability Mode
# CHECK-RV32-C: <stdin>:[[#@LINE-2]]:12: error: invalid operand for instruction
# CHECK-RV64-NO-C: <stdin>:[[#@LINE-3]]:1: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores), Not Capability Mode
# CHECK-RV64-C: <stdin>:[[#@LINE-4]]:12: error: invalid operand for instruction

# Bad operands:
c.cjalr a1
# CHECK: <stdin>:[[#@LINE-1]]:9: error: invalid operand for instruction
Expand Down
14 changes: 13 additions & 1 deletion llvm/test/MC/RISCV/cheri/rv32cxcheri-cap-mode-only-valid.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,30 @@
# CHECK-ASM-AND-OBJ: c.clccsp cra, 40(csp)
# CHECK-ASM-SAME: encoding: [0xa2,0x70]
c.clccsp cra, 40(csp)
# CHECK-ASM-AND-OBJ: c.clccsp cra, 40(csp)
# CHECK-ASM-SAME: encoding: [0xa2,0x70]
c.lcsp cra, 40(csp)
# CHECK-ASM-AND-OBJ: c.csccsp cra, 256(csp)
# CHECK-ASM-SAME: encoding: [0x06,0xe2]
c.csccsp cra, 256(csp)
# CHECK-ASM-AND-OBJ: c.csccsp cra, 256(csp)
# CHECK-ASM-SAME: encoding: [0x06,0xe2]
c.scsp cra, 256(csp)
# CHECK-ASM-AND-OBJ: c.clc ca2, 16(ca0)
# CHECK-ASM-SAME: encoding: [0x10,0x69]
c.clc ca2, 16(ca0)
# CHECK-ASM-AND-OBJ: c.clc ca2, 16(ca0)
# CHECK-ASM-SAME: encoding: [0x10,0x69]
c.lc ca2, 16(ca0)
# CHECK-ASM-AND-OBJ: c.csc ca5, 128(ca3)
# CHECK-ASM-SAME: encoding: [0xdc,0xe2]
c.csc ca5, 128(ca3)
# CHECK-ASM-AND-OBJ: c.csc ca5, 128(ca3)
# CHECK-ASM-SAME: encoding: [0xdc,0xe2]
c.sc ca5, 128(ca3)

## C.JAL is only defined for RV32C:
# CHECK-OBJ: c.cjal 0x806
# CHECK-OBJ: c.cjal 0x80e
# CHECK-ASM: c.cjal 2046
# CHECK-ASM-SAME: encoding: [0xfd,0x2f]
c.cjal 2046
12 changes: 12 additions & 0 deletions llvm/test/MC/RISCV/cheri/rv32cxcheri-cap-mode-valid.s
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@
# CHECK-ASM-AND-OBJ: c.clwcsp ra, 0(csp)
# CHECK-ASM-SAME: encoding: [0x82,0x40]
c.clwcsp ra, 0(csp)
# CHECK-ASM-AND-OBJ: c.clwcsp ra, 0(csp)
# CHECK-ASM-SAME: encoding: [0x82,0x40]
c.lwsp ra, 0(csp)
# CHECK-ASM-AND-OBJ: c.cswcsp ra, 252(csp)
# CHECK-ASM-SAME: encoding: [0x86,0xdf]
c.cswcsp ra, 252(csp)
# CHECK-ASM-AND-OBJ: c.cswcsp ra, 252(csp)
# CHECK-ASM-SAME: encoding: [0x86,0xdf]
c.swsp ra, 252(csp)
# CHECK-ASM-AND-OBJ: c.clw a2, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x10,0x41]
c.clw a2, 0(ca0)
# CHECK-ASM-AND-OBJ: c.clw a2, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x10,0x41]
c.lw a2, 0(ca0)
# CHECK-ASM-AND-OBJ: c.csw a5, 124(ca3)
# CHECK-ASM-SAME: encoding: [0xfc,0xde]
c.csw a5, 124(ca3)
# CHECK-ASM-AND-OBJ: c.csw a5, 124(ca3)
# CHECK-ASM-SAME: encoding: [0xfc,0xde]
c.sw a5, 124(ca3)

# CHECK-ASM-AND-OBJ: c.cjr ca7
# CHECK-ASM-SAME: encoding: [0x82,0x88]
Expand Down
33 changes: 33 additions & 0 deletions llvm/test/MC/RISCV/cheri/rv32fdcxcheri-cap-mode-only-valid.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# RUN: llvm-mc %s -triple=riscv32 -mattr=+c,+xcheri,+cap-mode,+f,+d -riscv-no-aliases -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c,+xcheri,+cap-mode,+f,+d < %s \
# RUN: | llvm-objdump -M no-aliases --mattr=+c,+xcheri,+cap-mode,+f,+d -d - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s

## Floating-point store is only supported in capmode for RV32

# CHECK-ASM-AND-OBJ: c.cfsd fa0, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x08,0xb5]
c.cfsd fa0, 40(ca0)
# CHECK-ASM-AND-OBJ: c.cfsd fa0, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x08,0xb5]
c.fsd fa0, 40(ca0)
# CHECK-ASM-AND-OBJ: c.cfld fa0, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x08,0x35]
c.cfld fa0, 40(ca0)
# CHECK-ASM-AND-OBJ: c.cfld fa0, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x08,0x35]
c.fld fa0, 40(ca0)

# CHECK-ASM-AND-OBJ: c.cfsdcsp ft1, 40(csp)
# CHECK-ASM-SAME: encoding: [0x06,0xb4]
c.cfsdcsp ft1, 40(csp)
# CHECK-ASM-AND-OBJ: c.cfsdcsp ft1, 40(csp)
# CHECK-ASM-SAME: encoding: [0x06,0xb4]
c.fsdsp ft1, 40(csp)
# CHECK-ASM-AND-OBJ: c.cfldcsp ft1, 40(csp)
# CHECK-ASM-SAME: encoding: [0xa2,0x30]
c.cfldcsp ft1, 40(csp)
# CHECK-ASM-AND-OBJ: c.cfldcsp ft1, 40(csp)
# CHECK-ASM-SAME: encoding: [0xa2,0x30]
c.fldsp ft1, 40(csp)
63 changes: 63 additions & 0 deletions llvm/test/MC/RISCV/cheri/rv32fdxcheri-cap-mode-valid.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# RUN: llvm-mc %s -triple=riscv32 -mattr=+xcheri,+cap-mode,+f,+d -riscv-no-aliases -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+xcheri,+cap-mode,+f,+d < %s \
# RUN: | llvm-objdump -M no-aliases --mattr=+xcheri,+cap-mode,+f,+d -d - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc %s -triple=riscv64 -mattr=+xcheri,+cap-mode,+f,+d -riscv-no-aliases -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+xcheri,+cap-mode,+f,+d < %s \
# RUN: | llvm-objdump -M no-aliases --mattr=+xcheri,+cap-mode,+f,+d -d - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s


# CHECK-ASM-AND-OBJ: cfsd fa0, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x27,0x34,0xa5,0x02]
cfsd fa0, 40(ca0)
# CHECK-ASM-AND-OBJ: cfsd fa0, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x27,0x34,0xa5,0x02]
fsd fa0, 40(ca0)
# CHECK-ASM-AND-OBJ: cfld fa0, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x07,0x35,0x85,0x02]
cfld fa0, 40(ca0)
# CHECK-ASM-AND-OBJ: cfld fa0, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x07,0x35,0x85,0x02]
cfld fa0, 40(ca0)

# CHECK-ASM-AND-OBJ: cfsw ft1, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x27,0x24,0x15,0x02]
cfsw ft1, 40(ca0)
# CHECK-ASM-AND-OBJ: cfsw ft1, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x27,0x24,0x15,0x02]
fsw ft1, 40(ca0)
# CHECK-ASM-AND-OBJ: cflw ft1, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x87,0x20,0x85,0x02]
cflw ft1, 40(ca0)
# CHECK-ASM-AND-OBJ: cflw ft1, 40(ca0)
# CHECK-ASM-SAME: encoding: [0x87,0x20,0x85,0x02]
flw ft1, 40(ca0)

# CHECK-ASM-AND-OBJ: cfsd fa0, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x27,0x30,0xa5,0x00]
cfsd fa0, (ca0)
# CHECK-ASM-AND-OBJ: cfsd fa0, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x27,0x30,0xa5,0x00]
fsd fa0, (ca0)
# CHECK-ASM-AND-OBJ: cfld fa0, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x07,0x35,0x05,0x00]
cfld fa0, (ca0)
# CHECK-ASM-AND-OBJ: cfld fa0, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x07,0x35,0x05,0x00]
fld fa0, (ca0)

# CHECK-ASM-AND-OBJ: cfsw ft1, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x27,0x20,0x15,0x00]
cfsw ft1, (ca0)
# CHECK-ASM-AND-OBJ: cfsw ft1, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x27,0x20,0x15,0x00]
fsw ft1, (ca0)
# CHECK-ASM-AND-OBJ: cflw ft1, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x87,0x20,0x05,0x00]
cflw ft1, (ca0)
# CHECK-ASM-AND-OBJ: cflw ft1, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x87,0x20,0x05,0x00]
flw ft1, (ca0)
30 changes: 30 additions & 0 deletions llvm/test/MC/RISCV/cheri/rv32xcheri-cap-mode-only-valid.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# RUN: llvm-mc -triple=riscv32 -mattr=+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %s \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+xcheri,+cap-mode < %s \
# RUN: | llvm-objdump -M no-aliases --mattr=+xcheri,+cap-mode -d - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s

## Same test again without the "c" prefix on all lines
# RUN: sed -e 's/^c//' < %s > %t.s
# RUN: llvm-mc -triple=riscv32 -mattr=+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %t.s \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+xcheri,+cap-mode < %t.s \
# RUN: | llvm-objdump -M no-aliases --mattr=+xcheri,+cap-mode -d - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s

# Capability load/store uses different encodings for RV32 vs RV64

# CHECK-ASM-AND-OBJ: clc ca2, 17(ca0)
# CHECK-ASM-SAME: encoding: [0x03,0x36,0x15,0x01]
clc ca2, 17(ca0)
# CHECK-ASM-AND-OBJ: csc ca5, 25(ca3)
# CHECK-ASM-SAME: encoding: [0xa3,0xbc,0xf6,0x00]
csc ca5, 25(ca3)


# CHECK-ASM-AND-OBJ: clc ca2, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x03,0x36,0x05,0x00]
clc ca2, (ca0)
# CHECK-ASM-AND-OBJ: csc ca5, 0(ca3)
# CHECK-ASM-SAME: encoding: [0x23,0xb0,0xf6,0x00]
csc ca5, (ca3)
81 changes: 81 additions & 0 deletions llvm/test/MC/RISCV/cheri/rv32xcheri-cap-mode-valid.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# RUN: llvm-mc -triple=riscv32 -mattr=+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %s \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -triple=riscv64 -mattr=+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %s \
# RUN: | FileCheck --check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+xcheri,+cap-mode < %s \
# RUN: | llvm-objdump -M no-aliases --mattr=+xcheri,+cap-mode -d - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+xcheri,+cap-mode < %s \
# RUN: | llvm-objdump -M no-aliases --mattr=+xcheri,+cap-mode -d - \
# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s

## Same test again without the "c" prefix on all lines
# RUN: sed -e 's/^c//' < %s > %t.s
# RUN: llvm-mc -triple=riscv32 -mattr=+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %t.s \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -triple=riscv64 -mattr=+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %t.s \
# RUN: | FileCheck --check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+xcheri,+cap-mode < %t.s \
# RUN: | llvm-objdump -M no-aliases --mattr=+xcheri,+cap-mode -d - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+xcheri,+cap-mode < %t.s \
# RUN: | llvm-objdump -M no-aliases --mattr=+xcheri,+cap-mode -d - \
# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s

# CHECK-ASM-AND-OBJ: clb a2, 17(ca0)
# CHECK-ASM-SAME: encoding: [0x03,0x06,0x15,0x01]
clb a2, 17(ca0)
# CHECK-ASM-AND-OBJ: csb a5, 25(ca3)
# CHECK-ASM-SAME: encoding: [0xa3,0x8c,0xf6,0x00]
csb a5, 25(ca3)

# CHECK-ASM-AND-OBJ: clh a2, 17(ca0)
# CHECK-ASM-SAME: encoding: [0x03,0x16,0x15,0x01]
clh a2, 17(ca0)
# CHECK-ASM-AND-OBJ: csh a5, 25(ca3)
# CHECK-ASM-SAME: encoding: [0xa3,0x9c,0xf6,0x00]
csh a5, 25(ca3)

# CHECK-ASM-AND-OBJ: clw ra, 17(csp)
# CHECK-ASM-SAME: encoding: [0x83,0x20,0x11,0x01]
clw ra, 17(csp)
# CHECK-ASM-AND-OBJ: csw ra, 25(csp)
# CHECK-ASM-SAME: encoding: [0xa3,0x2c,0x11,0x00]
csw ra, 25(csp)

# CHECK-ASM-AND-OBJ: clbu ra, 17(csp)
# CHECK-ASM-SAME: encoding: [0x83,0x40,0x11,0x01]
clbu ra, 17(csp)

# CHECK-ASM-AND-OBJ: clhu ra, 17(csp)
# CHECK-ASM-SAME: encoding: [0x83,0x50,0x11,0x01]
clhu ra, 17(csp)

# CHECK-ASM-AND-OBJ: clb a2, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x03,0x06,0x05,0x00]
clb a2, (ca0)
# CHECK-ASM-AND-OBJ: csb a5, 0(ca3)
# CHECK-ASM-SAME: encoding: [0x23,0x80,0xf6,0x00]
csb a5, (ca3)

# CHECK-ASM-AND-OBJ: clh a2, 0(ca0)
# CHECK-ASM-SAME: encoding: [0x03,0x16,0x05,0x00]
clh a2, (ca0)
# CHECK-ASM-AND-OBJ: csh a5, 0(ca3)
# CHECK-ASM-SAME: encoding: [0x23,0x90,0xf6,0x00]
csh a5, (ca3)

# CHECK-ASM-AND-OBJ: clw ra, 0(csp)
# CHECK-ASM-SAME: encoding: [0x83,0x20,0x01,0x00]
clw ra, (csp)
# CHECK-ASM-AND-OBJ: csw ra, 0(csp)
# CHECK-ASM-SAME: encoding: [0x23,0x20,0x11,0x00]
csw ra, (csp)

# CHECK-ASM-AND-OBJ: clbu ra, 0(csp)
# CHECK-ASM-SAME: encoding: [0x83,0x40,0x01,0x00]
clbu ra, (csp)

# CHECK-ASM-AND-OBJ: clhu ra, 0(csp)
# CHECK-ASM-SAME: encoding: [0x83,0x50,0x01,0x00]
clhu ra, (csp)
1 change: 1 addition & 0 deletions llvm/test/MC/RISCV/cheri/rv64axcheri-cap-mode-invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ camoswap.d a1, a2, ca3 # CHECK: :[[@LINE]]:20: error: expected '(' or optional i
camomin.d a1, a2, 1 # CHECK: :[[@LINE]]:21: error: expected '(' after optional integer offset
camomin.d a1, a2, 1(ca3) # CHECK: :[[@LINE]]:19: error: optional integer offset must be 0
clr.d a4, a5 # CHECK: :[[@LINE]]:11: error: expected '(' or optional integer offset
clr.d a4, (a5) # CHECK: :[[@LINE]]:12: error: invalid operand for instruction

# Only .aq, .rl, and .aqrl suffixes are valid
camoxor.d.rlqa a2, a3, (ca4) # CHECK: :[[@LINE]]:1: error: unrecognized instruction mnemonic
Expand Down
11 changes: 10 additions & 1 deletion llvm/test/MC/RISCV/cheri/rv64axcheri-cap-mode-valid.s
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# RUN: llvm-mc %s -triple=riscv64 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding \
# RUN: llvm-mc -triple=riscv64 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %s \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+a,+xcheri,+cap-mode < %s \
# RUN: | llvm-objdump --mattr=+a,+xcheri,+cap-mode -M no-aliases -d -r - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s

## Same test again without the "c" prefix on all lines
# RUN: sed -e 's/^c//' < %s > %t.s
# RUN: llvm-mc -triple=riscv64 -mattr=+a,+xcheri,+cap-mode -riscv-no-aliases -show-encoding < %t.s \
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+a,+xcheri,+cap-mode < %t.s \
# RUN: | llvm-objdump --mattr=+a,+xcheri,+cap-mode -M no-aliases -d -r - \
# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s


# CHECK-ASM-AND-OBJ: clr.d t0, (ct1)
# CHECK-ASM: encoding: [0xaf,0x32,0x03,0x10]
clr.d t0, (ct1)
Expand Down
Loading
Loading