Skip to content

Commit

Permalink
[CHERI-RISC-V] Default to emitting compressed CHERI instructions
Browse files Browse the repository at this point in the history
Both hardware implementations and QEMU have supported these for a long
time, so it makes sense for the compiler to default to emitting them if
the "C" extension is enabled. This retains the flags that were used to
enable the instructions but turns them into an opt-out flag instead.
Once the exact impact of compressed CHERI instructions has been evaluated,
these command line options and the SubtargetFeature can be removed.

See #681
  • Loading branch information
arichardson committed Feb 17, 2023
1 parent 1ba57bf commit 9aa80c2
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 70 deletions.
10 changes: 7 additions & 3 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3389,10 +3389,14 @@ def mcmodel_EQ_medany : Flag<["-"], "mcmodel=medany">, Group<m_riscv_Features_Gr
HelpText<"Equivalent to -mcmodel=medium, compatible with RISC-V gcc.">;
def menable_experimental_extensions : Flag<["-"], "menable-experimental-extensions">, Group<m_Group>,
HelpText<"Enable use of experimental RISC-V extensions.">;
def mxcheri_rvc : Flag<["-"], "mxcheri-rvc">, Group<m_riscv_Features_Group>,
HelpText<"Enable using compressed CHERI instructions">;
def mno_xcheri_rvc : Flag<["-"], "mno-xcheri-rvc">, Group<m_riscv_Features_Group>,
// TODO: Remove these options (https://github.com/CTSRD-CHERI/llvm-project/issues/681)
def mxcheri_norvc : Flag<["-"], "mxcheri-norvc">, Group<m_riscv_Features_Group>,
HelpText<"Disable using compressed CHERI instructions">;
def mno_xcheri_rvc : Flag<["-"], "mno-xcheri-rvc">, Alias<mxcheri_norvc>;
// Positive (i.e. double negated) flag for backwards compatibility/consistency.
def mno_xcheri_norvc : Flag<["-"], "mno-xcheri-norvc">, Group<m_riscv_Features_Group>,
HelpText<"Enable using compressed CHERI instructions">;
def mxcheri_rvc : Flag<["-"], "mxcheri-rvc">, Alias<mno_xcheri_norvc>;

def munaligned_access : Flag<["-"], "munaligned-access">, Group<m_arm_Features_Group>,
HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;
Expand Down
34 changes: 17 additions & 17 deletions clang/test/CodeGen/cheri/riscv/riscv-default-ir-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@
// RUN: %clang --target=riscv64 -march=rv64ixcheri -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-XCHERI '-DFEATURES=+64bit,+relax,+xcheri,-save-restore'
// RUN: %clang --target=riscv32 -march=rv32ixcheri -S -mxcheri-rvc -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-XCHERI '-DFEATURES=+relax,+xcheri,+xcheri-rvc,-save-restore'
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-XCHERI '-DFEATURES=+relax,+xcheri,-save-restore,-xcheri-norvc'
// RUN: %clang --target=riscv64 -march=rv64ixcheri -S -mxcheri-rvc -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-XCHERI '-DFEATURES=+64bit,+relax,+xcheri,+xcheri-rvc,-save-restore'
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-XCHERI '-DFEATURES=+64bit,+relax,+xcheri,-save-restore,-xcheri-norvc'
// RUN: %clang --target=riscv32 -march=rv32ixcheri -S -mno-xcheri-rvc -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-XCHERI '-DFEATURES=+relax,+xcheri,-save-restore,-xcheri-rvc'
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-XCHERI '-DFEATURES=+relax,+xcheri,+xcheri-norvc,-save-restore'
// RUN: %clang --target=riscv64 -march=rv64ixcheri -S -mno-xcheri-rvc -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-XCHERI '-DFEATURES=+64bit,+relax,+xcheri,-save-restore,-xcheri-rvc'
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-XCHERI '-DFEATURES=+64bit,+relax,+xcheri,+xcheri-norvc,-save-restore'

/// Same checks for purecap
// RUN: %clang --target=riscv32 -march=rv32ixcheri -mabi=il32pc64 -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-XCHERI-PURECAP '-DFEATURES=+cap-mode,+relax,+xcheri,-save-restore'
// RUN: %clang --target=riscv64 -march=rv64ixcheri -mabi=l64pc128 -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-XCHERI-PURECAP '-DFEATURES=+64bit,+cap-mode,+relax,+xcheri,-save-restore'
// RUN: %clang --target=riscv32 -march=rv32ixcheri -mabi=il32pc64 -S -mxcheri-rvc -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-XCHERI-PURECAP '-DFEATURES=+cap-mode,+relax,+xcheri,+xcheri-rvc,-save-restore'
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-XCHERI-PURECAP '-DFEATURES=+cap-mode,+relax,+xcheri,-save-restore,-xcheri-norvc'
// RUN: %clang --target=riscv64 -march=rv64ixcheri -mabi=l64pc128 -S -mxcheri-rvc -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-XCHERI-PURECAP '-DFEATURES=+64bit,+cap-mode,+relax,+xcheri,+xcheri-rvc,-save-restore'
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-XCHERI-PURECAP '-DFEATURES=+64bit,+cap-mode,+relax,+xcheri,-save-restore,-xcheri-norvc'
// RUN: %clang --target=riscv32 -march=rv32ixcheri -mabi=il32pc64 -S -mno-xcheri-rvc -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-XCHERI-PURECAP '-DFEATURES=+cap-mode,+relax,+xcheri,-save-restore,-xcheri-rvc'
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-XCHERI-PURECAP '-DFEATURES=+cap-mode,+relax,+xcheri,+xcheri-norvc,-save-restore'
// RUN: %clang --target=riscv64 -march=rv64ixcheri -mabi=l64pc128 -S -mno-xcheri-rvc -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-XCHERI-PURECAP '-DFEATURES=+64bit,+cap-mode,+relax,+xcheri,-save-restore,-xcheri-rvc'
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-XCHERI-PURECAP '-DFEATURES=+64bit,+cap-mode,+relax,+xcheri,+xcheri-norvc,-save-restore'

/// Enabling -mxcheri-rvc with a non-CHERI triple shouldn't enable the CHERI datalayout
// RUN: %clang --target=riscv32 -mxcheri-rvc -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-NOCHERI '-DFEATURES=+a,+c,+m,+relax,+xcheri-rvc,-save-restore'
// RUN: %clang --target=riscv64 -mxcheri-rvc -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-NOCHERI '-DFEATURES=+64bit,+a,+c,+m,+relax,+xcheri-rvc,-save-restore'
// RUN: %clang --target=riscv32 -mno-xcheri-rvc -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-NOCHERI '-DFEATURES=+a,+c,+m,+relax,-save-restore,-xcheri-rvc'
// RUN: %clang --target=riscv64 -mno-xcheri-rvc -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-NOCHERI '-DFEATURES=+64bit,+a,+c,+m,+relax,-save-restore,-xcheri-rvc'
/// Enabling -mxcheri-norvc with a non-CHERI triple shouldn't enable the CHERI datalayout
// RUN: %clang --target=riscv32 -mxcheri-norvc -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-NOCHERI '-DFEATURES=+a,+c,+m,+relax,+xcheri-norvc,-save-restore'
// RUN: %clang --target=riscv64 -mxcheri-norvc -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-NOCHERI '-DFEATURES=+64bit,+a,+c,+m,+relax,+xcheri-norvc,-save-restore'
// RUN: %clang --target=riscv32 -mno-xcheri-norvc -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV32-NOCHERI '-DFEATURES=+a,+c,+m,+relax,-save-restore,-xcheri-norvc'
// RUN: %clang --target=riscv64 -mno-xcheri-norvc -S -emit-llvm %s -o - \
// RUN: | FileCheck %s --check-prefixes=CHECK,RV64-NOCHERI '-DFEATURES=+64bit,+a,+c,+m,+relax,-save-restore,-xcheri-norvc'

// RV32-NOCHERI: target datalayout = "e-m:e-p:32:32-i64:64-n32-S128"
// RV64-NOCHERI: target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
Expand Down
19 changes: 13 additions & 6 deletions clang/test/Driver/riscv-default-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@

// RUN: %clang --target=riscv32-unknown-elf -march=rv32ixcheri -S -emit-llvm %s -o - | FileCheck %s -check-prefix=RV32-XCHERI
// RUN: %clang --target=riscv64-unknown-elf -march=rv64ixcheri -S -emit-llvm %s -o - | FileCheck %s -check-prefix=RV64-XCHERI
// RUN: %clang --target=riscv32-unknown-elf -march=rv32ixcheri -S -mxcheri-rvc -emit-llvm %s -o - | FileCheck %s -check-prefix=RV32-XCHERI-RVC
// RUN: %clang --target=riscv64-unknown-elf -march=rv64ixcheri -S -mxcheri-rvc -emit-llvm %s -o - | FileCheck %s -check-prefix=RV64-XCHERI-RVC
// RUN: %clang --target=riscv32-unknown-elf -march=rv32ixcheri -S -mno-xcheri-rvc -emit-llvm %s -o - | FileCheck %s -check-prefix=RV32-XCHERI-NORVC
// RUN: %clang --target=riscv64-unknown-elf -march=rv64ixcheri -S -mno-xcheri-rvc -emit-llvm %s -o - | FileCheck %s -check-prefix=RV64-XCHERI-NORVC
// RUN: %clang --target=riscv32-unknown-elf -march=rv32ixcheri -S -mxcheri-norvc -emit-llvm %s -o - | FileCheck %s -check-prefix=RV32-XCHERI-NORVC
// RUN: %clang --target=riscv64-unknown-elf -march=rv64ixcheri -S -mxcheri-norvc -emit-llvm %s -o - | FileCheck %s -check-prefix=RV64-XCHERI-NORVC
// The -mxcheri-rvc flag to explicitly disable xcheri-norvc:
// RUN: %clang --target=riscv32-unknown-elf -march=rv32ixcheri -S -mxcheri-rvc -emit-llvm %s -o - | FileCheck %s -check-prefix=RV32-XCHERI-EXPLICIT-RVC
// RUN: %clang --target=riscv64-unknown-elf -march=rv64ixcheri -S -mxcheri-rvc -emit-llvm %s -o - | FileCheck %s -check-prefix=RV64-XCHERI-EXPLICIT-RVC
// RUN: %clang --target=riscv32-unknown-elf -march=rv32ixcheri -S -mno-xcheri-norvc -emit-llvm %s -o - | FileCheck %s -check-prefix=RV32-XCHERI-EXPLICIT-RVC
// RUN: %clang --target=riscv64-unknown-elf -march=rv64ixcheri -S -mno-xcheri-norvc -emit-llvm %s -o - | FileCheck %s -check-prefix=RV64-XCHERI-EXPLICIT-RVC

// RV32: "target-features"="+a,+c,+m,+relax,-save-restore"
// RV64: "target-features"="+64bit,+a,+c,+m,+relax,-save-restore"

// RV32-XCHERI: "target-features"="+relax,+xcheri,-save-restore"
// RV64-XCHERI: "target-features"="+64bit,+relax,+xcheri,-save-restore"

// RV32-XCHERI-RVC: "target-features"="+relax,+xcheri,+xcheri-rvc,-save-restore"
// RV64-XCHERI-RVC: "target-features"="+64bit,+relax,+xcheri,+xcheri-rvc,-save-restore"
// RV32-XCHERI-NORVC: "target-features"="+relax,+xcheri,-save-restore,-xcheri-rvc"
// RV64-XCHERI-NORVC: "target-features"="+64bit,+relax,+xcheri,-save-restore,-xcheri-rvc"
// RV32-XCHERI-RVC: "target-features"="+relax,+xcheri,-save-restore"
// RV64-XCHERI-RVC: "target-features"="+64bit,+relax,+xcheri,-save-restore"
// RV32-XCHERI-NORVC: "target-features"="+relax,+xcheri,+xcheri-norvc,-save-restore"
// RV64-XCHERI-NORVC: "target-features"="+64bit,+relax,+xcheri,+xcheri-norvc,-save-restore"
// RV32-XCHERI-EXPLICIT-RVC: "target-features"="+relax,+xcheri,-save-restore,-xcheri-norvc"
// RV64-XCHERI-EXPLICIT-RVC: "target-features"="+64bit,+relax,+xcheri,-save-restore,-xcheri-norvc"

// Dummy function
int foo(){
Expand Down
13 changes: 8 additions & 5 deletions clang/test/Driver/riscv-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
// DEFAULT: "-target-feature" "-save-restore"
// DEFAULT-NOT: "-target-feature" "+save-restore"

// RUN: %clang -target riscv32 -### %s -march=rv32ixcheri 2>&1 | FileCheck %s --check-prefixes=XCHERI,XCHERI-NORVC
// RUN: %clang -target riscv64 -### %s -march=rv64ixcheri 2>&1 | FileCheck %s --check-prefixes=XCHERI,XCHERI-NORVC
// RUN: %clang -target riscv32-unknown-elf -### %s -march=rv64ixcheri -mxcheri-rvc 2>&1 | FileCheck %s --check-prefixes=XCHERI,XCHERI-RVC
// RUN: %clang -target riscv32 -### %s -march=rv32ixcheri 2>&1 | FileCheck %s --check-prefixes=XCHERI
// RUN: %clang -target riscv64 -### %s -march=rv64ixcheri 2>&1 | FileCheck %s --check-prefixes=XCHERI
// RUN: %clang -target riscv32-unknown-elf -### %s -march=rv64ixcheri -mxcheri-rvc 2>&1 | FileCheck %s --check-prefixes=XCHERI,XCHERI-EXPLICIT-RVC
// RUN: %clang -target riscv32-unknown-elf -### %s -march=rv64ixcheri -mxcheri-norvc 2>&1 | FileCheck %s --check-prefixes=XCHERI,XCHERI-NORVC
// RUN: %clang -target riscv32-unknown-elf -### %s -march=rv64ixcheri -mno-xcheri-rvc 2>&1 | FileCheck %s --check-prefixes=XCHERI,XCHERI-NORVC
// XCHERI: "-target-feature" "+xcheri"
// XCHERI-RVC: "-target-feature" "+xcheri-rvc"
// XCHERI-NORVC: "-target-feature" "-xcheri-rvc"
// XCHERI-NOT: "{{[+|-]}}xcheri-
// XCHERI-EXPLICIT-RVC: "-target-feature" "-xcheri-norvc"
// XCHERI-NORVC: "-target-feature" "+xcheri-norvc"
// XCHERI-NOT: "{{[+|-]}}xcheri-

// RUN: %clang -target riscv32-linux -### %s -fsyntax-only 2>&1 \
// RUN: | FileCheck %s -check-prefix=DEFAULT-LINUX
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Object/ELFObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ SubtargetFeatures ELFObjectFileBase::getRISCVFeatures() const {

if (PlatformFlags & ELF::EF_RISCV_CAP_MODE) {
Features.AddFeature("xcheri");
Features.AddFeature("xcheri-rvc");
Features.AddFeature("cap-mode");
}

Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/RISCV/RISCV.td
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,11 @@ def FeatureCheri
def HasCheri : Predicate<"Subtarget->hasCheri()">,
AssemblerPredicate<(all_of FeatureCheri),
"CHERI Extension">;
def FeatureCheriRVC
: SubtargetFeature<"xcheri-rvc", "EnableCheriRVCInstrs", "true",
"Enable CHERI RVC Instructions.">;
def FeatureCheriNoRVC
: SubtargetFeature<"xcheri-norvc", "EnableCheriRVCInstrs", "false",
"Disable CHERI RVC Instructions.">;
def HasCheriRVC : Predicate<"Subtarget->enableCheriRVCInstrs()">,
AssemblerPredicate<(all_of FeatureCheriRVC),
AssemblerPredicate<(all_of (not FeatureCheriNoRVC)),
"CHERI RVC Instructions">;

def FeatureCapMode
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/RISCV/RISCVSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
bool IsCapMode = false;
bool EnableLinkerRelax = false;
bool EnableRVCHintInstrs = true;
bool EnableCheriRVCInstrs = false;
bool EnableCheriRVCInstrs = true;
bool EnableSaveRestore = false;
unsigned XLen = 32;
ExtZvl ZvlLen = ExtZvl::NotSet;
Expand Down
16 changes: 8 additions & 8 deletions llvm/test/CodeGen/RISCV/cheri/compress.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
;
; RUN: cat %s > %t.tgtattr
; RUN: echo 'attributes #0 = { nounwind }' >> %t.tgtattr
; RUN: %riscv32_cheri_purecap_llc -mattr=+c,+xcheri,+cap-mode,+xcheri-rvc -filetype=obj < %t.tgtattr \
; RUN: | llvm-objdump -d -M no-aliases - | FileCheck %s
; RUN: %riscv64_cheri_purecap_llc -mattr=+c,+xcheri,+cap-mode,+xcheri-rvc -filetype=obj < %t.tgtattr \
; RUN: %riscv32_cheri_purecap_llc -mattr=+c,+xcheri,+cap-mode -filetype=obj < %t.tgtattr \
; RUN: | llvm-objdump -d -M no-aliases - | FileCheck %s
; RUN: %riscv64_cheri_purecap_llc -mattr=+c,+xcheri,+cap-mode -filetype=obj < %t.tgtattr \
; RUN: | llvm-objdump -d -M no-aliases - | FileCheck %s
; RUN: %riscv64_cheri_purecap_llc -mattr=+c,+xcheri,+cap-mode,+xcheri-norvc -filetype=obj < %t.tgtattr \
; RUN: | llvm-objdump -d -M no-aliases - | FileCheck %s --check-prefix=CHECK-NORVC

; RUN: cat %s > %t.fnattr
; RUN: echo 'attributes #0 = { nounwind "target-features"="+c,+xcheri,+cap-mode,+xcheri-rvc" }' >> %t.fnattr
; RUN: echo 'attributes #0 = { nounwind "target-features"="+c,+xcheri,+cap-mode" }' >> %t.fnattr
; RUN: %riscv32_cheri_purecap_llc -filetype=obj < %t.fnattr \
; RUN: | llvm-objdump -d --mattr=+c,+xcheri-rvc -M no-aliases - | FileCheck %s
; RUN: | llvm-objdump -d --mattr=+c -M no-aliases - | FileCheck %s
; RUN: %riscv64_cheri_purecap_llc -filetype=obj < %t.fnattr \
; RUN: | llvm-objdump -d --mattr=+c,+xcheri-rvc -M no-aliases - | FileCheck %s
; RUN: | llvm-objdump -d --mattr=+c -M no-aliases - | FileCheck %s
; RUN: cat %s > %t.fnattr
; RUN: echo 'attributes #0 = { nounwind "target-features"="+c,+xcheri,+cap-mode" }' >> %t.fnattr
; RUN: echo 'attributes #0 = { nounwind "target-features"="+c,+xcheri,+cap-mode,+xcheri-norvc" }' >> %t.fnattr
; RUN: %riscv64_cheri_purecap_llc -filetype=obj < %t.fnattr \
; RUN: | llvm-objdump -d --mattr=+c,+xcheri-rvc -M no-aliases - | FileCheck %s --check-prefix=CHECK-NORVC
; RUN: | llvm-objdump -d --mattr=+c -M no-aliases - | FileCheck %s --check-prefix=CHECK-NORVC

; Basic check that we can use CHERI compressed instructions

Expand Down
14 changes: 7 additions & 7 deletions llvm/test/MC/RISCV/cheri/rv32cxcheri-cap-mode-invalid.s
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# RUN: not llvm-mc -triple riscv32 -mattr=+c,+xcheri,+xcheri-rvc,+cap-mode -filetype=null -riscv-no-aliases -show-encoding < %s 2>&1 \
# RUN: not llvm-mc -triple riscv32 -mattr=+c,+xcheri,+cap-mode -filetype=null -riscv-no-aliases -show-encoding < %s 2>&1 \
# RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-RV32,CHECK-RV32-C --implicit-check-not="error:"
# RUN: not llvm-mc -triple riscv32 -mattr=+xcheri,+cap-mode -filetype=null -riscv-no-aliases -show-encoding < %s 2>&1 \
# RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-RV32,CHECK-RV32-NO-C --implicit-check-not="error:"
# RUN: not llvm-mc -triple riscv64 -mattr=+c,+xcheri,+xcheri-rvc,+cap-mode -filetype=null -riscv-no-aliases -show-encoding < %s 2>&1\
# RUN: not llvm-mc -triple riscv64 -mattr=+c,+xcheri,+cap-mode -filetype=null -riscv-no-aliases -show-encoding < %s 2>&1\
# RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-RV64-C --implicit-check-not="error:"
# RUN: not llvm-mc -triple riscv64 -mattr=+xcheri,+cap-mode -filetype=null -riscv-no-aliases -show-encoding < %s 2>&1 \
# RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-RV64-NO-C --implicit-check-not="error:"

## C.JAL is only defined for RV32C:
c.cjal 2046
# CHECK-RV64-C: <stdin>:[[#@LINE-1]]:1: error: instruction requires the following: RV32I Base Instruction Set{{$}}
# CHECK-RV32-NO-C: <stdin>:[[#@LINE-2]]:1: error: instruction requires the following: CHERI RVC Instructions, 'C' (Compressed Instructions){{$}}
# CHECK-RV64-NO-C: <stdin>:[[#@LINE-3]]:1: error: instruction requires the following: CHERI RVC Instructions, 'C' (Compressed Instructions), RV32I Base Instruction Set{{$}}
# CHECK-RV32-NO-C: <stdin>:[[#@LINE-2]]:1: error: instruction requires the following: 'C' (Compressed Instructions){{$}}
# CHECK-RV64-NO-C: <stdin>:[[#@LINE-3]]:1: error: instruction requires the following: 'C' (Compressed Instructions), RV32I Base Instruction Set{{$}}

## C.CSD needs RV64C:
c.csd a5, 124(ca3)
# CHECK-RV32: <stdin>:[[#@LINE-1]]:11: error: invalid operand for instruction
# CHECK-RV64-C: <stdin>:[[#@LINE-2]]:11: error: immediate must be a multiple of 8 bytes in the range [0, 248]
# TODO-RV64-NO-C: <stdin>:[[#@LINE-3]]:11: error: instruction requires the following: CHERI RVC Instructions, 'C' (Compressed Instructions){{$}}
# TODO-RV64-NO-C: <stdin>:[[#@LINE-3]]:11: error: instruction requires the following: 'C' (Compressed Instructions){{$}}
# CHECK-RV64-NO-C: <stdin>:[[#@LINE-4]]:11: error: invalid operand for instruction

## misaligned immediate:
c.csw a5, 1(ca3)
# CHECK-RV32-C: <stdin>:[[#@LINE-1]]:11: error: immediate must be a multiple of 4 bytes in the range [0, 124]
# TODO-RV32-NO-C: <stdin>:[[#@LINE-2]]:11: error: instruction requires the following: CHERI RVC Instructions, 'C' (Compressed Instructions){{$}}
# TODO-RV32-NO-C: <stdin>:[[#@LINE-2]]:11: error: instruction requires the following: 'C' (Compressed Instructions){{$}}
# CHECK-RV32-NO-C: <stdin>:[[#@LINE-3]]:11: error: invalid operand for instruction
# CHECK-RV64-C: <stdin>:[[#@LINE-4]]:11: error: immediate must be a multiple of 4 bytes in the range [0, 124]
# TODO-RV64-NO-C: <stdin>:[[#@LINE-5]]:11: error: instruction requires the following: CHERI RVC Instructions, 'C' (Compressed Instructions){{$}}
# 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

# Bad operands:
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/MC/RISCV/cheri/rv32cxcheri-cap-mode-only-valid.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RUN: llvm-mc %s -triple=riscv32 -mattr=+c,+xcheri,+xcheri-rvc,+cap-mode -riscv-no-aliases -show-encoding \
# RUN: llvm-mc %s -triple=riscv32 -mattr=+c,+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=+c,+xcheri,+xcheri-rvc,+cap-mode < %s \
# RUN: | llvm-objdump -M no-aliases --mattr=+c,+xcheri,+xcheri-rvc,+cap-mode -d - \
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c,+xcheri,+cap-mode < %s \
# RUN: | llvm-objdump -M no-aliases --mattr=+c,+xcheri,+cap-mode -d - \
# RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s

## Different encoding between RV64 and RV32 (see rv64cxcheri-cap-mode-only-valid.s)
Expand Down
Loading

0 comments on commit 9aa80c2

Please sign in to comment.