@@ -1052,6 +1052,7 @@ fn trans_ptr_binop<'a, 'tcx: 'a>(
1052
1052
} else {
1053
1053
let ( lhs_ptr, lhs_extra) = lhs. load_scalar_pair ( fx) ;
1054
1054
let ( rhs_ptr, rhs_extra) = rhs. load_scalar_pair ( fx) ;
1055
+
1055
1056
let res = match bin_op {
1056
1057
BinOp :: Eq => {
1057
1058
let ptr_eq = fx. bcx . ins ( ) . icmp ( IntCC :: Equal , lhs_ptr, rhs_ptr) ;
@@ -1063,10 +1064,28 @@ fn trans_ptr_binop<'a, 'tcx: 'a>(
1063
1064
let extra_ne = fx. bcx . ins ( ) . icmp ( IntCC :: NotEqual , lhs_extra, rhs_extra) ;
1064
1065
fx. bcx . ins ( ) . bor ( ptr_ne, extra_ne)
1065
1066
}
1066
- _ => unimplemented ! (
1067
- "trans_ptr_binop({:?}, <fat ptr>, <fat ptr>) not implemented" ,
1068
- bin_op
1069
- ) ,
1067
+ BinOp :: Lt | BinOp :: Le | BinOp :: Ge | BinOp :: Gt => {
1068
+ let ptr_eq = fx. bcx . ins ( ) . icmp ( IntCC :: Equal , lhs_ptr, rhs_ptr) ;
1069
+
1070
+ let ptr_cmp = fx. bcx . ins ( ) . icmp ( match bin_op {
1071
+ BinOp :: Lt => IntCC :: UnsignedLessThan ,
1072
+ BinOp :: Le => IntCC :: UnsignedLessThanOrEqual ,
1073
+ BinOp :: Ge => IntCC :: UnsignedGreaterThanOrEqual ,
1074
+ BinOp :: Gt => IntCC :: UnsignedGreaterThan ,
1075
+ _ => unreachable ! ( ) ,
1076
+ } , lhs_ptr, rhs_ptr) ;
1077
+
1078
+ let extra_cmp = fx. bcx . ins ( ) . icmp ( match bin_op {
1079
+ BinOp :: Lt => IntCC :: UnsignedLessThan ,
1080
+ BinOp :: Le => IntCC :: UnsignedLessThanOrEqual ,
1081
+ BinOp :: Ge => IntCC :: UnsignedGreaterThanOrEqual ,
1082
+ BinOp :: Gt => IntCC :: UnsignedGreaterThan ,
1083
+ _ => unreachable ! ( ) ,
1084
+ } , lhs_extra, rhs_extra) ;
1085
+
1086
+ fx. bcx . ins ( ) . select ( ptr_eq, extra_cmp, ptr_cmp)
1087
+ }
1088
+ _ => panic ! ( "bin_op {:?} on ptr" , bin_op) ,
1070
1089
} ;
1071
1090
1072
1091
assert_eq ! ( fx. tcx. types. bool , ret_ty) ;
0 commit comments