-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ssa refactor): Handle codegen for literals (#1209)
* Add Context structs and start ssa gen pass * Fix block arguments * Fix clippy lint * Use the correct dfg * Rename contexts to highlight the inner contexts are shared rather than used directly * Correctly handle function parameters * Rename Nested to Tree; add comment * Add codegen for literals * PR feedback * chore(ssa refactor): Add debug printing for the new ssa ir (#1211) Implement debug printing for the new ssa ir
- Loading branch information
Showing
14 changed files
with
566 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
pub(crate) mod basic_block; | ||
pub(crate) mod constant; | ||
pub(crate) mod dfg; | ||
pub(crate) mod function; | ||
pub(crate) mod instruction; | ||
pub(crate) mod map; | ||
pub(crate) mod printer; | ||
pub(crate) mod types; | ||
pub(crate) mod value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use acvm::FieldElement; | ||
|
||
use super::map::Id; | ||
|
||
/// Represents a numeric constant in Ssa. Constants themselves are | ||
/// uniqued in the DataFlowGraph and immutable. | ||
/// | ||
/// This is just a thin wrapper around FieldElement so that | ||
/// we can use Id<NumericConstant> without it getting confused | ||
/// with a possible future use of Id<FieldElement>. | ||
#[derive(Debug, Clone, Hash, PartialEq, Eq)] | ||
pub(crate) struct NumericConstant(FieldElement); | ||
|
||
impl NumericConstant { | ||
pub(crate) fn new(value: FieldElement) -> Self { | ||
Self(value) | ||
} | ||
|
||
pub(crate) fn value(&self) -> &FieldElement { | ||
&self.0 | ||
} | ||
} | ||
|
||
pub(crate) type NumericConstantId = Id<NumericConstant>; | ||
|
||
impl std::ops::Add for NumericConstant { | ||
type Output = NumericConstant; | ||
|
||
fn add(self, rhs: Self) -> Self::Output { | ||
Self::new(self.0 + rhs.0) | ||
} | ||
} | ||
|
||
impl std::ops::Sub for NumericConstant { | ||
type Output = NumericConstant; | ||
|
||
fn sub(self, rhs: Self) -> Self::Output { | ||
Self::new(self.0 - rhs.0) | ||
} | ||
} | ||
|
||
impl std::ops::Mul for NumericConstant { | ||
type Output = NumericConstant; | ||
|
||
fn mul(self, rhs: Self) -> Self::Output { | ||
Self::new(self.0 * rhs.0) | ||
} | ||
} | ||
|
||
impl std::ops::Div for NumericConstant { | ||
type Output = NumericConstant; | ||
|
||
fn div(self, rhs: Self) -> Self::Output { | ||
Self::new(self.0 / rhs.0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.