def o_bool(self, builder): r = VBool() if builder is not None: zero = ll.Constant(ll.IntType(64), 0) a = builder.extract_element(self.auto_load(builder), 0) r.auto_store(builder, builder.icmp_signed("!=", a, zero)) return r
def o_bool(self, builder): r = VBool() if builder is not None: zero = lc.Constant.int(lc.Type.int(64), 0) a = builder.extract_element( self.auto_load(builder), lc.Constant.int(lc.Type.int(), 0)) r.auto_store(builder, builder.icmp(lc.ICMP_NE, a, zero)) return r
def _o_cmp(self, other, icmp, builder): diff = self.o_sub(other, builder) if diff is NotImplemented: return NotImplemented r = VBool() if builder is not None: diff = diff.auto_load(builder) a = builder.extract_value(diff, 0) zero = ll.Constant(ll.IntType(64), 0) ssa_r = builder.icmp_signed(icmp, a, zero) r.auto_store(builder, ssa_r) return r
def _o_cmp(self, other, icmp, builder): diff = self.o_sub(other, builder) if diff is NotImplemented: return NotImplemented r = VBool() if builder is not None: diff = diff.auto_load(builder) a = builder.extract_element( diff, lc.Constant.int(lc.Type.int(), 0)) zero = lc.Constant.int(lc.Type.int(64), 0) ssa_r = builder.icmp(icmp, a, zero) r.auto_store(builder, ssa_r) return r
def _o_eq_inv(self, other, builder, ne): if not isinstance(other, (VInt, VFraction)): return NotImplemented r = VBool() if builder is not None: if isinstance(other, VInt): other = other.o_int64(builder) a, b = self._nd(builder) ssa_r = builder.and_( builder.icmp_signed("==", a, other.auto_load()), builder.icmp_signed("==", b, ll.Constant(ll.IntType(64), 1))) else: a, b = self._nd(builder) c, d = other._nd(builder) ssa_r = builder.and_( builder.icmp_signed("==", a, c), builder.icmp_signed("==", b, d)) if ne: ssa_r = builder.xor(ssa_r, ll.Constant(ll.IntType(1), 1)) r.auto_store(builder, ssa_r) return r