w6c+selfhost: cgen N_CAST signed narrow + peel !T on unsigned narrow
TY_RUNE excluded — wwstage primsize skips it; task #5 will collapse both gates back to symmetric once type_isunsigned recurses TY_ENUM.
This commit is contained in:
@@ -499,11 +499,39 @@ a_encode(Asm *a)
|
||||
a_emit_byte(a, 0xBF);
|
||||
emit_modrm_mem(a, rcode(p->to.type),
|
||||
p->from.reg, p->from.offset);
|
||||
} else if (p->from.type >= D_AX && p->from.type <= D_R15
|
||||
&& p->to.type >= D_AX && p->to.type <= D_R15) {
|
||||
emit_rex(a, rhi(p->to.type), rhi(p->from.type), 1);
|
||||
a_emit_byte(a, 0x0F);
|
||||
a_emit_byte(a, 0xBF);
|
||||
a_emit_byte(a, modrm(3,
|
||||
rcode(p->to.type), rcode(p->from.type)));
|
||||
} else {
|
||||
fprintf(stderr, "w6a: line %d: unsupported MOVSWQ shape\n", p->line);
|
||||
a->errs++;
|
||||
}
|
||||
break;
|
||||
case A_MOVSBQ:
|
||||
/* MOVSX r64, r/m8 — 0F BE /r with REX.W */
|
||||
if (p->from.type == D_INDIR
|
||||
&& p->to.type >= D_AX && p->to.type <= D_R15) {
|
||||
emit_rex(a, rhi(p->to.type), rhi(p->from.reg), 1);
|
||||
a_emit_byte(a, 0x0F);
|
||||
a_emit_byte(a, 0xBE);
|
||||
emit_modrm_mem(a, rcode(p->to.type),
|
||||
p->from.reg, p->from.offset);
|
||||
} else if (p->from.type >= D_AX && p->from.type <= D_R15
|
||||
&& p->to.type >= D_AX && p->to.type <= D_R15) {
|
||||
emit_rex(a, rhi(p->to.type), rhi(p->from.type), 1);
|
||||
a_emit_byte(a, 0x0F);
|
||||
a_emit_byte(a, 0xBE);
|
||||
a_emit_byte(a, modrm(3,
|
||||
rcode(p->to.type), rcode(p->from.type)));
|
||||
} else {
|
||||
fprintf(stderr, "w6a: line %d: unsupported MOVSBQ shape\n", p->line);
|
||||
a->errs++;
|
||||
}
|
||||
break;
|
||||
case A_MOVB:
|
||||
/* MOV r/m8, r8 — 88 /r. No REX.W. We always emit REX
|
||||
* to allow access to SIL/DIL/BPL/SPL. */
|
||||
@@ -574,6 +602,12 @@ a_encode(Asm *a)
|
||||
a_emit_byte(a, 0x63);
|
||||
emit_modrm_mem(a, rcode(p->to.type),
|
||||
p->from.reg, p->from.offset);
|
||||
} else if (p->from.type >= D_AX && p->from.type <= D_R15
|
||||
&& p->to.type >= D_AX && p->to.type <= D_R15) {
|
||||
emit_rex(a, rhi(p->to.type), rhi(p->from.type), 1);
|
||||
a_emit_byte(a, 0x63);
|
||||
a_emit_byte(a, modrm(3,
|
||||
rcode(p->to.type), rcode(p->from.type)));
|
||||
} else {
|
||||
fprintf(stderr, "w6a: line %d: unsupported MOVSXD shape\n", p->line);
|
||||
a->errs++;
|
||||
|
||||
Reference in New Issue
Block a user