Skip to content

Commit 762cb47

Browse files
committed
add C-cmse-nonsecure-entry ABI
1 parent ee0fd6c commit 762cb47

File tree

22 files changed

+133
-14
lines changed

22 files changed

+133
-14
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
@@ -407,6 +407,9 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
407407
if let Conv::RiscvInterrupt { kind } = self.conv {
408408
func_attrs.push(llvm::CreateAttrStringValue(cx.llcx, "interrupt", kind.as_str()));
409409
}
410+
if let Conv::CCmseNonSecureEntry = self.conv {
411+
func_attrs.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry"))
412+
}
410413
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &{ func_attrs });
411414

412415
let mut i = 0;
@@ -606,9 +609,11 @@ impl<'tcx> AbiBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
606609
impl From<Conv> for llvm::CallConv {
607610
fn from(conv: Conv) -> Self {
608611
match conv {
609-
Conv::C | Conv::Rust | Conv::CCmseNonSecureCall | Conv::RiscvInterrupt { .. } => {
610-
llvm::CCallConv
611-
}
612+
Conv::C
613+
| Conv::Rust
614+
| Conv::CCmseNonSecureCall
615+
| Conv::CCmseNonSecureEntry
616+
| Conv::RiscvInterrupt { .. } => llvm::CCallConv,
612617
Conv::Cold => llvm::ColdCallConv,
613618
Conv::PreserveMost => llvm::PreserveMost,
614619
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
@@ -1212,6 +1212,7 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
12121212
| RiscvInterruptM
12131213
| RiscvInterruptS
12141214
| CCmseNonSecureCall
1215+
| CCmseNonSecureEntry
12151216
| Unadjusted => false,
12161217
Rust | RustCall | RustCold | RustIntrinsic => {
12171218
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
@@ -467,6 +467,7 @@ impl RustcInternal for Abi {
467467
Abi::AvrInterrupt => rustc_target::spec::abi::Abi::AvrInterrupt,
468468
Abi::AvrNonBlockingInterrupt => rustc_target::spec::abi::Abi::AvrNonBlockingInterrupt,
469469
Abi::CCmseNonSecureCall => rustc_target::spec::abi::Abi::CCmseNonSecureCall,
470+
Abi::CCmseNonSecureEntry => rustc_target::spec::abi::Abi::CCmseNonSecureEntry,
470471
Abi::System { unwind } => rustc_target::spec::abi::Abi::System { unwind },
471472
Abi::RustIntrinsic => rustc_target::spec::abi::Abi::RustIntrinsic,
472473
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
@@ -104,6 +104,7 @@ impl<'tcx> Stable<'tcx> for rustc_target::abi::call::Conv {
104104
Conv::PreserveAll => CallConvention::PreserveAll,
105105
Conv::ArmAapcs => CallConvention::ArmAapcs,
106106
Conv::CCmseNonSecureCall => CallConvention::CCmseNonSecureCall,
107+
Conv::CCmseNonSecureEntry => CallConvention::CCmseNonSecureEntry,
107108
Conv::Msp430Intr => CallConvention::Msp430Intr,
108109
Conv::PtxKernel => CallConvention::PtxKernel,
109110
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
@@ -909,6 +909,7 @@ impl<'tcx> Stable<'tcx> for rustc_target::spec::abi::Abi {
909909
abi::Abi::AvrInterrupt => Abi::AvrInterrupt,
910910
abi::Abi::AvrNonBlockingInterrupt => Abi::AvrNonBlockingInterrupt,
911911
abi::Abi::CCmseNonSecureCall => Abi::CCmseNonSecureCall,
912+
abi::Abi::CCmseNonSecureEntry => Abi::CCmseNonSecureEntry,
912913
abi::Abi::System { unwind } => Abi::System { unwind },
913914
abi::Abi::RustIntrinsic => Abi::RustIntrinsic,
914915
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
@@ -748,6 +748,7 @@ pub enum Conv {
748748
// Target-specific calling conventions.
749749
ArmAapcs,
750750
CCmseNonSecureCall,
751+
CCmseNonSecureEntry,
751752

752753
Msp430Intr,
753754

@@ -942,6 +943,7 @@ impl FromStr for Conv {
942943
"RustCold" => Ok(Conv::Rust),
943944
"ArmAapcs" => Ok(Conv::ArmAapcs),
944945
"CCmseNonSecureCall" => Ok(Conv::CCmseNonSecureCall),
946+
"CCmseNonSecureEntry" => Ok(Conv::CCmseNonSecureEntry),
945947
"Msp430Intr" => Ok(Conv::Msp430Intr),
946948
"PtxKernel" => Ok(Conv::PtxKernel),
947949
"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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,9 +1251,9 @@ impl StackProbeType {
12511251
.and_then(|o| o.as_array())
12521252
.ok_or_else(|| "expected `min-llvm-version-for-inline` to be an array")?;
12531253
let mut iter = min_version.into_iter().map(|v| {
1254-
let int = v.as_u64().ok_or_else(
1255-
|| "expected `min-llvm-version-for-inline` values to be integers",
1256-
)?;
1254+
let int = v.as_u64().ok_or_else(|| {
1255+
"expected `min-llvm-version-for-inline` values to be integers"
1256+
})?;
12571257
u32::try_from(int)
12581258
.map_err(|_| "`min-llvm-version-for-inline` values don't convert to u32")
12591259
});
@@ -2657,6 +2657,7 @@ impl Target {
26572657
X86Interrupt => ["x86", "x86_64"].contains(&&self.arch[..]),
26582658
Aapcs { .. } => "arm" == self.arch,
26592659
CCmseNonSecureCall => ["arm", "aarch64"].contains(&&self.arch[..]),
2660+
CCmseNonSecureEntry => ["arm", "aarch64"].contains(&&self.arch[..]),
26602661
Win64 { .. } | SysV64 { .. } => self.arch == "x86_64",
26612662
PtxKernel => self.arch == "nvptx64",
26622663
Msp430Interrupt => self.arch == "msp430",

0 commit comments

Comments
 (0)