OSDN Git Service

471676ee03543e130317ba32942de2cbaf648c14
[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 Free Software Foundation, Inc.
3    Contributed by Doug Evans (dje@cygnus.com).
4    
5    This file is part of GCC.
6
7    GCC is free software; you can redistribute it and/or modify it
8    under the terms of the GNU General Public License as published
9    by the Free Software Foundation; either version 2, or (at your
10    option) any later version.
11
12    GCC is distributed in the hope that it will be useful, but WITHOUT
13    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15    License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GCC; 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 /* Enable PE specific code.  */
23 #define ARM_PE          1
24
25 #define ARM_PE_FLAG_CHAR '@'
26
27 /* Ensure that @x. will be stripped from the function name.  */
28 #undef SUBTARGET_NAME_ENCODING_LENGTHS
29 #define SUBTARGET_NAME_ENCODING_LENGTHS  \
30   case ARM_PE_FLAG_CHAR: return 3;
31
32 #undef  USER_LABEL_PREFIX
33 #define USER_LABEL_PREFIX "_"
34
35 \f
36 /* Run-time Target Specification.  */
37 #undef  TARGET_VERSION
38 #define TARGET_VERSION fputs (" (ARM/pe)", stderr)
39
40 /* Get tree.c to declare a target-specific specialization of
41    merge_decl_attributes.  */
42 #define TARGET_DLLIMPORT_DECL_ATTRIBUTES
43
44 /* Support the __declspec keyword by turning them into attributes.
45    We currently only support: naked, dllimport, and dllexport.
46    Note that the current way we do this may result in a collision with
47    predefined attributes later on.  This can be solved by using one attribute,
48    say __declspec__, and passing args to it.  The problem with that approach
49    is that args are not accumulated: each new appearance would clobber any
50    existing args.  */
51 #undef  SUBTARGET_CPP_SPEC
52 #define SUBTARGET_CPP_SPEC "-D__pe__ -D__declspec(x)=__attribute__((x))"
53
54
55 /* Experimental addition for pr 7885.
56    Ignore dllimport for functions.  */
57 #define TARGET_FLAG_NOP_FUN     (1 << 24)
58
59 #undef  TARGET_NOP_FUN_DLLIMPORT
60 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & TARGET_FLAG_NOP_FUN)
61
62 #undef  SUBTARGET_SWITCHES
63 #define SUBTARGET_SWITCHES                                      \
64 { "nop-fun-dllimport",            TARGET_FLAG_NOP_FUN,          \
65   N_("Ignore dllimport attribute for functions") },             \
66 { "no-nop-fun-dllimport",       - TARGET_FLAG_NOP_FUN, "" },
67
68 #undef  TARGET_DEFAULT
69 #define TARGET_DEFAULT  (ARM_FLAG_SOFT_FLOAT | TARGET_FLAG_NOP_FUN)
70
71 \f
72 #undef  WCHAR_TYPE
73 #define WCHAR_TYPE      "short unsigned int"
74 #undef  WCHAR_TYPE_SIZE
75 #define WCHAR_TYPE_SIZE 16
76
77 /* r11 is fixed.  */
78 #undef  SUBTARGET_CONDITIONAL_REGISTER_USAGE
79 #define SUBTARGET_CONDITIONAL_REGISTER_USAGE \
80   fixed_regs [11] = 1; \
81   call_used_regs [11] = 1;
82
83 \f
84 /* Define this macro if in some cases global symbols from one translation
85    unit may not be bound to undefined symbols in another translation unit
86    without user intervention.  For instance, under Microsoft Windows
87    symbols must be explicitly imported from shared libraries (DLLs).  */
88 #define MULTIPLE_SYMBOL_SPACES
89
90 #define TARGET_ASM_UNIQUE_SECTION arm_pe_unique_section
91
92 #define SUPPORTS_ONE_ONLY 1
93
94 /* Switch into a generic section.  */
95 #undef TARGET_ASM_NAMED_SECTION
96 #define TARGET_ASM_NAMED_SECTION  default_pe_asm_named_section
97 \f
98 /* This outputs a lot of .req's to define alias for various registers.
99    Let's try to avoid this.  */
100 #undef  ASM_FILE_START
101 #define ASM_FILE_START(STREAM)                                  \
102   do                                                            \
103     {                                                           \
104       asm_fprintf (STREAM, "%@ Generated by gcc %s for ARM/pe\n",\
105            version_string);                                     \
106       output_file_directive ((STREAM), main_input_filename);    \
107     }                                                           \
108   while (0)
109
110 /* Output a reference to a label.  */
111 #undef  ASM_OUTPUT_LABELREF
112 #define ASM_OUTPUT_LABELREF(STREAM, NAME)  \
113   asm_fprintf (STREAM, "%U%s", arm_strip_name_encoding (NAME))
114
115 /* Output a function definition label.  */
116 #undef  ASM_DECLARE_FUNCTION_NAME
117 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)           \
118   do                                                            \
119     {                                                           \
120       if (arm_dllexport_name_p (NAME))                          \
121         {                                                       \
122           drectve_section ();                                   \
123           fprintf (STREAM, "\t.ascii \" -export:%s\"\n",        \
124                    arm_strip_name_encoding (NAME));             \
125           function_section (DECL);                              \
126         }                                                       \
127       ARM_DECLARE_FUNCTION_NAME (STREAM, NAME, DECL);           \
128       if (TARGET_THUMB)                                         \
129         fprintf (STREAM, "\t.code 16\n");                       \
130       ASM_OUTPUT_LABEL (STREAM, NAME);                          \
131     }                                                           \
132   while (0)
133
134 /* Output a common block.  */
135 #undef  ASM_OUTPUT_COMMON
136 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)  \
137   do                                                    \
138     {                                                   \
139       if (arm_dllexport_name_p (NAME))                  \
140         {                                               \
141           drectve_section ();                           \
142           fprintf ((STREAM), "\t.ascii \" -export:%s\"\n",\
143                    arm_strip_name_encoding (NAME));     \
144         }                                               \
145       if (! arm_dllimport_name_p (NAME))                \
146         {                                               \
147           fprintf ((STREAM), "\t.comm\t");              \
148           assemble_name ((STREAM), (NAME));             \
149           asm_fprintf ((STREAM), ", %d\t%@ %d\n",       \
150                    (int)(ROUNDED), (int)(SIZE));        \
151         }                                               \
152     }                                                   \
153   while (0)
154
155 /* Output the label for an initialized variable.  */
156 #undef  ASM_DECLARE_OBJECT_NAME
157 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)     \
158   do                                                    \
159     {                                                   \
160       if (arm_dllexport_name_p (NAME))                  \
161         {                                               \
162           enum in_section save_section = in_section;    \
163           drectve_section ();                           \
164           fprintf (STREAM, "\t.ascii \" -export:%s\"\n",\
165                    arm_strip_name_encoding (NAME));     \
166           switch_to_section (save_section, (DECL));     \
167         }                                               \
168       ASM_OUTPUT_LABEL ((STREAM), (NAME));              \
169     }                                                   \
170   while (0)
171 \f
172 /* Support the ctors/dtors and other sections.  */
173
174 #define DRECTVE_SECTION_ASM_OP  "\t.section .drectve"
175
176 /* A list of other sections which the compiler might be "in" at any
177    given time.  */
178
179 #undef  EXTRA_SECTIONS
180 #define EXTRA_SECTIONS in_drectve
181
182 /* A list of extra section function definitions.  */
183
184 #undef  EXTRA_SECTION_FUNCTIONS
185 #define EXTRA_SECTION_FUNCTIONS \
186   DRECTVE_SECTION_FUNCTION      \
187   SWITCH_TO_SECTION_FUNCTION
188
189 #define DRECTVE_SECTION_FUNCTION \
190 void                                                                    \
191 drectve_section ()                                                      \
192 {                                                                       \
193   if (in_section != in_drectve)                                         \
194     {                                                                   \
195       fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP);           \
196       in_section = in_drectve;                                          \
197     }                                                                   \
198 }
199
200 /* Switch to SECTION (an `enum in_section').
201
202    ??? This facility should be provided by GCC proper.
203    The problem is that we want to temporarily switch sections in
204    ASM_DECLARE_OBJECT_NAME and then switch back to the original section
205    afterwards.  */
206 #define SWITCH_TO_SECTION_FUNCTION                              \
207 static void switch_to_section PARAMS ((enum in_section, tree)); \
208 static void                                                     \
209 switch_to_section (section, decl)                               \
210      enum in_section section;                                   \
211      tree decl;                                                 \
212 {                                                               \
213   switch (section)                                              \
214     {                                                           \
215       case in_text: text_section (); break;                     \
216       case in_data: data_section (); break;                     \
217       case in_named: named_section (decl, NULL, 0); break;      \
218       case in_readonly_data: readonly_data_section (); break;   \
219       case in_ctors: ctors_section (); break;                   \
220       case in_dtors: dtors_section (); break;                   \
221       case in_drectve: drectve_section (); break;               \
222       default: abort (); break;                                 \
223     }                                                           \
224 }