mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Add Uint ty to SMIR
This commit is contained in:
parent
458ead41d6
commit
42eccffce3
@ -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};
|
||||
use crate::stable_mir::ty::{IntTy, RigidTy, TyKind, UintTy};
|
||||
use crate::stable_mir::{self, Context};
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
@ -80,7 +80,14 @@ impl<'tcx> Tables<'tcx> {
|
||||
ty::IntTy::I64 => TyKind::RigidTy(RigidTy::Int(IntTy::I64)),
|
||||
ty::IntTy::I128 => TyKind::RigidTy(RigidTy::Int(IntTy::I128)),
|
||||
},
|
||||
ty::Uint(_) => todo!(),
|
||||
ty::Uint(uint_ty) => match uint_ty {
|
||||
ty::UintTy::Usize => TyKind::RigidTy(RigidTy::Uint(stable_mir::ty::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::Adt(_, _) => todo!(),
|
||||
ty::Foreign(_) => todo!(),
|
||||
|
@ -19,6 +19,7 @@ pub enum RigidTy {
|
||||
Bool,
|
||||
Char,
|
||||
Int(IntTy),
|
||||
Uint(UintTy),
|
||||
Tuple(Vec<Ty>),
|
||||
}
|
||||
|
||||
@ -31,3 +32,13 @@ pub enum IntTy {
|
||||
I64,
|
||||
I128,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum UintTy {
|
||||
Usize,
|
||||
U8,
|
||||
U16,
|
||||
U32,
|
||||
U64,
|
||||
U128,
|
||||
}
|
||||
|
@ -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(), 4);
|
||||
assert_eq!(body.locals.len(), 5);
|
||||
assert_matches!(
|
||||
body.locals[0].kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
|
||||
@ -84,6 +84,10 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
|
||||
body.locals[3].kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32))
|
||||
);
|
||||
assert_matches!(
|
||||
body.locals[4].kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64))
|
||||
);
|
||||
|
||||
let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap();
|
||||
let body = drop.body();
|
||||
@ -175,7 +179,7 @@ fn generate_input(path: &str) -> std::io::Result<()> {
|
||||
x_64.wrapping_add(y_64)
|
||||
}}
|
||||
|
||||
pub fn types(b: bool, _: char, _: i32) -> bool {{
|
||||
pub fn types(b: bool, _: char, _: i32, _: u64) -> bool {{
|
||||
b
|
||||
}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user