@@ -60,22 +60,43 @@ pub fn maybe_codegen<'a, 'tcx>(
60
60
assert ! ( !checked) ;
61
61
let ( lhs_lsb, lhs_msb) = fx. bcx . ins ( ) . isplit ( lhs_val) ;
62
62
let ( rhs_lsb, rhs_msb) = fx. bcx . ins ( ) . isplit ( rhs_val) ;
63
- let res = match ( bin_op, is_signed) {
64
- ( BinOp :: Eq , _) => {
63
+
64
+ let res = match bin_op {
65
+ BinOp :: Eq => {
65
66
let lsb_eq = fx. bcx . ins ( ) . icmp ( IntCC :: Equal , lhs_lsb, rhs_lsb) ;
66
67
let msb_eq = fx. bcx . ins ( ) . icmp ( IntCC :: Equal , lhs_msb, rhs_msb) ;
67
68
fx. bcx . ins ( ) . band ( lsb_eq, msb_eq)
68
69
}
69
- ( BinOp :: Ne , _ ) => {
70
+ BinOp :: Ne => {
70
71
let lsb_ne = fx. bcx . ins ( ) . icmp ( IntCC :: NotEqual , lhs_lsb, rhs_lsb) ;
71
72
let msb_ne = fx. bcx . ins ( ) . icmp ( IntCC :: NotEqual , lhs_msb, rhs_msb) ;
72
73
fx. bcx . ins ( ) . bor ( lsb_ne, msb_ne)
73
74
}
74
75
_ => {
75
- // FIXME implement it
76
- let out_layout = fx. layout_of ( out_ty) ;
77
- return Some ( crate :: trap:: trap_unreachable_ret_value ( fx, out_layout, format ! ( "unimplemented 128bit binop {:?}" , bin_op) ) ) ;
78
- } ,
76
+ // if msb_eq {
77
+ // lhs_cc
78
+ // } else {
79
+ // msb_cc
80
+ // }
81
+ let cc = match ( bin_op, is_signed) {
82
+ ( BinOp :: Ge , false ) => IntCC :: UnsignedGreaterThanOrEqual ,
83
+ ( BinOp :: Gt , false ) => IntCC :: UnsignedGreaterThan ,
84
+ ( BinOp :: Lt , false ) => IntCC :: UnsignedLessThan ,
85
+ ( BinOp :: Le , false ) => IntCC :: UnsignedLessThanOrEqual ,
86
+
87
+ ( BinOp :: Ge , true ) => IntCC :: SignedGreaterThanOrEqual ,
88
+ ( BinOp :: Gt , true ) => IntCC :: SignedGreaterThan ,
89
+ ( BinOp :: Lt , true ) => IntCC :: SignedLessThan ,
90
+ ( BinOp :: Le , true ) => IntCC :: SignedLessThanOrEqual ,
91
+ _ => unreachable ! ( ) ,
92
+ } ;
93
+
94
+ let msb_eq = fx. bcx . ins ( ) . icmp ( IntCC :: Equal , lhs_msb, rhs_msb) ;
95
+ let lsb_cc = fx. bcx . ins ( ) . icmp ( cc, lhs_lsb, rhs_lsb) ;
96
+ let msb_cc = fx. bcx . ins ( ) . icmp ( cc, lhs_msb, rhs_msb) ;
97
+
98
+ fx. bcx . ins ( ) . select ( msb_eq, lsb_cc, msb_cc)
99
+ }
79
100
} ;
80
101
81
102
let res = fx. bcx . ins ( ) . bint ( types:: I8 , res) ;
0 commit comments