summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kempf <stefan@cvs.openbsd.org>2007-10-14 19:58:01 +0000
committerStefan Kempf <stefan@cvs.openbsd.org>2007-10-14 19:58:01 +0000
commitdcd904b920ff0f4afd73bb1a86fa78a92cc94213 (patch)
tree7c3e3f2a1a0d35b1f856f259e62646d39ed9844a
parent83028d7554ff9140520c821a96351f91ae0ff77b (diff)
From master repo:
Use xor to clear 32/16-bit registers instead of mov. ok ragge@, otto@
-rw-r--r--usr.bin/pcc/x86/local2.c15
-rw-r--r--usr.bin/pcc/x86/macdefs.h9
-rw-r--r--usr.bin/pcc/x86/table.c70
3 files changed, 86 insertions, 8 deletions
diff --git a/usr.bin/pcc/x86/local2.c b/usr.bin/pcc/x86/local2.c
index 117263171be..e5ab696747d 100644
--- a/usr.bin/pcc/x86/local2.c
+++ b/usr.bin/pcc/x86/local2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local2.c,v 1.1 2007/10/07 17:58:52 otto Exp $ */
+/* $OpenBSD: local2.c,v 1.2 2007/10/14 19:58:00 stefan Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
# include "pass2.h"
# include <ctype.h>
# include <string.h>
@@ -1047,6 +1046,18 @@ special(NODE *p, int shape)
p->n_lval < 0 || p->n_lval > 0x7fffffff)
break;
return SRDIR;
+ case SMIXOR:
+ return tshape(p, SZERO);
+ case SMILWXOR:
+ if (o != ICON || p->n_name[0] ||
+ p->n_lval == 0 || p->n_lval & 0xffffffff)
+ break;
+ return SRDIR;
+ case SMIHWXOR:
+ if (o != ICON || p->n_name[0] ||
+ p->n_lval == 0 || (p->n_lval >> 32) != 0)
+ break;
+ return SRDIR;
}
return SRNOPE;
}
diff --git a/usr.bin/pcc/x86/macdefs.h b/usr.bin/pcc/x86/macdefs.h
index c50b1e3e738..5fc828b02d3 100644
--- a/usr.bin/pcc/x86/macdefs.h
+++ b/usr.bin/pcc/x86/macdefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: macdefs.h,v 1.1 2007/10/07 17:58:52 otto Exp $ */
+/* $OpenBSD: macdefs.h,v 1.2 2007/10/14 19:58:00 stefan Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -299,3 +299,10 @@ int COLORMAP(int c, int *r);
#define SHSTR (MAXSPECIAL+1) /* short struct */
#define SFUNCALL (MAXSPECIAL+2) /* struct assign after function call */
#define SPCON (MAXSPECIAL+3) /* positive nonnamed constant */
+
+/*
+ * Specials that indicate the applicability of machine idioms.
+ */
+#define SMIXOR (MAXSPECIAL+4)
+#define SMILWXOR (MAXSPECIAL+5)
+#define SMIHWXOR (MAXSPECIAL+6)
diff --git a/usr.bin/pcc/x86/table.c b/usr.bin/pcc/x86/table.c
index 71d88e53499..fc2adc2df61 100644
--- a/usr.bin/pcc/x86/table.c
+++ b/usr.bin/pcc/x86/table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table.c,v 1.1 2007/10/07 17:58:52 otto Exp $ */
+/* $OpenBSD: table.c,v 1.2 2007/10/14 19:58:00 stefan Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -794,17 +794,41 @@ struct optab table[] = {
/*
* The next rules takes care of assignments. "=".
*/
+{ ASSIGN, FORCC|FOREFF|INLL,
+ SHLL, TLL,
+ SMIXOR, TANY,
+ 0, RDEST,
+ " xorl AL,AL\n xorl UL,UL\n", },
+
+{ ASSIGN, FORCC|FOREFF|INLL,
+ SHLL, TLL,
+ SMILWXOR, TANY,
+ 0, RDEST,
+ " xorl AL,AL\n movl UR,UL\n", },
+
+{ ASSIGN, FORCC|FOREFF|INLL,
+ SHLL, TLL,
+ SMIHWXOR, TANY,
+ 0, RDEST,
+ " movl AR,AL\n xorl UL,UL\n", },
+
+{ ASSIGN, FOREFF|INLL,
+ SHLL, TLL,
+ SCON, TANY,
+ 0, RDEST,
+ " movl AR,AL\n movl UR,UL\n", },
+
{ ASSIGN, FOREFF,
SHLL|SNAME|SOREG, TLL,
SCON, TANY,
0, 0,
" movl AR,AL\n movl UR,UL\n", },
-{ ASSIGN, FOREFF|INLL,
- SHLL, TLL,
- SCON, TANY,
+{ ASSIGN, FORCC|FOREFF|INAREG,
+ SAREG, TWORD|TPOINT,
+ SMIXOR, TANY,
0, RDEST,
- " movl AR,AL\n movl UR,UL\n", },
+ " xorl AL,AL\n", },
{ ASSIGN, FOREFF,
SAREG|SNAME|SOREG, TWORD|TPOINT,
@@ -818,6 +842,12 @@ struct optab table[] = {
0, RDEST,
" movl AR,AL\n", },
+{ ASSIGN, FORCC|FOREFF|INAREG,
+ SAREG, TSHORT|TUSHORT,
+ SMIXOR, TANY,
+ 0, RDEST,
+ " xorw AL,AL\n", },
+
{ ASSIGN, FOREFF,
SAREG|SNAME|SOREG, TSHORT|TUSHORT,
SCON, TANY,
@@ -1252,12 +1282,36 @@ struct optab table[] = {
/*
* Convert LTYPE to reg.
*/
+{ OPLTYPE, FORCC|INLL,
+ SCREG, TLL,
+ SMIXOR, TANY,
+ NCREG, RESC1,
+ " xorl U1,U1\n xorl A1,A1\n", },
+
+{ OPLTYPE, FORCC|INLL,
+ SCREG, TLL,
+ SMILWXOR, TANY,
+ NCREG, RESC1,
+ " movl UL,U1\n xorl A1,A1\n", },
+
+{ OPLTYPE, FORCC|INLL,
+ SCREG, TLL,
+ SMIHWXOR, TANY,
+ NCREG, RESC1,
+ " xorl U1,U1\n movl AL,A1\n", },
+
{ OPLTYPE, INLL,
SANY, TANY,
SCREG|SCON|SOREG|SNAME, TLL,
NCREG, RESC1,
" movl UL,U1\n movl AL,A1\n", },
+{ OPLTYPE, FORCC|INAREG,
+ SAREG, TWORD|TPOINT,
+ SMIXOR, TANY,
+ NAREG|NASL, RESC1,
+ " xorl A1,A1\n", },
+
{ OPLTYPE, INAREG,
SANY, TANY,
SAREG|SCON|SOREG|SNAME, TWORD|TPOINT,
@@ -1270,6 +1324,12 @@ struct optab table[] = {
NBREG, RESC1,
" movb AL,A1\n", },
+{ OPLTYPE, FORCC|INAREG,
+ SAREG, TSHORT|TUSHORT,
+ SMIXOR, TANY,
+ NAREG, RESC1,
+ " xorw A1,A1\n", },
+
{ OPLTYPE, INAREG,
SANY, TANY,
SAREG|SOREG|SNAME|SCON, TSHORT|TUSHORT,