| ... | ... | @@ -9451,6 +9451,10 @@ static TypeTableEntry *ir_analyze_instruction_set_fn_visible(IrAnalyze *ira, |
| 9451 | 9451 | return ira->codegen->builtin_types.entry_void; |
| 9452 | 9452 | } |
| 9453 | 9453 | |
| 9454 | static bool is_power_of_2(uint64_t x) { |
| 9455 | return x != 0 && ((x & (~x + 1)) == x); |
| 9456 | } |
| 9457 | |
| 9454 | 9458 | static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira, |
| 9455 | 9459 | IrInstructionSetGlobalAlign *instruction) |
| 9456 | 9460 | { |
| ... | ... | @@ -9461,7 +9465,10 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira, |
| 9461 | 9465 | if (!ir_resolve_usize(ira, align_value, &scalar_align)) |
| 9462 | 9466 | return ira->codegen->builtin_types.entry_invalid; |
| 9463 | 9467 | |
| 9464 | | // TODO error if not power of 2 |
| 9468 | if (!is_power_of_2(scalar_align)) { |
| 9469 | ir_add_error(ira, instruction->value, buf_sprintf("alignment value must be power of 2")); |
| 9470 | return ira->codegen->builtin_types.entry_invalid; |
| 9471 | } |
| 9465 | 9472 | |
| 9466 | 9473 | AstNode *source_node = instruction->base.source_node; |
| 9467 | 9474 | if (tld_var->set_global_align_node) { |