1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use std::fmt;

#[derive(PartialEq, PartialOrd, Eq, Ord, Debug)]
pub struct FloatAlignment {
    pub size: FloatAlignmentSize,
    pub abi: i32,
    pub pref: Option<i32>,
}

impl fmt::Display for FloatAlignment {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self.pref {
            Some(pref) => write!(f, "f{}:{}:{}", self.size, self.abi, pref),
            None => write!(f, "f{}:{}", self.size, self.abi),
        }
    }
}

#[derive(PartialEq, PartialOrd, Eq, Ord, Debug)]
pub enum FloatAlignmentSize {
    FLOAT,
    DOUBLE,
    LONGDOUBLE80,
    LONGDOUBLE128,
}

impl fmt::Display for FloatAlignmentSize {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let size = match self {
            Self::FLOAT => 32,
            Self::DOUBLE => 64,
            Self::LONGDOUBLE80 => 80,
            Self::LONGDOUBLE128 => 128,
        };

        write!(f, "{}", size)
    }
}