@@ -91,6 +91,10 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
91
91
self . const_uint ( self . type_i1 ( ) , val as u64 )
92
92
}
93
93
94
+ fn const_i16 ( & self , i : i16 ) -> RValue < ' gcc > {
95
+ self . const_int ( self . type_i16 ( ) , i as i64 )
96
+ }
97
+
94
98
fn const_i32 ( & self , i : i32 ) -> RValue < ' gcc > {
95
99
self . const_int ( self . type_i32 ( ) , i as i64 )
96
100
}
@@ -154,14 +158,14 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
154
158
}
155
159
156
160
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 ( ) } ;
158
162
match cv {
159
163
Scalar :: Int ( ScalarInt :: ZST ) => {
160
- assert_eq ! ( 0 , layout. value . size( self ) . bytes( ) ) ;
164
+ assert_eq ! ( 0 , layout. size( self ) . bytes( ) ) ;
161
165
self . const_undef ( self . type_ix ( 0 ) )
162
166
}
163
167
Scalar :: Int ( int) => {
164
- let data = int. assert_bits ( layout. value . size ( self ) ) ;
168
+ let data = int. assert_bits ( layout. size ( self ) ) ;
165
169
166
170
// FIXME(antoyo): there's some issues with using the u128 code that follows, so hard-code
167
171
// the paths for floating-point values.
@@ -205,7 +209,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
205
209
let base_addr = self . const_bitcast ( base_addr, self . usize_type ) ;
206
210
let offset = self . context . new_rvalue_from_long ( self . usize_type , offset. bytes ( ) as i64 ) ;
207
211
let ptr = self . const_bitcast ( base_addr + offset, ptr_type) ;
208
- if layout. value != Pointer {
212
+ if layout. primitive ( ) != Pointer {
209
213
self . const_bitcast ( ptr. dereference ( None ) . to_rvalue ( ) , ty)
210
214
}
211
215
else {
@@ -275,6 +279,21 @@ impl<'gcc, 'tcx> SignType<'gcc, 'tcx> for Type<'gcc> {
275
279
else if self . is_u128 ( cx) {
276
280
cx. i128_type
277
281
}
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
+ }
278
297
else {
279
298
self . clone ( )
280
299
}
@@ -296,6 +315,21 @@ impl<'gcc, 'tcx> SignType<'gcc, 'tcx> for Type<'gcc> {
296
315
else if self . is_i128 ( cx) {
297
316
cx. u128_type
298
317
}
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
+ }
299
333
else {
300
334
self . clone ( )
301
335
}
@@ -308,6 +342,11 @@ pub trait TypeReflection<'gcc, 'tcx> {
308
342
fn is_uint ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
309
343
fn is_ulong ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
310
344
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 ;
311
350
312
351
fn is_i8 ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
313
352
fn is_u8 ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool ;
@@ -328,11 +367,11 @@ pub trait TypeReflection<'gcc, 'tcx> {
328
367
329
368
impl < ' gcc , ' tcx > TypeReflection < ' gcc , ' tcx > for Type < ' gcc > {
330
369
fn is_uchar ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
331
- self . unqualified ( ) == cx. u8_type
370
+ self . unqualified ( ) == cx. uchar_type
332
371
}
333
372
334
373
fn is_ushort ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
335
- self . unqualified ( ) == cx. u16_type
374
+ self . unqualified ( ) == cx. ushort_type
336
375
}
337
376
338
377
fn is_uint ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
@@ -347,6 +386,26 @@ impl<'gcc, 'tcx> TypeReflection<'gcc, 'tcx> for Type<'gcc> {
347
386
self . unqualified ( ) == cx. ulonglong_type
348
387
}
349
388
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
+
350
409
fn is_i8 ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> bool {
351
410
self . unqualified ( ) == cx. i8_type
352
411
}
0 commit comments