From a093f3d5a03b790de027da4ec0fd6c29144c4d52 Mon Sep 17 00:00:00 2001 From: Ken Thompson Date: Thu, 13 Jan 2011 20:05:08 -0800 Subject: [PATCH] fix tst instruction on arm to set overflow bit R=r CC=golang-dev https://golang.org/cl/4009041 --- src/cmd/5g/cgen.c | 2 +- src/cmd/5l/asm.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd/5g/cgen.c b/src/cmd/5g/cgen.c index 587b500a9e8..bd44cab46db 100644 --- a/src/cmd/5g/cgen.c +++ b/src/cmd/5g/cgen.c @@ -832,7 +832,7 @@ gencmp0(Node *n, Type *t, int o, Prog *to) } else gins(ATST, &n1, N); a = optoas(o, t); - patch(gbranch(optoas(o, t), t), to); + patch(gbranch(a, t), to); regfree(&n1); } diff --git a/src/cmd/5l/asm.c b/src/cmd/5l/asm.c index b48a7a88b53..9767e830360 100644 --- a/src/cmd/5l/asm.c +++ b/src/cmd/5l/asm.c @@ -1559,11 +1559,9 @@ if(debug['G']) print("%ux: %s: arm %d %d %d\n", (uint32)(p->pc), p->from.sym->na o1 |= (p->from.reg<<16); o1 |= (p->to.reg<<12); break; - case 90: /* tst reg */ - o1 = oprrr(AMOVW, p->scond); - o1 |= p->from.reg | (p->from.reg<<12); - o1 |= 1 << 20; // SBIT + o1 = oprrr(ACMP+AEND, p->scond); + o1 |= p->from.reg<<16; break; } @@ -1716,6 +1714,8 @@ oprrr(int a, int sc) return o | (0xe<<24) | (0x0<<20) | (0xb<<8) | (1<<4); case AMOVFW+AEND: // copy FtoW return o | (0xe<<24) | (0x1<<20) | (0xb<<8) | (1<<4); + case ACMP+AEND: // cmp imm + return o | (0x3<<24) | (0x5<<20); } diag("bad rrr %d", a); prasm(curp);