1/* Target definitions for GNU compiler for Intel 80860 running System V.3
2   Copyright (C) 1991, 1996 Free Software Foundation, Inc.
3   Contributed by Ron Guilmette (rfg@monkeys.com).
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING.  If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA.  */
21
22#undef TARGET_VERSION
23#define TARGET_VERSION fprintf (stderr, " (i860, System V Release 3)")
24
25/* Provide a set of pre-definitions and pre-assertions appropriate for
26   the i860 running svr3.  */
27#define CPP_PREDEFINES "-Di860 -Dunix -D__svr3__ -Asystem(unix) -Asystem(svr3) -Acpu(i860) -Amachine(i860)"
28
29/* Use crt1.o as a startup file and crtn.o as a closing file.  */
30
31#define STARTFILE_SPEC  \
32  "%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}"
33
34#define LIB_SPEC "%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp} -lc crtn.o%s"
35
36/* Special flags for the linker.  I don't know what they do.  */
37
38#define LINK_SPEC "%{T*} %{z:-lm}"
39
40/* The prefix to be used in assembler output for all names of registers.
41   None is needed in V.3.  */
42
43#define I860_REG_PREFIX	""
44
45/* Delimiter that starts comments in the assembler code.  */
46
47#define ASM_COMMENT_START "//"
48
49/* Don't renumber the regusters for debugger output.  */
50
51#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
52
53/* Output the special word the System V SDB wants to see just before
54   the first word of each function's prologue code.  */
55
56extern char *current_function_original_name;
57
58/* This special macro is used to output a magic word just before the
59   first word of each function.  On some versions of UNIX running on
60   the i860, this word can be any word that looks like a NOP, however
61   under svr4, this neds to be an `shr r0,r0,r0' instruction in which
62   the normally unused low-order bits contain the length of the function
63   prologue code (in bytes).  This is needed to make the System V SDB
64   debugger happy.  */
65
66#undef ASM_OUTPUT_FUNCTION_PREFIX
67#define ASM_OUTPUT_FUNCTION_PREFIX(FILE, FNNAME)			\
68  do {	ASM_OUTPUT_ALIGN (FILE, 2);					\
69  	fprintf ((FILE), "\t.long\t.ep.");				\
70	assemble_name (FILE, FNNAME);					\
71	fprintf (FILE, "-");						\
72	assemble_name (FILE, FNNAME);					\
73	fprintf (FILE, "+0xc8000000\n");				\
74	current_function_original_name = (FNNAME);			\
75  } while (0)
76
77/* Output the special label that must go just after each function's
78   prologue code to support svr4 SDB.  */
79
80#define ASM_OUTPUT_PROLOGUE_SUFFIX(FILE)				\
81  do {	fprintf (FILE, ".ep.");						\
82	assemble_name (FILE, current_function_original_name);		\
83	fprintf (FILE, ":\n");						\
84  } while (0)
85
86/* This says how to output an assembler line
87   to define a local common symbol.
88   The difference from svr3.h is we don't limit align to 2.  */
89
90#undef ASM_OUTPUT_LOCAL
91#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)	\
92  do {							\
93    int align = exact_log2 (ROUNDED);			\
94    data_section ();					\
95    ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align);	\
96    ASM_OUTPUT_LABEL ((FILE), (NAME));			\
97    fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED));	\
98  } while (0)
99
100/* The routine used to output string literals.
101
102#define ASCII_DATA_ASM_OP	".byte"
103
104#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)				\
105  do									\
106    {									\
107      register unsigned char *str = (unsigned char *) (STR);		\
108      register unsigned char *limit = str + (LENGTH);			\
109      register unsigned bytes_in_chunk = 0;				\
110      for (; str < limit; str++)					\
111        {								\
112          register unsigned ch = *str;					\
113          if (ch < 32 || ch == '\\' || ch == '"' || ch >= 127)		\
114	    {								\
115	      if (bytes_in_chunk > 0)					\
116	        {							\
117	          fprintf ((FILE), "\"\n");				\
118	          bytes_in_chunk = 0;					\
119	        }							\
120	      fprintf ((FILE), "\t%s\t%d\n", ASM_BYTE_OP, ch);		\
121	    }								\
122          else								\
123	    {								\
124	      if (bytes_in_chunk >= 60)					\
125	        {							\
126	          fprintf ((FILE), "\"\n");				\
127	          bytes_in_chunk = 0;					\
128	        }							\
129	      if (bytes_in_chunk == 0)					\
130	        fprintf ((FILE), "\t%s\t\"", ASCII_DATA_ASM_OP);	\
131	      putc (ch, (FILE));					\
132	      bytes_in_chunk++;						\
133	    }								\
134        }								\
135      if (bytes_in_chunk > 0)						\
136        fprintf ((FILE), "\"\n");					\
137    }									\
138  while (0)
139
140
141#undef CTORS_SECTION_ASM_OP
142#define CTORS_SECTION_ASM_OP	".section\t.ctors,\"x\""
143#undef DTORS_SECTION_ASM_OP
144#define DTORS_SECTION_ASM_OP	".section\t.dtors,\"x\""
145
146/* Add definitions to support the .tdesc section as specified in the svr4
147   ABI for the i860.  */
148
149#define TDESC_SECTION_ASM_OP    ".section\t.tdesc"
150
151#undef EXTRA_SECTIONS
152#define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_tdesc
153
154#undef EXTRA_SECTION_FUNCTIONS
155#define EXTRA_SECTION_FUNCTIONS						\
156  CONST_SECTION_FUNCTION						\
157  CTORS_SECTION_FUNCTION						\
158  DTORS_SECTION_FUNCTION						\
159  TDESC_SECTION_FUNCTION
160
161#define TDESC_SECTION_FUNCTION						\
162void									\
163tdesc_section ()							\
164{									\
165  if (in_section != in_tdesc)						\
166    {									\
167      fprintf (asm_out_file, "%s\n", TDESC_SECTION_ASM_OP);		\
168      in_section = in_tdesc;						\
169    }									\
170}
171
172/* Enable the `const' section that svr3.h defines how to use.  */
173#undef USE_CONST_SECTION
174#define USE_CONST_SECTION	1
175