11use super :: misc:: MiscMethods ;
22use super :: Backend ;
33use super :: HasCodegen ;
4- use crate :: common:: { self , TypeKind } ;
4+ use crate :: common:: TypeKind ;
55use crate :: mir:: place:: PlaceRef ;
6- use rustc:: ty:: layout:: { self , Align , Size , TyLayout } ;
76use rustc:: ty:: { self , Ty } ;
7+ use rustc:: ty:: layout:: { self , TyLayout } ;
88use rustc_target:: abi:: call:: { ArgType , CastTarget , FnType , Reg } ;
9- use syntax :: ast ;
9+ use syntax_pos :: DUMMY_SP ;
1010
1111// This depends on `Backend` and not `BackendTypes`, because consumers will probably want to use
1212// `LayoutOf` or `HasTyCtxt`. This way, they don't have to add a constraint on it themselves.
1313pub trait BaseTypeMethods < ' tcx > : Backend < ' tcx > {
14- fn type_void ( & self ) -> Self :: Type ;
15- fn type_metadata ( & self ) -> Self :: Type ;
1614 fn type_i1 ( & self ) -> Self :: Type ;
1715 fn type_i8 ( & self ) -> Self :: Type ;
1816 fn type_i16 ( & self ) -> Self :: Type ;
1917 fn type_i32 ( & self ) -> Self :: Type ;
2018 fn type_i64 ( & self ) -> Self :: Type ;
2119 fn type_i128 ( & self ) -> Self :: Type ;
22-
23- // Creates an integer type with the given number of bits, e.g., i24
24- fn type_ix ( & self , num_bits : u64 ) -> Self :: Type ;
2520 fn type_isize ( & self ) -> Self :: Type ;
2621
2722 fn type_f32 ( & self ) -> Self :: Type ;
2823 fn type_f64 ( & self ) -> Self :: Type ;
29- fn type_x86_mmx ( & self ) -> Self :: Type ;
3024
3125 fn type_func ( & self , args : & [ Self :: Type ] , ret : Self :: Type ) -> Self :: Type ;
3226 fn type_variadic_func ( & self , args : & [ Self :: Type ] , ret : Self :: Type ) -> Self :: Type ;
3327 fn type_struct ( & self , els : & [ Self :: Type ] , packed : bool ) -> Self :: Type ;
3428 fn type_array ( & self , ty : Self :: Type , len : u64 ) -> Self :: Type ;
35- fn type_vector ( & self , ty : Self :: Type , len : u64 ) -> Self :: Type ;
3629 fn type_kind ( & self , ty : Self :: Type ) -> TypeKind ;
3730 fn type_ptr_to ( & self , ty : Self :: Type ) -> Self :: Type ;
3831 fn element_type ( & self , ty : Self :: Type ) -> Self :: Type ;
3932
4033 /// Returns the number of elements in `self` if it is a LLVM vector type.
4134 fn vector_length ( & self , ty : Self :: Type ) -> usize ;
4235
43- fn func_params_types ( & self , ty : Self :: Type ) -> Vec < Self :: Type > ;
4436 fn float_width ( & self , ty : Self :: Type ) -> usize ;
4537
4638 /// Retrieves the bit width of the integer type `self`.
@@ -50,10 +42,6 @@ pub trait BaseTypeMethods<'tcx>: Backend<'tcx> {
5042}
5143
5244pub trait DerivedTypeMethods < ' tcx > : BaseTypeMethods < ' tcx > + MiscMethods < ' tcx > {
53- fn type_bool ( & self ) -> Self :: Type {
54- self . type_i8 ( )
55- }
56-
5745 fn type_i8p ( & self ) -> Self :: Type {
5846 self . type_ptr_to ( self . type_i8 ( ) )
5947 }
@@ -67,35 +55,6 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
6755 }
6856 }
6957
70- fn type_int_from_ty ( & self , t : ast:: IntTy ) -> Self :: Type {
71- match t {
72- ast:: IntTy :: Isize => self . type_isize ( ) ,
73- ast:: IntTy :: I8 => self . type_i8 ( ) ,
74- ast:: IntTy :: I16 => self . type_i16 ( ) ,
75- ast:: IntTy :: I32 => self . type_i32 ( ) ,
76- ast:: IntTy :: I64 => self . type_i64 ( ) ,
77- ast:: IntTy :: I128 => self . type_i128 ( ) ,
78- }
79- }
80-
81- fn type_uint_from_ty ( & self , t : ast:: UintTy ) -> Self :: Type {
82- match t {
83- ast:: UintTy :: Usize => self . type_isize ( ) ,
84- ast:: UintTy :: U8 => self . type_i8 ( ) ,
85- ast:: UintTy :: U16 => self . type_i16 ( ) ,
86- ast:: UintTy :: U32 => self . type_i32 ( ) ,
87- ast:: UintTy :: U64 => self . type_i64 ( ) ,
88- ast:: UintTy :: U128 => self . type_i128 ( ) ,
89- }
90- }
91-
92- fn type_float_from_ty ( & self , t : ast:: FloatTy ) -> Self :: Type {
93- match t {
94- ast:: FloatTy :: F32 => self . type_f32 ( ) ,
95- ast:: FloatTy :: F64 => self . type_f64 ( ) ,
96- }
97- }
98-
9958 fn type_from_integer ( & self , i : layout:: Integer ) -> Self :: Type {
10059 use rustc:: ty:: layout:: Integer :: * ;
10160 match i {
@@ -107,32 +66,16 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
10766 }
10867 }
10968
110- fn type_pointee_for_align ( & self , align : Align ) -> Self :: Type {
111- // FIXME(eddyb) We could find a better approximation if ity.align < align.
112- let ity = layout:: Integer :: approximate_align ( self , align) ;
113- self . type_from_integer ( ity)
114- }
115-
116- /// Return a LLVM type that has at most the required alignment,
117- /// and exactly the required size, as a best-effort padding array.
118- fn type_padding_filler ( & self , size : Size , align : Align ) -> Self :: Type {
119- let unit = layout:: Integer :: approximate_align ( self , align) ;
120- let size = size. bytes ( ) ;
121- let unit_size = unit. size ( ) . bytes ( ) ;
122- assert_eq ! ( size % unit_size, 0 ) ;
123- self . type_array ( self . type_from_integer ( unit) , size / unit_size)
124- }
125-
12669 fn type_needs_drop ( & self , ty : Ty < ' tcx > ) -> bool {
127- common :: type_needs_drop ( self . tcx ( ) , ty)
70+ ty . needs_drop ( self . tcx ( ) , ty:: ParamEnv :: reveal_all ( ) )
12871 }
12972
13073 fn type_is_sized ( & self , ty : Ty < ' tcx > ) -> bool {
131- common :: type_is_sized ( self . tcx ( ) , ty)
74+ ty . is_sized ( self . tcx ( ) . at ( DUMMY_SP ) , ty:: ParamEnv :: reveal_all ( ) )
13275 }
13376
13477 fn type_is_freeze ( & self , ty : Ty < ' tcx > ) -> bool {
135- common :: type_is_freeze ( self . tcx ( ) , ty)
78+ ty . is_freeze ( self . tcx ( ) , ty:: ParamEnv :: reveal_all ( ) , DUMMY_SP )
13679 }
13780
13881 fn type_has_metadata ( & self , ty : Ty < ' tcx > ) -> bool {
@@ -155,7 +98,6 @@ impl<T> DerivedTypeMethods<'tcx> for T where Self: BaseTypeMethods<'tcx> + MiscM
15598pub trait LayoutTypeMethods < ' tcx > : Backend < ' tcx > {
15699 fn backend_type ( & self , layout : TyLayout < ' tcx > ) -> Self :: Type ;
157100 fn cast_backend_type ( & self , ty : & CastTarget ) -> Self :: Type ;
158- fn fn_backend_type ( & self , ty : & FnType < ' tcx , Ty < ' tcx > > ) -> Self :: Type ;
159101 fn fn_ptr_backend_type ( & self , ty : & FnType < ' tcx , Ty < ' tcx > > ) -> Self :: Type ;
160102 fn reg_backend_type ( & self , ty : & Reg ) -> Self :: Type ;
161103 fn immediate_backend_type ( & self , layout : TyLayout < ' tcx > ) -> Self :: Type ;
0 commit comments