|
|
1.1 root 1: /* Target definitions for GNU compiler for mc680x0 running System V.4
2: Copyright (C) 1991 Free Software Foundation, Inc.
3:
4: Written by Ron Guilmette ([email protected]) and Fred Fish ([email protected]).
5:
6: This file is part of GNU CC.
7:
8: GNU CC is free software; you can redistribute it and/or modify
9: it under the terms of the GNU General Public License as published by
10: the Free Software Foundation; either version 2, or (at your option)
11: any later version.
12:
13: GNU CC is distributed in the hope that it will be useful,
14: but WITHOUT ANY WARRANTY; without even the implied warranty of
15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: GNU General Public License for more details.
17:
18: You should have received a copy of the GNU General Public License
19: along with GNU CC; see the file COPYING. If not, write to
20: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21:
22: /* Use SGS_* macros to control compilation in m68k.md */
23:
24: #define SGS_SWITCH_TABLES /* Different switch table handling */
25:
26: #include "m68k/sgs.h" /* The m68k/SVR4 assembler is SGS based */
27: #include "svr4.h" /* Pick up the generic SVR4 macros */
28:
29: /* See m68k.h. 7 means 68020 with 68881. */
30:
31: #ifndef TARGET_DEFAULT
32: #define TARGET_DEFAULT (5 /*68020*/ + 2 /*68881*/)
33: #endif
34:
35: /* Override the definition of NO_DOLLAR_IN_LABEL in svr4.h, for special
36: g++ assembler names. When this is defined, g++ uses embedded '.'
37: characters and some m68k assemblers have problems with this. The
38: chances are much greater that any particular assembler will permit
39: embedded '$' characters. */
40:
41: #undef NO_DOLLAR_IN_LABEL
42:
43: /* Define PCC_STATIC_STRUCT_RETURN if the convention on the target machine
44: is to use the nonreentrant technique for returning structure and union
45: values, as commonly implemented by the AT&T Portable C Compiler (PCC).
46: When defined, the gcc option -fpcc-struct-return can be used to cause
47: this form to be generated. When undefined, the option does nothing.
48: For m68k SVR4, the convention is to use a reentrant technique compatible
49: with the gcc default, so override the definition of this macro in m68k.h */
50:
51: #undef PCC_STATIC_STRUCT_RETURN
52:
53: /* Provide a set of pre-definitions and pre-assertions appropriate for
54: the m68k running svr4. __svr4__ is our extension. */
55:
56: #define CPP_PREDEFINES \
57: "-Dm68k -Dunix -D__svr4__ -Asystem(unix) -Acpu(m68k) -Amachine(m68k)"
58:
59: /* Test to see if the target includes a 68881 by default, and use CPP_SPEC
60: to control whether or not __HAVE_68881__ is defined by default or not.
61: If a 68881 is the default, gcc will use inline 68881 instructions, by
62: predefining __HAVE_68881__, unless -msoft-float is specified.
63: If a 68881 is not the default, gcc will only define __HAVE_68881__ if
64: -m68881 is specified. */
65:
66: #if TARGET_DEFAULT & 2
67: #define CPP_SPEC "%{!msoft-float:-D__HAVE_68881__}"
68: #else
69: #define CPP_SPEC "%{m68881:-D__HAVE_68881__}"
70: #endif
71:
72: /* Output assembler code to FILE to increment profiler label # LABELNO
73: for profiling a function entry. We override the definition in m68k.h
74: and match the way the native m68k/SVR4 compiler does profiling, with the
75: address of the profile counter in a1, not a0, and using bsr rather
76: than jsr. */
77:
78: #undef FUNCTION_PROFILER
79: #define FUNCTION_PROFILER(FILE, LABELNO) \
80: asm_fprintf ((FILE), "\tlea.l\t(%LLP%d,%Rpc),%Ra1\n\tbsr\t_mcount\n", \
81: (LABELNO))
82:
83: /* Local common symbols are declared to the assembler with ".lcomm" rather
84: than ".bss", so override the definition in svr4.h */
85:
86: #undef BSS_ASM_OP
87: #define BSS_ASM_OP ".lcomm"
88:
89: /* Register in which address to store a structure value is passed to a
90: function. The default in m68k.h is a1. For m68k/SVR4 it is a0. */
91:
92: #undef STRUCT_VALUE_REGNUM
93: #define STRUCT_VALUE_REGNUM 8
94:
95: #define ASM_COMMENT_START "#"
96:
97: #undef TYPE_OPERAND_FMT
98: #define TYPE_OPERAND_FMT "@%s"
99:
100: /* Define how the m68k registers should be numbered for Dwarf output.
101: The numbering provided here should be compatible with the native
102: SVR4 SDB debugger in the m68k/SVR4 reference port, where d0-d7
103: are 0-7, a0-a8 are 8-15, and fp0-fp7 are 16-23. */
104:
105: #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
106:
107: /* The ASM_OUTPUT_SKIP macro is first defined in m68k.h, using ".skip".
108: It is then overridden by m68k/sgs.h to use ".space", and again by svr4.h
109: to use ".zero". The m68k/SVR4 assembler uses ".space", so repeat the
110: definition from m68k/sgs.h here. Note that ASM_NO_SKIP_IN_TEXT is
111: defined in m68k/sgs.h, so we don't have to repeat it here. */
112:
113: #undef ASM_OUTPUT_SKIP
114: #define ASM_OUTPUT_SKIP(FILE,SIZE) \
115: fprintf (FILE, "\t%s %u\n", SPACE_ASM_OP, (SIZE))
116:
117: /* 1 if N is a possible register number for a function value.
118: For m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
119: pointer, or floating types, respectively. Reject fp0 if not using a
120: 68881 coprocessor. */
121:
122: #undef FUNCTION_VALUE_REGNO_P
123: #define FUNCTION_VALUE_REGNO_P(N) \
124: ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))
125:
126: /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
127: more than one register. */
128:
129: #undef NEEDS_UNTYPED_CALL
130: #define NEEDS_UNTYPED_CALL 1
131:
132: /* Define how to generate (in the callee) the output value of a function
133: and how to find (in the caller) the value returned by a function. VALTYPE
134: is the data type of the value (as a tree). If the precise function being
135: called is known, FUNC is its FUNCTION_DECL; otherwise, FUNC is 0.
136: For m68k/SVR4 generate the result in d0, a0, or fp0 as appropriate. */
137:
138: #undef FUNCTION_VALUE
139: #define FUNCTION_VALUE(VALTYPE, FUNC) \
140: (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881 \
141: ? gen_rtx (REG, TYPE_MODE (VALTYPE), 16) \
142: : (TREE_CODE (VALTYPE) == POINTER_TYPE \
143: ? gen_rtx (REG, TYPE_MODE (VALTYPE), 8) \
144: : gen_rtx (REG, TYPE_MODE (VALTYPE), 0)))
145:
146: /* For compatibility with the large body of existing code which does not
147: always properly declare external functions returning pointer types, the
148: m68k/SVR4 convention is to copy the value returned for pointer functions
149: from a0 to d0 in the function epilogue, so that callers that have
150: neglected to properly declare the callee can still find the correct return
151: value. */
152:
153: extern int current_function_returns_pointer;
154: #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) \
155: do { \
156: if ((current_function_returns_pointer) && \
157: ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode)) \
158: asm_fprintf (FILE, "\tmov.l %Ra0,%Rd0\n"); \
159: } while (0);
160:
161: /* Define how to find the value returned by a library function assuming the
162: value has mode MODE.
163: For m68k/SVR4 look for integer values in d0, pointer values in d0
164: (returned in both d0 and a0), and floating values in fp0. */
165:
166: #undef LIBCALL_VALUE
167: #define LIBCALL_VALUE(MODE) \
168: (((MODE) == SFmode || (MODE) == DFmode) && TARGET_68881 \
169: ? gen_rtx (REG, (MODE), 16) \
170: : gen_rtx (REG, (MODE), 0))
171:
172: /* Boundary (in *bits*) on which stack pointer should be aligned.
173: The m68k/SVR4 convention is to keep the stack pointer longword aligned. */
174:
175: #undef STACK_BOUNDARY
176: #define STACK_BOUNDARY 32
177:
178: /* Alignment of field after `int : 0' in a structure.
179: For m68k/SVR4, this is the next longword boundary. */
180:
181: #undef EMPTY_FIELD_BOUNDARY
182: #define EMPTY_FIELD_BOUNDARY 32
183:
184: /* No data type wants to be aligned rounder than this.
185: For m68k/SVR4, some types (doubles for example) are aligned on 8 byte
186: boundaries */
187:
188: #undef BIGGEST_ALIGNMENT
189: #define BIGGEST_ALIGNMENT 64
190:
191: /* SVR4 m68k assembler is bitching on the `comm i,1,1' which askes for
192: 1 byte alignment. Don't generate alignment for COMMON seems to be
193: safer until we the assembler is fixed. */
194: #undef ASM_OUTPUT_ALIGNED_COMMON
195: /* Same problem with this one. */
196: #undef ASM_OUTPUT_ALIGNED_LOCAL
197:
198: /* The `string' directive on m68k svr4 does not handle string with
199: escape char (ie., `\') right. Use normal way to output ASCII bytes
200: seems to be safer. */
201: #undef ASM_OUTPUT_ASCII
202: #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \
203: { \
204: register int sp = 0, lp = 0, ch; \
205: fprintf ((FILE), "\t%s ", BYTE_ASM_OP); \
206: do { \
207: ch = (PTR)[sp]; \
208: if (ch > ' ' && ! (ch & 0x80) && ch != '\\') \
209: { \
210: fprintf ((FILE), "'%c", ch); \
211: } \
212: else \
213: { \
214: fprintf ((FILE), "0x%x", ch); \
215: } \
216: if (++sp < (LEN)) \
217: { \
218: if ((sp % 10) == 0) \
219: { \
220: fprintf ((FILE), "\n\t%s ", BYTE_ASM_OP); \
221: } \
222: else \
223: { \
224: putc (',', (FILE)); \
225: } \
226: } \
227: } while (sp < (LEN)); \
228: putc ('\n', (FILE)); \
229: }
230:
231: /* SVR4 m68k assembler is bitching on the syntax `2.b'.
232: So use the "LLDnnn-LLnnn" format. Define LLDnnn after the table. */
233:
234: #undef ASM_OUTPUT_CASE_END
235: #define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
236: do { \
237: if (switch_table_difference_label_flag) \
238: asm_fprintf ((FILE), "\t%s %LLD%d,%LL%d\n", SET_ASM_OP, (NUM), (NUM));\
239: switch_table_difference_label_flag = 0; \
240: } while (0)
241:
242: int switch_table_difference_label_flag;
243:
244: #undef ASM_OUTPUT_COMMON
245: #undef ASM_OUTPUT_LOCAL
246: #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
247: ( fputs (".comm ", (FILE)), \
248: assemble_name ((FILE), (NAME)), \
249: fprintf ((FILE), ",%u\n", (SIZE)))
250:
251: #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
252: ( fputs (".lcomm ", (FILE)), \
253: assemble_name ((FILE), (NAME)), \
254: fprintf ((FILE), ",%u\n", (SIZE)))
255:
256: /* Override the definition in svr4.h. In m68k svr4, using swbeg is the
257: standard way to do switch table. */
258: #undef ASM_OUTPUT_BEFORE_CASE_LABEL
259: #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
260: fprintf ((FILE), "\t%s &%d\n", SWBEG_ASM_OP, XVECLEN (PATTERN (TABLE), 1));
261:
262: /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is an
263: operand of a function call. */
264: #undef LEGITIMATE_PIC_OPERAND_P
265: #define LEGITIMATE_PIC_OPERAND_P(X) \
266: (! symbolic_operand (X, VOIDmode) \
267: || ((GET_CODE(X) == SYMBOL_REF) && SYMBOL_REF_FLAG(X)))
268:
269: /* Turn off function cse if we are doing PIC. We always want function call
270: to be done as `bsr foo@PLTPC', so it will force the assembler to create
271: the PLT entry for `foo'. Doing function cse will cause the address of `foo'
272: to be loaded into a register, which is exactly what we want to avoid when
273: we are doing PIC on svr4 m68k. */
274: #undef OVERRIDE_OPTIONS
275: #define OVERRIDE_OPTIONS \
276: { \
277: if (flag_pic) flag_no_function_cse = 1; \
278: if (! TARGET_68020 && flag_pic == 2) \
279: error("-fPIC is not currently supported on the 68000 or 68010\n"); \
280: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.