@@ -255,124 +255,6 @@ pub fn bin_op_to_fcmp_predicate(op: hir::BinOp_) -> llvm::RealPredicate {
255
255
}
256
256
}
257
257
258
- pub fn compare_fat_ptrs < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
259
- lhs_addr : ValueRef ,
260
- lhs_extra : ValueRef ,
261
- rhs_addr : ValueRef ,
262
- rhs_extra : ValueRef ,
263
- _t : Ty < ' tcx > ,
264
- op : hir:: BinOp_ ,
265
- debug_loc : DebugLoc )
266
- -> ValueRef {
267
- match op {
268
- hir:: BiEq => {
269
- let addr_eq = ICmp ( bcx, llvm:: IntEQ , lhs_addr, rhs_addr, debug_loc) ;
270
- let extra_eq = ICmp ( bcx, llvm:: IntEQ , lhs_extra, rhs_extra, debug_loc) ;
271
- And ( bcx, addr_eq, extra_eq, debug_loc)
272
- }
273
- hir:: BiNe => {
274
- let addr_eq = ICmp ( bcx, llvm:: IntNE , lhs_addr, rhs_addr, debug_loc) ;
275
- let extra_eq = ICmp ( bcx, llvm:: IntNE , lhs_extra, rhs_extra, debug_loc) ;
276
- Or ( bcx, addr_eq, extra_eq, debug_loc)
277
- }
278
- hir:: BiLe | hir:: BiLt | hir:: BiGe | hir:: BiGt => {
279
- // a OP b ~ a.0 STRICT(OP) b.0 | (a.0 == b.0 && a.1 OP a.1)
280
- let ( op, strict_op) = match op {
281
- hir:: BiLt => ( llvm:: IntULT , llvm:: IntULT ) ,
282
- hir:: BiLe => ( llvm:: IntULE , llvm:: IntULT ) ,
283
- hir:: BiGt => ( llvm:: IntUGT , llvm:: IntUGT ) ,
284
- hir:: BiGe => ( llvm:: IntUGE , llvm:: IntUGT ) ,
285
- _ => bug ! ( ) ,
286
- } ;
287
-
288
- let addr_eq = ICmp ( bcx, llvm:: IntEQ , lhs_addr, rhs_addr, debug_loc) ;
289
- let extra_op = ICmp ( bcx, op, lhs_extra, rhs_extra, debug_loc) ;
290
- let addr_eq_extra_op = And ( bcx, addr_eq, extra_op, debug_loc) ;
291
-
292
- let addr_strict = ICmp ( bcx, strict_op, lhs_addr, rhs_addr, debug_loc) ;
293
- Or ( bcx, addr_strict, addr_eq_extra_op, debug_loc)
294
- }
295
- _ => {
296
- bug ! ( "unexpected fat ptr binop" ) ;
297
- }
298
- }
299
- }
300
-
301
- pub fn compare_scalar_types < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
302
- lhs : ValueRef ,
303
- rhs : ValueRef ,
304
- t : Ty < ' tcx > ,
305
- op : hir:: BinOp_ ,
306
- debug_loc : DebugLoc )
307
- -> ValueRef {
308
- match t. sty {
309
- ty:: TyTuple ( ref tys) if tys. is_empty ( ) => {
310
- // We don't need to do actual comparisons for nil.
311
- // () == () holds but () < () does not.
312
- match op {
313
- hir:: BiEq | hir:: BiLe | hir:: BiGe => return C_bool ( bcx. ccx ( ) , true ) ,
314
- hir:: BiNe | hir:: BiLt | hir:: BiGt => return C_bool ( bcx. ccx ( ) , false ) ,
315
- // refinements would be nice
316
- _ => bug ! ( "compare_scalar_types: must be a comparison operator" ) ,
317
- }
318
- }
319
- ty:: TyBool => {
320
- // FIXME(#36856) -- using `from_immediate` forces these booleans into `i8`,
321
- // which works around some LLVM bugs
322
- ICmp ( bcx,
323
- bin_op_to_icmp_predicate ( op, false ) ,
324
- from_immediate ( bcx, lhs) ,
325
- from_immediate ( bcx, rhs) ,
326
- debug_loc)
327
- }
328
- ty:: TyFnDef ( ..) | ty:: TyFnPtr ( _) | ty:: TyUint ( _) | ty:: TyChar => {
329
- ICmp ( bcx,
330
- bin_op_to_icmp_predicate ( op, false ) ,
331
- lhs,
332
- rhs,
333
- debug_loc)
334
- }
335
- ty:: TyRawPtr ( mt) if common:: type_is_sized ( bcx. tcx ( ) , mt. ty ) => {
336
- ICmp ( bcx,
337
- bin_op_to_icmp_predicate ( op, false ) ,
338
- lhs,
339
- rhs,
340
- debug_loc)
341
- }
342
- ty:: TyRawPtr ( _) => {
343
- let lhs_addr = Load ( bcx, GEPi ( bcx, lhs, & [ 0 , abi:: FAT_PTR_ADDR ] ) ) ;
344
- let lhs_extra = Load ( bcx, GEPi ( bcx, lhs, & [ 0 , abi:: FAT_PTR_EXTRA ] ) ) ;
345
-
346
- let rhs_addr = Load ( bcx, GEPi ( bcx, rhs, & [ 0 , abi:: FAT_PTR_ADDR ] ) ) ;
347
- let rhs_extra = Load ( bcx, GEPi ( bcx, rhs, & [ 0 , abi:: FAT_PTR_EXTRA ] ) ) ;
348
- compare_fat_ptrs ( bcx,
349
- lhs_addr,
350
- lhs_extra,
351
- rhs_addr,
352
- rhs_extra,
353
- t,
354
- op,
355
- debug_loc)
356
- }
357
- ty:: TyInt ( _) => {
358
- ICmp ( bcx,
359
- bin_op_to_icmp_predicate ( op, true ) ,
360
- lhs,
361
- rhs,
362
- debug_loc)
363
- }
364
- ty:: TyFloat ( _) => {
365
- FCmp ( bcx,
366
- bin_op_to_fcmp_predicate ( op) ,
367
- lhs,
368
- rhs,
369
- debug_loc)
370
- }
371
- // Should never get here, because t is scalar.
372
- _ => bug ! ( "non-scalar type passed to compare_scalar_types" ) ,
373
- }
374
- }
375
-
376
258
pub fn compare_simd_types < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
377
259
lhs : ValueRef ,
378
260
rhs : ValueRef ,
@@ -693,12 +575,9 @@ pub fn store_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, dst: ValueRef, t
693
575
debug ! ( "store_ty: {:?} : {:?} <- {:?}" , Value ( dst) , t, Value ( v) ) ;
694
576
695
577
if common:: type_is_fat_ptr ( cx. tcx ( ) , t) {
696
- Store ( cx,
697
- ExtractValue ( cx, v, abi:: FAT_PTR_ADDR ) ,
698
- get_dataptr ( cx, dst) ) ;
699
- Store ( cx,
700
- ExtractValue ( cx, v, abi:: FAT_PTR_EXTRA ) ,
701
- get_meta ( cx, dst) ) ;
578
+ let lladdr = ExtractValue ( cx, v, abi:: FAT_PTR_ADDR ) ;
579
+ let llextra = ExtractValue ( cx, v, abi:: FAT_PTR_EXTRA ) ;
580
+ store_fat_ptr ( cx, lladdr, llextra, dst, t) ;
702
581
} else {
703
582
Store ( cx, from_immediate ( cx, v) , dst) ;
704
583
}
0 commit comments