| ... | @@ -25197,10 +25197,16 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch | ... | @@ -25197,10 +25197,16 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch |
| 25197 | ZigType *result_type = get_optional_type(ira->codegen, operand_type); | 25197 | ZigType *result_type = get_optional_type(ira->codegen, operand_type); |
| 25198 | | 25198 | |
| 25199 | // special case zero bit types | 25199 | // special case zero bit types |
| 25200 | if (type_has_one_possible_value(ira->codegen, operand_type) == OnePossibleValueYes) { | 25200 | switch (type_has_one_possible_value(ira->codegen, operand_type)) { |
| 25201 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); | 25201 | case OnePossibleValueInvalid: |
| 25202 | set_optional_value_to_null(result->value); | 25202 | return ira->codegen->invalid_inst_gen; |
| 25203 | return result; | 25203 | case OnePossibleValueYes: { |
| | 25204 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| | 25205 | set_optional_value_to_null(result->value); |
| | 25206 | return result; |
| | 25207 | } |
| | 25208 | case OnePossibleValueNo: |
| | 25209 | break; |
| 25204 | } | 25210 | } |
| 25205 | | 25211 | |
| 25206 | if (instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 25212 | if (instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| ... | @@ -28432,8 +28438,13 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto | ... | @@ -28432,8 +28438,13 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto |
| 28432 | } | 28438 | } |
| 28433 | | 28439 | |
| 28434 | // special case zero bit types | 28440 | // special case zero bit types |
| 28435 | if (type_has_one_possible_value(ira->codegen, operand_type) == OnePossibleValueYes) { | 28441 | switch (type_has_one_possible_value(ira->codegen, operand_type)) { |
| 28436 | return ir_const_move(ira, &instruction->base.base, get_the_one_possible_value(ira->codegen, operand_type)); | 28442 | case OnePossibleValueInvalid: |
| | 28443 | return ira->codegen->invalid_inst_gen; |
| | 28444 | case OnePossibleValueYes: |
| | 28445 | return ir_const_move(ira, &instruction->base.base, get_the_one_possible_value(ira->codegen, operand_type)); |
| | 28446 | case OnePossibleValueNo: |
| | 28447 | break; |
| 28437 | } | 28448 | } |
| 28438 | | 28449 | |
| 28439 | IrInst *source_inst = &instruction->base.base; | 28450 | IrInst *source_inst = &instruction->base.base; |
| ... | @@ -28450,9 +28461,11 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto | ... | @@ -28450,9 +28461,11 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto |
| 28450 | if (op2_val == nullptr) | 28461 | if (op2_val == nullptr) |
| 28451 | return ira->codegen->invalid_inst_gen; | 28462 | return ira->codegen->invalid_inst_gen; |
| 28452 | | 28463 | |
| | 28464 | IrInstGen *result = ir_const(ira, source_inst, operand_type); |
| | 28465 | copy_const_val(ira->codegen, result->value, op1_val); |
| 28453 | if (op == AtomicRmwOp_xchg) { | 28466 | if (op == AtomicRmwOp_xchg) { |
| 28454 | ir_analyze_store_ptr(ira, source_inst, casted_ptr, casted_operand, false); | 28467 | copy_const_val(ira->codegen, op1_val, op2_val); |
| 28455 | return ir_const_move(ira, source_inst, op1_val); | 28468 | return result; |
| 28456 | } | 28469 | } |
| 28457 | | 28470 | |
| 28458 | if (operand_type->id == ZigTypeIdPointer || operand_type->id == ZigTypeIdOptional) { | 28471 | if (operand_type->id == ZigTypeIdPointer || operand_type->id == ZigTypeIdOptional) { |
| ... | @@ -28461,6 +28474,7 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto | ... | @@ -28461,6 +28474,7 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto |
| 28461 | return ira->codegen->invalid_inst_gen; | 28474 | return ira->codegen->invalid_inst_gen; |
| 28462 | } | 28475 | } |
| 28463 | | 28476 | |
| | 28477 | ErrorMsg *msg; |
| 28464 | if (op == AtomicRmwOp_min || op == AtomicRmwOp_max) { | 28478 | if (op == AtomicRmwOp_min || op == AtomicRmwOp_max) { |
| 28465 | IrBinOp bin_op; | 28479 | IrBinOp bin_op; |
| 28466 | if (op == AtomicRmwOp_min) | 28480 | if (op == AtomicRmwOp_min) |
| ... | @@ -28471,9 +28485,12 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto | ... | @@ -28471,9 +28485,12 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto |
| 28471 | bin_op = IrBinOpCmpLessThan; | 28485 | bin_op = IrBinOpCmpLessThan; |
| 28472 | | 28486 | |
| 28473 | IrInstGen *dummy_value = ir_const(ira, source_inst, operand_type); | 28487 | IrInstGen *dummy_value = ir_const(ira, source_inst, operand_type); |
| 28474 | ir_eval_bin_op_cmp_scalar(ira, source_inst, op1_val, bin_op, op2_val, dummy_value->value); | 28488 | msg = ir_eval_bin_op_cmp_scalar(ira, source_inst, op1_val, bin_op, op2_val, dummy_value->value); |
| | 28489 | if (msg != nullptr) { |
| | 28490 | return ira->codegen->invalid_inst_gen; |
| | 28491 | } |
| 28475 | if (dummy_value->value->data.x_bool) | 28492 | if (dummy_value->value->data.x_bool) |
| 28476 | ir_analyze_store_ptr(ira, source_inst, casted_ptr, casted_operand, false); | 28493 | copy_const_val(ira->codegen, op1_val, op2_val); |
| 28477 | } else { | 28494 | } else { |
| 28478 | IrBinOp bin_op; | 28495 | IrBinOp bin_op; |
| 28479 | switch (op) { | 28496 | switch (op) { |
| ... | @@ -28504,13 +28521,16 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto | ... | @@ -28504,13 +28521,16 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto |
| 28504 | bin_op = IrBinOpBinXor; | 28521 | bin_op = IrBinOpBinXor; |
| 28505 | break; | 28522 | break; |
| 28506 | } | 28523 | } |
| 28507 | ir_eval_math_op_scalar(ira, source_inst, operand_type, op1_val, bin_op, op2_val, op1_val); | 28524 | msg = ir_eval_math_op_scalar(ira, source_inst, operand_type, op1_val, bin_op, op2_val, op1_val); |
| | 28525 | if (msg != nullptr) { |
| | 28526 | return ira->codegen->invalid_inst_gen; |
| | 28527 | } |
| 28508 | if (op == AtomicRmwOp_nand) { | 28528 | if (op == AtomicRmwOp_nand) { |
| 28509 | bigint_not(&op1_val->data.x_bigint, &op1_val->data.x_bigint, | 28529 | bigint_not(&op1_val->data.x_bigint, &op1_val->data.x_bigint, |
| 28510 | operand_type->data.integral.bit_count, operand_type->data.integral.is_signed); | 28530 | operand_type->data.integral.bit_count, operand_type->data.integral.is_signed); |
| 28511 | } | 28531 | } |
| 28512 | } | 28532 | } |
| 28513 | return ir_const_move(ira, source_inst, op1_val); | 28533 | return result; |
| 28514 | } | 28534 | } |
| 28515 | | 28535 | |
| 28516 | return ir_build_atomic_rmw_gen(ira, source_inst, casted_ptr, casted_operand, op, | 28536 | return ir_build_atomic_rmw_gen(ira, source_inst, casted_ptr, casted_operand, op, |
| ... | @@ -28586,8 +28606,13 @@ static IrInstGen *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInstSrcA | ... | @@ -28586,8 +28606,13 @@ static IrInstGen *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInstSrcA |
| 28586 | } | 28606 | } |
| 28587 | | 28607 | |
| 28588 | // special case zero bit types | 28608 | // special case zero bit types |
| 28589 | if (type_has_one_possible_value(ira->codegen, operand_type) == OnePossibleValueYes) { | 28609 | switch (type_has_one_possible_value(ira->codegen, operand_type)) { |
| 28590 | return ir_const_void(ira, &instruction->base.base); | 28610 | case OnePossibleValueInvalid: |
| | 28611 | return ira->codegen->invalid_inst_gen; |
| | 28612 | case OnePossibleValueYes: |
| | 28613 | return ir_const_void(ira, &instruction->base.base); |
| | 28614 | case OnePossibleValueNo: |
| | 28615 | break; |
| 28591 | } | 28616 | } |
| 28592 | | 28617 | |
| 28593 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { | 28618 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { |