|
|
1.1 root 1: /* Definitions of target machine for GNU compiler.
2: AT&T UNIX PC version (pc7300, 3b1)
3:
4: Written by Alex Crain
5: bug reports to [email protected]
6:
7: Copyright (C) 1987 Free Software Foundation, Inc.
8:
9: This file is part of GNU CC.
10:
11: GNU CC is free software; you can redistribute it and/or modify
12: it under the terms of the GNU General Public License as published by
13: the Free Software Foundation; either version 2, or (at your option)
14: any later version.
15:
16: GNU CC is distributed in the hope that it will be useful,
17: but WITHOUT ANY WARRANTY; without even the implied warranty of
18: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19: GNU General Public License for more details.
20:
21: You should have received a copy of the GNU General Public License
22: along with GNU CC; see the file COPYING. If not, write to
23: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
24:
25: #define SGS_SWAP_W /* Use swap.w rather than just plain swap */
26: #define SGS_SWITCH_TABLES /* Different switch table handling */
27:
28: #include "hp320.h"
29:
30: /* See m68k.h. 0 means 680[01]0 with no 68881. */
31:
32: #undef TARGET_DEFAULT
33: #define TARGET_DEFAULT 0
34:
35: /* -m68020 requires special flags to the assembler. */
36:
37: #undef ASM_SPEC
38: #define ASM_SPEC "%{m68020:-68020}%{!m68020:-68010} %{m68881:-68881}"
39:
40: /* we use /lib/libp/lib* when profiling */
41:
42: #undef LIB_SPEC
43: #define LIB_SPEC "%{!shlib:%{p:-L/lib/libp} %{pg:-L/lib/libp} -lc}"
44:
45: /* shared libraries need to use crt0s.o */
46:
47: #undef STARTFILE_SPEC
48: #define STARTFILE_SPEC \
49: "%{!shlib:%{pg:mcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}\
50: %{shlib:crt0s.o%s shlib.ifile%s} "
51:
52: /* cpp has to support a #sccs directive for the /usr/include files */
53:
54: #define SCCS_DIRECTIVE
55:
56: /* Make output for SDB. */
57:
58: #define SDB_DEBUGGING_INFO
59:
60: /* The .file command should always begin the output. */
61:
62: #undef ASM_FILE_START
63: #define ASM_FILE_START(FILE) \
64: output_file_directive ((FILE), main_input_filename)
65:
66: /* Don't try to define `gcc_compiled.' since the assembler might not
67: accept symbols with periods and GDB doesn't run on this machine anyway. */
68: #define ASM_IDENTIFY_GCC(FILE)
69:
70: /* Define __HAVE_68881__ in preprocessor if -m68881 is specified.
71: This will control the use of inline 68881 insns in certain macros. */
72:
73: #undef CPP_SPEC
74: #define CPP_SPEC "%{m68881:-D__HAVE_68881__}"
75:
76: /* Names to predefine in the preprocessor for this target machine. */
77: /* [email protected] says mc68000 and m68k should not be here. */
78:
79: #undef CPP_PREDEFINES
80: #define CPP_PREDEFINES "-Dmc68k -Dunix -Dunixpc"
81:
82: #undef REGISTER_NAMES
83: #define REGISTER_NAMES \
84: {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
85: "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp", \
86: "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7"}
87:
88: /* Specify how to pad function arguments.
89: Value should be `upward', `downward' or `none'.
90: Same as the default, except no padding for large or variable-size args. */
91:
92: #define FUNCTION_ARG_PADDING(MODE, TYPE) \
93: (((MODE) == BLKmode \
94: ? ((TYPE) && TREE_CODE (TYPE_SIZE (TYPE)) == INTEGER_CST \
95: && int_size_in_bytes (TYPE) < PARM_BOUNDARY / BITS_PER_UNIT) \
96: : GET_MODE_BITSIZE (MODE) < PARM_BOUNDARY) \
97: ? downward : none)
98:
99: /* Override part of the obstack macros. */
100:
101: #define __PTR_TO_INT(P) ((int)(P))
102: #define __INT_TO_PTR(P) ((char *)(P))
103:
104: /* Override parts of m68k.h to fit the SGS-3b1 assembler. */
105:
106: #undef TARGET_VERSION
107: #undef ASM_FORMAT_PRIVATE_NAME
108: #undef ASM_OUTPUT_DOUBLE
109: #undef ASM_OUTPUT_FLOAT
110: #undef ASM_OUTPUT_ALIGN
111: #undef ASM_OUTPUT_SOURCE_FILENAME
112: #undef ASM_OUTPUT_SOURCE_LINE
113: #undef PRINT_OPERAND_ADDRESS
114: #undef ASM_GENERATE_INTERNAL_LABEL
115: #undef FUNCTION_PROFILER
116: #undef ASM_OUTPUT_ADDR_VEC_ELT
117: #undef ASM_OUTPUT_ADDR_DIFF_ELT
118: #undef ASM_OUTPUT_INTERNAL_LABEL
119: #undef ASM_OUTPUT_OPCODE
120: #undef ASM_OUTPUT_LOCAL
121: #undef ASM_OUTPUT_LABELREF
122: #undef ASM_OUTPUT_ASCII
123:
124: #define TARGET_VERSION fprintf (stderr, " (68k, SGS/AT&T unixpc syntax)");
125:
126: /* Store in OUTPUT a string (made with alloca) containing
127: an assembler-name for a local static variable named NAME.
128: LABELNO is an integer which is different for each call. */
129:
130: #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
131: ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 12), \
132: sprintf ((OUTPUT), "%s_%%%d", (NAME), (LABELNO)))
133:
134: /* The unixpc doesn't know about double's and float's */
135:
136: #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
137: do { union { double d; long l[2]; } tem; \
138: tem.d = (VALUE); \
139: fprintf(FILE, "\tlong 0x%x,0x%x\n", tem.l[0], tem.l[1]); \
140: } while (0)
141:
142: #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
143: do { union { float f; long l;} tem; \
144: tem.f = (VALUE); \
145: fprintf (FILE, "\tlong 0x%x\n", tem.l); \
146: } while (0)
147:
148: #define ASM_OUTPUT_ALIGN(FILE,LOG) \
149: if ((LOG) == 1) \
150: fprintf (FILE, "\teven\n"); \
151: else if ((LOG) != 0) \
152: abort ();
153:
154: /* This is how to output an assembler line
155: that says to advance the location counter by SIZE bytes. */
156:
157: #undef ASM_OUTPUT_SKIP
158: #define ASM_OUTPUT_SKIP(FILE,SIZE) \
159: fprintf (FILE, "\tspace %d\n", (SIZE))
160:
161: /* Can't use ASM_OUTPUT_SKIP in text section; it doesn't leave 0s. */
162:
163: #define ASM_NO_SKIP_IN_TEXT 1
164:
165: /* The beginnings of sdb support... */
166:
167: #define ASM_OUTPUT_SOURCE_FILENAME(FILE, FILENAME) \
168: fprintf (FILE, "\tfile\t\"%s\"\n", FILENAME)
169:
170: #define ASM_OUTPUT_SOURCE_LINE(FILE, LINENO) \
171: fprintf (FILE, "\tln\t%d\n", \
172: (sdb_begin_function_line \
173: ? last_linenum - sdb_begin_function_line : 1))
174:
175: /* Yet another null terminated string format. */
176:
177: #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
178: { register int sp = 0, lp = 0; \
179: fprintf ((FILE), "\tbyte\t"); \
180: loop: \
181: if ((PTR)[sp] > ' ' && ! ((PTR)[sp] & 0x80) && (PTR)[sp] != '\\') \
182: { lp += 3; \
183: fprintf ((FILE), "'%c", (PTR)[sp]); } \
184: else \
185: { lp += 5; \
186: fprintf ((FILE), "0x%x", (PTR)[sp]); } \
187: if (++sp < (LEN)) \
188: { if (lp > 60) \
189: { lp = 0; \
190: fprintf ((FILE), "\n%s ", ASCII_DATA_ASM_OP); } \
191: else \
192: putc (',', (FILE)); \
193: goto loop; } \
194: putc ('\n', (FILE)); }
195:
196: /* Note that in the case of the movhi which fetches an element of
197: an ADDR_DIFF_VEC the offset output is too large by 2.
198: This is because the 3b1 assembler refuses to subtract 2.
199: ASM_OUTPUT_CASE_LABEL, below, compensates for this. */
200:
201: #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
202: { register rtx reg1, reg2, breg, ireg; \
203: register rtx addr = ADDR; \
204: rtx offset; \
205: switch (GET_CODE (addr)) \
206: { \
207: case REG: \
208: fprintf (FILE, "(%s)", reg_names[REGNO (addr)]); \
209: break; \
210: case PRE_DEC: \
211: fprintf (FILE, "-(%s)", reg_names[REGNO (XEXP (addr, 0))]); \
212: break; \
213: case POST_INC: \
214: fprintf (FILE, "(%s)+", reg_names[REGNO (XEXP (addr, 0))]); \
215: break; \
216: case PLUS: \
217: reg1 = 0; reg2 = 0; \
218: ireg = 0; breg = 0; \
219: offset = 0; \
220: if (CONSTANT_ADDRESS_P (XEXP (addr, 0))) \
221: { \
222: offset = XEXP (addr, 0); \
223: addr = XEXP (addr, 1); \
224: } \
225: else if (CONSTANT_ADDRESS_P (XEXP (addr, 1))) \
226: { \
227: offset = XEXP (addr, 1); \
228: addr = XEXP (addr, 0); \
229: } \
230: if (GET_CODE (addr) != PLUS) ; \
231: else if (GET_CODE (XEXP (addr, 0)) == SIGN_EXTEND) \
232: { \
233: reg1 = XEXP (addr, 0); \
234: addr = XEXP (addr, 1); \
235: } \
236: else if (GET_CODE (XEXP (addr, 1)) == SIGN_EXTEND) \
237: { \
238: reg1 = XEXP (addr, 1); \
239: addr = XEXP (addr, 0); \
240: } \
241: else if (GET_CODE (XEXP (addr, 0)) == MULT) \
242: { \
243: reg1 = XEXP (addr, 0); \
244: addr = XEXP (addr, 1); \
245: } \
246: else if (GET_CODE (XEXP (addr, 1)) == MULT) \
247: { \
248: reg1 = XEXP (addr, 1); \
249: addr = XEXP (addr, 0); \
250: } \
251: else if (GET_CODE (XEXP (addr, 0)) == REG) \
252: { \
253: reg1 = XEXP (addr, 0); \
254: addr = XEXP (addr, 1); \
255: } \
256: else if (GET_CODE (XEXP (addr, 1)) == REG) \
257: { \
258: reg1 = XEXP (addr, 1); \
259: addr = XEXP (addr, 0); \
260: } \
261: if (GET_CODE (addr) == REG || GET_CODE (addr) == MULT \
262: || GET_CODE (addr) == SIGN_EXTEND) \
263: { if (reg1 == 0) reg1 = addr; else reg2 = addr; addr = 0; } \
264: /* for OLD_INDEXING \
265: else if (GET_CODE (addr) == PLUS) \
266: { \
267: if (GET_CODE (XEXP (addr, 0)) == REG) \
268: { \
269: reg2 = XEXP (addr, 0); \
270: addr = XEXP (addr, 1); \
271: } \
272: else if (GET_CODE (XEXP (addr, 1)) == REG) \
273: { \
274: reg2 = XEXP (addr, 1); \
275: addr = XEXP (addr, 0); \
276: } \
277: } \
278: */ \
279: if (offset != 0) { if (addr != 0) abort (); addr = offset; } \
280: if ((reg1 && (GET_CODE (reg1) == SIGN_EXTEND \
281: || GET_CODE (reg1) == MULT)) \
282: || (reg2 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg2)))) \
283: { breg = reg2; ireg = reg1; } \
284: else if (reg1 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg1))) \
285: { breg = reg1; ireg = reg2; } \
286: if (ireg != 0 && breg == 0 && GET_CODE (addr) == LABEL_REF) \
287: { int scale = 1; \
288: if (GET_CODE (ireg) == MULT) \
289: { scale = INTVAL (XEXP (ireg, 1)); \
290: ireg = XEXP (ireg, 0); } \
291: if (GET_CODE (ireg) == SIGN_EXTEND) \
292: fprintf (FILE, "LD%%%d(%%pc,%s.w", \
293: CODE_LABEL_NUMBER (XEXP (addr, 0)), \
294: reg_names[REGNO (XEXP (ireg, 0))]); \
295: else \
296: fprintf (FILE, "LD%%%d(%%pc,%s.l", \
297: CODE_LABEL_NUMBER (XEXP (addr, 0)), \
298: reg_names[REGNO (ireg)]); \
299: if (scale != 1) fprintf (FILE, "*%d", scale); \
300: fprintf (FILE, ")"); \
301: break; } \
302: if (breg != 0 && ireg == 0 && GET_CODE (addr) == LABEL_REF) \
303: { fprintf (FILE, "LD%%%d(%%pc,%s.l", \
304: CODE_LABEL_NUMBER (XEXP (addr, 0)), \
305: reg_names[REGNO (breg)]); \
306: putc (')', FILE); \
307: break; } \
308: if (ireg != 0 || breg != 0) \
309: { int scale = 1; \
310: if (breg == 0) \
311: abort (); \
312: if (addr != 0) \
313: output_addr_const (FILE, addr); \
314: fprintf (FILE, "(%s", reg_names[REGNO (breg)]); \
315: if (ireg != 0) \
316: putc (',', FILE); \
317: if (ireg != 0 && GET_CODE (ireg) == MULT) \
318: { scale = INTVAL (XEXP (ireg, 1)); \
319: ireg = XEXP (ireg, 0); } \
320: if (ireg != 0 && GET_CODE (ireg) == SIGN_EXTEND) \
321: fprintf (FILE, "%s.w", reg_names[REGNO (XEXP (ireg, 0))]); \
322: else if (ireg != 0) \
323: fprintf (FILE, "%s.l", reg_names[REGNO (ireg)]); \
324: if (scale != 1) fprintf (FILE, "*%d", scale); \
325: putc (')', FILE); \
326: break; \
327: } \
328: else if (reg1 != 0 && GET_CODE (addr) == LABEL_REF) \
329: { fprintf (FILE, "LD%%%d(%%pc,%s.w)", \
330: CODE_LABEL_NUMBER (XEXP (addr, 0)), \
331: reg_names[REGNO (reg1)]); \
332: break; } \
333: default: \
334: if (GET_CODE (addr) == CONST_INT \
335: && INTVAL (addr) < 0x8000 \
336: && INTVAL (addr) >= -0x8000) \
337: fprintf (FILE, "%d", INTVAL (addr)); \
338: else \
339: output_addr_const (FILE, addr); \
340: }}
341:
342: #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
343: sprintf ((LABEL), "%s%%%d", (PREFIX), (NUM))
344:
345: #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
346: fprintf (FILE, "%s%%%d:\n", PREFIX, NUM)
347:
348: /* Must put address in %a0 , not %d0 . -- LGM, 7/15/88 */
349: #define FUNCTION_PROFILER(FILE, LABEL_NO) \
350: fprintf (FILE, "\tmov.l &LP%%%d,%%a0\n\tjsr mcount\n", (LABEL_NO))
351:
352: #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
353: fprintf (FILE, "\tlong L%%%d\n", (VALUE))
354:
355: #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
356: fprintf (FILE, "\tshort L%%%d-L%%%d\n", (VALUE), (REL))
357:
358: /* ihnp4!lmayk!lgm says that `short 0' triggers assembler bug;
359: `short L%nn-L%nn' supposedly works. */
360: #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
361: if (! RTX_INTEGRATED_P (TABLE)) \
362: fprintf (FILE, "\tswbeg &%d\n%s%%%d:\n", \
363: XVECLEN (PATTERN (TABLE), 1), (PREFIX), (NUM)); \
364: else \
365: fprintf (FILE, "\tswbeg &%d\n%s%%%d:\n\tshort %s%%%d-%s%%%d\n", \
366: XVECLEN (PATTERN (TABLE), 1) + 1, (PREFIX), (NUM), \
367: (PREFIX), (NUM), (PREFIX), (NUM))
368:
369: /* At end of a switch table, define LD%n iff the symbol LI%n was defined. */
370: #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
371: if (RTX_INTEGRATED_P (TABLE)) \
372: fprintf (FILE, "\tset LD%%%d,L%%%d-LI%%%d\n", (NUM), (NUM), (NUM))
373:
374: #define ASM_OUTPUT_OPCODE(FILE, PTR) \
375: { if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
376: { ++(PTR); \
377: while (*(PTR) != ' ') \
378: { putc (*(PTR), (FILE)); ++(PTR); } \
379: fprintf ((FILE), ".w"); } \
380: else if ((PTR)[0] == 'f') \
381: { \
382: if (!strncmp ((PTR), "fmove", 5)) \
383: { fprintf ((FILE), "fmov"); (PTR) += 5; } \
384: else if (!strncmp ((PTR), "fbne", 4)) \
385: { fprintf ((FILE), "fbneq"); (PTR) += 4; } \
386: } \
387: /* MOVE, MOVEA, MOVEQ, MOVEC ==> MOV */ \
388: else if ((PTR)[0] == 'm' && (PTR)[1] == 'o' \
389: && (PTR)[2] == 'v' && (PTR)[3] == 'e') \
390: { fprintf ((FILE), "mov"); (PTR) += 4; \
391: if ((PTR)[0] == 'q' || (PTR)[0] == 'a' || \
392: (PTR)[0] == 'c') (PTR)++; } \
393: /* SUB, SUBQ, SUBA, SUBI ==> SUB */ \
394: else if ((PTR)[0] == 's' && (PTR)[1] == 'u' \
395: && (PTR)[2] == 'b') \
396: { fprintf ((FILE), "sub"); (PTR) += 3; \
397: if ((PTR)[0] == 'q' || (PTR)[0] == 'i' || \
398: (PTR)[0] == 'a') (PTR)++; } \
399: /* CMP, CMPA, CMPI, CMPM ==> CMP */ \
400: else if ((PTR)[0] == 'c' && (PTR)[1] == 'm' \
401: && (PTR)[2] == 'p') \
402: { fprintf ((FILE), "cmp"); (PTR) += 3; \
403: if ((PTR)[0] == 'a' || (PTR)[0] == 'i' || \
404: (PTR)[0] == 'm') (PTR)++; } \
405: }
406:
407: #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
408: ( fputs ("\tlcomm ", (FILE)), \
409: assemble_name ((FILE), (NAME)), \
410: fprintf ((FILE), ",%u\n", (ROUNDED)))
411:
412: #define ASM_OUTPUT_LABELREF(FILE,NAME) \
413: fprintf (FILE, "%s", NAME)
414:
415: /* Override usual definitions of SDB output macros.
416: These definitions differ only in the absence of the period
417: at the beginning of the name of the directive
418: and in the use of `~' as the symbol for the current location. */
419:
420: #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\tscl\t%d;", (a))
421: #define PUT_SDB_INT_VAL(a) fprintf (asm_out_file, "\tval\t%d;", (a))
422: #define PUT_SDB_VAL(a) \
423: ( fputs ("\tval\t", asm_out_file), \
424: output_addr_const (asm_out_file, (a)), \
425: fputc (';', asm_out_file))
426:
427: #define PUT_SDB_DEF(a) \
428: do { fprintf (asm_out_file, "\tdef\t"); \
429: ASM_OUTPUT_LABELREF (asm_out_file, a); \
430: fprintf (asm_out_file, ";"); } while (0)
431:
432: #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\tdef\t~%s;",a)
433: #define PUT_SDB_ENDEF fputs("\tendef\n", asm_out_file)
434: #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\ttype\t0%o;", a)
435: #define PUT_SDB_SIZE(a) fprintf(asm_out_file, "\tsize\t%d;", a)
436: #define PUT_SDB_START_DIM fprintf(asm_out_file, "\tdim\t")
437:
438: #define PUT_SDB_TAG(a) \
439: do { fprintf (asm_out_file, "\ttag\t"); \
440: ASM_OUTPUT_LABELREF (asm_out_file, a); \
441: fprintf (asm_out_file, ";"); } while (0)
442:
443: #define PUT_SDB_BLOCK_START(LINE) \
444: fprintf (asm_out_file, \
445: "\tdef\t~bb;\tval\t~;\tscl\t100;\tline\t%d;\tendef\n", \
446: (LINE))
447:
448: #define PUT_SDB_BLOCK_END(LINE) \
449: fprintf (asm_out_file, \
450: "\tdef\t~eb;\tval\t~;\tscl\t100;\tline\t%d;\tendef\n", \
451: (LINE))
452:
453: #define PUT_SDB_FUNCTION_START(LINE) \
454: fprintf (asm_out_file, \
455: "\tdef\t~bf;\tval\t~;\tscl\t101;\tline\t%d;\tendef\n", \
456: (LINE))
457:
458: #define PUT_SDB_FUNCTION_END(LINE) \
459: fprintf (asm_out_file, \
460: "\tdef\t~ef;\tval\t~;\tscl\t101;\tline\t%d;\tendef\n", \
461: (LINE))
462:
463: #define PUT_SDB_EPILOGUE_END(NAME) \
464: fprintf (asm_out_file, \
465: "\tdef\t%s;\tval\t~;\tscl\t-1;\tendef\n", \
466: (NAME))
467:
468: #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
469: sprintf ((BUFFER), "~%dfake", (NUMBER));
470:
471: /* Define subroutines to call to handle multiply, divide, and remainder.
472: Use the subroutines that the 3b1's library provides.
473: The `*' prevents an underscore from being prepended by the compiler. */
474:
475: #define DIVSI3_LIBCALL "*ldiv"
476: #define UDIVSI3_LIBCALL "*uldiv"
477: #define MODSI3_LIBCALL "*lrem"
478: #define UMODSI3_LIBCALL "*ulrem"
479: #define MULSI3_LIBCALL "*lmul"
480: #define UMULSI3_LIBCALL "*ulmul"
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.