revive_llvm_builder/
target_triple.rs

1//! The PolkaVM LLVM target triples.
2
3/// The list of target triples used as constants.
4///
5/// It must be in the lowercase.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub enum TargetTriple {
8    /// The PolkaVM RISC-V target triple.
9    PolkaVM,
10}
11
12impl std::str::FromStr for TargetTriple {
13    type Err = String;
14
15    fn from_str(value: &str) -> Result<Self, Self::Err> {
16        match value {
17            "polkavm" => Ok(Self::PolkaVM),
18            value => Err(format!("Unsupported target triple: `{value}`")),
19        }
20    }
21}
22
23impl std::fmt::Display for TargetTriple {
24    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
25        match self {
26            Self::PolkaVM => write!(f, "riscv64-unknown-elf"),
27        }
28    }
29}