Add support to new float types
This commit is contained in:
parent
e3ac2c68b8
commit
0567162933
2 changed files with 31 additions and 8 deletions
|
@ -293,8 +293,9 @@ pub enum Primitive {
|
|||
length: IntegerLength,
|
||||
signed: bool,
|
||||
},
|
||||
F32,
|
||||
F64,
|
||||
Float {
|
||||
length: FloatLength,
|
||||
},
|
||||
Pointer(AddressSpace),
|
||||
}
|
||||
|
||||
|
@ -302,8 +303,7 @@ impl Primitive {
|
|||
pub fn size(self, target: &MachineInfo) -> Size {
|
||||
match self {
|
||||
Primitive::Int { length, .. } => Size::from_bits(length.bits()),
|
||||
Primitive::F32 => Size::from_bits(32),
|
||||
Primitive::F64 => Size::from_bits(64),
|
||||
Primitive::Float { length } => Size::from_bits(length.bits()),
|
||||
Primitive::Pointer(_) => target.pointer_width,
|
||||
}
|
||||
}
|
||||
|
@ -319,6 +319,15 @@ pub enum IntegerLength {
|
|||
I128,
|
||||
}
|
||||
|
||||
/// Enum representing the existing float lengths.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
pub enum FloatLength {
|
||||
F16,
|
||||
F32,
|
||||
F64,
|
||||
F128,
|
||||
}
|
||||
|
||||
impl IntegerLength {
|
||||
pub fn bits(self) -> usize {
|
||||
match self {
|
||||
|
@ -331,6 +340,17 @@ impl IntegerLength {
|
|||
}
|
||||
}
|
||||
|
||||
impl FloatLength {
|
||||
pub fn bits(self) -> usize {
|
||||
match self {
|
||||
FloatLength::F16 => 16,
|
||||
FloatLength::F32 => 32,
|
||||
FloatLength::F64 => 64,
|
||||
FloatLength::F128 => 128,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An identifier that specifies the address space that some operation
|
||||
/// should operate on. Special address spaces have an effect on code generation,
|
||||
/// depending on the target and the address spaces it implements.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue