Add asm directive #align N

This commit is contained in:
gingerBill
2026-08-17 13:32:28 +01:00
parent 55377f71ef
commit bd95d2ae66
2 changed files with 40 additions and 0 deletions

View File

@@ -495,6 +495,15 @@ struct lbAsmGenerate_amd64 : lbAsmGenerate {
asm_string = gb_string_append_fmt(asm_string, "%d", cast(int)i);
op_index += 1;
}
} else if (name == "align") {
asm_string = gb_string_appendc(asm_string, ".p2align ");
GB_ASSERT(dir->operands.count == 1);
auto const &op = dir->operands[0];
ExactValue ev = exact_value_to_integer(op->tav.value);
GB_ASSERT(ev.kind == ExactValue_Integer);
u64 i = exact_value_to_u64(ev);
u64 i_log2 = floor_log2(i);
asm_string = gb_string_append_fmt(asm_string, "%llu", cast(unsigned long long)i_log2);
} else {
GB_PANIC("Invalid asm directive: %.*s", LIT(name));
}