Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanuppal committed Aug 7, 2024
1 parent 0e94687 commit 732d6e4
Show file tree
Hide file tree
Showing 21 changed files with 251 additions and 129 deletions.
6 changes: 3 additions & 3 deletions source/calyx_frontend/enum.Attribute.html

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions source/calyx_frontend/enum.BoolAttr.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions source/calyx_frontend/enum.InternalAttr.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions source/calyx_frontend/enum.NumAttr.html

Large diffs are not rendered by default.

162 changes: 81 additions & 81 deletions source/calyx_frontend/parser/enum.AliasedRule.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions source/calyx_ir/enum.Attribute.html

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions source/calyx_ir/enum.BoolAttr.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions source/calyx_ir/enum.InternalAttr.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions source/calyx_ir/enum.NumAttr.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions source/calyx_opt/passes/struct.StaticPromotion.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions source/calyx_opt/passes/struct.TopDownCompileControl.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions source/calyx_opt/passes/struct.WellFormed.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/calyx_opt/traversal/trait.ConstructVisitor.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/calyx_opt/traversal/trait.DiagnosticPass.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
fn <a href="#tymethod.diagnostics" class="fnname">diagnostics</a>(&amp;self) -&gt; &amp;<a class="struct" href="struct.DiagnosticContext.html" title="struct calyx_opt::traversal::DiagnosticContext">DiagnosticContext</a>;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A pass that implements reporting Diagnostics</p>
</div></details><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.diagnostics" class="method has-srclink"><a class="srclink rightside" href="../../src/calyx_opt/traversal/diagnostics.rs.html#8">source</a><h4 class="code-header">fn <a href="#tymethod.diagnostics" class="fnname">diagnostics</a>(&amp;self) -&gt; &amp;<a class="struct" href="struct.DiagnosticContext.html" title="struct calyx_opt::traversal::DiagnosticContext">DiagnosticContext</a></h4></section></summary><div class="docblock"><p>Return an iterator of the diagnostics gathered by this pass.</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"><section id="impl-DiagnosticPass-for-Papercut" class="impl has-srclink"><a class="srclink rightside" href="../../src/calyx_opt/passes/papercut.rs.html#107-111">source</a><a href="#impl-DiagnosticPass-for-Papercut" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.DiagnosticPass.html" title="trait calyx_opt::traversal::DiagnosticPass">DiagnosticPass</a> for <a class="struct" href="../passes/struct.Papercut.html" title="struct calyx_opt::passes::Papercut">Papercut</a></h3></section><section id="impl-DiagnosticPass-for-SynthesisPapercut" class="impl has-srclink"><a class="srclink rightside" href="../../src/calyx_opt/passes/synthesis_papercut.rs.html#64-68">source</a><a href="#impl-DiagnosticPass-for-SynthesisPapercut" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.DiagnosticPass.html" title="trait calyx_opt::traversal::DiagnosticPass">DiagnosticPass</a> for <a class="struct" href="../passes/struct.SynthesisPapercut.html" title="struct calyx_opt::passes::SynthesisPapercut">SynthesisPapercut</a></h3></section><section id="impl-DiagnosticPass-for-WellFormed" class="impl has-srclink"><a class="srclink rightside" href="../../src/calyx_opt/passes/well_formed.rs.html#222-226">source</a><a href="#impl-DiagnosticPass-for-WellFormed" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.DiagnosticPass.html" title="trait calyx_opt::traversal::DiagnosticPass">DiagnosticPass</a> for <a class="struct" href="../passes/struct.WellFormed.html" title="struct calyx_opt::passes::WellFormed">WellFormed</a></h3></section></div><script src="../../implementors/calyx_opt/traversal/diagnostics/trait.DiagnosticPass.js" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="calyx_opt" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0 (69f9c33d7 2022-12-12)" ></div></body></html>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"><section id="impl-DiagnosticPass-for-Papercut" class="impl has-srclink"><a class="srclink rightside" href="../../src/calyx_opt/passes/papercut.rs.html#107-111">source</a><a href="#impl-DiagnosticPass-for-Papercut" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.DiagnosticPass.html" title="trait calyx_opt::traversal::DiagnosticPass">DiagnosticPass</a> for <a class="struct" href="../passes/struct.Papercut.html" title="struct calyx_opt::passes::Papercut">Papercut</a></h3></section><section id="impl-DiagnosticPass-for-SynthesisPapercut" class="impl has-srclink"><a class="srclink rightside" href="../../src/calyx_opt/passes/synthesis_papercut.rs.html#64-68">source</a><a href="#impl-DiagnosticPass-for-SynthesisPapercut" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.DiagnosticPass.html" title="trait calyx_opt::traversal::DiagnosticPass">DiagnosticPass</a> for <a class="struct" href="../passes/struct.SynthesisPapercut.html" title="struct calyx_opt::passes::SynthesisPapercut">SynthesisPapercut</a></h3></section><section id="impl-DiagnosticPass-for-WellFormed" class="impl has-srclink"><a class="srclink rightside" href="../../src/calyx_opt/passes/well_formed.rs.html#223-227">source</a><a href="#impl-DiagnosticPass-for-WellFormed" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.DiagnosticPass.html" title="trait calyx_opt::traversal::DiagnosticPass">DiagnosticPass</a> for <a class="struct" href="../passes/struct.WellFormed.html" title="struct calyx_opt::passes::WellFormed">WellFormed</a></h3></section></div><script src="../../implementors/calyx_opt/traversal/diagnostics/trait.DiagnosticPass.js" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="calyx_opt" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0 (69f9c33d7 2022-12-12)" ></div></body></html>
2 changes: 1 addition & 1 deletion source/calyx_opt/traversal/trait.Named.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/calyx_opt/traversal/trait.Visitor.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions source/search-index.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions source/src/calyx_frontend/attribute.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@
<span id="244">244</span>
<span id="245">245</span>
<span id="246">246</span>
<span id="247">247</span>
<span id="248">248</span>
<span id="249">249</span>
<span id="250">250</span>
</pre><pre class="rust"><code><span class="kw">use </span>calyx_utils::{CalyxResult, Error, Id};
<span class="kw">use </span>std::str::FromStr;
<span class="kw">use </span>strum::EnumCount;
Expand Down Expand Up @@ -315,7 +319,11 @@
<span class="attribute">#[strum(serialize = <span class="string">&quot;promoted&quot;</span>)]
</span><span class="doccomment">/// denotes a static component or control promoted from dynamic
</span>Promoted,
<span class="attribute">#[strum(serialize = <span class="string">&quot;fast&quot;</span>)]
</span><span class="doccomment">/// https://github.com/calyxir/calyx/issues/1828
</span>Fast,
}

<span class="kw">impl </span>From&lt;BoolAttr&gt; <span class="kw">for </span>Attribute {
<span class="kw">fn </span>from(attr: BoolAttr) -&gt; <span class="self">Self </span>{
Attribute::Bool(attr)
Expand Down
14 changes: 13 additions & 1 deletion source/src/calyx_opt/passes/static_promotion.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,20 @@
<span id="681">681</span>
<span id="682">682</span>
<span id="683">683</span>
<span id="684">684</span>
<span id="685">685</span>
<span id="686">686</span>
<span id="687">687</span>
<span id="688">688</span>
<span id="689">689</span>
</pre><pre class="rust"><code><span class="kw">use </span><span class="kw">crate</span>::analysis::{
CompactionAnalysis, InferenceAnalysis, PromotionAnalysis,
};
<span class="kw">use </span><span class="kw">crate</span>::traversal::{
Action, ConstructVisitor, Named, Order, ParseVal, PassOpt, VisResult,
Visitor,
};
<span class="kw">use </span>calyx_ir::{<span class="self">self </span><span class="kw">as </span>ir, LibrarySignatures};
<span class="kw">use </span>calyx_ir::{<span class="self">self </span><span class="kw">as </span>ir, BoolAttr, LibrarySignatures};
<span class="kw">use </span>calyx_utils::CalyxResult;
<span class="kw">use </span>ir::GetAttributes;
<span class="kw">use </span>itertools::Itertools;
Expand Down Expand Up @@ -1173,6 +1179,12 @@
})
};
<span class="self">self</span>.inference_analysis.fixup_ctrl(<span class="kw-2">&amp;mut </span>new_ctrl);

<span class="comment">// this might be part of a larger issue where passes remove some attributes they shouldn&#39;t
</span><span class="kw">if </span>s.get_attributes().has(BoolAttr::Fast) {
new_ctrl.get_mut_attributes().insert(BoolAttr::Fast, <span class="number">1</span>);
}

<span class="prelude-val">Ok</span>(Action::change(new_ctrl))
}

Expand Down
28 changes: 24 additions & 4 deletions source/src/calyx_opt/passes/top_down_compile_control.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,16 @@
<span id="1458">1458</span>
<span id="1459">1459</span>
<span id="1460">1460</span>
<span id="1461">1461</span>
<span id="1462">1462</span>
<span id="1463">1463</span>
<span id="1464">1464</span>
<span id="1465">1465</span>
<span id="1466">1466</span>
<span id="1467">1467</span>
<span id="1468">1468</span>
<span id="1469">1469</span>
<span id="1470">1470</span>
</pre><pre class="rust"><code><span class="kw">use </span><span class="kw">super</span>::math_utilities::get_bit_width_from;
<span class="kw">use </span><span class="kw">crate</span>::passes;
<span class="kw">use </span><span class="kw">crate</span>::traversal::{
Expand Down Expand Up @@ -2171,6 +2181,8 @@
</span>preds: Vec&lt;PredEdge&gt;,
<span class="comment">// True if early_transitions are allowed
</span>early_transitions: bool,
<span class="comment">// True if the `@fast` attribute has successfully been applied to the parent of this control
</span>has_fast_guarantee: bool,
) -&gt; CalyxResult&lt;Vec&lt;PredEdge&gt;&gt; {
<span class="kw">match </span>con {
<span class="comment">// See explanation of FSM states generated in [ir::TopDownCompileControl].
Expand Down Expand Up @@ -2206,7 +2218,7 @@
// NOTE: We explicilty do not add `not_done` to the guard.
// See explanation in [ir::TopDownCompileControl] to understand
// why.
</span><span class="kw">if </span>early_transitions {
</span><span class="kw">if </span>early_transitions || has_fast_guarantee {
<span class="kw">for </span>(st, g) <span class="kw">in </span><span class="kw-2">&amp;</span>prev_states {
<span class="kw">let </span>early_go = <span class="macro">build_assignments!</span>(<span class="self">self</span>.builder;
group[<span class="string">&quot;go&quot;</span>] = g <span class="question-mark">? </span>signal_on[<span class="string">&quot;out&quot;</span>];
Expand Down Expand Up @@ -2253,9 +2265,13 @@
</span>early_transitions: bool,
) -&gt; CalyxResult&lt;Vec&lt;PredEdge&gt;&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>prev = preds;
<span class="kw">for </span>stmt <span class="kw">in </span><span class="kw-2">&amp;</span>seq.stmts {
prev =
<span class="self">self</span>.calculate_states_recur(stmt, prev, early_transitions)<span class="question-mark">?</span>;
<span class="kw">for </span>(i, stmt) <span class="kw">in </span>seq.stmts.iter().enumerate() {
prev = <span class="self">self</span>.calculate_states_recur(
stmt,
prev,
early_transitions,
i &gt; <span class="number">0 </span>&amp;&amp; seq.get_attributes().has(BoolAttr::Fast),
)<span class="question-mark">?</span>;
}
<span class="prelude-val">Ok</span>(prev)
}
Expand Down Expand Up @@ -2288,6 +2304,7 @@
<span class="kw-2">&amp;</span>if_stmt.tbranch,
tru_transitions,
early_transitions,
<span class="bool-val">false</span>,
)<span class="question-mark">?</span>;
<span class="comment">// Previous states transitioning into false branch need the conditional
// to be false.
Expand All @@ -2305,6 +2322,7 @@
<span class="kw-2">&amp;</span>if_stmt.fbranch,
fal_transitions,
early_transitions,
<span class="bool-val">false</span>,
)<span class="question-mark">?
</span>};

Expand Down Expand Up @@ -2347,6 +2365,7 @@
<span class="kw-2">&amp;</span>while_stmt.body,
transitions,
early_transitions,
<span class="bool-val">false</span>,
)<span class="question-mark">?</span>;

<span class="comment">// Step 3: The final out edges from the while come from:
Expand Down Expand Up @@ -2451,6 +2470,7 @@
con,
<span class="macro">vec!</span>[first_state],
early_transitions,
<span class="bool-val">false</span>,
)<span class="question-mark">?</span>;
<span class="self">self</span>.add_nxt_transition(prev);
<span class="prelude-val">Ok</span>(())
Expand Down
78 changes: 78 additions & 0 deletions source/src/calyx_opt/passes/well_formed.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,52 @@
<span id="880">880</span>
<span id="881">881</span>
<span id="882">882</span>
<span id="883">883</span>
<span id="884">884</span>
<span id="885">885</span>
<span id="886">886</span>
<span id="887">887</span>
<span id="888">888</span>
<span id="889">889</span>
<span id="890">890</span>
<span id="891">891</span>
<span id="892">892</span>
<span id="893">893</span>
<span id="894">894</span>
<span id="895">895</span>
<span id="896">896</span>
<span id="897">897</span>
<span id="898">898</span>
<span id="899">899</span>
<span id="900">900</span>
<span id="901">901</span>
<span id="902">902</span>
<span id="903">903</span>
<span id="904">904</span>
<span id="905">905</span>
<span id="906">906</span>
<span id="907">907</span>
<span id="908">908</span>
<span id="909">909</span>
<span id="910">910</span>
<span id="911">911</span>
<span id="912">912</span>
<span id="913">913</span>
<span id="914">914</span>
<span id="915">915</span>
<span id="916">916</span>
<span id="917">917</span>
<span id="918">918</span>
<span id="919">919</span>
<span id="920">920</span>
<span id="921">921</span>
</pre><pre class="rust"><code><span class="kw">use </span><span class="kw">crate</span>::traversal::{Action, ConstructVisitor, Named, VisResult, Visitor};
<span class="kw">use </span><span class="kw">crate</span>::traversal::{DiagnosticContext, DiagnosticPass, DiagnosticResult};
<span class="kw">use </span>calyx_ir::{
<span class="self">self </span><span class="kw">as </span>ir, Cell, CellType, Component, GetAttributes, LibrarySignatures,
RESERVED_NAMES,
};
<span class="kw">use </span>calyx_ir::{BoolAttr, Seq};
<span class="kw">use </span>calyx_utils::{CalyxResult, Error, WithPos};
<span class="kw">use </span>ir::Nothing;
<span class="kw">use </span>ir::StaticTiming;
Expand Down Expand Up @@ -1164,6 +1204,30 @@
<span class="bool-val">true
</span>}

<span class="doccomment">/// Confirms (in agreement with [this discussion](https://github.com/calyxir/calyx/issues/1828))
/// that the `@fast` sequence `seq` is composed of alternating static-dynamic controls.
</span><span class="kw">fn </span>check_fast_seq_invariant(seq: <span class="kw-2">&amp;</span>Seq) -&gt; CalyxResult&lt;()&gt; {
<span class="kw">if </span>seq.stmts.is_empty() {
<span class="kw">return </span><span class="prelude-val">Ok</span>(());
}
<span class="kw">let </span><span class="kw-2">mut </span>last_is_static = seq
.stmts
.first()
.expect(<span class="string">&quot;non-empty already asserted&quot;</span>)
.is_static();
<span class="kw">for </span>stmt <span class="kw">in </span>seq.stmts.iter().skip(<span class="number">1</span>) {
<span class="kw">if </span>stmt.is_static() == last_is_static {
<span class="kw">return </span><span class="prelude-val">Err</span>(
Error::malformed_control(
<span class="string">&quot;`seq` marked `@fast` does not contain alternating static-dynamic control children (see #1828)&quot;
</span>)
);
}
last_is_static = stmt.is_static();
}
<span class="prelude-val">Ok</span>(())
}

<span class="kw">impl </span>Visitor <span class="kw">for </span>WellFormed {
<span class="kw">fn </span>start(
<span class="kw-2">&amp;mut </span><span class="self">self</span>,
Expand Down Expand Up @@ -1623,6 +1687,20 @@
<span class="prelude-val">Ok</span>(Action::Continue)
}

<span class="kw">fn </span>start_seq(
<span class="kw-2">&amp;mut </span><span class="self">self</span>,
s: <span class="kw-2">&amp;mut </span>calyx_ir::Seq,
_comp: <span class="kw-2">&amp;mut </span>Component,
_sigs: <span class="kw-2">&amp;</span>LibrarySignatures,
_comps: <span class="kw-2">&amp;</span>[calyx_ir::Component],
) -&gt; VisResult {
<span class="kw">if </span>s.attributes.has(BoolAttr::Fast) {
check_fast_seq_invariant(s)<span class="question-mark">?</span>;
}

<span class="prelude-val">Ok</span>(Action::Continue)
}

<span class="kw">fn </span>finish_if(
<span class="kw-2">&amp;mut </span><span class="self">self</span>,
s: <span class="kw-2">&amp;mut </span>ir::If,
Expand Down

0 comments on commit 732d6e4

Please sign in to comment.