OSDN Git Service

b8378591706353f995406c87c540cdecfd8f59f9
[pf3gnuchains/gcc-fork.git] / gcc / config / mcore / mcore-elf.h
1 /* Definitions of MCore target. 
2    Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3    Contributed by Cygnus Solutions.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #ifndef __MCORE_ELF_H__
23 #define __MCORE_ELF_H__
24
25 /* Run-time Target Specification.  */
26 #define TARGET_VERSION fputs (" (Motorola MCORE/elf)", stderr)
27
28 #define TARGET_OS_CPP_BUILTINS()                                \
29   do                                                            \
30     {                                                           \
31       builtin_define ("__ELF__");                               \
32     }                                                           \
33   while (0)
34
35 /* Use DWARF2 debugging info.  */
36 #define DWARF2_DEBUGGING_INFO 1
37
38 #undef  PREFERRED_DEBUGGING_TYPE
39 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
40
41 /* But allow DWARF 1 if the user wants it.  */
42 #define DWARF_DEBUGGING_INFO 1
43
44 #define EXPORTS_SECTION_ASM_OP  "\t.section .exports"
45
46 #define SUBTARGET_EXTRA_SECTIONS in_exports
47
48 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS       \
49   EXPORT_SECTION_FUNCTION
50
51 #define EXPORT_SECTION_FUNCTION                                 \
52 void                                                            \
53 exports_section ()                                              \
54 {                                                               \
55   if (in_section != in_exports)                                 \
56     {                                                           \
57       fprintf (asm_out_file, "%s\n", EXPORTS_SECTION_ASM_OP);   \
58       in_section = in_exports;                                  \
59     }                                                           \
60 }
61
62 #define SUBTARGET_SWITCH_SECTIONS               \
63   case in_exports: exports_section (); break;
64
65
66 #define MCORE_EXPORT_NAME(STREAM, NAME)                 \
67   do                                                    \
68     {                                                   \
69       exports_section ();                               \
70       fprintf (STREAM, "\t.ascii \" -export:%s\"\n",    \
71                (* targetm.strip_name_encoding) (NAME)); \
72     }                                                   \
73   while (0);
74
75 /* Write the extra assembler code needed to declare a function properly.
76    Some svr4 assemblers need to also have something extra said about the
77    function's return value.  We allow for that here.  */
78 #undef  ASM_DECLARE_FUNCTION_NAME
79 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)             \
80   do                                                            \
81     {                                                           \
82       if (mcore_dllexport_name_p (NAME))                        \
83         {                                                       \
84           MCORE_EXPORT_NAME (FILE, NAME);                       \
85           function_section (DECL);                              \
86         }                                                       \
87       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function");       \
88       ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));            \
89       ASM_OUTPUT_LABEL (FILE, NAME);                            \
90     }                                                           \
91   while (0)
92
93 /* Write the extra assembler code needed to declare an object properly.  */
94 #undef  ASM_DECLARE_OBJECT_NAME
95 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)               \
96   do                                                            \
97     {                                                           \
98       HOST_WIDE_INT size;                                       \
99       if (mcore_dllexport_name_p (NAME))                        \
100         {                                                       \
101           enum in_section save_section = in_section;            \
102           MCORE_EXPORT_NAME (FILE, NAME);                       \
103           switch_to_section (save_section, (DECL));             \
104         }                                                       \
105       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");         \
106       size_directive_output = 0;                                \
107       if (!flag_inhibit_size_directive && DECL_SIZE (DECL))     \
108         {                                                       \
109           size_directive_output = 1;                            \
110           size = int_size_in_bytes (TREE_TYPE (DECL));          \
111           ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);         \
112         }                                                       \
113       ASM_OUTPUT_LABEL(FILE, NAME);                             \
114     }                                                           \
115   while (0)
116  
117 /* Output the size directive for a decl in rest_of_decl_compilation
118    in the case where we did not do so before the initializer.
119    Once we find the error_mark_node, we know that the value of
120    size_directive_output was set
121    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
122 #undef  ASM_FINISH_DECLARE_OBJECT
123 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)         \
124   do                                                                     \
125     {                                                                    \
126       const char * name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);           \
127       HOST_WIDE_INT size;                                                \
128       if (!flag_inhibit_size_directive && DECL_SIZE (DECL)               \
129           && ! AT_END && TOP_LEVEL                                       \
130           && DECL_INITIAL (DECL) == error_mark_node                      \
131           && !size_directive_output)                                     \
132         {                                                                \
133           size_directive_output = 1;                                     \
134           size = int_size_in_bytes (TREE_TYPE (DECL));                   \
135           ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);                  \
136         }                                                                \
137     }                                                                    \
138   while (0)
139
140
141 #undef  STARTFILE_SPEC
142 #define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
143
144 /* Include the OS stub library, so that the code can be simulated.
145    This is not the right way to do this.  Ideally this kind of thing
146    should be done in the linker script - but I have not worked out how
147    to specify the location of a linker script in a gcc command line yet.  */
148 #undef  ENDFILE_SPEC
149 #define ENDFILE_SPEC  "%{!mno-lsim:-lsim} crtend.o%s crtn.o%s"
150
151 /* The subroutine calls in the .init and .fini sections create literal
152    pools which must be jumped around...  */
153 #define FORCE_CODE_SECTION_ALIGN        asm ("br 1f ; .literals ; 1:");
154
155 #undef  CTORS_SECTION_ASM_OP
156 #define CTORS_SECTION_ASM_OP    "\t.section\t.ctors,\"aw\""
157 #undef  DTORS_SECTION_ASM_OP
158 #define DTORS_SECTION_ASM_OP    "\t.section\t.dtors,\"aw\""
159      
160 #endif /* __MCORE_ELF_H__ */