Skip to content

Commit

Permalink
[CHERI-RISC-V] Add a temporary -mxcheri-v9-semantics clang flag
Browse files Browse the repository at this point in the history
This will be removed once we default to the new semantics. This also
adds a mxcheri-v8-compat flag to opt-in to the old semantics (although
that is currently the default).
  • Loading branch information
arichardson committed Aug 9, 2023
1 parent 8cf1be0 commit 3f3b302
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3397,6 +3397,14 @@ def mno_xcheri_rvc : Flag<["-"], "mno-xcheri-rvc">, Alias<mxcheri_norvc>;
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>;
// Temporary flags to enable/disable CHERI ISAv8 compatibility.
// Flag name is a bit odd but this is required by handleTargetFeaturesGroup().
def mxcheri_v9_semantics : Flag<["-"], "mxcheri-v9-semantics">, Group<m_riscv_Features_Group>,
HelpText<"Generate code that is no longer compatible with CHERI ISAv8">;
def mno_xcheri_v9_semantics : Flag<["-"], "mno-xcheri-v9-semantics">, Group<m_riscv_Features_Group>,
HelpText<"Generate code that is compatible with CHERI ISAv8">;
// Add an alias with a more sensible name for when the default is flipped.
def mxcheri_v8_compat : Flag<["-"], "mxcheri-v8-compat">, Alias<mno_xcheri_v9_semantics>;

def munaligned_access : Flag<["-"], "munaligned-access">, Group<m_arm_Features_Group>,
HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Driver/riscv-default-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
// 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

// RUN: %clang --target=riscv64-unknown-elf -march=rv64ixcheri -mxcheri-v9-semantics -S -emit-llvm %s -o - | FileCheck %s -check-prefix=RV64-XCHERI-V9
// RUN: %clang --target=riscv64-unknown-elf -march=rv64ixcheri -mxcheri-v8-compat -S -emit-llvm %s -o - | FileCheck %s -check-prefix=RV64-XCHERI-V8

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

Expand All @@ -26,6 +29,9 @@
// 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"

// RV64-XCHERI-V8: "target-features"="+64bit,+relax,+xcheri,-save-restore,-xcheri-v9-semantics"
// RV64-XCHERI-V9: "target-features"="+64bit,+relax,+xcheri,+xcheri-v9-semantics,-save-restore"

// Dummy function
int foo(){
return 3;
Expand Down

0 comments on commit 3f3b302

Please sign in to comment.