OSDN Git Service

Imported from mainline FSF repositories
[pf3gnuchains/gcc-fork.git] / gcc / config / arm / pe.h
1 /* Definitions of target machine for GNU compiler, for ARM with PE obj format.
2    Copyright (C) 1995, 1996, 1999, 2000, 2002, 2003, 2004
3    Free Software Foundation, Inc.
4    Contributed by Doug Evans (dje@cygnus.com).
5    
6    This file is part of GCC.
7
8    GCC is free software; you can redistribute it and/or modify it
9    under the terms of the GNU General Public License as published
10    by the Free Software Foundation; either version 2, or (at your
11    option) any later version.
12
13    GCC is distributed in the hope that it will be useful, but WITHOUT
14    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16    License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with GCC; see the file COPYING.  If not, write to
20    the Free Software Foundation, 59 Temple Place - Suite 330,
21    Boston, MA 02111-1307, USA.  */
22
23 /* Enable PE specific code.  */
24 #define ARM_PE          1
25
26 #define ARM_PE_FLAG_CHAR '@'
27
28 /* Ensure that @x. will be stripped from the function name.  */
29 #undef SUBTARGET_NAME_ENCODING_LENGTHS
30 #define SUBTARGET_NAME_ENCODING_LENGTHS  \
31   case ARM_PE_FLAG_CHAR: return 3;
32
33 #undef  USER_LABEL_PREFIX
34 #define USER_LABEL_PREFIX "_"
35
36 \f
37 /* Run-time Target Specification.  */
38 #undef  TARGET_VERSION
39 #define TARGET_VERSION fputs (" (ARM/pe)", stderr)
40
41 /* Get tree.c to declare a target-specific specialization of
42    merge_decl_attributes.  */
43 #define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
44
45 #undef  SUBTARGET_CPP_SPEC
46 #define SUBTARGET_CPP_SPEC "-D__pe__"
47
48
49 /* Experimental addition for pr 7885.
50    Ignore dllimport for functions.  */
51 #define TARGET_FLAG_NOP_FUN     (1 << 24)
52
53 #undef  TARGET_NOP_FUN_DLLIMPORT
54 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & TARGET_FLAG_NOP_FUN)
55
56 #undef  SUBTARGET_SWITCHES
57 #define SUBTARGET_SWITCHES                                      \
58 { "nop-fun-dllimport",            TARGET_FLAG_NOP_FUN,          \
59   N_("Ignore dllimport attribute for functions") },             \
60 { "no-nop-fun-dllimport",       - TARGET_FLAG_NOP_FUN, "" },
61
62 #undef  TARGET_DEFAULT
63 #define TARGET_DEFAULT  (TARGET_FLAG_NOP_FUN)
64
65 #undef  MULTILIB_DEFAULTS
66 #define MULTILIB_DEFAULTS \
67   { "marm", "mlittle-endian", "msoft-float", "mno-thumb-interwork" }  
68 \f
69 #undef  WCHAR_TYPE
70 #define WCHAR_TYPE      "short unsigned int"
71 #undef  WCHAR_TYPE_SIZE
72 #define WCHAR_TYPE_SIZE 16
73
74 /* r11 is fixed.  */
75 #undef  SUBTARGET_CONDITIONAL_REGISTER_USAGE
76 #define SUBTARGET_CONDITIONAL_REGISTER_USAGE \
77   fixed_regs [11] = 1; \
78   call_used_regs [11] = 1;
79
80 \f
81 /* PE/COFF uses explicit import from shared libraries.  */
82 #define MULTIPLE_SYMBOL_SPACES 1
83
84 #define TARGET_ASM_UNIQUE_SECTION arm_pe_unique_section
85 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
86
87 #define SUPPORTS_ONE_ONLY 1
88
89 /* Switch into a generic section.  */
90 #undef  TARGET_ASM_NAMED_SECTION
91 #define TARGET_ASM_NAMED_SECTION  default_pe_asm_named_section
92 \f
93 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
94
95 /* Output a reference to a label.  */
96 #undef  ASM_OUTPUT_LABELREF
97 #define ASM_OUTPUT_LABELREF(STREAM, NAME)  \
98   asm_fprintf (STREAM, "%U%s", arm_strip_name_encoding (NAME))
99
100 /* Output a function definition label.  */
101 #undef  ASM_DECLARE_FUNCTION_NAME
102 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)           \
103   do                                                            \
104     {                                                           \
105       if (arm_dllexport_name_p (NAME))                          \
106         {                                                       \
107           drectve_section ();                                   \
108           fprintf (STREAM, "\t.ascii \" -export:%s\"\n",        \
109                    arm_strip_name_encoding (NAME));             \
110           function_section (DECL);                              \
111         }                                                       \
112       ARM_DECLARE_FUNCTION_NAME (STREAM, NAME, DECL);           \
113       if (TARGET_THUMB)                                         \
114         fprintf (STREAM, "\t.code 16\n");                       \
115       ASM_OUTPUT_LABEL (STREAM, NAME);                          \
116     }                                                           \
117   while (0)
118
119 /* Output a common block.  */
120 #undef  ASM_OUTPUT_COMMON
121 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)  \
122   do                                                    \
123     {                                                   \
124       if (arm_dllexport_name_p (NAME))                  \
125         {                                               \
126           drectve_section ();                           \
127           fprintf ((STREAM), "\t.ascii \" -export:%s\"\n",\
128                    arm_strip_name_encoding (NAME));     \
129         }                                               \
130       if (! arm_dllimport_name_p (NAME))                \
131         {                                               \
132           fprintf ((STREAM), "\t.comm\t");              \
133           assemble_name ((STREAM), (NAME));             \
134           asm_fprintf ((STREAM), ", %d\t%@ %d\n",       \
135                    (int)(ROUNDED), (int)(SIZE));        \
136         }                                               \
137     }                                                   \
138   while (0)
139
140 /* Output the label for an initialized variable.  */
141 #undef  ASM_DECLARE_OBJECT_NAME
142 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)     \
143   do                                                    \
144     {                                                   \
145       if (arm_dllexport_name_p (NAME))                  \
146         {                                               \
147           enum in_section save_section = in_section;    \
148           drectve_section ();                           \
149           fprintf (STREAM, "\t.ascii \" -export:%s\"\n",\
150                    arm_strip_name_encoding (NAME));     \
151           switch_to_section (save_section, (DECL));     \
152         }                                               \
153       ASM_OUTPUT_LABEL ((STREAM), (NAME));              \
154     }                                                   \
155   while (0)
156 \f
157 /* Support the ctors/dtors and other sections.  */
158
159 #define DRECTVE_SECTION_ASM_OP  "\t.section .drectve"
160
161 /* A list of other sections which the compiler might be "in" at any
162    given time.  */
163
164 #undef  EXTRA_SECTIONS
165 #define EXTRA_SECTIONS in_drectve
166
167 /* A list of extra section function definitions.  */
168
169 #undef  EXTRA_SECTION_FUNCTIONS
170 #define EXTRA_SECTION_FUNCTIONS \
171   DRECTVE_SECTION_FUNCTION      \
172   SWITCH_TO_SECTION_FUNCTION
173
174 #define DRECTVE_SECTION_FUNCTION \
175 void                                                                    \
176 drectve_section (void)                                                  \
177 {                                                                       \
178   if (in_section != in_drectve)                                         \
179     {                                                                   \
180       fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP);           \
181       in_section = in_drectve;                                          \
182     }                                                                   \
183 }
184
185 /* Switch to SECTION (an `enum in_section').
186
187    ??? This facility should be provided by GCC proper.
188    The problem is that we want to temporarily switch sections in
189    ASM_DECLARE_OBJECT_NAME and then switch back to the original section
190    afterwards.  */
191 #define SWITCH_TO_SECTION_FUNCTION                              \
192 static void                                                     \
193 switch_to_section (enum in_section section, tree decl)          \
194 {                                                               \
195   switch (section)                                              \
196     {                                                           \
197       case in_text: text_section (); break;                     \
198       case in_unlikely_executed_text: unlikely_text_section (); break; \
199       case in_data: data_section (); break;                     \
200       case in_named: named_section (decl, NULL, 0); break;      \
201       case in_readonly_data: readonly_data_section (); break;   \
202       case in_ctors: ctors_section (); break;                   \
203       case in_dtors: dtors_section (); break;                   \
204       case in_drectve: drectve_section (); break;               \
205       default: abort (); break;                                 \
206     }                                                           \
207 }
208