1
1
use super :: misc:: MiscMethods ;
2
2
use super :: Backend ;
3
3
use super :: HasCodegen ;
4
- use crate :: common:: { self , TypeKind } ;
4
+ use crate :: common:: TypeKind ;
5
5
use crate :: mir:: place:: PlaceRef ;
6
- use rustc:: ty:: layout:: { self , Align , Size , TyLayout } ;
7
6
use rustc:: ty:: { self , Ty } ;
7
+ use rustc:: ty:: layout:: { self , TyLayout } ;
8
8
use rustc_target:: abi:: call:: { ArgType , CastTarget , FnType , Reg } ;
9
- use syntax :: ast ;
9
+ use syntax_pos :: DUMMY_SP ;
10
10
11
11
// This depends on `Backend` and not `BackendTypes`, because consumers will probably want to use
12
12
// `LayoutOf` or `HasTyCtxt`. This way, they don't have to add a constraint on it themselves.
13
13
pub trait BaseTypeMethods < ' tcx > : Backend < ' tcx > {
14
- fn type_void ( & self ) -> Self :: Type ;
15
- fn type_metadata ( & self ) -> Self :: Type ;
16
14
fn type_i1 ( & self ) -> Self :: Type ;
17
15
fn type_i8 ( & self ) -> Self :: Type ;
18
16
fn type_i16 ( & self ) -> Self :: Type ;
19
17
fn type_i32 ( & self ) -> Self :: Type ;
20
18
fn type_i64 ( & self ) -> Self :: Type ;
21
19
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 ;
25
20
fn type_isize ( & self ) -> Self :: Type ;
26
21
27
22
fn type_f32 ( & self ) -> Self :: Type ;
28
23
fn type_f64 ( & self ) -> Self :: Type ;
29
- fn type_x86_mmx ( & self ) -> Self :: Type ;
30
24
31
25
fn type_func ( & self , args : & [ Self :: Type ] , ret : Self :: Type ) -> Self :: Type ;
32
26
fn type_variadic_func ( & self , args : & [ Self :: Type ] , ret : Self :: Type ) -> Self :: Type ;
33
27
fn type_struct ( & self , els : & [ Self :: Type ] , packed : bool ) -> Self :: Type ;
34
28
fn type_array ( & self , ty : Self :: Type , len : u64 ) -> Self :: Type ;
35
- fn type_vector ( & self , ty : Self :: Type , len : u64 ) -> Self :: Type ;
36
29
fn type_kind ( & self , ty : Self :: Type ) -> TypeKind ;
37
30
fn type_ptr_to ( & self , ty : Self :: Type ) -> Self :: Type ;
38
31
fn element_type ( & self , ty : Self :: Type ) -> Self :: Type ;
39
32
40
33
/// Returns the number of elements in `self` if it is a LLVM vector type.
41
34
fn vector_length ( & self , ty : Self :: Type ) -> usize ;
42
35
43
- fn func_params_types ( & self , ty : Self :: Type ) -> Vec < Self :: Type > ;
44
36
fn float_width ( & self , ty : Self :: Type ) -> usize ;
45
37
46
38
/// Retrieves the bit width of the integer type `self`.
@@ -50,10 +42,6 @@ pub trait BaseTypeMethods<'tcx>: Backend<'tcx> {
50
42
}
51
43
52
44
pub trait DerivedTypeMethods < ' tcx > : BaseTypeMethods < ' tcx > + MiscMethods < ' tcx > {
53
- fn type_bool ( & self ) -> Self :: Type {
54
- self . type_i8 ( )
55
- }
56
-
57
45
fn type_i8p ( & self ) -> Self :: Type {
58
46
self . type_ptr_to ( self . type_i8 ( ) )
59
47
}
@@ -67,35 +55,6 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
67
55
}
68
56
}
69
57
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
-
99
58
fn type_from_integer ( & self , i : layout:: Integer ) -> Self :: Type {
100
59
use rustc:: ty:: layout:: Integer :: * ;
101
60
match i {
@@ -107,32 +66,16 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
107
66
}
108
67
}
109
68
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
-
126
69
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 ( ) )
128
71
}
129
72
130
73
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 ( ) )
132
75
}
133
76
134
77
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 )
136
79
}
137
80
138
81
fn type_has_metadata ( & self , ty : Ty < ' tcx > ) -> bool {
@@ -155,7 +98,6 @@ impl<T> DerivedTypeMethods<'tcx> for T where Self: BaseTypeMethods<'tcx> + MiscM
155
98
pub trait LayoutTypeMethods < ' tcx > : Backend < ' tcx > {
156
99
fn backend_type ( & self , layout : TyLayout < ' tcx > ) -> Self :: Type ;
157
100
fn cast_backend_type ( & self , ty : & CastTarget ) -> Self :: Type ;
158
- fn fn_backend_type ( & self , ty : & FnType < ' tcx , Ty < ' tcx > > ) -> Self :: Type ;
159
101
fn fn_ptr_backend_type ( & self , ty : & FnType < ' tcx , Ty < ' tcx > > ) -> Self :: Type ;
160
102
fn reg_backend_type ( & self , ty : & Reg ) -> Self :: Type ;
161
103
fn immediate_backend_type ( & self , layout : TyLayout < ' tcx > ) -> Self :: Type ;
0 commit comments