@@ -18,7 +18,6 @@ use rustc_apfloat::{ieee, Float, Status, Round};
1818use rustc_const_math:: MAX_F32_PLUS_HALF_ULP ;
1919use std:: { u128, i128} ;
2020
21- use abi;
2221use base;
2322use builder:: Builder ;
2423use callee;
@@ -54,10 +53,10 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
5453 bcx
5554 }
5655
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 ( ) {
6160 // into-coerce of a thin pointer to a fat pointer - just
6261 // use the operand path.
6362 let ( bcx, temp) = self . trans_rvalue_operand ( bcx, rvalue) ;
@@ -223,6 +222,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
223222 operand. val
224223 }
225224 mir:: CastKind :: Unsize => {
225+ assert ! ( cast. is_llvm_scalar_pair( ) ) ;
226226 match operand. val {
227227 OperandValue :: Pair ( lldata, llextra) => {
228228 // unsize from a fat pointer - this is a
@@ -248,12 +248,11 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
248248 }
249249 }
250250 }
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 ( ) => {
252252 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 ( ) {
255254 let data_cast = bcx. pointercast ( data_ptr,
256- thin_ptr . llvm_type ( bcx. ccx ) ) ;
255+ cast . scalar_pair_element_llvm_type ( bcx. ccx , 0 ) ) ;
257256 OperandValue :: Pair ( data_cast, meta)
258257 } else { // cast to thin-ptr
259258 // Cast of fat-ptr to thin-ptr is an extraction of data-ptr and
@@ -368,22 +367,21 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
368367 mir:: Rvalue :: BinaryOp ( op, ref lhs, ref rhs) => {
369368 let lhs = self . trans_operand ( & bcx, lhs) ;
370369 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 )
381377 }
382378
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 ! ( )
387385 } ;
388386 let operand = OperandRef {
389387 val : OperandValue :: Immediate ( llresult) ,
0 commit comments