| ... | ... | @@ -20363,24 +20363,45 @@ static IrInstGen *ir_analyze_bin_not(IrAnalyze *ira, IrInstSrcUnOp *instruction) |
| 20363 | 20363 | if (type_is_invalid(expr_type)) |
| 20364 | 20364 | return ira->codegen->invalid_inst_gen; |
| 20365 | 20365 | |
| 20366 | | if (expr_type->id == ZigTypeIdInt) { |
| 20367 | | if (instr_is_comptime(value)) { |
| 20368 | | ZigValue *target_const_val = ir_resolve_const(ira, value, UndefBad); |
| 20369 | | if (target_const_val == nullptr) |
| 20370 | | return ira->codegen->invalid_inst_gen; |
| 20366 | ZigType *scalar_type = (expr_type->id == ZigTypeIdVector) ? |
| 20367 | expr_type->data.vector.elem_type : expr_type; |
| 20371 | 20368 | |
| 20372 | | IrInstGen *result = ir_const(ira, &instruction->base.base, expr_type); |
| 20373 | | bigint_not(&result->value->data.x_bigint, &target_const_val->data.x_bigint, |
| 20374 | | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); |
| 20375 | | return result; |
| 20369 | if (scalar_type->id != ZigTypeIdInt) { |
| 20370 | ir_add_error(ira, &instruction->base.base, |
| 20371 | buf_sprintf("unable to perform binary not operation on type '%s'", buf_ptr(&expr_type->name))); |
| 20372 | return ira->codegen->invalid_inst_gen; |
| 20373 | } |
| 20374 | |
| 20375 | if (instr_is_comptime(value)) { |
| 20376 | ZigValue *expr_val = ir_resolve_const(ira, value, UndefBad); |
| 20377 | if (expr_val == nullptr) |
| 20378 | return ira->codegen->invalid_inst_gen; |
| 20379 | |
| 20380 | IrInstGen *result = ir_const(ira, &instruction->base.base, expr_type); |
| 20381 | |
| 20382 | if (expr_type->id == ZigTypeIdVector) { |
| 20383 | expand_undef_array(ira->codegen, expr_val); |
| 20384 | result->value->special = ConstValSpecialUndef; |
| 20385 | expand_undef_array(ira->codegen, result->value); |
| 20386 | |
| 20387 | for (size_t i = 0; i < expr_type->data.vector.len; i++) { |
| 20388 | ZigValue *src_val = &expr_val->data.x_array.data.s_none.elements[i]; |
| 20389 | ZigValue *dst_val = &result->value->data.x_array.data.s_none.elements[i]; |
| 20390 | |
| 20391 | dst_val->type = scalar_type; |
| 20392 | dst_val->special = ConstValSpecialStatic; |
| 20393 | bigint_not(&dst_val->data.x_bigint, &src_val->data.x_bigint, |
| 20394 | scalar_type->data.integral.bit_count, scalar_type->data.integral.is_signed); |
| 20395 | } |
| 20396 | } else { |
| 20397 | bigint_not(&result->value->data.x_bigint, &expr_val->data.x_bigint, |
| 20398 | scalar_type->data.integral.bit_count, scalar_type->data.integral.is_signed); |
| 20376 | 20399 | } |
| 20377 | 20400 | |
| 20378 | | return ir_build_binary_not(ira, &instruction->base.base, value, expr_type); |
| 20401 | return result; |
| 20379 | 20402 | } |
| 20380 | 20403 | |
| 20381 | | ir_add_error(ira, &instruction->base.base, |
| 20382 | | buf_sprintf("unable to perform binary not operation on type '%s'", buf_ptr(&expr_type->name))); |
| 20383 | | return ira->codegen->invalid_inst_gen; |
| 20404 | return ir_build_binary_not(ira, &instruction->base.base, value, expr_type); |
| 20384 | 20405 | } |
| 20385 | 20406 | |
| 20386 | 20407 | static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *instruction) { |