OSDN Git Service

2001-07-26 Andrew Haley <aph@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / config / clipper / clix.h
1 /* Definitions of target machine for GNU compiler.  Clipper/Clix version.
2    Copyright (C) 1988, 1993, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 /* Names to predefine in the preprocessor for this target machine.  */
22
23 #define CPP_PREDEFINES "-Dclipper -Dunix -Asystem=unix -Asystem=svr3 -Acpu=clipper -Amachine=clipper"
24
25 #undef STARTFILE_SPEC
26 #define STARTFILE_SPEC  \
27   "%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}} crtbegin.o%s"
28
29 #undef ENDFILE_SPEC
30 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
31
32 #undef LIB_SPEC
33
34 #define TARGET_MEM_FUNCTIONS
35
36 #define ASM_OUTPUT_ASCII(FILE,PTR,LEN)                  \
37 do {                                                    \
38   const unsigned char *s;                               \
39   int i;                                                \
40   for (i = 0, s = (const unsigned char *)(PTR); i < (LEN); s++, i++) \
41     {                                                   \
42       if ((i % 8) == 0)                                 \
43         fputs ("\n\t.byte\t", (FILE));                  \
44       fprintf ((FILE), "%s0x%x", (i%8?",":""), (unsigned)*s); \
45     }                                                   \
46   fputs ("\n", (FILE));                                 \
47 } while (0)
48
49 #undef ASM_OUTPUT_DOUBLE
50 #define ASM_OUTPUT_DOUBLE(FILE,VALUE)   \
51 {                                       \
52   union { int i[2]; double d; } _d_;    \
53   _d_.d = VALUE;                                \
54   fprintf (FILE, "\t.long 0x%08x,0x%08x\n", _d_.i[0],_d_.i[1]); \
55 }
56
57 #undef ASM_OUTPUT_FLOAT
58 #define ASM_OUTPUT_FLOAT(FILE,VALUE)    \
59 {                                       \
60   union { int i; float f; } _f_;        \
61   _f_.f = VALUE;                                \
62   fprintf (FILE, "\t.long 0x%08x\n", _f_.i); \
63 }
64
65 /* This is how to output an assembler line
66    that says to advance the location counter
67    to a multiple of 2**LOG bytes.  */
68
69 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
70   fprintf(FILE, "\t.align %d\n", 1 << (LOG))
71
72
73 #define ASM_LONG ".long"
74 #define BSS_SECTION_ASM_OP  "\t.bss"
75 #undef INIT_SECTION_ASM_OP
76 #define INIT_SECTION_ASM_OP "\t.section .init,\"x\""
77
78 \f
79 /* Define a few machine-specific details of the implementation of
80    constructors.
81
82    The __CTORS_LIST__ goes in the .init section.  Define CTOR_LIST_BEGIN
83    and CTOR_LIST_END to contribute to the .init section an instruction to
84    push a word containing 0 (or some equivalent of that).
85
86    ASM_OUTPUT_CONSTRUCTOR should be defined to push the address of the
87    constructor.  */
88
89 #define CTOR_LIST_BEGIN                         \
90   asm (INIT_SECTION_ASM_OP);                    \
91   asm ("subq   $8,sp");                         \
92   asm ("loadq  $0,r0");                         \
93   asm ("storw  r0,(sp)")
94
95 /* don't need end marker */
96
97 #undef CTOR_LIST_END
98
99 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)       \
100   do {                                          \
101     init_section ();                            \
102     fputs ("\tloada  ", FILE);                  \
103     assemble_name (FILE, NAME);                 \
104     fputs (",r0\n\tsubq   $8,sp\n\tstorw   r0,(sp)\n", FILE);   \
105   } while (0)
106
107
108 /* fini psect is 8 aligned */
109
110 #define DTOR_LIST_BEGIN \
111   asm (DTORS_SECTION_ASM_OP);                           \
112   func_ptr __DTOR_LIST__[2] = { (func_ptr) (-1), 0 };
113
114 /* A C statement (sans semicolon) to output an element in the table of
115    global destructors.  */
116
117 #undef ASM_OUTPUT_DESTRUCTOR
118 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                                \
119   do {                                                                  \
120     fini_section ();                                                    \
121     fprintf (FILE, "%s\t ", ASM_LONG);                                  \
122     assemble_name (FILE, NAME);                                         \
123     fprintf (FILE, ",0\n");                                             \
124   } while (0)
125
126
127 /* On clix crt1.o first calls init code and then sets environ and a valid
128    chrclass. Unfortunately stdio routines bomb with unset chrclass.
129    Therefore we set chrclass prior to calling global constructors. */
130
131 #undef DO_GLOBAL_CTORS_BODY
132 #define DO_GLOBAL_CTORS_BODY                                    \
133 do {                                                            \
134   func_ptr *p, *beg = alloca (0);                               \
135   _setchrclass (0);                                             \
136   for (p = beg; *p; p+=2)                                       \
137     ;                                                           \
138   while (p != beg)                                              \
139     { p-= 2; (*p) (); }                                         \
140 } while (0)
141
142
143 #undef DO_GLOBAL_DTORS_BODY
144 #define DO_GLOBAL_DTORS_BODY    \
145   func_ptr *f = &__DTOR_LIST__[2];      /* 0,1 contains -1,0 */ \
146   int n = 0;                                                    \
147   while (*f)                                                    \
148     {                                                           \
149      f+= 2;                             /* skip over alignment 0 */     \
150      n++;                                                       \
151     }                                                           \
152   f -= 2;                                                       \
153   while (--n >= 0)                                              \
154     {                                                           \
155      (*f) ();                                                   \
156      f-= 2;                             /* skip over alignment 0 */     \
157     }
158
159