@@ -308,7 +308,7 @@ pub fn trans_switch<'a, 'tcx>(
308
308
scrutinee : ValueRef ,
309
309
range_assert : bool
310
310
) -> ( BranchKind , Option < ValueRef > ) {
311
- let l = bcx. ccx ( ) . layout_of ( t) ;
311
+ let l = bcx. ccx . layout_of ( t) ;
312
312
match * l {
313
313
layout:: CEnum { .. } | layout:: General { .. } |
314
314
layout:: RawNullablePointer { .. } | layout:: StructWrappedNullablePointer { .. } => {
@@ -343,7 +343,7 @@ pub fn trans_get_discr<'a, 'tcx>(
343
343
} ;
344
344
345
345
debug ! ( "trans_get_discr t: {:?}" , t) ;
346
- let l = bcx. ccx ( ) . layout_of ( t) ;
346
+ let l = bcx. ccx . layout_of ( t) ;
347
347
348
348
let val = match * l {
349
349
layout:: CEnum { discr, min, max, .. } => {
@@ -354,11 +354,11 @@ pub fn trans_get_discr<'a, 'tcx>(
354
354
load_discr ( bcx, discr, ptr, 0 , def. variants . len ( ) as u64 - 1 ,
355
355
range_assert)
356
356
}
357
- layout:: Univariant { .. } | layout:: UntaggedUnion { .. } => C_u8 ( bcx. ccx ( ) , 0 ) ,
357
+ layout:: Univariant { .. } | layout:: UntaggedUnion { .. } => C_u8 ( bcx. ccx , 0 ) ,
358
358
layout:: RawNullablePointer { nndiscr, .. } => {
359
359
let cmp = if nndiscr == 0 { IntEQ } else { IntNE } ;
360
- let llptrty = type_of:: sizing_type_of ( bcx. ccx ( ) ,
361
- monomorphize:: field_ty ( bcx. ccx ( ) . tcx ( ) , substs,
360
+ let llptrty = type_of:: sizing_type_of ( bcx. ccx ,
361
+ monomorphize:: field_ty ( bcx. ccx . tcx ( ) , substs,
362
362
& def. variants [ nndiscr as usize ] . fields [ 0 ] ) ) ;
363
363
bcx. icmp ( cmp, bcx. load ( scrutinee) , C_null ( llptrty) )
364
364
}
@@ -390,7 +390,7 @@ fn struct_wrapped_nullable_bitdiscr(
390
390
fn load_discr ( bcx : & BlockAndBuilder , ity : layout:: Integer , ptr : ValueRef , min : u64 , max : u64 ,
391
391
range_assert : bool )
392
392
-> ValueRef {
393
- let llty = Type :: from_integer ( bcx. ccx ( ) , ity) ;
393
+ let llty = Type :: from_integer ( bcx. ccx , ity) ;
394
394
assert_eq ! ( val_ty( ptr) , llty. ptr_to( ) ) ;
395
395
let bits = ity. size ( ) . bits ( ) ;
396
396
assert ! ( bits <= 64 ) ;
@@ -416,16 +416,16 @@ fn load_discr(bcx: &BlockAndBuilder, ity: layout::Integer, ptr: ValueRef, min: u
416
416
///
417
417
/// This should ideally be less tightly tied to `_match`.
418
418
pub fn trans_case < ' a , ' tcx > ( bcx : & BlockAndBuilder < ' a , ' tcx > , t : Ty < ' tcx > , value : Disr ) -> ValueRef {
419
- let l = bcx. ccx ( ) . layout_of ( t) ;
419
+ let l = bcx. ccx . layout_of ( t) ;
420
420
match * l {
421
421
layout:: CEnum { discr, .. }
422
422
| layout:: General { discr, .. } => {
423
- C_integral ( Type :: from_integer ( bcx. ccx ( ) , discr) , value. 0 , true )
423
+ C_integral ( Type :: from_integer ( bcx. ccx , discr) , value. 0 , true )
424
424
}
425
425
layout:: RawNullablePointer { .. } |
426
426
layout:: StructWrappedNullablePointer { .. } => {
427
427
assert ! ( value == Disr ( 0 ) || value == Disr ( 1 ) ) ;
428
- C_bool ( bcx. ccx ( ) , value != Disr ( 0 ) )
428
+ C_bool ( bcx. ccx , value != Disr ( 0 ) )
429
429
}
430
430
_ => {
431
431
bug ! ( "{} does not have a discriminant. Represented as {:#?}" , t, l) ;
@@ -438,15 +438,15 @@ pub fn trans_case<'a, 'tcx>(bcx: &BlockAndBuilder<'a, 'tcx>, t: Ty<'tcx>, value:
438
438
pub fn trans_set_discr < ' a , ' tcx > (
439
439
bcx : & BlockAndBuilder < ' a , ' tcx > , t : Ty < ' tcx > , val : ValueRef , to : Disr
440
440
) {
441
- let l = bcx. ccx ( ) . layout_of ( t) ;
441
+ let l = bcx. ccx . layout_of ( t) ;
442
442
match * l {
443
443
layout:: CEnum { discr, min, max, .. } => {
444
444
assert_discr_in_range ( Disr ( min) , Disr ( max) , to) ;
445
- bcx. store ( C_integral ( Type :: from_integer ( bcx. ccx ( ) , discr) , to. 0 , true ) ,
445
+ bcx. store ( C_integral ( Type :: from_integer ( bcx. ccx , discr) , to. 0 , true ) ,
446
446
val) ;
447
447
}
448
448
layout:: General { discr, .. } => {
449
- bcx. store ( C_integral ( Type :: from_integer ( bcx. ccx ( ) , discr) , to. 0 , true ) ,
449
+ bcx. store ( C_integral ( Type :: from_integer ( bcx. ccx , discr) , to. 0 , true ) ,
450
450
bcx. struct_gep ( val, 0 ) ) ;
451
451
}
452
452
layout:: Univariant { .. }
@@ -455,9 +455,9 @@ pub fn trans_set_discr<'a, 'tcx>(
455
455
assert_eq ! ( to, Disr ( 0 ) ) ;
456
456
}
457
457
layout:: RawNullablePointer { nndiscr, .. } => {
458
- let nnty = compute_fields ( bcx. ccx ( ) , t, nndiscr as usize , false ) [ 0 ] ;
458
+ let nnty = compute_fields ( bcx. ccx , t, nndiscr as usize , false ) [ 0 ] ;
459
459
if to. 0 != nndiscr {
460
- let llptrty = type_of:: sizing_type_of ( bcx. ccx ( ) , nnty) ;
460
+ let llptrty = type_of:: sizing_type_of ( bcx. ccx , nnty) ;
461
461
bcx. store ( C_null ( llptrty) , val) ;
462
462
}
463
463
}
@@ -467,10 +467,10 @@ pub fn trans_set_discr<'a, 'tcx>(
467
467
// Issue #34427: As workaround for LLVM bug on
468
468
// ARM, use memset of 0 on whole struct rather
469
469
// than storing null to single target field.
470
- let llptr = bcx. pointercast ( val, Type :: i8 ( bcx. ccx ( ) ) . ptr_to ( ) ) ;
471
- let fill_byte = C_u8 ( bcx. ccx ( ) , 0 ) ;
472
- let size = C_uint ( bcx. ccx ( ) , nonnull. stride ( ) . bytes ( ) ) ;
473
- let align = C_i32 ( bcx. ccx ( ) , nonnull. align . abi ( ) as i32 ) ;
470
+ let llptr = bcx. pointercast ( val, Type :: i8 ( bcx. ccx ) . ptr_to ( ) ) ;
471
+ let fill_byte = C_u8 ( bcx. ccx , 0 ) ;
472
+ let size = C_uint ( bcx. ccx , nonnull. stride ( ) . bytes ( ) ) ;
473
+ let align = C_i32 ( bcx. ccx , nonnull. align . abi ( ) as i32 ) ;
474
474
base:: call_memset ( bcx, llptr, fill_byte, size, align, false ) ;
475
475
} else {
476
476
let path = discrfield. iter ( ) . map ( |& i| i as usize ) . collect :: < Vec < _ > > ( ) ;
@@ -504,7 +504,7 @@ pub fn trans_field_ptr<'a, 'tcx>(
504
504
discr : Disr ,
505
505
ix : usize
506
506
) -> ValueRef {
507
- let l = bcx. ccx ( ) . layout_of ( t) ;
507
+ let l = bcx. ccx . layout_of ( t) ;
508
508
debug ! ( "trans_field_ptr on {} represented as {:#?}" , t, l) ;
509
509
// Note: if this ever needs to generate conditionals (e.g., if we
510
510
// decide to do some kind of cdr-coding-like non-unique repr
@@ -513,7 +513,7 @@ pub fn trans_field_ptr<'a, 'tcx>(
513
513
layout:: Univariant { ref variant, .. } => {
514
514
assert_eq ! ( discr, Disr ( 0 ) ) ;
515
515
struct_field_ptr ( bcx, & variant,
516
- & compute_fields ( bcx. ccx ( ) , t, 0 , false ) ,
516
+ & compute_fields ( bcx. ccx , t, 0 , false ) ,
517
517
val, ix, false )
518
518
}
519
519
layout:: Vector { count, .. } => {
@@ -522,37 +522,37 @@ pub fn trans_field_ptr<'a, 'tcx>(
522
522
bcx. struct_gep ( val. value , ix)
523
523
}
524
524
layout:: General { discr : d, ref variants, .. } => {
525
- let mut fields = compute_fields ( bcx. ccx ( ) , t, discr. 0 as usize , false ) ;
526
- fields. insert ( 0 , d. to_ty ( & bcx. ccx ( ) . tcx ( ) , false ) ) ;
525
+ let mut fields = compute_fields ( bcx. ccx , t, discr. 0 as usize , false ) ;
526
+ fields. insert ( 0 , d. to_ty ( & bcx. ccx . tcx ( ) , false ) ) ;
527
527
struct_field_ptr ( bcx, & variants[ discr. 0 as usize ] ,
528
528
& fields,
529
529
val, ix + 1 , true )
530
530
}
531
531
layout:: UntaggedUnion { .. } => {
532
- let fields = compute_fields ( bcx. ccx ( ) , t, 0 , false ) ;
533
- let ty = type_of:: in_memory_type_of ( bcx. ccx ( ) , fields[ ix] ) ;
532
+ let fields = compute_fields ( bcx. ccx , t, 0 , false ) ;
533
+ let ty = type_of:: in_memory_type_of ( bcx. ccx , fields[ ix] ) ;
534
534
bcx. pointercast ( val. value , ty. ptr_to ( ) )
535
535
}
536
536
layout:: RawNullablePointer { nndiscr, .. } |
537
537
layout:: StructWrappedNullablePointer { nndiscr, .. } if discr. 0 != nndiscr => {
538
- let nullfields = compute_fields ( bcx. ccx ( ) , t, ( 1 -nndiscr) as usize , false ) ;
538
+ let nullfields = compute_fields ( bcx. ccx , t, ( 1 -nndiscr) as usize , false ) ;
539
539
// The unit-like case might have a nonzero number of unit-like fields.
540
540
// (e.d., Result of Either with (), as one side.)
541
- let ty = type_of:: type_of ( bcx. ccx ( ) , nullfields[ ix] ) ;
542
- assert_eq ! ( machine:: llsize_of_alloc( bcx. ccx( ) , ty) , 0 ) ;
541
+ let ty = type_of:: type_of ( bcx. ccx , nullfields[ ix] ) ;
542
+ assert_eq ! ( machine:: llsize_of_alloc( bcx. ccx, ty) , 0 ) ;
543
543
bcx. pointercast ( val. value , ty. ptr_to ( ) )
544
544
}
545
545
layout:: RawNullablePointer { nndiscr, .. } => {
546
- let nnty = compute_fields ( bcx. ccx ( ) , t, nndiscr as usize , false ) [ 0 ] ;
546
+ let nnty = compute_fields ( bcx. ccx , t, nndiscr as usize , false ) [ 0 ] ;
547
547
assert_eq ! ( ix, 0 ) ;
548
548
assert_eq ! ( discr. 0 , nndiscr) ;
549
- let ty = type_of:: type_of ( bcx. ccx ( ) , nnty) ;
549
+ let ty = type_of:: type_of ( bcx. ccx , nnty) ;
550
550
bcx. pointercast ( val. value , ty. ptr_to ( ) )
551
551
}
552
552
layout:: StructWrappedNullablePointer { ref nonnull, nndiscr, .. } => {
553
553
assert_eq ! ( discr. 0 , nndiscr) ;
554
554
struct_field_ptr ( bcx, & nonnull,
555
- & compute_fields ( bcx. ccx ( ) , t, discr. 0 as usize , false ) ,
555
+ & compute_fields ( bcx. ccx , t, discr. 0 as usize , false ) ,
556
556
val, ix, false )
557
557
}
558
558
_ => bug ! ( "element access in type without elements: {} represented as {:#?}" , t, l)
@@ -568,7 +568,7 @@ fn struct_field_ptr<'a, 'tcx>(
568
568
needs_cast : bool
569
569
) -> ValueRef {
570
570
let fty = fields[ ix] ;
571
- let ccx = bcx. ccx ( ) ;
571
+ let ccx = bcx. ccx ;
572
572
573
573
let ptr_val = if needs_cast {
574
574
let fields = st. field_index_by_increasing_offset ( ) . map ( |i| {
@@ -585,7 +585,7 @@ fn struct_field_ptr<'a, 'tcx>(
585
585
// * Packed struct - There is no alignment padding
586
586
// * Field is sized - pointer is properly aligned already
587
587
if st. offsets [ ix] == layout:: Size :: from_bytes ( 0 ) || st. packed ||
588
- bcx. ccx ( ) . shared ( ) . type_is_sized ( fty) {
588
+ bcx. ccx . shared ( ) . type_is_sized ( fty) {
589
589
return bcx. struct_gep ( ptr_val, st. memory_index [ ix] as usize ) ;
590
590
}
591
591
@@ -624,7 +624,7 @@ fn struct_field_ptr<'a, 'tcx>(
624
624
625
625
626
626
let offset = st. offsets [ ix] . bytes ( ) ;
627
- let unaligned_offset = C_uint ( bcx. ccx ( ) , offset) ;
627
+ let unaligned_offset = C_uint ( bcx. ccx , offset) ;
628
628
629
629
// Get the alignment of the field
630
630
let ( _, align) = glue:: size_and_align_of_dst ( bcx, fty, meta) ;
@@ -635,18 +635,18 @@ fn struct_field_ptr<'a, 'tcx>(
635
635
// (unaligned offset + (align - 1)) & -align
636
636
637
637
// Calculate offset
638
- let align_sub_1 = bcx. sub ( align, C_uint ( bcx. ccx ( ) , 1u64 ) ) ;
638
+ let align_sub_1 = bcx. sub ( align, C_uint ( bcx. ccx , 1u64 ) ) ;
639
639
let offset = bcx. and ( bcx. add ( unaligned_offset, align_sub_1) ,
640
640
bcx. neg ( align) ) ;
641
641
642
642
debug ! ( "struct_field_ptr: DST field offset: {:?}" , Value ( offset) ) ;
643
643
644
644
// Cast and adjust pointer
645
- let byte_ptr = bcx. pointercast ( ptr_val, Type :: i8p ( bcx. ccx ( ) ) ) ;
645
+ let byte_ptr = bcx. pointercast ( ptr_val, Type :: i8p ( bcx. ccx ) ) ;
646
646
let byte_ptr = bcx. gep ( byte_ptr, & [ offset] ) ;
647
647
648
648
// Finally, cast back to the type expected
649
- let ll_fty = type_of:: in_memory_type_of ( bcx. ccx ( ) , fty) ;
649
+ let ll_fty = type_of:: in_memory_type_of ( bcx. ccx , fty) ;
650
650
debug ! ( "struct_field_ptr: Field type is {:?}" , ll_fty) ;
651
651
bcx. pointercast ( byte_ptr, ll_fty. ptr_to ( ) )
652
652
}
0 commit comments