@@ -91,6 +91,10 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
9191 self . const_uint ( self . type_i1 ( ) , val as u64 )
9292 }
9393
94+ fn const_i16 ( & self , i : i16 ) -> RValue < ' gcc > {
95+ self . const_int ( self . type_i16 ( ) , i as i64 )
96+ }
97+
9498 fn const_i32 ( & self , i : i32 ) -> RValue < ' gcc > {
9599 self . const_int ( self . type_i32 ( ) , i as i64 )
96100 }
@@ -154,14 +158,14 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
154158 }
155159
156160 fn scalar_to_backend ( & self , cv : Scalar , layout : abi:: Scalar , ty : Type < ' gcc > ) -> RValue < ' gcc > {
157- let bitsize = if layout. is_bool ( ) { 1 } else { layout. value . size ( self ) . bits ( ) } ;
161+ let bitsize = if layout. is_bool ( ) { 1 } else { layout. size ( self ) . bits ( ) } ;
158162 match cv {
159163 Scalar :: Int ( ScalarInt :: ZST ) => {
160- assert_eq ! ( 0 , layout. value . size( self ) . bytes( ) ) ;
164+ assert_eq ! ( 0 , layout. size( self ) . bytes( ) ) ;
161165 self . const_undef ( self . type_ix ( 0 ) )
162166 }
163167 Scalar :: Int ( int) => {
164- let data = int. assert_bits ( layout. value . size ( self ) ) ;
168+ let data = int. assert_bits ( layout. size ( self ) ) ;
165169
166170 // FIXME(antoyo): there's some issues with using the u128 code that follows, so hard-code
167171 // the paths for floating-point values.
@@ -205,7 +209,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
205209 let base_addr = self . const_bitcast ( base_addr, self . usize_type ) ;
206210 let offset = self . context . new_rvalue_from_long ( self . usize_type , offset. bytes ( ) as i64 ) ;
207211 let ptr = self . const_bitcast ( base_addr + offset, ptr_type) ;
208- if layout. value != Pointer {
212+ if layout. primitive ( ) != Pointer {
209213 self . const_bitcast ( ptr. dereference ( None ) . to_rvalue ( ) , ty)
210214 }
211215 else {
@@ -275,6 +279,21 @@ impl<'gcc, 'tcx> SignType<'gcc, 'tcx> for Type<'gcc> {
275279 else if self . is_u128 ( cx) {
276280 cx. i128_type
277281 }
282+ else if self . is_uchar ( cx) {
283+ cx. char_type
284+ }
285+ else if self . is_ushort ( cx) {
286+ cx. short_type
287+ }
288+ else if self . is_uint ( cx) {
289+ cx. int_type
290+ }
291+ else if self . is_ulong ( cx) {
292+ cx. long_type
293+ }
294+ else if self . is_ulonglong ( cx) {
295+ cx. longlong_type
296+ }
278297 else {
279298 self . clone ( )
280299 }
@@ -296,6 +315,21 @@ impl<'gcc, 'tcx> SignType<'gcc, 'tcx> for Type<'gcc> {
296315 else if self . is_i128 ( cx) {
297316 cx. u128_type
298317 }
318+ else if self . is_char ( cx) {
319+ cx. uchar_type
320+ }
321+ else if self . is_short ( cx) {
322+ cx. ushort_type
323+ }
324+ else if self . is_int ( cx) {
325+ cx. uint_type
326+ }
327+ else if self . is_long ( cx) {
328+ cx. ulong_type
329+ }
330+ else if self . is_longlong ( cx) {
331+ cx. ulonglong_type
332+ }
299333 else {
300334 self . clone ( )
301335 }
@@ -308,6 +342,11 @@ pub trait TypeReflection<'gcc, 'tcx> {
308342 fn is_uint ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
309343 fn is_ulong ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
310344 fn is_ulonglong ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
345+ fn is_char ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
346+ fn is_short ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
347+ fn is_int ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
348+ fn is_long ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
349+ fn is_longlong ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
311350
312351 fn is_i8 ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
313352 fn is_u8 ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
@@ -328,11 +367,11 @@ pub trait TypeReflection<'gcc, 'tcx> {
328367
329368impl < ' gcc , ' tcx > TypeReflection < ' gcc , ' tcx > for Type < ' gcc > {
330369 fn is_uchar ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
331- self . unqualified ( ) == cx. u8_type
370+ self . unqualified ( ) == cx. uchar_type
332371 }
333372
334373 fn is_ushort ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
335- self . unqualified ( ) == cx. u16_type
374+ self . unqualified ( ) == cx. ushort_type
336375 }
337376
338377 fn is_uint ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
@@ -347,6 +386,26 @@ impl<'gcc, 'tcx> TypeReflection<'gcc, 'tcx> for Type<'gcc> {
347386 self . unqualified ( ) == cx. ulonglong_type
348387 }
349388
389+ fn is_char ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
390+ self . unqualified ( ) == cx. char_type
391+ }
392+
393+ fn is_short ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
394+ self . unqualified ( ) == cx. short_type
395+ }
396+
397+ fn is_int ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
398+ self . unqualified ( ) == cx. int_type
399+ }
400+
401+ fn is_long ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
402+ self . unqualified ( ) == cx. long_type
403+ }
404+
405+ fn is_longlong ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
406+ self . unqualified ( ) == cx. longlong_type
407+ }
408+
350409 fn is_i8 ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
351410 self . unqualified ( ) == cx. i8_type
352411 }
0 commit comments