OSDN Git Service

1cdd74682842e83cbf1984cc6f7de0d4513c62d0
[pf3gnuchains/gcc-fork.git] / gcc / config / mep / mep.h
1 /* Definitions for Toshiba Media Processor
2    Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2009
3    Free Software Foundation, Inc.
4    Contributed by Red Hat, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21 \f
22
23 #undef  CPP_SPEC
24 #define CPP_SPEC "\
25 -D__MEP__ -D__MeP__ \
26 -D__section(_x)=__attribute__((section(_x))) \
27 -D__align(_x)=__attribute__((aligned(_x))) \
28 -D__io(_x)=__attribute__((io(_x))) \
29 -D__cb(_x)=__attribute__((cb(_x))) \
30 -D__based=__attribute__((based)) \
31 -D__tiny=__attribute__((tiny)) \
32 -D__near=__attribute__((near)) \
33 -D__far=__attribute__((far)) \
34 -D__vliw=__attribute__((vliw)) \
35 -D__interrupt=__attribute__((interrupt)) \
36 -D__disinterrupt=__attribute__((disinterrupt)) \
37 %{!meb:%{!mel:-D__BIG_ENDIAN__}} \
38 %{meb:-U__LITTLE_ENDIAN__ -D__BIG_ENDIAN__} \
39 %{mel:-U__BIG_ENDIAN__ -D__LITTLE_ENDIAN__} \
40 %{mconfig=*:-D__MEP_CONFIG_%*} \
41 %{mivc2:-D__MEP_CONFIG_CP_DATA_BUS_WIDTH=64} \
42 "
43
44 #undef  CC1_SPEC
45 #define CC1_SPEC "%{!mlibrary:%(config_cc_spec)} \
46 %{!.cc:%{O2:%{!funroll*:--param max-completely-peeled-insns=6 \
47                         --param max-unrolled-insns=6 -funroll-loops}}}"
48
49 #undef  CC1PLUS_SPEC
50 #define CC1PLUS_SPEC "%{!mlibrary:%(config_cc_spec)}"
51
52 #undef  ASM_SPEC
53 #define ASM_SPEC "%{mconfig=*} %{meb:-EB} %{mel:-EL} \
54 %{mno-satur} %{msatur} %{mno-clip} %{mclip} %{mno-minmax} %{mminmax} \
55 %{mno-absdiff} %{mabsdiff} %{mno-leadz} %{mleadz} %{mno-bitops} %{mbitops} \
56 %{mno-div} %{mdiv} %{mno-mult} %{mmult} %{mno-average} %{maverage} \
57 %{mcop32} %{mno-debug} %{mdebug} %{mlibrary}"
58
59 /* The MeP config tool will edit this spec.  */
60 #undef  STARTFILE_SPEC
61 #define STARTFILE_SPEC "%{msdram:%{msim:simsdram-crt0.o%s}} \
62 %{mno-sdram:%{msim:sim-crt0.o%s}} \
63 %{msdram:%{!msim*:sdram-crt0.o%s}} \
64 %{mno-sdram:%{!msim*:crt0.o%s}} \
65 %(config_start_spec) \
66 %{msimnovec:simnovec-crt0.o%s} \
67 crtbegin.o%s"
68
69 #undef  LIB_SPEC
70 #define LIB_SPEC "-( -lc %{msim*:-lsim}%{!msim*:-lnosys} -) %(config_link_spec)"
71
72 #undef  LINK_SPEC
73 #define LINK_SPEC "%{meb:-EB} %{mel:-EL}"
74
75 #undef  ENDFILE_SPEC
76 #define ENDFILE_SPEC "crtend.o%s %{msim*:sim-crtn.o%s}%{!msim*:crtn.o%s}"
77
78 /* The MeP config tool will edit this spec.  */
79 #define CONFIG_CC_SPEC "\
80 %{mconfig=default: -mbitops -mleadz -mabsdiff -maverage -mminmax -mclip -msatur -mvl64 -mvliw -mcop64 -D__MEP_CONFIG_CP_DATA_BUS_WIDTH=64 -mivc2}\
81 "
82 /* end-config-cc-spec */
83
84 /* The MeP config tool will edit this spec.  */
85 #define CONFIG_LINK_SPEC "\
86 %{mconfig=default: %{!T*:-Tdefault.ld}}\
87 "
88 /* end-config-link-spec */
89
90 /* The MeP config tool will edit this spec.  */
91 #define CONFIG_START_SPEC "\
92 %{!msdram:%{!mno-sdram:%{!msim*:crt0.o%s}}} \
93 %{!msdram:%{!mno-sdram:%{msim:sim-crt0.o%s}}} \
94 "
95 /* end-config-start-spec */
96
97 #define EXTRA_SPECS \
98   { "config_cc_spec",  CONFIG_CC_SPEC }, \
99   { "config_link_spec",  CONFIG_LINK_SPEC }, \
100   { "config_start_spec",  CONFIG_START_SPEC },
101 \f
102
103 #define TARGET_CPU_CPP_BUILTINS()               \
104   do                                            \
105     {                                           \
106       builtin_define_std ("mep");               \
107       builtin_assert ("machine=mep");           \
108     }                                           \
109   while (0)
110
111 extern int target_flags;
112
113 /* Controlled by MeP-Integrator.  */
114 #define TARGET_H1               0
115
116 #define MEP_ALL_OPTS    (MASK_OPT_AVERAGE       \
117                          | MASK_OPT_MULT        \
118                          | MASK_OPT_DIV         \
119                          | MASK_OPT_BITOPS      \
120                          | MASK_OPT_LEADZ       \
121                          | MASK_OPT_ABSDIFF     \
122                          | MASK_OPT_MINMAX      \
123                          | MASK_OPT_CLIP        \
124                          | MASK_OPT_SATUR )
125
126 #define TARGET_DEFAULT          (MASK_IO_VOLATILE | MASK_OPT_REPEAT | MEP_ALL_OPTS | MASK_LITTLE_ENDIAN)
127
128 #define TARGET_IO_NO_VOLATILE   (! (target_flags & MASK_IO_VOLATILE))
129 #define TARGET_OPT_NOREPEAT     (! (target_flags & MASK_OPT_REPEAT))
130 #define TARGET_32BIT_CR_REGS    (! (target_flags & MASK_64BIT_CR_REGS))
131 #define TARGET_BIG_ENDIAN       (! (target_flags & MASK_LITTLE_ENDIAN))
132
133 #define TARGET_COPRO_MULT       0
134
135 #define TARGET_VERSION fprintf (stderr, " (Toshiba Media Processor (MeP))");
136
137 #define OVERRIDE_OPTIONS mep_override_options ();
138
139 /* The MeP config tool will add TARGET_OPTION_TRANSLATE_TABLE here.  */
140 #define TARGET_OPTION_TRANSLATE_TABLE \
141   {"-mall-opts", "-maverage -mmult -mdiv -mbitops -mleadz \
142                   -mabsdiff -mminmax -mclip -msatur -mdebug" }, \
143   {"-mno-opts", "-mno-average -mno-mult -mno-div -mno-bitops -mno-leadz \
144                   -mno-absdiff -mno-minmax -mno-clip -mno-satur -mno-debug" }, \
145   {"-mfar", "-ml -mtf -mc=far" } \
146 /* start-target-option-table */ \
147 , {"-mconfig=default", "-mconfig=default -mmult -mdiv -D__MEP_CONFIG_ISA=1" } \
148 /* end-target-option-table */
149
150 /* The MeP config tool will replace this as appropriate.  */
151 #define DEFAULT_ENDIAN_SPEC "%{!meb: -mel}"
152
153 /* The MeP config tool will replace this with an -mconfig= switch.  */
154 #define LIBRARY_CONFIG_SPEC "-mconfig=default"
155
156 /* Don't add an endian option when building the libraries.  */
157 #define DRIVER_SELF_SPECS \
158   "%{!mlibrary:" DEFAULT_ENDIAN_SPEC "}", \
159   "%{mlibrary: " LIBRARY_CONFIG_SPEC " %{!mel:-meb}}"
160
161 /* The MeP config tool will add COPROC_SELECTION_TABLE here.  */
162 /* start-coproc-selection-table */
163 #define COPROC_SELECTION_TABLE \
164 {"default", ISA_EXT1}
165 /* end-coproc-selection-table */
166
167 #define CAN_DEBUG_WITHOUT_FP
168
169 #define OPTIMIZATION_OPTIONS(LEVEL, FOR_SIZE) mep_optimization_options ()
170 \f
171
172 #define BITS_BIG_ENDIAN 0
173 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN ? 0 : 1)
174 #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN ? 0 : 1)
175
176 #ifdef __LITTLE_ENDIAN__
177 #define LIBGCC2_WORDS_BIG_ENDIAN 0
178 #else
179 #define LIBGCC2_WORDS_BIG_ENDIAN 1
180 #endif
181
182 #define UNITS_PER_WORD 4
183
184 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE)     \
185   do                                            \
186     {                                           \
187       if (GET_MODE_CLASS (MODE) == MODE_INT     \
188           && GET_MODE_SIZE (MODE) < 4)          \
189         (MODE) = SImode;                \
190     }                                           \
191   while (0)
192
193 #define PARM_BOUNDARY 32
194 #define STACK_BOUNDARY 32
195 #define PREFERRED_STACK_BOUNDARY 64
196 #define FUNCTION_BOUNDARY 16
197 #define BIGGEST_ALIGNMENT 64
198
199 #define DATA_ALIGNMENT(TYPE, ALIGN)             \
200   (TREE_CODE (TYPE) == ARRAY_TYPE               \
201    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode    \
202    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
203
204 #define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
205   (TREE_CODE (EXP) == STRING_CST        \
206    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
207
208 #define STRICT_ALIGNMENT 1
209
210 #define PCC_BITFIELD_TYPE_MATTERS 1
211
212 #define DEFAULT_VTABLE_THUNKS 1
213
214 \f
215 #define INT_TYPE_SIZE         32
216 #define SHORT_TYPE_SIZE       16
217 #define LONG_TYPE_SIZE        32
218 #define LONG_LONG_TYPE_SIZE   64
219 #define CHAR_TYPE_SIZE         8
220 #define FLOAT_TYPE_SIZE       32
221 #define DOUBLE_TYPE_SIZE      64
222 #define LONG_DOUBLE_TYPE_SIZE 64
223 #define DEFAULT_SIGNED_CHAR    1
224 \f
225 /* Register numbers:
226         0..15   core registers
227         16..47  control registers
228         48..79  coprocessor registers
229         80..111 coprocessor control registers
230         112     virtual arg pointer register  */
231
232 #define FIRST_PSEUDO_REGISTER (LAST_SHADOW_REGISTER + 1)
233
234   /* R12 is optionally FP.  R13 is TP, R14 is GP, R15 is SP. */
235   /* hi and lo can be used as general registers.  Others have
236      immutable bits.  */
237 /* A "1" here means the register is generally not available to gcc,
238    and is assumed to remain unchanged or unused throughout.  */
239 #define FIXED_REGISTERS {                               \
240   /* core registers */                                  \
241   0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 1,    \
242   /* control registers */                               \
243   1, 1, 1, 1,  1, 1, 1, 0,  0, 1, 1, 1,  1, 1, 1, 1,    \
244   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
245   /* coprocessor registers */                           \
246   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
247   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
248   /* coprocessor control registers */                   \
249   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
250   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
251   /* virtual arg pointer */                             \
252   1, FIXED_SHADOW_REGISTERS                             \
253   }
254
255 /* This is a call-clobbered reg not used for args or return value,
256    that we use as a temp for saving control registers in the prolog
257    and restoring them in the epilog. */
258 #define REGSAVE_CONTROL_TEMP    11
259
260 /* A "1" here means a register may be changed by a function without
261    needing to preserve its previous value.  */
262 #define CALL_USED_REGISTERS {                           \
263   /* core registers */                                  \
264   1, 1, 1, 1,  1, 0, 0, 0,  0, 1, 1, 1,  1, 0, 0, 1,    \
265   /* control registers */                               \
266   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
267   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
268   /* coprocessor registers */                           \
269   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
270   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
271   /* coprocessor control registers */                   \
272   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
273   1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,    \
274   /* virtual arg pointer */                             \
275   1, CALL_USED_SHADOW_REGISTERS                         \
276   }
277
278 #define CONDITIONAL_REGISTER_USAGE \
279         mep_conditional_register_usage (fixed_regs, call_used_regs);
280
281 #define REG_ALLOC_ORDER {                                               \
282   /* core registers */                                                  \
283   3, 2, 1, 0, 9, 10, 11, 12, 4, 5, 6, 7, 8, 13, 14, 15,                 \
284   /* control registers */                                               \
285   16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,       \
286   32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,       \
287   /* coprocessor registers */                                           \
288   /* Prefer to use the non-loadable registers when looking for a        \
289      member of CR_REGS (as opposed to LOADABLE_CR_REGS).  */            \
290   64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 48, 49, 50, 51, 52, 58,       \
291   59, 60, 61, 62, 63, 53, 54, 55, 56, 57, 74, 75, 76, 77, 78, 79,       \
292   /* coprocessor control registers */                                   \
293   80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,       \
294   96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, \
295   /* virtual arg pointer */                                             \
296   112, SHADOW_REG_ALLOC_ORDER                                           \
297   }
298
299 /* We must somehow disable register remapping for interrupt functions.  */
300 extern char mep_leaf_registers[];
301 #define LEAF_REGISTERS mep_leaf_registers
302 #define LEAF_REG_REMAP(REG) (REG)
303
304 \f
305 #define FIRST_GR_REGNO 0
306 #define FIRST_CONTROL_REGNO (FIRST_GR_REGNO + 16)
307 #define FIRST_CR_REGNO (FIRST_CONTROL_REGNO + 32)
308 #define FIRST_CCR_REGNO (FIRST_CR_REGNO + 32)
309
310 #define GR_REGNO_P(REGNO) \
311   ((unsigned) ((REGNO) - FIRST_GR_REGNO) < 16)
312
313 #define CONTROL_REGNO_P(REGNO) \
314   ((unsigned) ((REGNO) - FIRST_CONTROL_REGNO) < 32)
315
316 #define LOADABLE_CR_REGNO_P(REGNO) \
317   ((unsigned) ((REGNO) - FIRST_CR_REGNO) < 16)
318
319 #define CR_REGNO_P(REGNO) \
320   ((unsigned) ((REGNO) - FIRST_CR_REGNO) < 32)
321
322 #define CCR_REGNO_P(REGNO) \
323   ((unsigned) ((REGNO) - FIRST_CCR_REGNO) < 32)
324
325 #define ANY_CONTROL_REGNO_P(REGNO) \
326   (CONTROL_REGNO_P (REGNO) || CCR_REGNO_P (REGNO))
327
328 #define HARD_REGNO_NREGS(REGNO, MODE)           \
329   ((CR_REGNO_P (REGNO) && TARGET_64BIT_CR_REGS) \
330    ? (GET_MODE_SIZE (MODE) + 8 - 1) / 8         \
331    : (GET_MODE_SIZE (MODE) + 4 - 1) / 4)
332
333 #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
334
335 #define MODES_TIEABLE_P(MODE1, MODE2) 1
336
337 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
338   mep_cannot_change_mode_class (FROM, TO, CLASS)
339 \f
340 enum reg_class
341 {
342   NO_REGS,
343   SP_REGS,
344   TP_REGS,
345   GP_REGS,
346   R0_REGS,
347   RPC_REGS,
348   HI_REGS,
349   LO_REGS,
350   HILO_REGS,
351   TPREL_REGS,
352   GENERAL_NOT_R0_REGS,
353   GENERAL_REGS,
354   CONTROL_REGS,
355   CONTROL_OR_GENERAL_REGS,
356   USER0_REGS,
357   USER1_REGS,
358   USER2_REGS,
359   USER3_REGS,
360   LOADABLE_CR_REGS,
361   CR_REGS,
362   CCR_REGS,
363   ALL_REGS,
364   LIM_REG_CLASSES
365 };
366
367 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
368
369 #define REG_CLASS_NAMES { \
370   "NO_REGS", \
371   "SP_REGS", \
372   "TP_REGS", \
373   "GP_REGS", \
374   "R0_REGS", \
375   "RPC_REGS", \
376   "HI_REGS", \
377   "LO_REGS", \
378   "HILO_REGS", \
379   "TPREL_REGS", \
380   "GENERAL_NOT_R0_REGS", \
381   "GENERAL_REGS", \
382   "CONTROL_REGS", \
383   "CONTROL_OR_GENERAL_REGS", \
384   "USER0_REGS", \
385   "USER1_REGS", \
386   "USER2_REGS", \
387   "USER3_REGS", \
388   "LOADABLE_CR_REGS", \
389   "CR_REGS", \
390   "CCR_REGS", \
391   "ALL_REGS" }
392
393 #define REG_CLASS_CONTENTS { \
394   { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \
395   { 0x00008000, 0x00000000, 0x00000000, 0x00000000 }, /* SP_REGS */ \
396   { 0x00002000, 0x00000000, 0x00000000, 0x00000000 }, /* TP_REGS */ \
397   { 0x00004000, 0x00000000, 0x00000000, 0x00000000 }, /* GP_REGS */ \
398   { 0x00000001, 0x00000000, 0x00000000, 0x00000000 }, /* R0_REGS */ \
399   { 0x00400000, 0x00000000, 0x00000000, 0x00000000 }, /* RPC_REGS */ \
400   { 0x00800000, 0x00000000, 0x00000000, 0x00000000 }, /* HI_REGS */ \
401   { 0x01000000, 0x00000000, 0x00000000, 0x00000000 }, /* LO_REGS */ \
402   { 0x01800000, 0x00000000, 0x00000000, 0x00000000 }, /* HILO_REGS */ \
403   { 0x000000ff, 0x00000000, 0x00000000, 0x00000000 }, /* TPREL_REGS */ \
404   { 0x0000fffe, 0x00000000, 0x00000000, 0x00000000 }, /* GENERAL_NOT_R0_REGS */ \
405   { 0x0000ffff, 0x00000000, 0x00000000, 0x00010000 }, /* GENERAL_REGS */ \
406   { 0xffff0000, 0x0000ffff, 0x00000000, 0x00000000 }, /* CONTROL_REGS */ \
407   { 0xffffffff, 0x0000ffff, 0x00000000, 0x00000000 }, /* CONTROL_OR_GENERAL_REGS */ \
408   { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* USER0_REGS */ \
409   { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* USER1_REGS */ \
410   { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* USER2_REGS */ \
411   { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* USER3_REGS */ \
412   { 0x00000000, 0xffff0000, 0x00000000, 0x00000000 }, /* LOADABLE_CR_REGS */ \
413   { 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000 }, /* CR_REGS */ \
414   { 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff }, /* CCR_REGS */ \
415   { 0xffffffff, 0xffffffff, 0xffffffff, 0x0001ffff }, /* ALL_REGS */ \
416   }
417
418 #define REGNO_REG_CLASS(REGNO) mep_regno_reg_class (REGNO)
419
420 #define IRA_COVER_CLASSES { GENERAL_REGS, CONTROL_REGS, CR_REGS, CCR_REGS, LIM_REG_CLASSES }
421
422 #define BASE_REG_CLASS GENERAL_REGS
423 #define INDEX_REG_CLASS GENERAL_REGS
424
425 #if 0
426 #define REG_CLASS_FROM_CONSTRAINT(CHAR, STRING) \
427         mep_reg_class_from_constraint (CHAR, STRING)
428 #endif
429
430 #define REGNO_OK_FOR_BASE_P(NUM) (GR_REGNO_P (NUM) \
431         || (NUM) == ARG_POINTER_REGNUM \
432         || (NUM) >= FIRST_PSEUDO_REGISTER)
433
434 #define REGNO_OK_FOR_INDEX_P(NUM) REGNO_OK_FOR_BASE_P (NUM)
435
436 #define PREFERRED_RELOAD_CLASS(X, CLASS) mep_preferred_reload_class (X, CLASS)
437
438 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
439         mep_secondary_input_reload_class (CLASS, MODE, X)
440 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
441         mep_secondary_output_reload_class (CLASS, MODE, X)
442 #define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \
443         mep_secondary_memory_needed (CLASS1, CLASS2, MODE)
444
445 #define CLASS_MAX_NREGS(CLASS, MODE) \
446   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
447
448 #if 0
449 #define CONST_OK_FOR_LETTER_P(VALUE, C) mep_const_ok_for_letter_p (VALUE, C)
450
451 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 0
452
453 #define CONSTRAINT_LEN(C, STR) \
454         ((C) == 'e' ? 2 : DEFAULT_CONSTRAINT_LEN (C, STR))
455 #define EXTRA_CONSTRAINT(VALUE, C) mep_extra_constraint (VALUE, C)
456 #endif
457
458 #define WANT_GCC_DECLARATIONS
459 #include "mep-intrin.h"
460 #undef WANT_GCC_DECLARATIONS
461
462 extern int mep_intrinsic_insn[];
463 extern unsigned int mep_selected_isa;
464
465 /* True if intrinsic X is available.  X is a mep_* value declared
466    in mep-intrin.h.  */
467 #define MEP_INTRINSIC_AVAILABLE_P(X) (mep_intrinsic_insn[X] >= 0)
468
469 /* Used to define CGEN_ENABLE_INTRINSIC_P in mep-intrin.h.  */
470 #define CGEN_CURRENT_ISAS mep_selected_isa
471 #define CGEN_CURRENT_GROUP \
472   (mep_vliw_function_p (cfun->decl) ? GROUP_VLIW : GROUP_NORMAL)
473
474 \f
475
476 #define STACK_GROWS_DOWNWARD       1
477 #define FRAME_GROWS_DOWNWARD       1
478 #define STARTING_FRAME_OFFSET      0
479 #define FIRST_PARM_OFFSET(FUNDECL) 0
480 #define INCOMING_FRAME_SP_OFFSET   0
481
482 #define RETURN_ADDR_RTX(COUNT, FRAMEADDR) mep_return_addr_rtx (COUNT)
483 #define INCOMING_RETURN_ADDR_RTX          gen_rtx_REG (SImode, LP_REGNO)
484 #define DWARF_FRAME_RETURN_COLUMN         LP_REGNO
485
486 #define STACK_POINTER_REGNUM          15
487 #define FRAME_POINTER_REGNUM           8
488 #define ARG_POINTER_REGNUM            112
489 #define RETURN_ADDRESS_POINTER_REGNUM 17
490 #define STATIC_CHAIN_REGNUM            0
491
492 \f
493
494 #define ELIMINABLE_REGS                                         \
495 {                                                               \
496   {ARG_POINTER_REGNUM,   STACK_POINTER_REGNUM},                 \
497   {ARG_POINTER_REGNUM,   FRAME_POINTER_REGNUM},                 \
498   {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}                  \
499 }
500
501 #define CAN_ELIMINATE(FROM, TO)                                 \
502  ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM  \
503   ? ! frame_pointer_needed                                      \
504   : 1)
505
506 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
507         (OFFSET) = mep_elimination_offset (FROM, TO)
508
509 #define ACCUMULATE_OUTGOING_ARGS 1
510
511 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0
512
513 \f
514
515 /* The ABI is thus: Arguments are in $1, $2, $3, $4, stack.  Arguments
516    larger than 4 bytes are passed indirectly.  Return value in 0,
517    unless bigger than 4 bytes, then the caller passes a pointer as the
518    first arg.  For varargs, we copy $1..$4 to the stack.  */
519
520 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
521         mep_function_arg (CUM, MODE, TYPE, NAMED)
522
523 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) 1
524
525 typedef struct
526 {
527   int nregs;
528   int vliw;
529 } CUMULATIVE_ARGS;
530
531 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
532         mep_init_cumulative_args (& (CUM), FNTYPE, LIBNAME, FNDECL)
533
534 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)            \
535         mep_arg_advance (& (CUM), MODE, TYPE, NAMED)
536
537 #define FUNCTION_ARG_REGNO_P(REGNO) \
538         (((REGNO) >= 1 && (REGNO) <= 4) \
539          || ((REGNO) >= FIRST_CR_REGNO + 1 && (REGNO) <= FIRST_CR_REGNO + 4))
540
541 #define RETURN_VALUE_REGNUM      0
542
543 #define FUNCTION_VALUE(VALTYPE, FUNC) mep_function_value (VALTYPE, FUNC)
544 #define LIBCALL_VALUE(MODE) mep_libcall_value (MODE)
545
546 #define FUNCTION_VALUE_REGNO_P(REGNO)                           \
547   ((REGNO) == RETURN_VALUE_REGNUM)
548
549 #define DEFAULT_PCC_STRUCT_RETURN 0
550
551 #define STRUCT_VALUE 0
552
553 #define FUNCTION_OK_FOR_SIBCALL(DECL) mep_function_ok_for_sibcall(DECL)
554 \f
555 /* Prologue and epilogues are all handled via RTL.  */
556
557 #define EXIT_IGNORE_STACK 1
558
559 #define EPILOGUE_USES(REGNO)  mep_epilogue_uses (REGNO)
560
561 /* Profiling is supported.  */
562      
563 #define FUNCTION_PROFILER(FILE, LABELNO) mep_function_profiler (FILE);
564 #undef TARGET_HAS_F_SETLKW
565 #define NO_PROFILE_COUNTERS 1
566 \f
567 /* Trampolines are built at run-time.  The cache is invalidated at
568    run-time also.  */
569
570 #define TRAMPOLINE_SIZE 20
571
572 #define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, STATIC_CHAIN) \
573         mep_init_trampoline (ADDR, FNADDR, STATIC_CHAIN)
574
575 \f
576
577 #define CONSTANT_ADDRESS_P(X) CONSTANT_P (X)
578
579 #define MAX_REGS_PER_ADDRESS 1
580
581 #ifdef REG_OK_STRICT
582 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL)                \
583         if (mep_legitimate_address ((MODE), (X), 1)) goto LABEL
584 #else
585 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL)                \
586         if (mep_legitimate_address ((MODE), (X), 0)) goto LABEL
587 #endif
588
589 #ifdef REG_OK_STRICT
590 #define REG_OK_FOR_BASE_P(X) GR_REGNO_P (REGNO (X))
591 #else
592 #define REG_OK_FOR_BASE_P(X) (GR_REGNO_P (REGNO (X)) \
593                                 || REGNO (X) == ARG_POINTER_REGNUM \
594                                 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
595 #endif
596
597 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X)
598
599 #define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) \
600   if (mep_legitimize_reload_address (&(X), (MODE), (OPNUM), (TYPE), (IND_LEVELS))) \
601     goto WIN
602
603 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)
604
605 #define LEGITIMATE_CONSTANT_P(X) 1
606
607 #define SELECT_CC_MODE(OP, X, Y)  CCmode
608 \f
609
610 /* Moves between control regs need a scratch.  */
611 #define REGISTER_MOVE_COST(MODE, FROM, TO) mep_register_move_cost (MODE, FROM, TO)
612
613 #define SLOW_BYTE_ACCESS 1
614
615 /* Define this macro if it is as good or better to call a constant function
616    address than to call an address kept in a register.  */
617 #define NO_FUNCTION_CSE 
618
619 \f
620 #define TEXT_SECTION_ASM_OP "\t.text\n\t.core"
621 #define DATA_SECTION_ASM_OP "\t.data"
622 #define BSS_SECTION_ASM_OP  ".bss"
623
624 #define USE_SELECT_SECTION_FOR_FUNCTIONS 1
625
626 #define TARGET_ASM_FILE_END mep_file_cleanups
627
628 #define ASM_APP_ON "#APP\n"
629 #define ASM_APP_OFF "#NO_APP\n"
630
631 #define ASM_OUTPUT_DOUBLE(FILE, VALUE)                          \
632   do                                                            \
633     {                                                           \
634       long l[2];                                                \
635                                                                 \
636       REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l);                   \
637       fprintf (FILE, "\t.long\t0x%lx,0x%lx\n", l[0], l[1]);     \
638     }                                                           \
639   while (0)
640
641 #define ASM_OUTPUT_FLOAT(FILE, VALUE)           \
642   do                                            \
643     {                                           \
644       long l;                                   \
645                                                 \
646       REAL_VALUE_TO_TARGET_SINGLE (VALUE, l);   \
647       fprintf ((FILE), "\t.long\t0x%lx\n", l);  \
648     }                                           \
649   while (0)
650
651 #define ASM_OUTPUT_CHAR(FILE, VALUE)            \
652   do                                            \
653     {                                           \
654       fprintf (FILE, "\t.byte\t");              \
655       output_addr_const (FILE, (VALUE));        \
656       fprintf (FILE, "\n");                     \
657     }                                           \
658   while (0)
659
660 #define ASM_OUTPUT_SHORT(FILE, VALUE)           \
661   do                                            \
662     {                                           \
663       fprintf (FILE, "\t.hword\t");             \
664       output_addr_const (FILE, (VALUE));        \
665       fprintf (FILE, "\n");                     \
666     }                                           \
667   while (0)
668
669 #define ASM_OUTPUT_INT(FILE, VALUE)             \
670   do                                            \
671     {                                           \
672       fprintf (FILE, "\t.word\t");              \
673       output_addr_const (FILE, (VALUE));        \
674       fprintf (FILE, "\n");                     \
675     }                                           \
676   while (0)
677
678 #define ASM_OUTPUT_BYTE(STREAM, VALUE) \
679   fprintf (STREAM, "\t%s\t0x%x\n", ASM_BYTE_OP, (VALUE))
680
681 /* Most of these are here to support based/tiny/far/io attributes.  */
682
683 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
684         mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 1)
685
686 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
687         mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
688
689 #define ASM_OUTPUT_LABEL(STREAM, NAME)          \
690   do                                            \
691     {                                           \
692       assemble_name (STREAM, NAME);             \
693       fputs (":\n", STREAM);                    \
694     }                                           \
695   while (0)
696
697 /* Globalizing directive for a label.  */
698 #define GLOBAL_ASM_OP "\t.globl "
699
700 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
701   asm_fprintf ((STREAM), "%U%s", mep_strip_name_encoding (NAME))
702
703 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR, NAME, NUMBER)           \
704   do                                                            \
705     {                                                           \
706       (OUTVAR) = (char *) alloca (strlen ((NAME)) + 12);        \
707       sprintf ((OUTVAR), "%s.%ld", (NAME), (long)(NUMBER));     \
708     }                                                           \
709   while (0)
710 \f
711
712 #define REGISTER_NAMES                                                  \
713 {                                                                       \
714   /* Core registers.  */                                                \
715   "$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7",                       \
716   "$8", "$9", "$10", "$11", "$12", "$tp", "$gp", "$sp",                 \
717   /* Control registers.  */                                             \
718   "$pc", "$lp", "$sar", "3", "$rpb", "$rpe", "$rpc", "$hi",             \
719   "$lo", "9", "10", "11", "$mb0", "$me0", "$mb1", "$me1",               \
720   "$psw", "$id", "$tmp", "$epc", "$exc", "$cfg", "22", "$npc",          \
721   "$dbg", "$depc", "$opt", "$rcfg", "$ccfg", "29", "30", "31",          \
722   /* Coprocessor registers.  */                                         \
723   "$c0", "$c1", "$c2", "$c3", "$c4", "$c5", "$c6", "$c7",               \
724   "$c8", "$c9", "$c10", "$c11", "$c12", "$c13", "$c14", "$c15",         \
725   "$c16", "$c17", "$c18", "$c19", "$c20", "$c21", "$c22", "$c23",       \
726   "$c24", "$c25", "$c26", "$c27", "$c28", "$c29", "$c30", "$c31",       \
727   /* Coprocessor control registers.  */                                 \
728   "$ccr0", "$ccr1", "$ccr2", "$ccr3", "$ccr4", "$ccr5", "$ccr6",        \
729   "$ccr7", "$ccr8", "$ccr9", "$ccr10", "$ccr11", "$ccr12", "$ccr13",    \
730   "$ccr14", "$ccr15", "$ccr16", "$ccr17", "$ccr18", "$ccr19", "$ccr20", \
731   "$ccr21", "$ccr22", "$ccr23", "$ccr24", "$ccr25", "$ccr26", "$ccr27", \
732   "$ccr28", "$ccr29", "$ccr30", "$ccr31",                               \
733   /* Virtual arg pointer.  */                                           \
734   "$argp", SHADOW_REGISTER_NAMES                                        \
735 }
736
737 /* We duplicate some of the above because we twiddle the above
738    according to *how* the registers are used.  Likewise, we include
739    the standard names for coprocessor control registers so that
740    coprocessor options can rename them in the default table.  Note
741    that these are compared to stripped names (see REGISTER_PREFIX
742    below).  */
743 #define ADDITIONAL_REGISTER_NAMES               \
744 {                                               \
745   {  "8",  8 }, { "fp",  8 },                   \
746   { "13", 13 }, { "tp", 13 },                   \
747   { "14", 14 }, { "gp", 14 },                   \
748   { "15", 15 }, { "sp", 15 },                   \
749   { "ccr0", FIRST_CCR_REGNO + 0 },              \
750   { "ccr1", FIRST_CCR_REGNO + 1 },              \
751   { "ccr2", FIRST_CCR_REGNO + 2 },              \
752   { "ccr3", FIRST_CCR_REGNO + 3 },              \
753   { "ccr4", FIRST_CCR_REGNO + 4 },              \
754   { "ccr5", FIRST_CCR_REGNO + 5 },              \
755   { "ccr6", FIRST_CCR_REGNO + 6 },              \
756   { "ccr7", FIRST_CCR_REGNO + 7 },              \
757   { "ccr8", FIRST_CCR_REGNO + 8 },              \
758   { "ccr9", FIRST_CCR_REGNO + 9 },              \
759   { "ccr10", FIRST_CCR_REGNO + 10 },            \
760   { "ccr11", FIRST_CCR_REGNO + 11 },            \
761   { "ccr12", FIRST_CCR_REGNO + 12 },            \
762   { "ccr13", FIRST_CCR_REGNO + 13 },            \
763   { "ccr14", FIRST_CCR_REGNO + 14 },            \
764   { "ccr15", FIRST_CCR_REGNO + 15 },            \
765   { "ccr16", FIRST_CCR_REGNO + 16 },            \
766   { "ccr17", FIRST_CCR_REGNO + 17 },            \
767   { "ccr18", FIRST_CCR_REGNO + 18 },            \
768   { "ccr19", FIRST_CCR_REGNO + 19 },            \
769   { "ccr20", FIRST_CCR_REGNO + 20 },            \
770   { "ccr21", FIRST_CCR_REGNO + 21 },            \
771   { "ccr22", FIRST_CCR_REGNO + 22 },            \
772   { "ccr23", FIRST_CCR_REGNO + 23 },            \
773   { "ccr24", FIRST_CCR_REGNO + 24 },            \
774   { "ccr25", FIRST_CCR_REGNO + 25 },            \
775   { "ccr26", FIRST_CCR_REGNO + 26 },            \
776   { "ccr27", FIRST_CCR_REGNO + 27 },            \
777   { "ccr28", FIRST_CCR_REGNO + 28 },            \
778   { "ccr29", FIRST_CCR_REGNO + 29 },            \
779   { "ccr30", FIRST_CCR_REGNO + 30 },            \
780   { "ccr31", FIRST_CCR_REGNO + 31 }             \
781 }
782
783 /* We watch for pipeline hazards with these */
784 #define ASM_OUTPUT_OPCODE(STREAM, PTR) mep_asm_output_opcode (STREAM, PTR)
785 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) mep_final_prescan_insn (INSN, OPVEC, NOPERANDS)
786
787 #define PRINT_OPERAND(STREAM, X, CODE) mep_print_operand (STREAM, X, CODE)
788
789 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '!' || (CODE) == '<')
790
791 #define PRINT_OPERAND_ADDRESS(STREAM, X) mep_print_operand_address (STREAM, X)
792
793 #define REGISTER_PREFIX    "$"
794 #define LOCAL_LABEL_PREFIX "."
795 #define USER_LABEL_PREFIX  ""
796 #define IMMEDIATE_PREFIX   ""
797
798 \f
799
800 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
801   fprintf (STREAM, "\t.word .L%d\n", VALUE)
802
803 \f
804
805 #undef  PREFERRED_DEBUGGING_TYPE
806 #define PREFERRED_DEBUGGING_TYPE  DWARF2_DEBUG
807 #define DWARF2_DEBUGGING_INFO     1
808 #define DWARF2_UNWIND_INFO        1
809
810 #define EH_RETURN_DATA_REGNO(N) ((N) < 2 ? (N) + 10 : INVALID_REGNUM)
811
812 #define EH_RETURN_STACKADJ_RTX mep_return_stackadj_rtx ()
813 #define EH_RETURN_HANDLER_RTX  mep_return_handler_rtx ()
814
815 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
816
817 \f
818
819 #define ASM_OUTPUT_ALIGN(STREAM, POWER) \
820   fprintf ((STREAM), "\t.p2align %d\n", (POWER))
821
822 \f
823
824 #define CASE_VECTOR_MODE SImode
825
826 #define WORD_REGISTER_OPERATIONS
827 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
828
829 #define SHORT_IMMEDIATES_SIGN_EXTEND
830
831 #define MOVE_MAX 4
832
833 #define SHIFT_COUNT_TRUNCATED 1
834
835 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
836
837 #define STORE_FLAG_VALUE 1
838
839 #define Pmode SImode
840
841 #define FUNCTION_MODE SImode
842
843 #define REGISTER_TARGET_PRAGMAS()        mep_register_pragmas ()
844
845 #define HANDLE_PRAGMA_PACK_PUSH_POP 1
846    
847 /* If defined, a C expression to determine the base term of address X.
848    This macro is used in only one place: `find_base_term' in alias.c.
849
850    It is always safe for this macro to not be defined.  It exists so
851    that alias analysis can understand machine-dependent addresses.
852
853    The typical use of this macro is to handle addresses containing
854    a label_ref or symbol_ref within an UNSPEC.  */
855 #define FIND_BASE_TERM(X) mep_find_base_term (X)