| ... | @@ -25618,9 +25618,29 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op | ... | @@ -25618,9 +25618,29 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op |
| 25618 | buf_sprintf("%" PRIu32 "-bit integer type is not a power of 2", operand_type->data.integral.bit_count)); | 25618 | buf_sprintf("%" PRIu32 "-bit integer type is not a power of 2", operand_type->data.integral.bit_count)); |
| 25619 | return ira->codegen->builtin_types.entry_invalid; | 25619 | return ira->codegen->builtin_types.entry_invalid; |
| 25620 | } | 25620 | } |
| | 25621 | } else if (operand_type->id == ZigTypeIdEnum) { |
| | 25622 | ZigType *int_type = operand_type->data.enumeration.tag_int_type; |
| | 25623 | if (int_type->data.integral.bit_count < 8) { |
| | 25624 | ir_add_error(ira, op, |
| | 25625 | buf_sprintf("expected enum tag type 8 bits or larger, found %" PRIu32 "-bit tag type", |
| | 25626 | int_type->data.integral.bit_count)); |
| | 25627 | return ira->codegen->builtin_types.entry_invalid; |
| | 25628 | } |
| | 25629 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); |
| | 25630 | if (int_type->data.integral.bit_count > max_atomic_bits) { |
| | 25631 | ir_add_error(ira, op, |
| | 25632 | buf_sprintf("expected %" PRIu32 "-bit enum tag type or smaller, found %" PRIu32 "-bit tag type", |
| | 25633 | max_atomic_bits, int_type->data.integral.bit_count)); |
| | 25634 | return ira->codegen->builtin_types.entry_invalid; |
| | 25635 | } |
| | 25636 | if (!is_power_of_2(int_type->data.integral.bit_count)) { |
| | 25637 | ir_add_error(ira, op, |
| | 25638 | buf_sprintf("%" PRIu32 "-bit enum tag type is not a power of 2", int_type->data.integral.bit_count)); |
| | 25639 | return ira->codegen->builtin_types.entry_invalid; |
| | 25640 | } |
| 25621 | } else if (get_codegen_ptr_type(operand_type) == nullptr) { | 25641 | } else if (get_codegen_ptr_type(operand_type) == nullptr) { |
| 25622 | ir_add_error(ira, op, | 25642 | ir_add_error(ira, op, |
| 25623 | buf_sprintf("expected integer or pointer type, found '%s'", buf_ptr(&operand_type->name))); | 25643 | buf_sprintf("expected integer, enum or pointer type, found '%s'", buf_ptr(&operand_type->name))); |
| 25624 | return ira->codegen->builtin_types.entry_invalid; | 25644 | return ira->codegen->builtin_types.entry_invalid; |
| 25625 | } | 25645 | } |
| 25626 | | 25646 | |