Skip to content

Commit

Permalink
Add a zkASM architecture
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`.
Some of the details are not exactly 100% correct in the current state of
the machine (e.g. pointer width is 256 bits), but this will potentially
change soon…
  • Loading branch information
nagisa committed Sep 18, 2023
1 parent a3cc06e commit 38469bf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ 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/
ZkAsm,
}

#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
Expand Down Expand Up @@ -855,7 +859,8 @@ impl Architecture {
| S390x
| Sparc
| Sparc64
| Sparcv9 => Ok(Endianness::Big),
| Sparcv9
| ZkAsm => Ok(Endianness::Big),
}

}
Expand Down Expand Up @@ -896,6 +901,9 @@ impl Architecture {
| LoongArch64
| Wasm64
| Clever(_) => Ok(PointerWidth::U64),
// Actually 256-bit, as are the rest of registers…
// But definitely can't address that much memory.
ZkAsm => Ok(PointerWidth::U64),
}
}

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

for target in targets.iter() {
Expand Down

0 comments on commit 38469bf

Please sign in to comment.