Emerge Yul recompiler (#1)

Provide a modified (and incomplete) version of ZKSync zksolc that can compile the most basic contracts
This commit is contained in:
Cyrill Leutwiler
2024-03-12 12:06:02 +01:00
committed by GitHub
parent d238d8f39e
commit cffa14a4d2
247 changed files with 35357 additions and 4905 deletions
@@ -0,0 +1,66 @@
//!
//! The LLVM target.
//!
use std::str::FromStr;
///
/// The LLVM target.
///
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Target {
/// The EraVM target.
PVM,
}
impl Target {
///
/// Returns the target name.
///
pub fn name(&self) -> &str {
match self {
Self::PVM => "riscv32",
}
}
///
/// Returns the target triple.
///
pub fn triple(&self) -> &str {
match self {
Self::PVM => "riscv32-unknown-unknown-elf",
}
}
///
/// Returns the target production name.
///
pub fn production_name(&self) -> &str {
match self {
Self::PVM => "PVM",
}
}
}
impl FromStr for Target {
type Err = anyhow::Error;
fn from_str(string: &str) -> Result<Self, Self::Err> {
match string {
"riscv32" => Ok(Self::PVM),
_ => Err(anyhow::anyhow!(
"Unknown target `{}`. Supported targets: {:?}",
string,
Self::PVM
)),
}
}
}
impl std::fmt::Display for Target {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Target::PVM => write!(f, "riscv32"),
}
}
}