Skip to content

Commit

Permalink
deploy: 13a4fd8
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe committed Feb 17, 2024
1 parent ca94a5a commit a5169ec
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 88 deletions.
2 changes: 1 addition & 1 deletion src-files.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/melior_macro/dialect.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<span class="kw">mod </span>input;
<span class="kw">mod </span>operation;
<span class="kw">mod </span>r#trait;
<span class="kw">mod </span>types;
<span class="kw">mod </span>r#type;
<span class="kw">mod </span>utility;

<span class="kw">use </span><span class="self">self</span>::{
Expand Down
20 changes: 10 additions & 10 deletions src/melior_macro/dialect/operation.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@
<span class="kw">use </span><span class="kw">crate</span>::dialect::{
error::{Error, OdsError},
r#trait::Trait,
types::TypeConstraint,
r#type::Type,
};
<span class="kw">pub use </span>operation_field::OperationField;
<span class="kw">use </span>tblgen::{error::WithLocation, record::Record, TypedInit};
Expand Down Expand Up @@ -627,7 +627,7 @@
<span class="self">Self</span>::collect_elements(
<span class="kw-2">&amp;</span><span class="self">Self</span>::dag_constraints(definition, <span class="string">"results"</span>)<span class="question-mark">?
</span>.into_iter()
.map(|(name, constraint)| (name, TypeConstraint::new(constraint)))
.map(|(name, constraint)| (name, Type::new(constraint)))
.collect::&lt;Vec&lt;<span class="kw">_</span>&gt;&gt;(),
OperationResult::new,
same_size,
Expand All @@ -644,7 +644,7 @@
<span class="kw-2">&amp;</span>arguments
.iter()
.filter(|(<span class="kw">_</span>, definition)| definition.subclass_of(<span class="string">"TypeConstraint"</span>))
.map(|(name, definition)| (<span class="kw-2">*</span>name, TypeConstraint::new(<span class="kw-2">*</span>definition)))
.map(|(name, definition)| (<span class="kw-2">*</span>name, Type::new(<span class="kw-2">*</span>definition)))
.collect::&lt;Vec&lt;<span class="kw">_</span>&gt;&gt;(),
Operand::new,
same_size,
Expand All @@ -654,24 +654,24 @@
}

<span class="kw">fn </span>collect_elements&lt;T&gt;(
elements: <span class="kw-2">&amp;</span>[(<span class="kw-2">&amp;</span><span class="lifetime">'a </span>str, TypeConstraint&lt;<span class="lifetime">'a</span>&gt;)],
create: <span class="kw">impl </span>Fn(<span class="kw-2">&amp;</span><span class="lifetime">'a </span>str, TypeConstraint&lt;<span class="lifetime">'a</span>&gt;, VariadicKind) -&gt; <span class="prelude-ty">Result</span>&lt;T, Error&gt;,
elements: <span class="kw-2">&amp;</span>[(<span class="kw-2">&amp;</span><span class="lifetime">'a </span>str, Type)],
create: <span class="kw">impl </span>Fn(<span class="kw-2">&amp;</span><span class="lifetime">'a </span>str, Type, VariadicKind) -&gt; <span class="prelude-ty">Result</span>&lt;T, Error&gt;,
same_size: bool,
attribute_sized: bool,
) -&gt; <span class="prelude-ty">Result</span>&lt;(Vec&lt;T&gt;, usize), Error&gt; {
<span class="kw">let </span>unfixed_count = elements
.iter()
.filter(|(<span class="kw">_</span>, constraint)| constraint.is_unfixed())
.filter(|(<span class="kw">_</span>, r#type)| r#type.is_unfixed())
.count();
<span class="kw">let </span><span class="kw-2">mut </span>variadic_kind = VariadicKind::new(unfixed_count, same_size, attribute_sized);
<span class="kw">let </span><span class="kw-2">mut </span>fields = <span class="macro">vec!</span>[];

<span class="kw">for </span>(name, constraint) <span class="kw">in </span>elements {
fields.push(create(name, <span class="kw-2">*</span>constraint, variadic_kind.clone())<span class="question-mark">?</span>);
<span class="kw">for </span>(name, r#type) <span class="kw">in </span>elements {
fields.push(create(name, <span class="kw-2">*</span>r#type, variadic_kind.clone())<span class="question-mark">?</span>);

<span class="kw">match </span><span class="kw-2">&amp;mut </span>variadic_kind {
VariadicKind::Simple { unfixed_seen } =&gt; {
<span class="kw">if </span>constraint.is_unfixed() {
<span class="kw">if </span>r#type.is_unfixed() {
<span class="kw-2">*</span>unfixed_seen = <span class="bool-val">true</span>;
}
}
Expand All @@ -680,7 +680,7 @@
preceding_variadic_count,
..
} =&gt; {
<span class="kw">if </span>constraint.is_unfixed() {
<span class="kw">if </span>r#type.is_unfixed() {
<span class="kw-2">*</span>preceding_variadic_count += <span class="number">1</span>;
} <span class="kw">else </span>{
<span class="kw-2">*</span>preceding_simple_count += <span class="number">1</span>;
Expand Down
18 changes: 9 additions & 9 deletions src/melior_macro/dialect/operation/operand.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
</pre></div><pre class="rust"><code><span class="kw">use super</span>::{OperationElement, OperationField, VariadicKind};
<span class="kw">use </span><span class="kw">crate</span>::dialect::{
error::Error,
types::TypeConstraint,
r#type::Type <span class="kw">as </span>ElementType,
utility::{generate_iterator_type, generate_result_type, sanitize_snake_case_identifier},
};
<span class="kw">use </span>proc_macro2::{Ident, TokenStream};
Expand All @@ -107,20 +107,20 @@
</span><span class="kw">pub struct </span>Operand&lt;<span class="lifetime">'a</span>&gt; {
name: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>str,
singular_identifier: Ident,
constraint: TypeConstraint&lt;<span class="lifetime">'a</span>&gt;,
r#type: ElementType,
variadic_kind: VariadicKind,
}

<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; Operand&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">pub fn </span>new(
name: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>str,
constraint: TypeConstraint&lt;<span class="lifetime">'a</span>&gt;,
r#type: ElementType,
variadic_kind: VariadicKind,
) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, Error&gt; {
<span class="prelude-val">Ok</span>(<span class="self">Self </span>{
name,
singular_identifier: sanitize_snake_case_identifier(name)<span class="question-mark">?</span>,
constraint,
r#type,
variadic_kind,
})
}
Expand All @@ -142,7 +142,7 @@
<span class="kw">fn </span>parameter_type(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Type {
<span class="kw">let </span>r#type: Type = <span class="macro">parse_quote!</span>(::melior::ir::Value&lt;<span class="lifetime">'c</span>, <span class="lifetime">'_</span>&gt;);

<span class="kw">if </span><span class="self">self</span>.constraint.is_variadic() {
<span class="kw">if </span><span class="self">self</span>.r#type.is_variadic() {
<span class="macro">parse_quote! </span>{ <span class="kw-2">&amp;</span>[#r#type] }
} <span class="kw">else </span>{
r#type
Expand All @@ -152,7 +152,7 @@
<span class="kw">fn </span>return_type(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Type {
<span class="kw">let </span>r#type: Type = <span class="macro">parse_quote!</span>(::melior::ir::Value&lt;<span class="lifetime">'c</span>, <span class="lifetime">'_</span>&gt;);

<span class="kw">if </span>!<span class="self">self</span>.constraint.is_variadic() {
<span class="kw">if </span>!<span class="self">self</span>.r#type.is_variadic() {
generate_result_type(r#type)
} <span class="kw">else if </span><span class="self">self</span>.variadic_kind == VariadicKind::AttributeSized {
generate_result_type(generate_iterator_type(r#type))
Expand All @@ -162,15 +162,15 @@
}

<span class="kw">fn </span>is_optional(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="self">self</span>.constraint.is_optional()
<span class="self">self</span>.r#type.is_optional()
}

<span class="kw">fn </span>is_result(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="bool-val">false
</span>}

<span class="kw">fn </span>add_arguments(<span class="kw-2">&amp;</span><span class="self">self</span>, name: <span class="kw-2">&amp;</span>Ident) -&gt; TokenStream {
<span class="kw">if </span><span class="self">self</span>.constraint.is_variadic() {
<span class="kw">if </span><span class="self">self</span>.r#type.is_variadic() {
<span class="macro">quote! </span>{ #name }
} <span class="kw">else </span>{
<span class="macro">quote! </span>{ <span class="kw-2">&amp;</span>[#name] }
Expand All @@ -180,7 +180,7 @@

<span class="kw">impl </span>OperationElement <span class="kw">for </span>Operand&lt;<span class="lifetime">'_</span>&gt; {
<span class="kw">fn </span>is_variadic(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="self">self</span>.constraint.is_variadic()
<span class="self">self</span>.r#type.is_variadic()
}

<span class="kw">fn </span>variadic_kind(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>VariadicKind {
Expand Down
18 changes: 9 additions & 9 deletions src/melior_macro/dialect/operation/result.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
</pre></div><pre class="rust"><code><span class="kw">use super</span>::{OperationElement, OperationField, VariadicKind};
<span class="kw">use </span><span class="kw">crate</span>::dialect::{
error::Error,
types::TypeConstraint,
r#type::Type <span class="kw">as </span>ElementType,
utility::{generate_iterator_type, generate_result_type, sanitize_snake_case_identifier},
};
<span class="kw">use </span>proc_macro2::{Span, TokenStream};
Expand All @@ -109,20 +109,20 @@
</span><span class="kw">pub struct </span>OperationResult&lt;<span class="lifetime">'a</span>&gt; {
name: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>str,
singular_identifier: Ident,
constraint: TypeConstraint&lt;<span class="lifetime">'a</span>&gt;,
r#type: ElementType,
variadic_kind: VariadicKind,
}

<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; OperationResult&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">pub fn </span>new(
name: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>str,
constraint: TypeConstraint&lt;<span class="lifetime">'a</span>&gt;,
r#type: ElementType,
variadic_kind: VariadicKind,
) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, Error&gt; {
<span class="prelude-val">Ok</span>(<span class="self">Self </span>{
name,
singular_identifier: sanitize_snake_case_identifier(name)<span class="question-mark">?</span>,
constraint,
r#type,
variadic_kind,
})
}
Expand All @@ -145,7 +145,7 @@
</span><span class="kw">fn </span>parameter_type(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Type {
<span class="kw">let </span>r#type: Type = <span class="macro">parse_quote!</span>(::melior::ir::Type&lt;<span class="lifetime">'c</span>&gt;);

<span class="kw">if </span><span class="self">self</span>.constraint.is_variadic() {
<span class="kw">if </span><span class="self">self</span>.r#type.is_variadic() {
<span class="macro">parse_quote! </span>{ <span class="kw-2">&amp;</span>[#r#type] }
} <span class="kw">else </span>{
r#type
Expand All @@ -156,7 +156,7 @@
</span><span class="kw">fn </span>return_type(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Type {
<span class="kw">let </span>r#type: Type = <span class="macro">parse_quote!</span>(::melior::ir::operation::OperationResult&lt;<span class="lifetime">'c</span>, <span class="lifetime">'_</span>&gt;);

<span class="kw">if </span>!<span class="self">self</span>.constraint.is_variadic() {
<span class="kw">if </span>!<span class="self">self</span>.r#type.is_variadic() {
generate_result_type(r#type)
} <span class="kw">else if </span><span class="self">self</span>.variadic_kind == VariadicKind::AttributeSized {
generate_result_type(generate_iterator_type(r#type))
Expand All @@ -166,15 +166,15 @@
}

<span class="kw">fn </span>is_optional(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="self">self</span>.constraint.is_optional()
<span class="self">self</span>.r#type.is_optional()
}

<span class="kw">fn </span>is_result(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="bool-val">true
</span>}

<span class="kw">fn </span>add_arguments(<span class="kw-2">&amp;</span><span class="self">self</span>, name: <span class="kw-2">&amp;</span>Ident) -&gt; TokenStream {
<span class="kw">if </span><span class="self">self</span>.constraint.is_unfixed() &amp;&amp; !<span class="self">self</span>.constraint.is_optional() {
<span class="kw">if </span><span class="self">self</span>.r#type.is_unfixed() &amp;&amp; !<span class="self">self</span>.r#type.is_optional() {
<span class="macro">quote! </span>{ #name }
} <span class="kw">else </span>{
<span class="macro">quote! </span>{ <span class="kw-2">&amp;</span>[#name] }
Expand All @@ -184,7 +184,7 @@

<span class="kw">impl </span>OperationElement <span class="kw">for </span>OperationResult&lt;<span class="lifetime">'_</span>&gt; {
<span class="kw">fn </span>is_variadic(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="self">self</span>.constraint.is_variadic()
<span class="self">self</span>.r#type.is_variadic()
}

<span class="kw">fn </span>variadic_kind(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>VariadicKind {
Expand Down
Loading

0 comments on commit a5169ec

Please sign in to comment.