Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -2465,7 +2465,8 @@ def CHERICCallee : DeclOrTypeAttr { // InheritableAttr {
}

def CHERICCallback : DeclOrTypeAttr { // InheritableAttr {
let Spellings = [GNU<"cheri_ccallback">];
let Spellings = [GNU<"cheri_ccallback">,
GNU<"cheriot_ccallback">];
let Documentation = [Undocumented];
}

Expand All @@ -2481,14 +2482,17 @@ def CHERIMethodClass : DeclOrTypeAttr { // InheritableAttr {
}

def CHERICompartmentName : DeclOrTypeAttr {
let Spellings = [GNU<"cheri_compartment">];
let Spellings = [GNU<"cheri_compartment">,
GNU<"cheriot_compartment">];
let Documentation = [Undocumented];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Args = [StringArgument<"CompartmentName">];
}

def CHERILibCall : DeclOrTypeAttr {
let Spellings = [GNU<"cheri_libcall">];
let Spellings = [GNU<"cheri_libcall">,
GNU<"cheriot_libcall">
];
let Documentation = [Undocumented];
let Subjects = SubjectList<[Function], ErrorDiag>;
}
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Basic/Targets/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,

// Macros for CHERIoT in the default and bare-metal ABIs.
if (ABI == "cheriot" || ABI == "cheriot-baremetal")
Builder.defineMacro("__CHERIOT__", "20250215");
Builder.defineMacro("__CHERIOT__", "20250217");
if (ABI == "cheriot-baremetal")
Builder.defineMacro("__CHERIOT_BAREMETAL__", "20250215");
Builder.defineMacro("__CHERIOT_BAREMETAL__", "20250217");

Builder.defineMacro("__riscv_clen", Twine(getCHERICapabilityWidth()));
// TODO: _MIPS_CAP_ALIGN_MASK equivalent?
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/cheri/cheri-mcu-call-libcall.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 %s -o - "-triple" "riscv32cheriot-unknown-cheriotrtos" "-emit-llvm" "-mframe-pointer=none" "-mcmodel=small" "-target-abi" "cheriot" "-Oz" "-Werror" "-cheri-compartment=example" | FileCheck %s
#define LIBCALL __attribute__((cheri_libcall))
#define LIBCALL __attribute__((cheriot_libcall))

LIBCALL
int add(int a, int b);
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGen/cheri/cheri-mcu-ccall.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// RUN: %clang_cc1 %s -o - "-triple" "riscv32cheriot-unknown-cheriotrtos" "-emit-llvm" "-mframe-pointer=none" "-mcmodel=small" "-target-abi" "cheriot" "-Oz" "-Werror" "-cheri-compartment=example" | FileCheck %s

// CHECK: define dso_local chericcallcce i32 @_Z5test2ii(i32 noundef %a0, i32 noundef %a1) local_unnamed_addr addrspace(200) #0
__attribute__((cheri_compartment("example"))) int test2(int a0, int a1) {
__attribute__((cheriot_compartment("example"))) int test2(int a0, int a1) {
return a0 + a1;
}

__attribute__((cheri_compartment("other"))) int test6callee(int *a0, int *a1, int *a2, int *a3, int *a4, int *a5);
__attribute__((cheriot_compartment("other"))) int test6callee(int *a0, int *a1, int *a2, int *a3, int *a4, int *a5);

int testcall6() {
static int stack_arg;
Expand Down
7 changes: 7 additions & 0 deletions clang/test/CodeGen/cheri/cheri-mcu-interrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ void default_enable_callback(void)
{
}

// CHECK: define dso_local chericcallcc void @default_enable_callback2() local_unnamed_addr addrspace(200) #[[DEFEN]]
__attribute__((cheriot_ccallback))
void default_enable_callback2(void)
{
}


// Explicitly setting interrupt status should override the default

// CHECK: define dso_local chericcallcce i32 @_Z23explicit_disable_calleev() local_unnamed_addr addrspace(200) #[[EXPDIS:[0-9]]]
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/cheri/cheriot-libcall-ptr-decay.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void foo(void (*bar)())
// CHECK-NEXT: entry:
// CHECK-NEXT: ret void
//
void __attribute__((cheri_libcall)) bar()
void __attribute__((cheriot_libcall)) bar()
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenCXX/cheri/cheriot-libcall-ptr-decay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void foo(void (*bar)())
// CHECK-NEXT: entry:
// CHECK-NEXT: ret void
//
void __attribute__((cheri_libcall)) bar()
void __attribute__((cheriot_libcall)) bar()
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Preprocessor/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@
// Check for CHERIoT-specific defines
// RUN: %clang_cc1 %s -o - "-triple" "riscv32-unknown-unknown" "-emit-llvm" "-mframe-pointer=none" "-mcmodel=small" "-target-cpu" "cheriot" "-target-feature" "+xcheri" "-target-feature" "-64bit" "-target-feature" "-relax" "-target-feature" "-xcheri-rvc" "-target-feature" "-save-restore" "-target-abi" "cheriot" -E -dM < /dev/null | FileCheck -check-prefix CHERIOT %s
// RUN: %clang_cc1 %s -o - "-triple" "riscv32-unknown-unknown" "-emit-llvm" "-mframe-pointer=none" "-mcmodel=small" "-target-cpu" "cheriot" "-target-feature" "+xcheri" "-target-feature" "-64bit" "-target-feature" "-relax" "-target-feature" "-xcheri-rvc" "-target-feature" "-save-restore" "-target-abi" "cheriot-baremetal" -E -dM < /dev/null | FileCheck -check-prefixes CHERIOT,CHERIOT-BAREMETAL %s
// CHERIOT-BAREMETAL: #define __CHERIOT_BAREMETAL__ 20250215
// CHERIOT: #define __CHERIOT__ 20250215
// CHERIOT-BAREMETAL: #define __CHERIOT_BAREMETAL__ 20250217
// CHERIOT: #define __CHERIOT__ 20250217


// RUN: %cheri128_cc1 -fgnuc-version=4.2.1 -E -dM -ffreestanding < /dev/null | FileCheck -check-prefixes CHERI-COMMON,CHERI-MIPS,CHERI128 %s
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Sema/cheri/cheri-mcu-compartment-warns.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// RUN: %clang_cc1 %s -o - -triple riscv32cheriot-unknown-cheriotrtos -emit-llvm -mframe-pointer=none -mcmodel=small -target-abi cheriot -Oz -Werror -verify=libcall
// RUN: %clang_cc1 %s -o - -triple riscv32cheriot-unknown-cheriotrtos -emit-llvm -mframe-pointer=none -mcmodel=small -target-abi cheriot -Oz -Werror -verify=wrong-compartment -cheri-compartment=wrong

__attribute__((cheri_libcall))
__attribute__((cheriot_libcall))
int add(int a, int b) // wrong-compartment-error{{CHERI libcall exported from compilation unit for compartment 'wrong' (provided with -cheri-compartment=)}}
{
return a+b;
}

__attribute__((cheri_compartment("example")))
__attribute__((cheriot_compartment("example")))
int shouldBePrototype(void) // libcall-error{{CHERI compartment entry declared for compartment 'example' but implemented in '' (provided with -cheri-compartment=)}} wrong-compartment-error{{CHERI compartment entry declared for compartment 'example' but implemented in 'wrong' (provided with -cheri-compartment=)}}
{
return 1;
Expand Down