use proc_macro2::TokenStream as TokenStream2; use quote::quote; use rtic_syntax::{ast::App, Context}; use crate::{ analyze::Analysis, check::Extra, codegen::{locals, module, resources_struct, util}, }; pub fn codegen( app: &App, analysis: &Analysis, extra: &Extra, ) -> ( // const_app_software_tasks -- free queues, buffers and `${task}Resources` constructors Vec, // root_software_tasks -- items that must be placed in the root of the crate: // - `${task}Locals` structs // - `${task}Resources` structs // - `${task}` modules Vec, // user_software_tasks -- the `#[task]` functions written by the user Vec, ) { let mut const_app = vec![]; let mut root = vec![]; let mut user_tasks = vec![]; for (name, task) in &app.software_tasks { let receiver = task.args.core; let inputs = &task.inputs; let (_, _, _, input_ty) = util::regroup_inputs(inputs); let cap = task.args.capacity; let cap_lit = util::capacity_literal(cap); let cap_ty = util::capacity_typenum(cap, true); // create free queues and inputs / instants buffers if let Some(free_queues) = analysis.free_queues.get(name) { for (&sender, &ceiling) in free_queues { let cfg_sender = util::cfg_core(sender, app.args.cores); let fq = util::fq_ident(name, sender); let (loc, fq_ty, fq_expr, bss, mk_uninit): ( _, _, _, _, Box Option<_>>, ) = if receiver == sender { ( cfg_sender.clone(), quote!(rtic::export::SCFQ<#cap_ty>), quote!(rtic::export::Queue(unsafe { rtic::export::iQueue::u8_sc() })), util::link_section("bss", sender), Box::new(|| util::link_section_uninit(Some(sender))), ) } else { let shared = if cfg!(feature = "heterogeneous") { Some(quote!(#[rtic::export::shared])) } else { None }; ( shared, quote!(rtic::export::MCFQ<#cap_ty>), quote!(rtic::export::Queue(rtic::export::iQueue::u8())), None, Box::new(|| util::link_section_uninit(None)), ) }; let loc = &loc; const_app.push(quote!( /// Queue version of a free-list that keeps track of empty slots in /// the following buffers #loc #bss static mut #fq: #fq_ty = #fq_expr; )); // Generate a resource proxy if needed if let Some(ceiling) = ceiling { const_app.push(quote!( #cfg_sender struct #fq<'a> { priority: &'a rtic::export::Priority, } )); const_app.push(util::impl_mutex( extra, &[], cfg_sender.as_ref(), false, &fq, fq_ty, ceiling, quote!(&mut #fq), )); } let ref elems = (0..cap) .map(|_| quote!(core::mem::MaybeUninit::uninit())) .collect::>(); if app.uses_schedule(receiver) { let m = extra.monotonic(); let instants = util::instants_ident(name, sender); let uninit = mk_uninit(); const_app.push(quote!( #loc #uninit /// Buffer that holds the instants associated to the inputs of a task static mut #instants: [core::mem::MaybeUninit<<#m as rtic::Monotonic>::Instant>; #cap_lit] = [#(#elems,)*]; )); } let uninit = mk_uninit(); let inputs = util::inputs_ident(name, sender); const_app.push(quote!( #loc #uninit /// Buffer that holds the inputs of a task static mut #inputs: [core::mem::MaybeUninit<#input_ty>; #cap_lit] = [#(#elems,)*]; )); } } // `${task}Resources` let mut needs_lt = false; if !task.args.resources.is_empty() { let (item, constructor) = resources_struct::codegen( Context::SoftwareTask(name), task.args.priority, &mut needs_lt, app, analysis, ); root.push(item); const_app.push(constructor); } // `${task}Locals` let mut locals_pat = None; if !task.locals.is_empty() { let (struct_, pat) = locals::codegen(Context::SoftwareTask(name), &task.locals, receiver, app); locals_pat = Some(pat); root.push(struct_); } let cfg_receiver = util::cfg_core(receiver, app.args.cores); let section = util::link_section("text", receiver); let context = &task.context; let attrs = &task.attrs; let cfgs = &task.cfgs; let stmts = &task.stmts; let locals_pat = locals_pat.iter(); user_tasks.push(quote!( #(#attrs)* #(#cfgs)* #[allow(non_snake_case)] #cfg_receiver #section fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) { use rtic::Mutex as _; #(#stmts)* } )); root.push(module::codegen( Context::SoftwareTask(name), needs_lt, app, extra, )); } (const_app, root, user_tasks) } -astro-replace-component-selector-with-astro-add'>feat/create-astro-replace-component-selector-with-astro-add Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2022-08-26chore: update readme to include alpine js integration (#4498)Gravatar Abdullah Mzaien 1-0/+1
2022-08-26Update astro check to use latest version of the language server (#4500)Gravatar Erika 3-50/+57
2022-08-26Vendor Vite's importMeta.d.ts inside our repo to workaround issue with `tsc` ...Gravatar Erika 3-1/+43
2022-08-26Only print file output only for 404 and 500 routes (#4497)Gravatar Ben Holmes 2-5/+9
2022-08-26[ci] formatGravatar matthewp 1-14/+9
2022-08-26chore: update to solid 1.5 (#4496)Gravatar Abdullah Mzaien 3-4/+17
2022-08-26Exit prerelease mode for 1.1 release (#4493)Gravatar Matthew Phillips 1-1/+1
2022-08-26Remove "as Props" from the astro examples (#4494)Gravatar Mohammed Elhaouari 8-8/+8
2022-08-26[ci] update lockfile (#4492)Gravatar Fred K. Bot 1-33/+41
2022-08-26Edit Alpinejs content generation for Docs (#4466)Gravatar Mark Spratt 1-6/+5
2022-08-26Note private env var handling with cloudflare builds (#4490)Gravatar Bjorn Lu 1-0/+14
2022-08-26Bump pnpm version (#4488)Gravatar Bjorn Lu 1-2/+2
2022-08-26Update blog.astro (#4486)Gravatar Peter Singh 1-2/+2
2022-08-25Earlier import snippet for `@astrojs/image` (#4484)Gravatar Tc001 1-0/+6
2022-08-25[ci] release (next) (#4480)create-astro@1.0.1-next.0astro@1.1.0-next.0@astrojs/react@1.1.0-next.0@astrojs/mdx@0.10.2-next.0@astrojs/markdown-remark@1.1.0-next.0Gravatar Fred K. Bot 38-76/+133
2022-08-25[ci] formatGravatar matthewp 2-11/+12
2022-08-25[MD] `extendDefaultPlugins` to preserve default remark plugins (#4474)Gravatar Ben Holmes 10-31/+100
2022-08-25Update Markdown type signature to match behavior (#4423)Gravatar Ben Holmes 8-15/+60
2022-08-25[ci] formatGravatar matthewp 1-2/+2
2022-08-25make Remark rehype options available in astro config (#4138)Gravatar gtnbssn 9-1/+108
2022-08-25[ci] formatGravatar matthewp 3-48/+60
2022-08-25Make Astro.url conform to build.format during the build (#4352)Gravatar Matthew Phillips 8-3/+108
2022-08-25[ci] formatGravatar matthewp 1-1/+1
2022-08-25Add template tsconfigs for users to extend from (#4439)Gravatar Erika 33-343/+119
2022-08-25Make astro package play nice with node16 module resolution (#4182)Gravatar Aleksander Heintz 5-13/+21