Skip to content

Commit

Permalink
Align constant data
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Apr 10, 2024
1 parent babd998 commit 0a26181
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ir_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,16 @@ static bool ir_loader_sym_dcl(ir_loader *loader, const char *name, uint32_t flag

if (flags & IR_CONST) {
data = l->code_buffer.pos;
// TODO: alignment ???
//data = (void*)IR_ALIGNED_SIZE(((size_t)(data)), 16);
/* Data Alignment */
if (size > 8) {
data = (void*)IR_ALIGNED_SIZE(((size_t)(data)), 16);
} else if (size == 8) {
data = (void*)IR_ALIGNED_SIZE(((size_t)(data)), 8);
} else if (size >= 4) {
data = (void*)IR_ALIGNED_SIZE(((size_t)(data)), 4);
} else if (size >= 2) {
data = (void*)IR_ALIGNED_SIZE(((size_t)(data)), 2);
}
if (size > (size_t)((char*)l->code_buffer.end - (char*)data)) {
return 0;
}
Expand Down

0 comments on commit 0a26181

Please sign in to comment.