cgen: extract the narrow-tail aggregate-register materialise into a shared helper (#14)

This commit is contained in:
2026-06-28 14:08:57 +09:00
parent ac6e86cefe
commit e7fefa3eb7
4 changed files with 159 additions and 432 deletions

View File

@@ -5387,44 +5387,7 @@ fn cgstructlitfill(c: *cgen, si: *structinfo, lit: *syntax.node,
if (mode == 3) {
emitline("\tMOVQ\t(SP), BX\n");
};
let full: i32 = cfsz / 8;
let ci: i32 = 0;
for (ci < full) {
let r: str = "AX";
if (ci == 1) { r = "DX"; };
if (ci == 2) { r = "CX"; };
emitline("\tMOVQ\t");
emitline(r);
emitline(", ");
if (mode == 0) {
emitoff((disp + fi.foff + ci * 8): i64);
emitline("(BP)\n");
} else {
emitdispreg((disp + fi.foff + ci * 8): i64, basereg);
emitline("\n");
};
ci += 1;
};
if (crem > 0) {
let top: str = "MOVB";
if (crem == 4) { top = "MOVL"; };
if (crem == 2) { top = "MOVW"; };
let tr: str = "AX";
if (full == 1) { tr = "DX"; };
if (full == 2) { tr = "CX"; };
emitline("\t");
emitline(top);
emitline("\t");
emitline(tr);
emitline(", ");
if (mode == 0) {
emitoff((disp + fi.foff + full * 8): i64);
emitline("(BP)\n");
} else {
emitdispreg((disp + fi.foff + full * 8): i64, basereg);
emitline("\n");
};
};
cgaggregstore(c, basereg, disp + fi.foff, cfsz, false);
callwhole = true;
};
};