Skip to content

Commit

Permalink
Add a zkASM architecture (#94)
Browse files Browse the repository at this point in the history
This is a very initial take on this if only to be able to specify
`zkasm-unknown-unknown` target in tooling that uses `target-lexicon`.
  • Loading branch information
nagisa authored Oct 19, 2023
1 parent a3cc06e commit 1f9d02e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ serde_json = "1.0"
default = []
serde_support = ["serde", "std"]
std = []
# Enable (unstable) support for the zkasm architecture.
arch_zkasm = []

[badges]
maintenance = { status = "passively-maintained" }
15 changes: 15 additions & 0 deletions src/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ pub enum Architecture {
X86_64h,
XTensa,
Clever(CleverArchitecture),
/// A software machine that produces zero-knowledge proofs of the execution.
///
/// See https://wiki.polygon.technology/docs/category/zk-assembly/
#[cfg(feature = "arch_zkasm")]
ZkAsm,
}

#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
Expand Down Expand Up @@ -856,6 +861,8 @@ impl Architecture {
| Sparc
| Sparc64
| Sparcv9 => Ok(Endianness::Big),
#[cfg(feature="arch_zkasm")]
ZkAsm => Ok(Endianness::Big),
}

}
Expand Down Expand Up @@ -896,6 +903,8 @@ impl Architecture {
| LoongArch64
| Wasm64
| Clever(_) => Ok(PointerWidth::U64),
#[cfg(feature="arch_zkasm")]
ZkAsm => Ok(PointerWidth::U64),
}
}

Expand Down Expand Up @@ -943,6 +952,8 @@ impl Architecture {
X86_64h => Cow::Borrowed("x86_64h"),
XTensa => Cow::Borrowed("xtensa"),
Clever(ver) => ver.into_str(),
#[cfg(feature = "arch_zkasm")]
ZkAsm => Cow::Borrowed("zkasm"),
}
}
}
Expand Down Expand Up @@ -1218,6 +1229,8 @@ impl FromStr for Architecture {
"x86_64" => X86_64,
"x86_64h" => X86_64h,
"xtensa" => XTensa,
#[cfg(feature = "arch_zkasm")]
"zkasm" => ZkAsm,
_ => {
if let Ok(arm) = ArmArchitecture::from_str(s) {
Arm(arm)
Expand Down Expand Up @@ -1709,6 +1722,8 @@ mod tests {
"x86_64-wrs-vxworks",
"xtensa-esp32-espidf",
"clever-unknown-elf",
#[cfg(feature = "arch_zkasm")]
"zkasm-unknown-unknown",
];

for target in targets.iter() {
Expand Down

0 comments on commit 1f9d02e

Please sign in to comment.