From 945d17aff2aa92dd1fbb0304d4ee7ab5ea6ce496 Mon Sep 17 00:00:00 2001 From: lemon Date: Tue, 20 Jun 2023 09:45:26 +0200 Subject: fix cls logic for comparison instrs previously instr.cls always represented the output dataclass. this doesn't work for comparisons because we know the output is always a boolean integer and we care about the actual comparison dataclass. so now .cls represents the operation dataclass, which matches the result class except for comparisons where the result is always KI4V --- amd64/emit.c | 3 ++- amd64/isel.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'amd64') diff --git a/amd64/emit.c b/amd64/emit.c index c7c6258..21a59b7 100644 --- a/amd64/emit.c +++ b/amd64/emit.c @@ -529,10 +529,11 @@ Xjcc(uchar **pcode, enum cc cc, struct block *dst) } static void -Xsetcc(uchar **pcode, enum cc cc, int reg) +Xsetcc(uchar **pcode, enum cc cc, enum reg reg) { int rex = 0; assert(in_range(cc, 0x0, 0xF)); + assert(in_range(reg, RAX, R15)); if (in_range(reg, RSP, RDI)) rex = 0x40; rex |= (reg >> 3); /* REX.B */ diff --git a/amd64/isel.c b/amd64/isel.c index a613f53..10ff5ea 100644 --- a/amd64/isel.c +++ b/amd64/isel.c @@ -355,7 +355,7 @@ amd64_isel(struct function *fn) for (i = 0; i < blk->ins.n; ++i) { struct instr *ins = &instrtab[blk->ins.p[i]]; sel(fn, ins, blk, &i); - if (ins->op < arraylength(opflags) && kisint(ins->cls)) { + if (ins->op < arraylength(opflags) && kisint(insrescls(*ins))) { if (opflags[ins->op] & ZF) iflagsrc = ins - instrtab; else if (opflags[ins->op] & CLOBF) iflagsrc = -1; } -- cgit v1.2.3