Skip to content

Commit 5d76fb9

Browse files
committed
add C-cmse-nonsecure-entry ABI
1 parent 0ba9db8 commit 5d76fb9

File tree

17 files changed

+43
-11
lines changed

17 files changed

+43
-11
lines changed

compiler/rustc_codegen_cranelift/src/abi/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: Call
6161
Conv::CCmseNonSecureCall => {
6262
sess.dcx().fatal("C-cmse-nonsecure-call call conv is not yet implemented");
6363
}
64+
Conv::CCmseNonSecureEntry => {
65+
sess.dcx().fatal("C-cmse-nonsecure-entry call conv is not yet implemented");
66+
}
6467

6568
Conv::Msp430Intr | Conv::PtxKernel | Conv::AvrInterrupt | Conv::AvrNonBlockingInterrupt => {
6669
unreachable!("tried to use {c:?} call conv which only exists on an unsupported target");

compiler/rustc_codegen_llvm/src/abi.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
422422
if let Conv::RiscvInterrupt { kind } = self.conv {
423423
func_attrs.push(llvm::CreateAttrStringValue(cx.llcx, "interrupt", kind.as_str()));
424424
}
425+
if let Conv::CCmseNonSecureEntry = self.conv {
426+
func_attrs.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry"))
427+
}
425428
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &{ func_attrs });
426429

427430
let mut i = 0;
@@ -661,9 +664,11 @@ impl<'tcx> AbiBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
661664
impl From<Conv> for llvm::CallConv {
662665
fn from(conv: Conv) -> Self {
663666
match conv {
664-
Conv::C | Conv::Rust | Conv::CCmseNonSecureCall | Conv::RiscvInterrupt { .. } => {
665-
llvm::CCallConv
666-
}
667+
Conv::C
668+
| Conv::Rust
669+
| Conv::CCmseNonSecureCall
670+
| Conv::CCmseNonSecureEntry
671+
| Conv::RiscvInterrupt { .. } => llvm::CCallConv,
667672
Conv::Cold => llvm::ColdCallConv,
668673
Conv::PreserveMost => llvm::PreserveMost,
669674
Conv::PreserveAll => llvm::PreserveAll,

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,7 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
12151215
| RiscvInterruptM
12161216
| RiscvInterruptS
12171217
| CCmseNonSecureCall
1218+
| CCmseNonSecureEntry
12181219
| Unadjusted => false,
12191220
Rust | RustCall | RustCold | RustIntrinsic => {
12201221
tcx.sess.panic_strategy() == PanicStrategy::Unwind

compiler/rustc_smir/src/rustc_internal/internal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ impl RustcInternal for Abi {
470470
Abi::AvrInterrupt => rustc_target::spec::abi::Abi::AvrInterrupt,
471471
Abi::AvrNonBlockingInterrupt => rustc_target::spec::abi::Abi::AvrNonBlockingInterrupt,
472472
Abi::CCmseNonSecureCall => rustc_target::spec::abi::Abi::CCmseNonSecureCall,
473+
Abi::CCmseNonSecureEntry => rustc_target::spec::abi::Abi::CCmseNonSecureEntry,
473474
Abi::System { unwind } => rustc_target::spec::abi::Abi::System { unwind },
474475
Abi::RustIntrinsic => rustc_target::spec::abi::Abi::RustIntrinsic,
475476
Abi::RustCall => rustc_target::spec::abi::Abi::RustCall,

compiler/rustc_smir/src/rustc_smir/convert/abi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl<'tcx> Stable<'tcx> for rustc_target::abi::call::Conv {
105105
Conv::PreserveAll => CallConvention::PreserveAll,
106106
Conv::ArmAapcs => CallConvention::ArmAapcs,
107107
Conv::CCmseNonSecureCall => CallConvention::CCmseNonSecureCall,
108+
Conv::CCmseNonSecureEntry => CallConvention::CCmseNonSecureEntry,
108109
Conv::Msp430Intr => CallConvention::Msp430Intr,
109110
Conv::PtxKernel => CallConvention::PtxKernel,
110111
Conv::X86Fastcall => CallConvention::X86Fastcall,

compiler/rustc_smir/src/rustc_smir/convert/ty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ impl<'tcx> Stable<'tcx> for rustc_target::spec::abi::Abi {
911911
abi::Abi::AvrInterrupt => Abi::AvrInterrupt,
912912
abi::Abi::AvrNonBlockingInterrupt => Abi::AvrNonBlockingInterrupt,
913913
abi::Abi::CCmseNonSecureCall => Abi::CCmseNonSecureCall,
914+
abi::Abi::CCmseNonSecureEntry => Abi::CCmseNonSecureEntry,
914915
abi::Abi::System { unwind } => Abi::System { unwind },
915916
abi::Abi::RustIntrinsic => Abi::RustIntrinsic,
916917
abi::Abi::RustCall => Abi::RustCall,

compiler/rustc_target/src/abi/call/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ pub enum Conv {
751751
// Target-specific calling conventions.
752752
ArmAapcs,
753753
CCmseNonSecureCall,
754+
CCmseNonSecureEntry,
754755

755756
Msp430Intr,
756757

@@ -945,6 +946,7 @@ impl FromStr for Conv {
945946
"RustCold" => Ok(Conv::Rust),
946947
"ArmAapcs" => Ok(Conv::ArmAapcs),
947948
"CCmseNonSecureCall" => Ok(Conv::CCmseNonSecureCall),
949+
"CCmseNonSecureEntry" => Ok(Conv::CCmseNonSecureEntry),
948950
"Msp430Intr" => Ok(Conv::Msp430Intr),
949951
"PtxKernel" => Ok(Conv::PtxKernel),
950952
"X86Fastcall" => Ok(Conv::X86Fastcall),

compiler/rustc_target/src/json.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ impl ToJson for crate::abi::call::Conv {
103103
Self::PreserveAll => "PreserveAll",
104104
Self::ArmAapcs => "ArmAapcs",
105105
Self::CCmseNonSecureCall => "CCmseNonSecureCall",
106+
Self::CCmseNonSecureEntry => "CCmseNonSecureEntry",
106107
Self::Msp430Intr => "Msp430Intr",
107108
Self::PtxKernel => "PtxKernel",
108109
Self::X86Fastcall => "X86Fastcall",

compiler/rustc_target/src/spec/abi/mod.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub enum Abi {
4848
AvrInterrupt,
4949
AvrNonBlockingInterrupt,
5050
CCmseNonSecureCall,
51+
CCmseNonSecureEntry,
5152
System {
5253
unwind: bool,
5354
},
@@ -122,6 +123,7 @@ const AbiDatas: &[AbiData] = &[
122123
AbiData { abi: Abi::AvrInterrupt, name: "avr-interrupt" },
123124
AbiData { abi: Abi::AvrNonBlockingInterrupt, name: "avr-non-blocking-interrupt" },
124125
AbiData { abi: Abi::CCmseNonSecureCall, name: "C-cmse-nonsecure-call" },
126+
AbiData { abi: Abi::CCmseNonSecureEntry, name: "C-cmse-nonsecure-entry" },
125127
AbiData { abi: Abi::System { unwind: false }, name: "system" },
126128
AbiData { abi: Abi::System { unwind: true }, name: "system-unwind" },
127129
AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic" },
@@ -242,6 +244,10 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
242244
feature: sym::abi_c_cmse_nonsecure_call,
243245
explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",
244246
}),
247+
"C-cmse-nonsecure-entry" => Err(AbiDisabled::Unstable {
248+
feature: sym::cmse_nonsecure_entry,
249+
explain: "C-cmse-nonsecure-entry ABI is experimental and subject to change",
250+
}),
245251
_ => Err(AbiDisabled::Unrecognized),
246252
}
247253
}
@@ -284,15 +290,16 @@ impl Abi {
284290
AvrInterrupt => 23,
285291
AvrNonBlockingInterrupt => 24,
286292
CCmseNonSecureCall => 25,
293+
CCmseNonSecureEntry => 26,
287294
// Cross-platform ABIs
288-
System { unwind: false } => 26,
289-
System { unwind: true } => 27,
290-
RustIntrinsic => 28,
291-
RustCall => 29,
292-
Unadjusted => 30,
293-
RustCold => 31,
294-
RiscvInterruptM => 32,
295-
RiscvInterruptS => 33,
295+
System { unwind: false } => 27,
296+
System { unwind: true } => 28,
297+
RustIntrinsic => 29,
298+
RustCall => 30,
299+
Unadjusted => 31,
300+
RustCold => 32,
301+
RiscvInterruptM => 33,
302+
RiscvInterruptS => 34,
296303
};
297304
debug_assert!(
298305
AbiDatas

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,7 @@ impl Target {
26742674
X86Interrupt => ["x86", "x86_64"].contains(&&self.arch[..]),
26752675
Aapcs { .. } => "arm" == self.arch,
26762676
CCmseNonSecureCall => ["arm", "aarch64"].contains(&&self.arch[..]),
2677+
CCmseNonSecureEntry => ["arm", "aarch64"].contains(&&self.arch[..]),
26772678
Win64 { .. } | SysV64 { .. } => self.arch == "x86_64",
26782679
PtxKernel => self.arch == "nvptx64",
26792680
Msp430Interrupt => self.arch == "msp430",

compiler/rustc_ty_utils/src/abi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv {
345345
SysV64 { .. } => Conv::X86_64SysV,
346346
Aapcs { .. } => Conv::ArmAapcs,
347347
CCmseNonSecureCall => Conv::CCmseNonSecureCall,
348+
CCmseNonSecureEntry => Conv::CCmseNonSecureEntry,
348349
PtxKernel => Conv::PtxKernel,
349350
Msp430Interrupt => Conv::Msp430Intr,
350351
X86Interrupt => Conv::X86Intr,

compiler/stable_mir/src/abi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ pub enum CallConvention {
433433
// Target-specific calling conventions.
434434
ArmAapcs,
435435
CCmseNonSecureCall,
436+
CCmseNonSecureEntry,
436437

437438
Msp430Intr,
438439

compiler/stable_mir/src/ty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ pub enum Abi {
10621062
AvrInterrupt,
10631063
AvrNonBlockingInterrupt,
10641064
CCmseNonSecureCall,
1065+
CCmseNonSecureEntry,
10651066
System { unwind: bool },
10661067
RustIntrinsic,
10671068
RustCall,

src/tools/rust-analyzer/crates/hir-ty/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ pub enum FnAbi {
374374
AvrNonBlockingInterrupt,
375375
C,
376376
CCmseNonsecureCall,
377+
CCmseNonsecureEntry,
377378
CDecl,
378379
CDeclUnwind,
379380
CUnwind,
@@ -431,6 +432,7 @@ impl FnAbi {
431432
s if *s == sym::avr_dash_interrupt => FnAbi::AvrInterrupt,
432433
s if *s == sym::avr_dash_non_dash_blocking_dash_interrupt => FnAbi::AvrNonBlockingInterrupt,
433434
s if *s == sym::C_dash_cmse_dash_nonsecure_dash_call => FnAbi::CCmseNonsecureCall,
435+
s if *s == sym::C_dash_cmse_dash_nonsecure_dash_entry => FnAbi::CCmseNonsecureEntry,
434436
s if *s == sym::C_dash_unwind => FnAbi::CUnwind,
435437
s if *s == sym::C => FnAbi::C,
436438
s if *s == sym::cdecl_dash_unwind => FnAbi::CDeclUnwind,
@@ -474,6 +476,7 @@ impl FnAbi {
474476
FnAbi::AvrNonBlockingInterrupt => "avr-non-blocking-interrupt",
475477
FnAbi::C => "C",
476478
FnAbi::CCmseNonsecureCall => "C-cmse-nonsecure-call",
479+
FnAbi::CCmseNonsecureEntry => "C-cmse-nonsecure-entry",
477480
FnAbi::CDecl => "C-decl",
478481
FnAbi::CDeclUnwind => "cdecl-unwind",
479482
FnAbi::CUnwind => "C-unwind",

src/tools/rust-analyzer/crates/ide-completion/src/completions/extern_abi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const SUPPORTED_CALLING_CONVENTIONS: &[&str] = &[
3232
"riscv-interrupt-m",
3333
"riscv-interrupt-s",
3434
"C-cmse-nonsecure-call",
35+
"C-cmse-nonsecure-entry",
3536
"wasm",
3637
"system",
3738
"system-unwind",

src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ define_symbols! {
9494
avr_dash_interrupt = "avr-interrupt",
9595
avr_dash_non_dash_blocking_dash_interrupt = "avr-non-blocking-interrupt",
9696
C_dash_cmse_dash_nonsecure_dash_call = "C-cmse-nonsecure-call",
97+
C_dash_cmse_dash_nonsecure_dash_entry = "C-cmse-nonsecure-entry",
9798
C_dash_unwind = "C-unwind",
9899
cdecl_dash_unwind = "cdecl-unwind",
99100
fastcall_dash_unwind = "fastcall-unwind",

tests/ui/print-calling-conventions.stdout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
C
22
C-cmse-nonsecure-call
3+
C-cmse-nonsecure-entry
34
C-unwind
45
Rust
56
aapcs

0 commit comments

Comments
 (0)