diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f6942f79884b..c501bc6641c5 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3397,6 +3397,14 @@ def mno_xcheri_rvc : Flag<["-"], "mno-xcheri-rvc">, Alias; def mno_xcheri_norvc : Flag<["-"], "mno-xcheri-norvc">, Group, HelpText<"Enable using compressed CHERI instructions">; def mxcheri_rvc : Flag<["-"], "mxcheri-rvc">, Alias; +// 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, + HelpText<"Generate code that is no longer compatible with CHERI ISAv8">; +def mno_xcheri_v9_semantics : Flag<["-"], "mno-xcheri-v9-semantics">, 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; def munaligned_access : Flag<["-"], "munaligned-access">, Group, HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">; diff --git a/clang/test/Driver/riscv-default-features.c b/clang/test/Driver/riscv-default-features.c index f41f601cbb97..8b990475c08c 100644 --- a/clang/test/Driver/riscv-default-features.c +++ b/clang/test/Driver/riscv-default-features.c @@ -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" @@ -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;