diff options
| author | 2023-08-07 23:10:34 +0200 | |
|---|---|---|
| committer | 2023-08-07 23:10:34 +0200 | |
| commit | e17d87d38b7e9f0df87ee6986f86e9c6712d017a (patch) | |
| tree | b83fa5df94e27a5dc34772b2977ea8d4ee8dffed /amd64 | |
| parent | 1f4b206aa39097ebacdfd645aa2a81a3350b004e (diff) | |
amd64: add mulf and divf codegen
Diffstat (limited to 'amd64')
| -rw-r--r-- | amd64/emit.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/amd64/emit.c b/amd64/emit.c index 2eff8e9..ffee31f 100644 --- a/amd64/emit.c +++ b/amd64/emit.c @@ -480,6 +480,18 @@ DEFINSTR2(Xsubf, {4, PFPR, PMEM, "\xF3\x0F\x5C", EN_RM}, /* SUBSS xmm, m32 */ {8, PFPR, PMEM, "\xF2\x0F\x5C", EN_RM}, /* SUBSD xmm, m64 */ ) +DEFINSTR2(Xmulf, + {4, PFPR, PFPR, "\xF3\x0F\x59", EN_RR}, /* MULSS xmm, xmm */ + {8, PFPR, PFPR, "\xF2\x0F\x59", EN_RR}, /* MULSD xmm, xmm */ + {4, PFPR, PMEM, "\xF3\x0F\x59", EN_RM}, /* MULSS xmm, m32 */ + {8, PFPR, PMEM, "\xF2\x0F\x59", EN_RM}, /* MULSD xmm, m64 */ +) +DEFINSTR2(Xdivf, + {4, PFPR, PFPR, "\xF3\x0F\x5E", EN_RR}, /* DIVSS xmm, xmm */ + {8, PFPR, PFPR, "\xF2\x0F\x5E", EN_RR}, /* DIVSD xmm, xmm */ + {4, PFPR, PMEM, "\xF3\x0F\x5E", EN_RM}, /* DIVSS xmm, m32 */ + {8, PFPR, PMEM, "\xF2\x0F\x5E", EN_RM}, /* DIVSD xmm, m64 */ +) DEFINSTR2(Xand, {4|8, PGPR, PGPR, "\x23", EN_RR}, /* AND r32/64, r32/64 */ {4|8, PGPR, PI8, "\x83", EN_RI8, .ext=4}, /* AND r32/64, imm8 */ @@ -838,9 +850,10 @@ emitinstr(uchar **pcode, struct function *fn, struct block *blk, int curi, struc X1(pcode, cls, dst); break; case Omul: - if (kisint(cls)) { + if (kisint(cls)) Xmul(pcode, cls, reg2oper(ins->reg-1), ref2oper(ins->l), ref2oper(ins->r)); - } else assert(0); + else + Xmulf(pcode, cls, reg2oper(ins->reg-1), ref2oper(ins->r)); break; case Odiv: switch (cls) { @@ -851,7 +864,9 @@ emitinstr(uchar **pcode, struct function *fn, struct block *blk, int curi, struc assert(mkregoper(ins->l).reg == RAX); Xidiv(pcode, cls, mkdatregoper(ins->r)); break; - case KF4: case KF8: assert(!"nyi"); + case KF4: case KF8: + Xdivf(pcode, cls, reg2oper(ins->reg-1), mkdatregoper(ins->r)); + break; } break; case Oequ: case Oneq: |