aboutsummaryrefslogtreecommitdiffhomepage
path: root/amd64
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-10-23 19:29:35 +0200
committerlemon <lsof@mailbox.org>2025-10-23 19:29:35 +0200
commit4dae8d9ab482aa5ca0ef9d10de1b1200e99b5859 (patch)
treec41fcccd270becc4b25f0660df76f005550eeb5a /amd64
parenta203377fffa4dfe57602904598c836245806c006 (diff)
amd64 missing stuff
Diffstat (limited to 'amd64')
-rw-r--r--amd64/emit.c3
-rw-r--r--amd64/isel.c12
2 files changed, 12 insertions, 3 deletions
diff --git a/amd64/emit.c b/amd64/emit.c
index bf7813f..3dce9cb 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -658,6 +658,7 @@ DEFINSTR2(Xtest,
{ 8, PRAX, PU32, "\xA9", EN_I32}, /* TEST EAX, imm32 */
{ 8, PRAX, PI32, "\xA9", EN_I32}, /* TEST RAX, imm32 */
{4|8, PGPR, PI8, "\xF6", EN_RI8, .r8=1}, /* TEST r8, imm8 */
+ {4|8, PGPR, PI32, "\xF7", EN_RI32, .ext=0}, /* TEST r32/64, imm32 */
{4|8, PGPR, PGPR, "\x85", EN_RR}, /* TEST r32/64, r32/64 */
{4|8, PGPR, PMEM, "\x85", EN_RM}, /* TEST r32/64, m32/64 */
)
@@ -851,7 +852,7 @@ gencopy(uchar **pcode, enum irclass cls, struct block *blk, int curi, struct ope
goto GOTLoad;
}
Xlea(pcode, cls, dst, ref2oper(val));
- } else if (val.bits == ZEROREF.bits && dst.t == OREG && !flagslivep(blk, curi)) {
+ } else if (val.bits == ZEROREF.bits && dst.t == OREG && (kisflt(cls) || !flagslivep(blk, curi))) {
/* dst = 0 -> xor dst, dst; but only if it is ok to clobber flags */
Xxor(pcode, kisint(cls) ? KI4 : cls, dst, dst);
} else if (isaddrcon(val)) {
diff --git a/amd64/isel.c b/amd64/isel.c
index 7ff84e4..b1929be 100644
--- a/amd64/isel.c
+++ b/amd64/isel.c
@@ -392,7 +392,15 @@ sel(struct function *fn, struct instr *ins, struct block *blk, int *curi)
/* commutative ops */
if (iscon(ins->l))
rswap(ins->l, ins->r);
- case Oneg: case Onot:
+ goto ALU;
+ case Oneg:
+ if (kisflt(ins->cls)) {
+ ins->op = Osub;
+ ins->r = ins->l;
+ ins->l = ZEROREF;
+ }
+ /* fallthru */
+ case Onot:
ALU:
if (!(op == Oadd && kisint(ins->cls))) /* 3-address add is lea */
if (!(in_range(op, Omul, Oumul) && kisint(ins->cls) && isimm32(ins->r))) /* for (I)MUL r,r/m,imm */
@@ -451,7 +459,7 @@ seljmp(struct function *fn, struct block *blk)
&& (oiscmp(instrtab[c.i].op) || instrtab[c.i].op == Oand || instrtab[c.i].op == Osub)) {
instrtab[c.i].keep = 1;
} else {
- if (!(opflags[instrtab[c.i].op] & ZF) || c.i != blk->ins.p[blk->ins.n - 1]) {
+ if (!(opflags[instrtab[c.i].op] & ZF) || blk->ins.n == 0 || c.i != blk->ins.p[blk->ins.n - 1]) {
blk->jmp.arg[0] = insertinstr(blk, blk->ins.n, mkinstr(Oneq, instrtab[c.i].cls, c, ZEROREF));
instrtab[blk->jmp.arg[0].i].keep = 1;
}