mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Add Float ty to SMIR
This commit is contained in:
parent
42eccffce3
commit
9ca51b92d4
@ -7,7 +7,7 @@
|
||||
//!
|
||||
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
|
||||
|
||||
use crate::stable_mir::ty::{IntTy, RigidTy, TyKind, UintTy};
|
||||
use crate::stable_mir::ty::{FloatTy, IntTy, RigidTy, TyKind, UintTy};
|
||||
use crate::stable_mir::{self, Context};
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
@ -81,14 +81,17 @@ impl<'tcx> Tables<'tcx> {
|
||||
ty::IntTy::I128 => TyKind::RigidTy(RigidTy::Int(IntTy::I128)),
|
||||
},
|
||||
ty::Uint(uint_ty) => match uint_ty {
|
||||
ty::UintTy::Usize => TyKind::RigidTy(RigidTy::Uint(stable_mir::ty::UintTy::Usize)),
|
||||
ty::UintTy::Usize => TyKind::RigidTy(RigidTy::Uint(UintTy::Usize)),
|
||||
ty::UintTy::U8 => TyKind::RigidTy(RigidTy::Uint(UintTy::U8)),
|
||||
ty::UintTy::U16 => TyKind::RigidTy(RigidTy::Uint(UintTy::U16)),
|
||||
ty::UintTy::U32 => TyKind::RigidTy(RigidTy::Uint(UintTy::U32)),
|
||||
ty::UintTy::U64 => TyKind::RigidTy(RigidTy::Uint(UintTy::U64)),
|
||||
ty::UintTy::U128 => TyKind::RigidTy(RigidTy::Uint(UintTy::U128)),
|
||||
},
|
||||
ty::Float(_) => todo!(),
|
||||
ty::Float(float_ty) => match float_ty {
|
||||
ty::FloatTy::F32 => TyKind::RigidTy(RigidTy::Float(FloatTy::F32)),
|
||||
ty::FloatTy::F64 => TyKind::RigidTy(RigidTy::Float(FloatTy::F64)),
|
||||
},
|
||||
ty::Adt(_, _) => todo!(),
|
||||
ty::Foreign(_) => todo!(),
|
||||
ty::Str => todo!(),
|
||||
|
@ -20,6 +20,7 @@ pub enum RigidTy {
|
||||
Char,
|
||||
Int(IntTy),
|
||||
Uint(UintTy),
|
||||
Float(FloatTy),
|
||||
Tuple(Vec<Ty>),
|
||||
}
|
||||
|
||||
@ -42,3 +43,9 @@ pub enum UintTy {
|
||||
U64,
|
||||
U128,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum FloatTy {
|
||||
F32,
|
||||
F64,
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
|
||||
|
||||
let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap();
|
||||
let body = types.body();
|
||||
assert_eq!(body.locals.len(), 5);
|
||||
assert_eq!(body.locals.len(), 6);
|
||||
assert_matches!(
|
||||
body.locals[0].kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
|
||||
@ -88,6 +88,12 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
|
||||
body.locals[4].kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64))
|
||||
);
|
||||
assert_matches!(
|
||||
body.locals[5].kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Float(
|
||||
stable_mir::ty::FloatTy::F64
|
||||
))
|
||||
);
|
||||
|
||||
let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap();
|
||||
let body = drop.body();
|
||||
@ -179,7 +185,7 @@ fn generate_input(path: &str) -> std::io::Result<()> {
|
||||
x_64.wrapping_add(y_64)
|
||||
}}
|
||||
|
||||
pub fn types(b: bool, _: char, _: i32, _: u64) -> bool {{
|
||||
pub fn types(b: bool, _: char, _: i32, _: u64, _: f64) -> bool {{
|
||||
b
|
||||
}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user