aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/util.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2019-06-18 10:31:31 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2019-06-18 10:31:31 +0200
commit9897728709528a02545523bea72576abce89dc4c (patch)
tree49619bfb8e3e09cccbc9c2bd1854abfe1618c8fd /macros/src/codegen/util.rs
parent81275bfa4f41e2066770087f3a33cad4227eab41 (diff)
downloadrtic-9897728709528a02545523bea72576abce89dc4c.tar.gz
rtic-9897728709528a02545523bea72576abce89dc4c.tar.zst
rtic-9897728709528a02545523bea72576abce89dc4c.zip
add homogeneous multi-core support
Diffstat (limited to 'macros/src/codegen/util.rs')
-rw-r--r--macros/src/codegen/util.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs
index 203fcee8..8c43b350 100644
--- a/macros/src/codegen/util.rs
+++ b/macros/src/codegen/util.rs
@@ -27,9 +27,11 @@ pub fn capacity_typenum(capacity: u8, round_up_to_power_of_two: bool) -> TokenSt
pub fn cfg_core(core: Core, cores: u8) -> Option<TokenStream2> {
if cores == 1 {
None
- } else {
+ } else if cfg!(feature = "heterogeneous") {
let core = core.to_string();
Some(quote!(#[cfg(core = #core)]))
+ } else {
+ None
}
}
@@ -102,6 +104,15 @@ pub fn instants_ident(task: &Ident, sender: Core) -> Ident {
Ident::new(&format!("{}_S{}_INSTANTS", task, sender), Span::call_site())
}
+pub fn interrupt_ident(core: Core, cores: u8) -> Ident {
+ let span = Span::call_site();
+ if cores == 1 {
+ Ident::new("Interrupt", span)
+ } else {
+ Ident::new(&format!("Interrupt_{}", core), span)
+ }
+}
+
/// Generates a pre-reexport identifier for the "late resources" struct
pub fn late_resources_ident(init: &Ident) -> Ident {
Ident::new(
@@ -245,6 +256,16 @@ pub fn spawn_t_ident(receiver: Core, priority: u8, sender: Core) -> Ident {
)
}
+pub fn suffixed(name: &str, core: u8) -> Ident {
+ let span = Span::call_site();
+
+ if cfg!(feature = "homogeneous") {
+ Ident::new(&format!("{}_{}", name, core), span)
+ } else {
+ Ident::new(name, span)
+ }
+}
+
/// Generates an identifier for a timer queue
///
/// At most there's one timer queue per core