summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorStefan Kempf <stefan@cvs.openbsd.org>2007-12-22 13:13:28 +0000
committerStefan Kempf <stefan@cvs.openbsd.org>2007-12-22 13:13:28 +0000
commit42fb310342bd3c17c926835e06388d425368bb54 (patch)
tree85299afa90013dccae47c90a469b4c69eb7a916e /usr.bin
parentaec35233e6f3ce55edccd0bd6665278e19c02ef2 (diff)
Sync with main repo.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/pcc/nova/code.c12
-rw-r--r--usr.bin/pcc/nova/local2.c17
-rw-r--r--usr.bin/pcc/nova/macdefs.h8
-rw-r--r--usr.bin/pcc/nova/order.c10
-rw-r--r--usr.bin/pcc/pdp10/README20
-rw-r--r--usr.bin/pcc/pdp10/code.c11
-rw-r--r--usr.bin/pcc/pdp10/local.c4
-rw-r--r--usr.bin/pcc/pdp10/local2.c14
-rw-r--r--usr.bin/pcc/pdp10/macdefs.h144
-rw-r--r--usr.bin/pcc/pdp10/order.c23
10 files changed, 185 insertions, 78 deletions
diff --git a/usr.bin/pcc/nova/code.c b/usr.bin/pcc/nova/code.c
index ee390ac99a2..1ffa242c0ad 100644
--- a/usr.bin/pcc/nova/code.c
+++ b/usr.bin/pcc/nova/code.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: code.c,v 1.3 2007/11/22 15:06:43 stefan Exp $ */
+/* $OpenBSD: code.c,v 1.4 2007/12/22 13:13:27 stefan Exp $ */
/*
* Copyright (c) 2006 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -162,16 +162,6 @@ bycode(int t, int i)
}
/*
- * n integer words of zeros
- */
-void
-zecode(int n)
-{
- printf(" .zero %d\n", n * (SZINT/SZCHAR));
- inoff += n * SZINT;
-}
-
-/*
* return the alignment of field of type t
*/
int
diff --git a/usr.bin/pcc/nova/local2.c b/usr.bin/pcc/nova/local2.c
index 00b90e878f9..8ac79c09c29 100644
--- a/usr.bin/pcc/nova/local2.c
+++ b/usr.bin/pcc/nova/local2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local2.c,v 1.1 2007/10/07 17:58:51 otto Exp $ */
+/* $OpenBSD: local2.c,v 1.2 2007/12/22 13:13:27 stefan Exp $ */
/*
* Copyright (c) 2006 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -35,13 +35,6 @@ void acon(NODE *p);
int argsize(NODE *p);
void
-lineid(int l, char *fn)
-{
- /* identify line l and file fn */
- printf("# line %d, file %s\n", l, fn);
-}
-
-void
deflab(int label)
{
printf(LABFMT ":\n", label);
@@ -561,3 +554,11 @@ special(NODE *p, int shape)
{
return SRNOPE;
}
+
+/*
+ * Target-dependent command-line options.
+ */
+void
+mflags(char *str)
+{
+}
diff --git a/usr.bin/pcc/nova/macdefs.h b/usr.bin/pcc/nova/macdefs.h
index 75c41f908d8..72798f3e18a 100644
--- a/usr.bin/pcc/nova/macdefs.h
+++ b/usr.bin/pcc/nova/macdefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: macdefs.h,v 1.1 2007/10/07 17:58:51 otto Exp $ */
+/* $OpenBSD: macdefs.h,v 1.2 2007/12/22 13:13:27 stefan Exp $ */
/*
* Copyright (c) 2006 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -119,8 +119,6 @@ typedef long OFFSZ;
#define BACKAUTO /* stack grows negatively for automatics */
#define BACKTEMP /* stack grows negatively for temporaries */
-#define MYP2TREE(p) myp2tree(p);
-
#undef FIELDOPS /* no bit-field instructions */
#define RTOLBYTES /* bytes are numbered right to left */
@@ -189,7 +187,3 @@ int COLORMAP(int c, int *r);
/* XXX - to die */
#define FPREG 28 /* frame pointer */
#define STKREG 29 /* stack pointer */
-
-#define MYREADER(p) myreader(p)
-#define MYCANON(p) mycanon(p)
-#define MYOPTIM
diff --git a/usr.bin/pcc/nova/order.c b/usr.bin/pcc/nova/order.c
index 0d79e82ca9c..6eae2c871c9 100644
--- a/usr.bin/pcc/nova/order.c
+++ b/usr.bin/pcc/nova/order.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: order.c,v 1.2 2007/11/16 09:00:13 otto Exp $ */
+/* $OpenBSD: order.c,v 1.3 2007/12/22 13:13:27 stefan Exp $ */
/*
* Copyright (c) 2006 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -174,3 +174,11 @@ livecall(NODE *p)
return &r[0];
}
+/*
+ * Signal whether the instruction is acceptable for this target.
+ */
+int
+acceptable(struct optab *op)
+{
+ return 1;
+}
diff --git a/usr.bin/pcc/pdp10/README b/usr.bin/pcc/pdp10/README
new file mode 100644
index 00000000000..176eca77d44
--- /dev/null
+++ b/usr.bin/pcc/pdp10/README
@@ -0,0 +1,20 @@
+
+
+PDP10 C calling convention
+--------------------------
+Register 1-7 are argument registers. Types of sizes up to 36 bits are
+given in one register, two otherwise. CHAR and SHORT are given as INTs.
+
+If the argument that would end up in register 7 requires two registers,
+it is saved on the stack instead and no more registers would end up
+on the stack.
+
+struct return: a hidden argument containing the address of the struct
+is stored as the first argument _on_the_stack_, never in register.
+
+struct argument: always saved on stack, and terminates the list
+of arguments that are kept in registers.
+
+In case of debugging all arguments are saved on stack in the function.
+
+All variadic arguments are always saved on the stack.
diff --git a/usr.bin/pcc/pdp10/code.c b/usr.bin/pcc/pdp10/code.c
index f52f41d48f7..eb8ac58e2d5 100644
--- a/usr.bin/pcc/pdp10/code.c
+++ b/usr.bin/pcc/pdp10/code.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: code.c,v 1.3 2007/11/22 15:06:43 stefan Exp $ */
+/* $OpenBSD: code.c,v 1.4 2007/12/22 13:13:06 stefan Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -226,15 +226,6 @@ bycode(int t, int i)
}
/*
- * n integer words of zeros
- */
-void
-zecode(int n)
-{
- printf(" .block %d\n", n);
-}
-
-/*
* return the alignment of field of type t
*/
int
diff --git a/usr.bin/pcc/pdp10/local.c b/usr.bin/pcc/pdp10/local.c
index cf95e0f7a8d..2b21bbc654b 100644
--- a/usr.bin/pcc/pdp10/local.c
+++ b/usr.bin/pcc/pdp10/local.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local.c,v 1.3 2007/11/18 17:39:55 ragge Exp $ */
+/* $OpenBSD: local.c,v 1.4 2007/12/22 13:13:06 stefan Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -484,7 +484,6 @@ xptype(TWORD t)
case DOUBLE:
case STRTY:
case UNIONTY:
- case ENUMTY:
case UNSIGNED:
case ULONG:
case ULONGLONG:
@@ -556,7 +555,6 @@ offcon(OFFSZ off, TWORD t, union dimfun *d, struct suedef *sue)
case ULONG:
case STRTY:
case UNIONTY:
- case ENUMTY:
case LONGLONG:
case ULONGLONG:
case FLOAT:
diff --git a/usr.bin/pcc/pdp10/local2.c b/usr.bin/pcc/pdp10/local2.c
index 66f20913c19..b10ccc08ce4 100644
--- a/usr.bin/pcc/pdp10/local2.c
+++ b/usr.bin/pcc/pdp10/local2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local2.c,v 1.2 2007/11/16 09:00:13 otto Exp $ */
+/* $OpenBSD: local2.c,v 1.3 2007/12/22 13:13:06 stefan Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -1101,11 +1101,11 @@ optim2(NODE *p)
m = BTYPE(p->n_type);
ml = BTYPE(l->n_type);
if ((m == INT || m == LONG || m == LONGLONG || m == FLOAT ||
- m == DOUBLE || m == STRTY || m == UNIONTY || m == ENUMTY ||
+ m == DOUBLE || m == STRTY || m == UNIONTY ||
m == UNSIGNED || m == ULONG || m == ULONGLONG) &&
(ml == INT || ml == LONG || ml == LONGLONG || ml == FLOAT ||
ml == DOUBLE || ml == STRTY || ml == UNIONTY ||
- ml == ENUMTY || ml == UNSIGNED || ml == ULONG ||
+ ml == UNSIGNED || ml == ULONG ||
ml == ULONGLONG) && ISPTR(l->n_type)) {
*p = *l;
nfree(l);
@@ -1299,3 +1299,11 @@ COLORMAP(int c, int *r)
comperr("COLORMAP");
return 0; /* XXX gcc */
}
+
+/*
+ * Target-dependent command-line options.
+ */
+void
+mflags(char *str)
+{
+}
diff --git a/usr.bin/pcc/pdp10/macdefs.h b/usr.bin/pcc/pdp10/macdefs.h
index 356c94dcd53..5017ae7b23b 100644
--- a/usr.bin/pcc/pdp10/macdefs.h
+++ b/usr.bin/pcc/pdp10/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/12/22 13:13:06 stefan Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -47,21 +47,25 @@
* Storage space requirements
*/
#define SZCHAR 9
+#define SZBOOL 36
#define SZINT 36
#define SZFLOAT 36
#define SZDOUBLE 72
+#define SZLDOUBLE 72
#define SZLONG 36
#define SZSHORT 18
-#define SZPOINT 36
+#define SZPOINT(x) 36
#define SZLONGLONG 72
/*
* Alignment constraints
*/
#define ALCHAR 9
+#define ALBOOL 36
#define ALINT 36
#define ALFLOAT 36
#define ALDOUBLE 36
+#define ALLDOUBLE 36
#define ALLONG 36
#define ALLONGLONG 36
#define ALSHORT 18
@@ -72,15 +76,27 @@
/*
* Max values.
*/
+#define MIN_CHAR -256
+#define MAX_CHAR 255
+#define MAX_UCHAR 511
+#define MIN_SHORT -131072
+#define MAX_SHORT 131071
+#define MAX_USHORT 262143
+#define MIN_INT (-0377777777777LL-1)
#define MAX_INT 0377777777777LL
#define MAX_UNSIGNED 0777777777777ULL
+#define MIN_LONG (-0377777777777LL-1)
#define MAX_LONG 0377777777777LL
#define MAX_ULONG 0777777777777ULL
+#define MIN_LONGLONG (000777777777777777777777LL-1) /* XXX cross */
#define MAX_LONGLONG 000777777777777777777777LL /* XXX cross */
#define MAX_ULONGLONG 001777777777777777777777ULL /* XXX cross */
/* Default char is unsigned */
+#define TARGET_STDARGS
#define CHAR_UNSIGNED
+#define WCHAR_TYPE INT /* what used to store wchar_t */
+#define BOOL_TYPE INT
/*
* Use large-enough types.
@@ -90,23 +106,12 @@ typedef unsigned long long U_CONSZ;
typedef long long OFFSZ;
#define CONFMT "0%llo" /* format for printing constants */
-#define LABFMT "L%d" /* format for printing labels */
+#define LABFMT ".L%d" /* format for printing labels */
+#define STABLBL ".LL%d" /* format for stab (debugging) labels */
-#define FPREG 016 /* frame pointer */
-#define STKREG 017 /* stack pointer */
-
-/*
- * Maximum and minimum register variables
- */
-#define MINRVAR 010 /* use 10 thru ... */
-#define MAXRVAR 015 /* ... 15 */
-
-#define PARAMS_UPWARD /* stack grows upwards for parameters */
#undef BACKAUTO /* stack grows negatively for automatics */
#undef BACKTEMP /* stack grows negatively for temporaries */
-#define MYP2TREE(p) myp2tree(p);
-
#undef FIELDOPS /* no bit-field instructions */
#undef RTOLBYTES /* bytes are numbered left to right */
@@ -114,9 +119,6 @@ typedef long long OFFSZ;
/* Definitions mostly used in pass2 */
-#define REGSZ 020
-#define TMPREG 016
-
#define BYTEOFF(x) ((x)&03)
#define wdal(k) (BYTEOFF(k)==0)
#define BITOOR(x) ((x)/36) /* bit offset to oreg offset */
@@ -133,10 +135,6 @@ typedef long long OFFSZ;
((o) == REG || (o) == NAME || (o) == ICON || \
(o) == OREG || ((o) == UMUL && shumul((p)->n_left)))
-#define MYREADER(p) myreader(p)
-#define MYCANON(p) mycanon(p)
-#define MYOPTIM
-
#undef SPECIAL_INTEGERS
/*
@@ -146,3 +144,105 @@ typedef long long OFFSZ;
#define SNSHCON (SPECIAL|7) /* negative short constant */
#define SILDB (SPECIAL|8) /* use ildb here */
+/*
+ * Register allocator definitions.
+ *
+ * The pdp10 has 16 general-purpose registers, but the two
+ * highest are used as sp and fp. Register 0 has special
+ * constraints in its possible use as index register.
+ * All regs can be used as pairs, named by the lowest number.
+ * In here we call the registers Rn and the pairs XRn, in assembler
+ * just its number prefixed with %.
+ *
+ * R1/XR1 are return registers.
+ *
+ * R0 is currently not used.
+ */
+
+#define MAXREGS 29 /* 16 + 13 regs */
+#define NUMCLASS 2
+
+#define R0 00
+#define R1 01
+#define R2 02
+#define R3 03
+#define R4 04
+#define R5 05
+#define R6 06
+#define R7 07
+#define R10 010
+#define R11 011
+#define R12 012
+#define R13 013
+#define R14 014
+#define R15 015
+#define R16 016
+#define R17 017
+#define FPREG R16 /* frame pointer */
+#define STKREG R17 /* stack pointer */
+
+
+#define XR0 020
+#define XR1 021
+#define XR2 022
+#define XR3 023
+#define XR4 024
+#define XR5 025
+#define XR6 026
+#define XR7 027
+#define XR10 030
+#define XR11 031
+#define XR12 032
+#define XR13 033
+#define XR14 034
+
+
+#define RSTATUS \
+ 0, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
+ SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
+ SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \
+ SAREG|PERMREG, SAREG|PERMREG, 0, 0, \
+ SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, \
+ SBREG, SBREG, SBREG, SBREG, SBREG,
+
+#define ROVERLAP \
+ { XR0, -1 }, \
+ { XR0, XR1, -1 }, \
+ { XR1, XR2, -1 }, \
+ { XR2, XR3, -1 }, \
+ { XR3, XR4, -1 }, \
+ { XR4, XR5, -1 }, \
+ { XR5, XR6, -1 }, \
+ { XR6, XR7, -1 }, \
+ { XR7, XR10, -1 }, \
+ { XR10, XR11, -1 }, \
+ { XR11, XR12, -1 }, \
+ { XR12, XR13, -1 }, \
+ { XR13, XR14, -1 }, \
+ { XR14, -1 }, \
+ { -1 }, \
+ { -1 }, \
+ { R0, R1, XR1, -1 }, \
+ { R1, R2, XR0, XR2, -1 }, \
+ { R2, R3, XR1, XR3, -1 }, \
+ { R3, R4, XR2, XR4, -1 }, \
+ { R4, R5, XR3, XR5, -1 }, \
+ { R5, R6, XR4, XR6, -1 }, \
+ { R6, R7, XR5, XR7, -1 }, \
+ { R7, R10, XR6, XR10, -1 }, \
+ { R10, R11, XR7, XR11, -1 }, \
+ { R11, R12, XR10, XR12, -1 }, \
+ { R12, R13, XR11, XR13, -1 }, \
+ { R13, R14, XR12, XR14, -1 }, \
+ { R14, R15, XR13, -1 },
+
+/* Return a register class based on the type of the node */
+#define PCLASS(p) (szty(p->n_type) == 2 ? SBREG : SAREG)
+#define RETREG(x) (szty(x) == 2 ? XR1 : R1)
+#define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */
+#define ENCRD(x) (x) /* Encode dest reg in n_reg */
+#define ENCRA1(x) ((x) << 6) /* A1 */
+#define ENCRA2(x) ((x) << 12) /* A2 */
+#define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */
+#define GCLASS(x) (x < 16 ? CLASSA : CLASSB)
+int COLORMAP(int c, int *r);
diff --git a/usr.bin/pcc/pdp10/order.c b/usr.bin/pcc/pdp10/order.c
index becaa5caeba..d56f295121c 100644
--- a/usr.bin/pcc/pdp10/order.c
+++ b/usr.bin/pcc/pdp10/order.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: order.c,v 1.2 2007/11/16 09:00:13 otto Exp $ */
+/* $OpenBSD: order.c,v 1.3 2007/12/22 13:13:06 stefan Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -82,18 +82,6 @@ offstar(NODE *p, int shape)
}
/*
- * Rewrite increment/decrement operation.
- */
-int
-setincr(NODE *p)
-{
- if (x2debug)
- printf("setincr(%p)\n", p);
-
- return(0);
-}
-
-/*
* findops() failed, see if we can rewrite it to match.
*/
int
@@ -223,3 +211,12 @@ livecall(NODE *p)
*s = -1;
return s;
}
+
+/*
+ * Signal whether the instruction is acceptable for this target.
+ */
+int
+acceptable(struct optab *op)
+{
+ return 1;
+}