with cgutils.goto_block(builder, bb_postest): builder.cbranch(cmp_pos, bb_pos, bb_neg) with cgutils.goto_block(builder, bb_pos): builder.store(POS, presult) builder.branch(bb_exit) with cgutils.goto_block(builder, bb_neg): builder.store(NEG, presult) builder.branch(bb_exit) builder.position_at_end(bb_exit) return builder.load(presult) builtin(implement('==', types.boolean, types.boolean)(int_eq_impl)) builtin(implement('!=', types.boolean, types.boolean)(int_ne_impl)) builtin(implement('<', types.boolean, types.boolean)(int_ult_impl)) builtin(implement('<=', types.boolean, types.boolean)(int_ule_impl)) builtin(implement('>', types.boolean, types.boolean)(int_ugt_impl)) builtin(implement('>=', types.boolean, types.boolean)(int_uge_impl)) builtin(implement('~', types.boolean)(int_invert_impl)) for ty in types.integer_domain: builtin(implement('+', ty, ty)(int_add_impl)) builtin(implement('-', ty, ty)(int_sub_impl)) builtin(implement('*', ty, ty)(int_mul_impl)) builtin(implement('==', ty, ty)(int_eq_impl)) builtin(implement('!=', ty, ty)(int_ne_impl)) builtin(implement('<<', ty, types.uint32)(int_shl_impl))
timedelta_eq_timedelta_impl = _create_timedelta_comparison_impl( lc.ICMP_EQ, cgutils.false_bit) timedelta_ne_timedelta_impl = _create_timedelta_comparison_impl( lc.ICMP_NE, cgutils.true_bit) timedelta_lt_timedelta_impl = _create_timedelta_ordering_impl(lc.ICMP_SLT) timedelta_le_timedelta_impl = _create_timedelta_ordering_impl(lc.ICMP_SLE) timedelta_gt_timedelta_impl = _create_timedelta_ordering_impl(lc.ICMP_SGT) timedelta_ge_timedelta_impl = _create_timedelta_ordering_impl(lc.ICMP_SGE) for op, func in [('==', timedelta_eq_timedelta_impl), ('!=', timedelta_ne_timedelta_impl), ('<', timedelta_lt_timedelta_impl), ('<=', timedelta_le_timedelta_impl), ('>', timedelta_gt_timedelta_impl), ('>=', timedelta_ge_timedelta_impl)]: builtin(implement(op, *TIMEDELTA_BINOP_SIG)(func)) # Arithmetic on datetime64 def is_leap_year(builder, year_val): """ Return a predicate indicating whether *year_val* (offset by 1970) is a leap year. """ actual_year = builder.add(year_val, Constant.int(DATETIME64, 1970)) multiple_of_4 = cgutils.is_null( builder, builder.and_(actual_year, Constant.int(DATETIME64, 3))) not_multiple_of_100 = cgutils.is_not_null( builder, builder.srem(actual_year, Constant.int(DATETIME64, 100))) multiple_of_400 = cgutils.is_null(
timedelta_eq_timedelta_impl = _create_timedelta_comparison_impl(lc.ICMP_EQ, cgutils.false_bit) timedelta_ne_timedelta_impl = _create_timedelta_comparison_impl(lc.ICMP_NE, cgutils.true_bit) timedelta_lt_timedelta_impl = _create_timedelta_ordering_impl(lc.ICMP_SLT) timedelta_le_timedelta_impl = _create_timedelta_ordering_impl(lc.ICMP_SLE) timedelta_gt_timedelta_impl = _create_timedelta_ordering_impl(lc.ICMP_SGT) timedelta_ge_timedelta_impl = _create_timedelta_ordering_impl(lc.ICMP_SGE) for op, func in [('==', timedelta_eq_timedelta_impl), ('!=', timedelta_ne_timedelta_impl), ('<', timedelta_lt_timedelta_impl), ('<=', timedelta_le_timedelta_impl), ('>', timedelta_gt_timedelta_impl), ('>=', timedelta_ge_timedelta_impl)]: builtin(implement(op, *TIMEDELTA_BINOP_SIG)(func)) # Arithmetic on datetime64 def is_leap_year(builder, year_val): """ Return a predicate indicating whether *year_val* (offset by 1970) is a leap year. """ actual_year = builder.add(year_val, Constant.int(DATETIME64, 1970)) multiple_of_4 = cgutils.is_null( builder, builder.and_(actual_year, Constant.int(DATETIME64, 3))) not_multiple_of_100 = cgutils.is_not_null( builder, builder.srem(actual_year, Constant.int(DATETIME64, 100))) multiple_of_400 = cgutils.is_null(