@@ -18,7 +18,6 @@ use rustc_apfloat::{ieee, Float, Status, Round};
18
18
use rustc_const_math:: MAX_F32_PLUS_HALF_ULP ;
19
19
use std:: { u128, i128} ;
20
20
21
- use abi;
22
21
use base;
23
22
use builder:: Builder ;
24
23
use callee;
@@ -54,10 +53,10 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
54
53
bcx
55
54
}
56
55
57
- mir:: Rvalue :: Cast ( mir:: CastKind :: Unsize , ref source, cast_ty ) => {
58
- let cast_ty = self . monomorphize ( & cast_ty ) ;
59
-
60
- if common :: type_is_fat_ptr ( bcx . ccx , cast_ty ) {
56
+ mir:: Rvalue :: Cast ( mir:: CastKind :: Unsize , ref source, _ ) => {
57
+ // The destination necessarily contains a fat pointer, so if
58
+ // it's a scalar pair, it's a fat pointer or newtype thereof.
59
+ if dest . layout . is_llvm_scalar_pair ( ) {
61
60
// into-coerce of a thin pointer to a fat pointer - just
62
61
// use the operand path.
63
62
let ( bcx, temp) = self . trans_rvalue_operand ( bcx, rvalue) ;
@@ -223,6 +222,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
223
222
operand. val
224
223
}
225
224
mir:: CastKind :: Unsize => {
225
+ assert ! ( cast. is_llvm_scalar_pair( ) ) ;
226
226
match operand. val {
227
227
OperandValue :: Pair ( lldata, llextra) => {
228
228
// unsize from a fat pointer - this is a
@@ -248,12 +248,11 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
248
248
}
249
249
}
250
250
}
251
- mir:: CastKind :: Misc if common :: type_is_fat_ptr ( bcx . ccx , operand. layout . ty ) => {
251
+ mir:: CastKind :: Misc if operand. layout . is_llvm_scalar_pair ( ) => {
252
252
if let OperandValue :: Pair ( data_ptr, meta) = operand. val {
253
- if common:: type_is_fat_ptr ( bcx. ccx , cast. ty ) {
254
- let thin_ptr = cast. field ( bcx. ccx , abi:: FAT_PTR_ADDR ) ;
253
+ if cast. is_llvm_scalar_pair ( ) {
255
254
let data_cast = bcx. pointercast ( data_ptr,
256
- thin_ptr . llvm_type ( bcx. ccx ) ) ;
255
+ cast . scalar_pair_element_llvm_type ( bcx. ccx , 0 ) ) ;
257
256
OperandValue :: Pair ( data_cast, meta)
258
257
} else { // cast to thin-ptr
259
258
// Cast of fat-ptr to thin-ptr is an extraction of data-ptr and
@@ -368,22 +367,21 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
368
367
mir:: Rvalue :: BinaryOp ( op, ref lhs, ref rhs) => {
369
368
let lhs = self . trans_operand ( & bcx, lhs) ;
370
369
let rhs = self . trans_operand ( & bcx, rhs) ;
371
- let llresult = if common:: type_is_fat_ptr ( bcx. ccx , lhs. layout . ty ) {
372
- match ( lhs. val , rhs. val ) {
373
- ( OperandValue :: Pair ( lhs_addr, lhs_extra) ,
374
- OperandValue :: Pair ( rhs_addr, rhs_extra) ) => {
375
- self . trans_fat_ptr_binop ( & bcx, op,
376
- lhs_addr, lhs_extra,
377
- rhs_addr, rhs_extra,
378
- lhs. layout . ty )
379
- }
380
- _ => bug ! ( )
370
+ let llresult = match ( lhs. val , rhs. val ) {
371
+ ( OperandValue :: Pair ( lhs_addr, lhs_extra) ,
372
+ OperandValue :: Pair ( rhs_addr, rhs_extra) ) => {
373
+ self . trans_fat_ptr_binop ( & bcx, op,
374
+ lhs_addr, lhs_extra,
375
+ rhs_addr, rhs_extra,
376
+ lhs. layout . ty )
381
377
}
382
378
383
- } else {
384
- self . trans_scalar_binop ( & bcx, op,
385
- lhs. immediate ( ) , rhs. immediate ( ) ,
386
- lhs. layout . ty )
379
+ ( OperandValue :: Immediate ( lhs_val) ,
380
+ OperandValue :: Immediate ( rhs_val) ) => {
381
+ self . trans_scalar_binop ( & bcx, op, lhs_val, rhs_val, lhs. layout . ty )
382
+ }
383
+
384
+ _ => bug ! ( )
387
385
} ;
388
386
let operand = OperandRef {
389
387
val : OperandValue :: Immediate ( llresult) ,
0 commit comments