forked from M-Labs/nac3
artiq: Fix timeline not resetting upon exiting sequential block
This commit is contained in:
parent
cbd333ab10
commit
9518d3fe14
|
@ -50,7 +50,14 @@ impl<'a> ArtiqCodeGenerator<'a> {
|
||||||
timeline: &'a (dyn TimeFns + Sync),
|
timeline: &'a (dyn TimeFns + Sync),
|
||||||
) -> ArtiqCodeGenerator<'a> {
|
) -> ArtiqCodeGenerator<'a> {
|
||||||
assert!(size_t == 32 || size_t == 64);
|
assert!(size_t == 32 || size_t == 64);
|
||||||
ArtiqCodeGenerator { name, size_t, name_counter: 0, start: None, end: None, timeline }
|
ArtiqCodeGenerator {
|
||||||
|
name,
|
||||||
|
size_t,
|
||||||
|
name_counter: 0,
|
||||||
|
start: None,
|
||||||
|
end: None,
|
||||||
|
timeline,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the generator is currently in a direct-`parallel` block context, emits IR that resets the
|
/// If the generator is currently in a direct-`parallel` block context, emits IR that resets the
|
||||||
|
@ -82,10 +89,14 @@ impl<'a> ArtiqCodeGenerator<'a> {
|
||||||
///
|
///
|
||||||
/// `parallel`-block context refers to when the generator is generating statements within a
|
/// `parallel`-block context refers to when the generator is generating statements within a
|
||||||
/// (possibly indirect) `parallel` block.
|
/// (possibly indirect) `parallel` block.
|
||||||
|
///
|
||||||
|
/// * `store_name` - The LLVM value name for the pointer to `end`. `.addr` will be appended to
|
||||||
|
/// the end of the provided value name.
|
||||||
fn timeline_update_end_max<'ctx, 'b>(
|
fn timeline_update_end_max<'ctx, 'b>(
|
||||||
&mut self,
|
&mut self,
|
||||||
ctx: &mut CodeGenContext<'ctx, 'b>,
|
ctx: &mut CodeGenContext<'ctx, 'b>,
|
||||||
end: Option<Expr<Option<Type>>>,
|
end: Option<Expr<Option<Type>>>,
|
||||||
|
store_name: Option<&str>,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
if let Some(end) = end {
|
if let Some(end) = end {
|
||||||
let old_end = self.gen_expr(ctx, &end)?
|
let old_end = self.gen_expr(ctx, &end)?
|
||||||
|
@ -106,7 +117,10 @@ impl<'a> ArtiqCodeGenerator<'a> {
|
||||||
.try_as_basic_value()
|
.try_as_basic_value()
|
||||||
.left()
|
.left()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let end_store = self.gen_store_target(ctx, &end, Some(""))?;
|
let end_store = self.gen_store_target(
|
||||||
|
ctx,
|
||||||
|
&end,
|
||||||
|
store_name.map(|name| format!("{name}.addr")).as_deref())?;
|
||||||
ctx.builder.build_store(end_store, max);
|
ctx.builder.build_store(end_store, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +150,7 @@ impl<'b> CodeGenerator for ArtiqCodeGenerator<'b> {
|
||||||
) -> Result<Option<BasicValueEnum<'ctx>>, String> {
|
) -> Result<Option<BasicValueEnum<'ctx>>, String> {
|
||||||
let result = gen_call(self, ctx, obj, fun, params)?;
|
let result = gen_call(self, ctx, obj, fun, params)?;
|
||||||
|
|
||||||
self.timeline_update_end_max(ctx, self.end.clone())?;
|
self.timeline_update_end_max(ctx, self.end.clone(), Some("end"))?;
|
||||||
self.timeline_reset_start(ctx)?;
|
self.timeline_reset_start(ctx)?;
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
@ -242,7 +256,7 @@ impl<'b> CodeGenerator for ArtiqCodeGenerator<'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// inside a parallel block, should update the outer max now_mu
|
// inside a parallel block, should update the outer max now_mu
|
||||||
self.timeline_update_end_max(ctx, old_end.clone())?;
|
self.timeline_update_end_max(ctx, old_end.clone(), Some("outer.end"))?;
|
||||||
|
|
||||||
self.start = old_start;
|
self.start = old_start;
|
||||||
self.end = old_end;
|
self.end = old_end;
|
||||||
|
@ -257,6 +271,9 @@ impl<'b> CodeGenerator for ArtiqCodeGenerator<'b> {
|
||||||
gen_block(self, ctx, body.iter())?;
|
gen_block(self, ctx, body.iter())?;
|
||||||
self.start = start;
|
self.start = start;
|
||||||
|
|
||||||
|
// Reset the timeline when we are exiting the sequential block
|
||||||
|
self.timeline_reset_start(ctx)?;
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue