Skip to content

Commit 533ea16

Browse files
committed
[cheriot] Add cheriot spellings to calling convention-related attributes.
1 parent f47a917 commit 533ea16

File tree

9 files changed

+25
-14
lines changed

9 files changed

+25
-14
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,7 +2564,8 @@ def CHERICCallee : DeclOrTypeAttr { // InheritableAttr {
25642564
}
25652565

25662566
def CHERICCallback : DeclOrTypeAttr { // InheritableAttr {
2567-
let Spellings = [GNU<"cheri_ccallback">];
2567+
let Spellings = [GNU<"cheri_ccallback">,
2568+
GNU<"cheriot_ccallback">];
25682569
let Documentation = [Undocumented];
25692570
}
25702571

@@ -2580,14 +2581,17 @@ def CHERIMethodClass : DeclOrTypeAttr { // InheritableAttr {
25802581
}
25812582

25822583
def CHERICompartmentName : DeclOrTypeAttr {
2583-
let Spellings = [GNU<"cheri_compartment">];
2584+
let Spellings = [GNU<"cheri_compartment">,
2585+
GNU<"cheriot_compartment">];
25842586
let Documentation = [Undocumented];
25852587
let Subjects = SubjectList<[Function], ErrorDiag>;
25862588
let Args = [StringArgument<"CompartmentName">];
25872589
}
25882590

25892591
def CHERILibCall : DeclOrTypeAttr {
2590-
let Spellings = [GNU<"cheri_libcall">];
2592+
let Spellings = [GNU<"cheri_libcall">,
2593+
GNU<"cheriot_libcall">
2594+
];
25912595
let Documentation = [Undocumented];
25922596
let Subjects = SubjectList<[Function], ErrorDiag>;
25932597
}

clang/lib/Basic/Targets/RISCV.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
246246

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

253253
Builder.defineMacro("__riscv_clen", Twine(getCHERICapabilityWidth()));
254254
// TODO: _MIPS_CAP_ALIGN_MASK equivalent?

clang/test/CodeGen/cheri/cheri-mcu-call-libcall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
2-
#define LIBCALL __attribute__((cheri_libcall))
2+
#define LIBCALL __attribute__((cheriot_libcall))
33

44
LIBCALL
55
int add(int a, int b);

clang/test/CodeGen/cheri/cheri-mcu-ccall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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
22

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

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

1010
int testcall6() {
1111
static int stack_arg;

clang/test/CodeGen/cheri/cheri-mcu-interrupts.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ void default_enable_callback(void)
3737
{
3838
}
3939

40+
// CHECK: define dso_local chericcallcc void @default_enable_callback2() local_unnamed_addr addrspace(200) #[[DEFEN]]
41+
__attribute__((cheriot_ccallback))
42+
void default_enable_callback2(void)
43+
{
44+
}
45+
46+
4047
// Explicitly setting interrupt status should override the default
4148

4249
// CHECK: define dso_local chericcallcce noundef i32 @_Z23explicit_disable_calleev() local_unnamed_addr addrspace(200) #[[EXPDIS:[0-9]]]

clang/test/CodeGen/cheri/cheriot-libcall-ptr-decay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void foo(void (*bar)())
1717
// CHECK-NEXT: entry:
1818
// CHECK-NEXT: ret void
1919
//
20-
void __attribute__((cheri_libcall)) bar()
20+
void __attribute__((cheriot_libcall)) bar()
2121
{
2222
return;
2323
}

clang/test/CodeGenCXX/cheri/cheriot-libcall-ptr-decay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void foo(void (*bar)())
1717
// CHECK-NEXT: entry:
1818
// CHECK-NEXT: ret void
1919
//
20-
void __attribute__((cheri_libcall)) bar()
20+
void __attribute__((cheriot_libcall)) bar()
2121
{
2222
return;
2323
}

clang/test/Preprocessor/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@
320320
// Check for CHERIoT-specific defines
321321
// 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
322322
// 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
323-
// CHERIOT-BAREMETAL: #define __CHERIOT_BAREMETAL__ 20250215
324-
// CHERIOT: #define __CHERIOT__ 20250215
323+
// CHERIOT-BAREMETAL: #define __CHERIOT_BAREMETAL__ 20250217
324+
// CHERIOT: #define __CHERIOT__ 20250217
325325

326326

327327
// RUN: %cheri128_cc1 -fgnuc-version=4.2.1 -E -dM -ffreestanding < /dev/null | FileCheck -check-prefixes CHERI-COMMON,CHERI-MIPS,CHERI128 %s

clang/test/Sema/cheri/cheri-mcu-compartment-warns.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// RUN: %clang_cc1 %s -o - -triple riscv32cheriot-unknown-cheriotrtos -emit-llvm -mframe-pointer=none -mcmodel=small -target-abi cheriot -Oz -Werror -verify=libcall
22
// 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
33

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

10-
__attribute__((cheri_compartment("example")))
10+
__attribute__((cheriot_compartment("example")))
1111
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=)}}
1212
{
1313
return 1;

0 commit comments

Comments
 (0)