@@ -84,33 +84,45 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
84
84
ty:: Adt ( adt, substs) if adt. repr ( ) . simd ( ) => {
85
85
let fields = & adt. non_enum_variant ( ) . fields ;
86
86
let elem_ty = fields[ FieldIdx :: from_u32 ( 0 ) ] . ty ( self . tcx , substs) ;
87
- match elem_ty. kind ( ) {
88
- ty:: Never | ty:: Error ( _) => return None ,
89
- ty:: Int ( IntTy :: I8 ) | ty:: Uint ( UintTy :: U8 ) => {
90
- Some ( InlineAsmType :: VecI8 ( fields. len ( ) as u64 ) )
87
+
88
+ let ( size, ty) = match elem_ty. kind ( ) {
89
+ ty:: Array ( ty, len) => {
90
+ if let Some ( len) =
91
+ len. try_eval_target_usize ( self . tcx , self . tcx . param_env ( adt. did ( ) ) )
92
+ {
93
+ ( len, * ty)
94
+ } else {
95
+ return None ;
96
+ }
91
97
}
98
+ _ => ( fields. len ( ) as u64 , elem_ty) ,
99
+ } ;
100
+
101
+ match ty. kind ( ) {
102
+ ty:: Never | ty:: Error ( _) => return None ,
103
+ ty:: Int ( IntTy :: I8 ) | ty:: Uint ( UintTy :: U8 ) => Some ( InlineAsmType :: VecI8 ( size) ) ,
92
104
ty:: Int ( IntTy :: I16 ) | ty:: Uint ( UintTy :: U16 ) => {
93
- Some ( InlineAsmType :: VecI16 ( fields . len ( ) as u64 ) )
105
+ Some ( InlineAsmType :: VecI16 ( size ) )
94
106
}
95
107
ty:: Int ( IntTy :: I32 ) | ty:: Uint ( UintTy :: U32 ) => {
96
- Some ( InlineAsmType :: VecI32 ( fields . len ( ) as u64 ) )
108
+ Some ( InlineAsmType :: VecI32 ( size ) )
97
109
}
98
110
ty:: Int ( IntTy :: I64 ) | ty:: Uint ( UintTy :: U64 ) => {
99
- Some ( InlineAsmType :: VecI64 ( fields . len ( ) as u64 ) )
111
+ Some ( InlineAsmType :: VecI64 ( size ) )
100
112
}
101
113
ty:: Int ( IntTy :: I128 ) | ty:: Uint ( UintTy :: U128 ) => {
102
- Some ( InlineAsmType :: VecI128 ( fields . len ( ) as u64 ) )
114
+ Some ( InlineAsmType :: VecI128 ( size ) )
103
115
}
104
116
ty:: Int ( IntTy :: Isize ) | ty:: Uint ( UintTy :: Usize ) => {
105
117
Some ( match self . tcx . sess . target . pointer_width {
106
- 16 => InlineAsmType :: VecI16 ( fields . len ( ) as u64 ) ,
107
- 32 => InlineAsmType :: VecI32 ( fields . len ( ) as u64 ) ,
108
- 64 => InlineAsmType :: VecI64 ( fields . len ( ) as u64 ) ,
118
+ 16 => InlineAsmType :: VecI16 ( size ) ,
119
+ 32 => InlineAsmType :: VecI32 ( size ) ,
120
+ 64 => InlineAsmType :: VecI64 ( size ) ,
109
121
_ => unreachable ! ( ) ,
110
122
} )
111
123
}
112
- ty:: Float ( FloatTy :: F32 ) => Some ( InlineAsmType :: VecF32 ( fields . len ( ) as u64 ) ) ,
113
- ty:: Float ( FloatTy :: F64 ) => Some ( InlineAsmType :: VecF64 ( fields . len ( ) as u64 ) ) ,
124
+ ty:: Float ( FloatTy :: F32 ) => Some ( InlineAsmType :: VecF32 ( size ) ) ,
125
+ ty:: Float ( FloatTy :: F64 ) => Some ( InlineAsmType :: VecF64 ( size ) ) ,
114
126
_ => None ,
115
127
}
116
128
}
0 commit comments