aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'macros/src/codegen/util.rs')
-rw-r--r--macros/src/codegen/util.rs148
1 files changed, 35 insertions, 113 deletions
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs
index 68aca5d1..2f9f3cce 100644
--- a/macros/src/codegen/util.rs
+++ b/macros/src/codegen/util.rs
@@ -2,7 +2,7 @@ use core::sync::atomic::{AtomicUsize, Ordering};
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::quote;
-use rtic_syntax::{ast::App, Context, Core};
+use rtic_syntax::{ast::App, Context};
use syn::{Attribute, Ident, LitInt, PatType};
use crate::check::Extra;
@@ -25,34 +25,15 @@ pub fn capacity_typenum(capacity: u8, round_up_to_power_of_two: bool) -> TokenSt
quote!(rtic::export::consts::#ident)
}
-/// Generates a `#[cfg(core = "0")]` attribute if we are in multi-core mode
-pub fn cfg_core(core: Core, cores: u8) -> Option<TokenStream2> {
- if cores == 1 {
- None
- } else if cfg!(feature = "heterogeneous") {
- let core = core.to_string();
- Some(quote!(#[cfg(core = #core)]))
- } else {
- None
- }
-}
-
/// Identifier for the free queue
-///
-/// There may be more than one free queue per task because we need one for each sender core so we
-/// include the sender (e.g. `S0`) in the name
-pub fn fq_ident(task: &Ident, sender: Core) -> Ident {
- Ident::new(
- &format!("{}_S{}_FQ", task.to_string(), sender),
- Span::call_site(),
- )
+pub fn fq_ident(task: &Ident) -> Ident {
+ Ident::new(&format!("{}_FQ", task.to_string()), Span::call_site())
}
/// Generates a `Mutex` implementation
pub fn impl_mutex(
extra: &Extra,
cfgs: &[Attribute],
- cfg_core: Option<&TokenStream2>,
resources_prefix: bool,
name: &Ident,
ty: TokenStream2,
@@ -68,7 +49,6 @@ pub fn impl_mutex(
let device = extra.device;
quote!(
#(#cfgs)*
- #cfg_core
impl<'a> rtic::Mutex for #path<'a> {
type T = #ty;
@@ -91,28 +71,19 @@ pub fn impl_mutex(
)
}
-/// Generates an identifier for a cross-initialization barrier
-pub fn init_barrier(initializer: Core) -> Ident {
- Ident::new(&format!("IB{}", initializer), Span::call_site())
-}
-
/// Generates an identifier for the `INPUTS` buffer (`spawn` & `schedule` API)
-pub fn inputs_ident(task: &Ident, sender: Core) -> Ident {
- Ident::new(&format!("{}_S{}_INPUTS", task, sender), Span::call_site())
+pub fn inputs_ident(task: &Ident) -> Ident {
+ Ident::new(&format!("{}_INPUTS", task), Span::call_site())
}
/// Generates an identifier for the `INSTANTS` buffer (`schedule` API)
-pub fn instants_ident(task: &Ident, sender: Core) -> Ident {
- Ident::new(&format!("{}_S{}_INSTANTS", task, sender), Span::call_site())
+pub fn instants_ident(task: &Ident) -> Ident {
+ Ident::new(&format!("{}_INSTANTS", task), Span::call_site())
}
-pub fn interrupt_ident(core: Core, cores: u8) -> Ident {
+pub fn interrupt_ident() -> Ident {
let span = Span::call_site();
- if cores == 1 {
- Ident::new("Interrupt", span)
- } else {
- Ident::new(&format!("Interrupt_{}", core), span)
- }
+ Ident::new("Interrupt", span)
}
/// Whether `name` is an exception with configurable priority
@@ -141,31 +112,12 @@ fn link_section_index() -> usize {
INDEX.fetch_add(1, Ordering::Relaxed)
}
-pub fn link_section(section: &str, core: Core) -> Option<TokenStream2> {
- if cfg!(feature = "homogeneous") {
- let section = format!(".{}_{}.rtic{}", section, core, link_section_index());
- Some(quote!(#[link_section = #section]))
- } else {
- None
- }
-}
-
// NOTE `None` means in shared memory
-pub fn link_section_uninit(core: Option<Core>) -> Option<TokenStream2> {
- let section = if let Some(core) = core {
+pub fn link_section_uninit(empty_expr: bool) -> Option<TokenStream2> {
+ let section = if empty_expr {
let index = link_section_index();
-
- if cfg!(feature = "homogeneous") {
- format!(".uninit_{}.rtic{}", core, index)
- } else {
- format!(".uninit.rtic{}", index)
- }
+ format!(".uninit.rtic{}", index)
} else {
- if cfg!(feature = "heterogeneous") {
- // `#[shared]` attribute sets the linker section
- return None;
- }
-
format!(".uninit.rtic{}", link_section_index())
};
@@ -175,8 +127,8 @@ pub fn link_section_uninit(core: Option<Core>) -> Option<TokenStream2> {
/// Generates a pre-reexport identifier for the "locals" struct
pub fn locals_ident(ctxt: Context, app: &App) -> Ident {
let mut s = match ctxt {
- Context::Init(core) => app.inits[&core].name.to_string(),
- Context::Idle(core) => app.idles[&core].name.to_string(),
+ Context::Init => app.inits.first().unwrap().name.to_string(),
+ Context::Idle => app.idles.first().unwrap().name.to_string(),
Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(),
};
@@ -185,11 +137,6 @@ pub fn locals_ident(ctxt: Context, app: &App) -> Ident {
Ident::new(&s, Span::call_site())
}
-/// Generates an identifier for a rendezvous barrier
-pub fn rendezvous_ident(core: Core) -> Ident {
- Ident::new(&format!("RV{}", core), Span::call_site())
-}
-
// Regroups the inputs of a task
//
// `inputs` could be &[`input: Foo`] OR &[`mut x: i32`, `ref y: i64`]
@@ -242,8 +189,8 @@ pub fn regroup_inputs(
/// Generates a pre-reexport identifier for the "resources" struct
pub fn resources_ident(ctxt: Context, app: &App) -> Ident {
let mut s = match ctxt {
- Context::Init(core) => app.inits[&core].name.to_string(),
- Context::Idle(core) => app.idles[&core].name.to_string(),
+ Context::Init => app.inits.first().unwrap().name.to_string(),
+ Context::Idle => app.idles.first().unwrap().name.to_string(),
Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(),
};
@@ -254,72 +201,47 @@ pub fn resources_ident(ctxt: Context, app: &App) -> Ident {
/// Generates an identifier for a ready queue
///
-/// Each core may have several task dispatchers, one for each priority level. Each task dispatcher
-/// in turn may use more than one ready queue because the queues are SPSC queues so one is needed
-/// per sender core.
-pub fn rq_ident(receiver: Core, priority: u8, sender: Core) -> Ident {
- Ident::new(
- &format!("R{}_P{}_S{}_RQ", receiver, priority, sender),
- Span::call_site(),
- )
+/// There may be several task dispatchers, one for each priority level.
+/// The ready queues are SPSC queues
+pub fn rq_ident(priority: u8) -> Ident {
+ Ident::new(&format!("P{}_RQ", priority), Span::call_site())
}
/// Generates an identifier for a "schedule" function
///
-/// The methods of the `Schedule` structs invoke these functions. As one task may be `schedule`-ed
-/// by different cores we need one "schedule" function per possible task-sender pair
-pub fn schedule_ident(name: &Ident, sender: Core) -> Ident {
- Ident::new(
- &format!("schedule_{}_S{}", name.to_string(), sender),
- Span::call_site(),
- )
+/// The methods of the `Schedule` structs invoke these functions.
+pub fn schedule_ident(name: &Ident) -> Ident {
+ Ident::new(&format!("schedule_{}", name.to_string()), Span::call_site())
}
/// Generates an identifier for the `enum` of `schedule`-able tasks
-pub fn schedule_t_ident(core: Core) -> Ident {
- Ident::new(&format!("T{}", core), Span::call_site())
-}
-
-/// Generates an identifier for a cross-spawn barrier
-pub fn spawn_barrier(receiver: Core) -> Ident {
- Ident::new(&format!("SB{}", receiver), Span::call_site())
+pub fn schedule_t_ident() -> Ident {
+ Ident::new(&format!("T"), Span::call_site())
}
/// Generates an identifier for a "spawn" function
///
-/// The methods of the `Spawn` structs invoke these functions. As one task may be `spawn`-ed by
-/// different cores we need one "spawn" function per possible task-sender pair
-pub fn spawn_ident(name: &Ident, sender: Core) -> Ident {
- Ident::new(
- &format!("spawn_{}_S{}", name.to_string(), sender),
- Span::call_site(),
- )
+/// The methods of the `Spawn` structs invoke these functions.
+pub fn spawn_ident(name: &Ident) -> Ident {
+ Ident::new(&format!("spawn_{}", name.to_string()), Span::call_site())
}
/// Generates an identifier for the `enum` of `spawn`-able tasks
///
/// This identifier needs the same structure as the `RQ` identifier because there's one ready queue
/// for each of these `T` enums
-pub fn spawn_t_ident(receiver: Core, priority: u8, sender: Core) -> Ident {
- Ident::new(
- &format!("R{}_P{}_S{}_T", receiver, priority, sender),
- Span::call_site(),
- )
+pub fn spawn_t_ident(priority: u8) -> Ident {
+ Ident::new(&format!("P{}_T", priority), Span::call_site())
}
-pub fn suffixed(name: &str, core: u8) -> Ident {
+pub fn suffixed(name: &str) -> Ident {
let span = Span::call_site();
-
- if cfg!(feature = "homogeneous") {
- Ident::new(&format!("{}_{}", name, core), span)
- } else {
- Ident::new(name, span)
- }
+ Ident::new(name, span)
}
/// Generates an identifier for a timer queue
///
-/// At most there's one timer queue per core
-pub fn tq_ident(core: Core) -> Ident {
- Ident::new(&format!("TQ{}", core), Span::call_site())
+/// At most there is one timer queue
+pub fn tq_ident() -> Ident {
+ Ident::new(&format!("TQ"), Span::call_site())
}