Skip to content

Commit

Permalink
Merge pull request #36 from soxfox42/main
Browse files Browse the repository at this point in the history
Fix address operator on struct and struct pointer fields
  • Loading branch information
MESYETI authored Jan 31, 2025
2 parents a06d606 + f0b31cd commit e1d867f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions source/backends/arm64.d
Original file line number Diff line number Diff line change
Expand Up @@ -1101,14 +1101,23 @@ class BackendARM64 : CompilerBackend {
if (GlobalExists(name)) {
auto var = GetGlobal(name);

LoadAddress("x9", format("__global_%s", node.func.Sanitise()));
LoadAddress("x9", format("__global_%s", name.Sanitise()));
if (var.type.ptr) {
output ~= "ldr x9, [x9]\n";
}
output ~= format("add x9, x9, #%d\n", offset);
output ~= "str x9, [x19], #8\n";
}
else if (VariableExists(name)) {
auto var = GetVariable(name);

output ~= format("add x9, x20, #%d\n", var.offset + offset);
if (var.type.ptr) {
output ~= format("add x9, x20, #%d\n", var.offset);
output ~= "ldr x9, [x9]\n";
output ~= format("add x9, x9, #%d\n", offset);
} else {
output ~= format("add x9, x20, #%d\n", var.offset + offset);
}
output ~= "str x9, [x19], #8\n";
}
else {
Expand Down

0 comments on commit e1d867f

Please sign in to comment.