nac3artiq: share isa->time_fns map

This commit is contained in:
Sebastien Bourdeauducq 2021-11-01 00:03:15 +08:00
parent 083eacc268
commit b37cf6de08
1 changed files with 3 additions and 5 deletions

View File

@ -57,6 +57,7 @@ pub struct PrimitivePythonId {
#[pyclass(unsendable, name = "NAC3")] #[pyclass(unsendable, name = "NAC3")]
struct Nac3 { struct Nac3 {
isa: Isa, isa: Isa,
time_fns: &'static (dyn TimeFns + Sync),
primitive: PrimitiveStore, primitive: PrimitiveStore,
builtins_ty: HashMap<StrRef, Type>, builtins_ty: HashMap<StrRef, Type>,
builtins_def: HashMap<StrRef, DefinitionId>, builtins_def: HashMap<StrRef, DefinitionId>,
@ -284,6 +285,7 @@ impl Nac3 {
Ok(Nac3 { Ok(Nac3 {
isa, isa,
time_fns,
primitive, primitive,
builtins_ty, builtins_ty,
builtins_def, builtins_def,
@ -438,14 +440,10 @@ impl Nac3 {
) )
.expect("couldn't write module to file"); .expect("couldn't write module to file");
}))); })));
let time_fns: &(dyn TimeFns + Sync) = match isa {
Isa::RiscV => &timeline::NOW_PINNING_TIME_FNS,
Isa::CortexA9 => &timeline::EXTERN_TIME_FNS,
};
let thread_names: Vec<String> = (0..4).map(|i| format!("module{}", i)).collect(); let thread_names: Vec<String> = (0..4).map(|i| format!("module{}", i)).collect();
let threads: Vec<_> = thread_names let threads: Vec<_> = thread_names
.iter() .iter()
.map(|s| Box::new(ArtiqCodeGenerator::new(s.to_string(), time_fns))) .map(|s| Box::new(ArtiqCodeGenerator::new(s.to_string(), self.time_fns)))
.collect(); .collect();
py.allow_threads(|| { py.allow_threads(|| {