Skip to content

Commit

Permalink
fix cg
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-s168 committed Oct 22, 2024
1 parent e0da64a commit 4197a82
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions cg/x86_stupid/cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,24 +524,17 @@ static void emiti_cmove(Location* src, Location* dest, const char *cc, FILE* out
static void emiti_cmp(Location* a, Location* b, FILE* out);

static void emiti_cmp0(Location* val, FILE* out) {
if (val->type == LOC_REG) {
fputs("test ", out);
emit(val, out);
fputs(", ", out);
if (val->type == LOC_REG || val->type == LOC_MEM) {
fputs("cmp ", out);
emit(val, out);
fputc('\n', out);
fputs(", 0\n", out);
}
else if (val->type == LOC_IMM || val->type == LOC_EA) {
Location* scratch = start_scratch_reg(val->bytesWidth, out);
emiti_move(val, scratch, false, out);
emiti_cmp0(scratch, out);
end_scratch_reg(scratch, out);
}
else if (val->type == LOC_MEM) {
fputs("cmp ", out);
emit(val, out);
fputs(", 0\n", out);
}
else {
assert(false);
}
Expand Down

0 comments on commit 4197a82

Please sign in to comment.