Skip to content

Commit f50aedb

Browse files
committed
[cheriot] Add cheriot spellings to calling convention-related attributes.
1 parent f94d283 commit f50aedb

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
@@ -2465,7 +2465,8 @@ def CHERICCallee : DeclOrTypeAttr { // InheritableAttr {
24652465
}
24662466

24672467
def CHERICCallback : DeclOrTypeAttr { // InheritableAttr {
2468-
let Spellings = [GNU<"cheri_ccallback">];
2468+
let Spellings = [GNU<"cheri_ccallback">,
2469+
GNU<"cheriot_ccallback">];
24692470
let Documentation = [Undocumented];
24702471
}
24712472

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

24832484
def CHERICompartmentName : DeclOrTypeAttr {
2484-
let Spellings = [GNU<"cheri_compartment">];
2485+
let Spellings = [GNU<"cheri_compartment">,
2486+
GNU<"cheriot_compartment">];
24852487
let Documentation = [Undocumented];
24862488
let Subjects = SubjectList<[Function], ErrorDiag>;
24872489
let Args = [StringArgument<"CompartmentName">];
24882490
}
24892491

24902492
def CHERILibCall : DeclOrTypeAttr {
2491-
let Spellings = [GNU<"cheri_libcall">];
2493+
let Spellings = [GNU<"cheri_libcall">,
2494+
GNU<"cheriot_libcall">
2495+
];
24922496
let Documentation = [Undocumented];
24932497
let Subjects = SubjectList<[Function], ErrorDiag>;
24942498
}

clang/lib/Basic/Targets/RISCV.cpp

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

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

248248
Builder.defineMacro("__riscv_clen", Twine(getCHERICapabilityWidth()));
249249
// 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 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)