Skip to content

Commit 6d22636

Browse files
committed
[CHERIoT] Add a spelling for interrupt_state in the cheriot namespace.
1 parent 10b5b96 commit 6d22636

File tree

5 files changed

+76
-13
lines changed

5 files changed

+76
-13
lines changed

clang/include/clang/Basic/Attr.td

+4-1
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,10 @@ def MinimumStack : InheritableAttr, TargetSpecificAttr<TargetRISCV> {
874874
}
875875

876876
def InterruptState : InheritableAttr, TargetSpecificAttr<TargetRISCV> {
877-
let Spellings = [CXX11<"cheri", "interrupt_state">,
877+
let Spellings = [CXX11<"cheriot", "interrupt_state">,
878+
C2x<"cheriot", "interrupt_state">,
879+
GNU<"cheriot_interrupt_state">,
880+
CXX11<"cheri", "interrupt_state">,
878881
C2x<"cheri", "interrupt_state">,
879882
GNU<"cheri_interrupt_state">];
880883
let Args = [EnumArgument<"State", "InterruptState",

clang/lib/Basic/Targets/RISCV.cpp

+2-2
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__", "20250108");
244+
Builder.defineMacro("__CHERIOT__", "20250113");
245245
if (ABI == "cheriot-baremetal")
246-
Builder.defineMacro("__CHERIOT_BAREMETAL__", "20250108");
246+
Builder.defineMacro("__CHERIOT_BAREMETAL__", "20250113");
247247

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

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

+43-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
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
int foo(void);
3+
34
// CHECK: define dso_local i32 @disabled() local_unnamed_addr addrspace(200) #[[DIS:[0-9]]]
4-
__attribute__((cheri_interrupt_state(disabled)))
5+
__attribute__((cheriot_interrupt_state(disabled)))
56
int disabled(void)
67
{
78
return foo();
89
}
910

1011
// CHECK: define dso_local i32 @enabled() local_unnamed_addr addrspace(200) #[[EN:[0-9]]]
11-
__attribute__((cheri_interrupt_state(enabled)))
12+
__attribute__((cheriot_interrupt_state(enabled)))
1213
int enabled(void)
1314
{
1415
return foo();
1516
}
1617

1718
// CHECK: define dso_local i32 @inherit() local_unnamed_addr addrspace(200) #[[INH:[0-9]]]
18-
__attribute__((cheri_interrupt_state(inherit)))
19+
__attribute__((cheriot_interrupt_state(inherit)))
1920
int inherit(void)
2021
{
2122
return foo();
@@ -39,20 +40,57 @@ void default_enable_callback(void)
3940
// Explicitly setting interrupt status should override the default
4041

4142
// CHECK: define dso_local chericcallcce i32 @_Z23explicit_disable_calleev() local_unnamed_addr addrspace(200) #[[EXPDIS:[0-9]]]
42-
__attribute__((cheri_interrupt_state(disabled)))
43+
__attribute__((cheriot_interrupt_state(disabled)))
4344
__attribute__((cheri_compartment("example")))
4445
int explicit_disable_callee(void)
4546
{
4647
return 0;
4748
}
4849

4950
// CHECK: define dso_local chericcallcc void @explicit_disable_callback() local_unnamed_addr addrspace(200) #[[EXPDIS]]
50-
__attribute__((cheri_interrupt_state(disabled)))
51+
__attribute__((cheriot_interrupt_state(disabled)))
5152
__attribute__((cheri_ccallback))
5253
void explicit_disable_callback(void)
5354
{
5455
}
5556

57+
// Check deprecated spellings
58+
59+
// CHECK: define dso_local i32 @disabled1() local_unnamed_addr addrspace(200) #[[DIS]]
60+
__attribute__((cheri_interrupt_state(disabled)))
61+
int disabled1(void)
62+
{
63+
return foo();
64+
}
65+
66+
// CHECK: define dso_local i32 @enabled1() local_unnamed_addr addrspace(200) #[[EN]]
67+
__attribute__((cheri_interrupt_state(enabled)))
68+
int enabled1(void)
69+
{
70+
return foo();
71+
}
72+
73+
// CHECK: define dso_local i32 @inherit1() local_unnamed_addr addrspace(200) #[[INH]]
74+
__attribute__((cheri_interrupt_state(inherit)))
75+
int inherit1(void)
76+
{
77+
return foo();
78+
}
79+
80+
// CHECK: define dso_local chericcallcce i32 @_Z24explicit_disable_callee1v() local_unnamed_addr addrspace(200) #[[EXPDIS]]
81+
__attribute__((cheri_interrupt_state(disabled)))
82+
__attribute__((cheri_compartment("example")))
83+
int explicit_disable_callee1(void)
84+
{
85+
return 0;
86+
}
87+
88+
// CHECK: define dso_local chericcallcc void @explicit_disable_callback1() local_unnamed_addr addrspace(200) #[[EXPDIS]]
89+
__attribute__((cheri_interrupt_state(disabled)))
90+
__attribute__((cheri_ccallback))
91+
void explicit_disable_callback1(void)
92+
{
93+
}
5694

5795
// CHECK: attributes #[[DIS]]
5896
// CHECK-SAME: "interrupt-state"="disabled"

clang/test/CodeGenCXX/cheri/cheri-mcu-interrupts.cpp

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,48 @@
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
int foo(void);
3+
34
// CHECK: define dso_local noundef i32 @_Z8disabledv() local_unnamed_addr addrspace(200) #[[DIS:[0-9]]]
4-
[[cheri::interrupt_state(disabled)]]
5+
[[cheriot::interrupt_state(disabled)]]
56
int disabled(void)
67
{
78
return foo();
89
}
910

1011
// CHECK: define dso_local noundef i32 @_Z7enabledv() local_unnamed_addr addrspace(200) #[[EN:[0-9]]]
11-
[[cheri::interrupt_state(enabled)]]
12+
[[cheriot::interrupt_state(enabled)]]
1213
int enabled(void)
1314
{
1415
return foo();
1516
}
1617

1718
// CHECK: define dso_local noundef i32 @_Z7inheritv() local_unnamed_addr addrspace(200) #[[INH:[0-9]]]
18-
[[cheri::interrupt_state(inherit)]]
19+
[[cheriot::interrupt_state(inherit)]]
1920
int inherit(void)
2021
{
2122
return foo();
2223
}
2324

25+
// CHECK: define dso_local noundef i32 @_Z9disabled1v() local_unnamed_addr addrspace(200) #[[DIS]]
26+
[[cheri::interrupt_state(disabled)]]
27+
int disabled1(void)
28+
{
29+
return foo();
30+
}
31+
32+
// CHECK: define dso_local noundef i32 @_Z8enabled1v() local_unnamed_addr addrspace(200) #[[EN]]
33+
[[cheri::interrupt_state(enabled)]]
34+
int enabled1(void)
35+
{
36+
return foo();
37+
}
38+
39+
// CHECK: define dso_local noundef i32 @_Z8inherit1v() local_unnamed_addr addrspace(200) #[[INH]]
40+
[[cheri::interrupt_state(inherit)]]
41+
int inherit1(void)
42+
{
43+
return foo();
44+
}
45+
2446
// CHECK: attributes #[[DIS]]
2547
// CHECK-SAME: "interrupt-state"="disabled"
2648
// CHECK: attributes #[[EN]]

clang/test/Preprocessor/init.c

+2-2
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__ 20250108
324-
// CHERIOT: #define __CHERIOT__ 20250108
323+
// CHERIOT-BAREMETAL: #define __CHERIOT_BAREMETAL__ 20250113
324+
// CHERIOT: #define __CHERIOT__ 20250113
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

0 commit comments

Comments
 (0)