Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables IR and Codegen #100

Merged
merged 6 commits into from
Dec 22, 2022
Merged

Variables IR and Codegen #100

merged 6 commits into from
Dec 22, 2022

Conversation

tohrnii
Copy link
Contributor

@tohrnii tohrnii commented Dec 8, 2022

Partly addressing #61.

@tohrnii tohrnii force-pushed the tohrnii-variables-ir-codegen branch 6 times, most recently from 4180902 to 5d980da Compare December 10, 2022 07:22
@tohrnii tohrnii marked this pull request as ready for review December 10, 2022 07:22
@tohrnii tohrnii force-pushed the tohrnii-variables-ir-codegen branch 2 times, most recently from 335e360 to b6fddf7 Compare December 10, 2022 07:39
@tohrnii tohrnii mentioned this pull request Dec 10, 2022
14 tasks
@tohrnii tohrnii marked this pull request as draft December 14, 2022 12:32
@tohrnii tohrnii force-pushed the tohrnii-variables-ir-codegen branch 5 times, most recently from 0424320 to c26a0bd Compare December 15, 2022 02:06
@tohrnii tohrnii marked this pull request as ready for review December 15, 2022 02:06
@tohrnii tohrnii force-pushed the tohrnii-variables-ir-codegen branch from c26a0bd to b37f500 Compare December 15, 2022 02:33
ir/src/boundary_stmts.rs Outdated Show resolved Hide resolved
ir/src/tests/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@grjte grjte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @tohrnii! I like the improvement to the boundary constraint handling to make them more generic. I left a few comments inline

ir/src/transition_stmts/mod.rs Outdated Show resolved Hide resolved
ir/src/transition_stmts/graph.rs Outdated Show resolved Hide resolved
ir/src/transition_stmts/graph.rs Outdated Show resolved Hide resolved
ir/src/symbol_table.rs Outdated Show resolved Hide resolved
ir/src/symbol_table.rs Outdated Show resolved Hide resolved
ir/src/boundary_stmts.rs Outdated Show resolved Hide resolved
ir/src/boundary_stmts.rs Outdated Show resolved Hide resolved
ir/src/boundary_stmts.rs Outdated Show resolved Hide resolved
ir/src/transition_stmts/graph.rs Outdated Show resolved Hide resolved
Comment on lines +208 to +239
IdentifierType::TransitionVariable(transition_variable) => {
if let TransitionVariableType::Scalar(expr) = transition_variable.value() {
if let Some((trace_segment, node_index)) =
variable_roots.get(&VariableValue::Scalar(ident.to_string()))
{
Ok((*trace_segment, *node_index))
} else {
let (trace_segment, node_index) =
self.insert_expr(symbol_table, expr.clone(), variable_roots)?;
variable_roots.insert(
VariableValue::Scalar(ident.to_string()),
(trace_segment, node_index),
);
Ok((trace_segment, node_index))
}
} else {
Err(SemanticError::InvalidUsage(format!(
"Identifier {} was declared as a {} which is not a supported type.",
ident, elem_type
)))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's quite a bit of similarity/near-redundancy between this, insert_vector_access, and `insert_matrix_access, so I think there's probably a better way. Can you take a look at refactoring a bit or ping me if you want to discuss?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that there is some redundancy but I can't think of a way to reduce it much here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's leave it for now and revisit in the future once the tests are in place.

@tohrnii tohrnii force-pushed the tohrnii-variables-ir-codegen branch from b37f500 to d2591d6 Compare December 20, 2022 05:22
@tohrnii tohrnii force-pushed the tohrnii-variables-ir-codegen branch 4 times, most recently from 8201cb5 to 02175ee Compare December 20, 2022 07:36
@tohrnii tohrnii requested review from grjte and Al-Kindi-0 December 20, 2022 07:37
@tohrnii
Copy link
Contributor Author

tohrnii commented Dec 20, 2022

Thank you @grjte and @Al-Kindi-0 for the review. Made suggested changes.

Copy link
Contributor

@grjte grjte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tohrnii! I have a few final comments, but they're all very small nits - should only take 5 min to update.

ir/src/boundary_stmts.rs Outdated Show resolved Hide resolved
ir/src/boundary_stmts.rs Outdated Show resolved Hide resolved
ir/src/transition_stmts/graph.rs Show resolved Hide resolved
ir/src/transition_stmts/graph.rs Outdated Show resolved Hide resolved
Comment on lines +208 to +239
IdentifierType::TransitionVariable(transition_variable) => {
if let TransitionVariableType::Scalar(expr) = transition_variable.value() {
if let Some((trace_segment, node_index)) =
variable_roots.get(&VariableValue::Scalar(ident.to_string()))
{
Ok((*trace_segment, *node_index))
} else {
let (trace_segment, node_index) =
self.insert_expr(symbol_table, expr.clone(), variable_roots)?;
variable_roots.insert(
VariableValue::Scalar(ident.to_string()),
(trace_segment, node_index),
);
Ok((trace_segment, node_index))
}
} else {
Err(SemanticError::InvalidUsage(format!(
"Identifier {} was declared as a {} which is not a supported type.",
ident, elem_type
)))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's leave it for now and revisit in the future once the tests are in place.

ir/src/transition_stmts/graph.rs Outdated Show resolved Hide resolved
@tohrnii tohrnii force-pushed the tohrnii-variables-ir-codegen branch 2 times, most recently from 13bf212 to 9ad732b Compare December 21, 2022 15:41
@tohrnii
Copy link
Contributor Author

tohrnii commented Dec 21, 2022

Thanks @grjte. Fixed.

@tohrnii tohrnii requested a review from grjte December 21, 2022 15:41
@tohrnii tohrnii force-pushed the tohrnii-variables-ir-codegen branch from 9ad732b to 51ccbe3 Compare December 22, 2022 14:43
- Remove variables for boundary constraints
- Remove variables graph
- Remove variables vector
@tohrnii tohrnii force-pushed the tohrnii-variables-ir-codegen branch from 51ccbe3 to f087117 Compare December 22, 2022 14:44
Copy link
Contributor

@grjte grjte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @tohrnii!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants