* ginclude/stdarg.h: Include va-mn10300.h.
[official-gcc.git] / gcc / config / mn10300 / mn10300.h
blobf70b6bf6a01faa286fff95d124c398d79f5766d9
1 /* Definitions of target machine for GNU compiler.
2 Matsushita MN10300 series
3 Copyright (C) 1996 Free Software Foundation, Inc.
4 Contributed by Jeff Law (law@cygnus.com).
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #include "svr4.h"
25 #undef ASM_SPEC
26 #undef ASM_FINAL_SPEC
27 #undef LIB_SPEC
28 #undef ENDFILE_SPEC
29 #undef LINK_SPEC
30 #undef STARTFILE_SPEC
32 /* Names to predefine in the preprocessor for this target machine. */
34 #define CPP_PREDEFINES "-D__mn10300__ -D__MN10300__"
36 /* Run-time compilation parameters selecting different hardware subsets. */
38 extern int target_flags;
40 /* Macros used in the machine description to test the flags. */
42 /* Macro to define tables used to set the flags.
43 This is a list in braces of pairs in braces,
44 each pair being { "NAME", VALUE }
45 where VALUE is the bits to set or minus the bits to clear.
46 An empty string NAME is used to identify the default VALUE. */
48 #define TARGET_SWITCHES \
49 {{ "", TARGET_DEFAULT}}
51 #ifndef TARGET_DEFAULT
52 #define TARGET_DEFAULT 0
53 #endif
55 /* Print subsidiary information on the compiler version in use. */
57 #define TARGET_VERSION fprintf (stderr, " (MN10300)");
60 /* Target machine storage layout */
62 /* Define this if most significant bit is lowest numbered
63 in instructions that operate on numbered bit-fields.
64 This is not true on the Matsushita MN1003. */
65 #define BITS_BIG_ENDIAN 0
67 /* Define this if most significant byte of a word is the lowest numbered. */
68 /* This is not true on the Matsushita MN10300. */
69 #define BYTES_BIG_ENDIAN 0
71 /* Define this if most significant word of a multiword number is lowest
72 numbered.
73 This is not true on the Matsushita MN10300. */
74 #define WORDS_BIG_ENDIAN 0
76 /* Number of bits in an addressable storage unit */
77 #define BITS_PER_UNIT 8
79 /* Width in bits of a "word", which is the contents of a machine register.
80 Note that this is not necessarily the width of data type `int';
81 if using 16-bit ints on a 68000, this would still be 32.
82 But on a machine with 16-bit registers, this would be 16. */
83 #define BITS_PER_WORD 32
85 /* Width of a word, in units (bytes). */
86 #define UNITS_PER_WORD 4
88 /* Width in bits of a pointer.
89 See also the macro `Pmode' defined below. */
90 #define POINTER_SIZE 32
92 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
93 #define PARM_BOUNDARY 32
95 /* The stack goes in 32 bit lumps. */
96 #define STACK_BOUNDARY 32
98 /* Allocation boundary (in *bits*) for the code of a function.
99 8 is the minimum boundary; it's unclear if bigger alignments
100 would improve performance. */
101 #define FUNCTION_BOUNDARY 8
103 /* No data type wants to be aligned rounder than this. */
104 #define BIGGEST_ALIGNMENT 32
106 /* Alignment of field after `int : 0' in a structure. */
107 #define EMPTY_FIELD_BOUNDARY 32
109 /* Define this if move instructions will actually fail to work
110 when given unaligned data. */
111 #define STRICT_ALIGNMENT 1
113 /* Define this as 1 if `char' should by default be signed; else as 0. */
114 #define DEFAULT_SIGNED_CHAR 0
116 /* Define results of standard character escape sequences. */
117 #define TARGET_BELL 007
118 #define TARGET_BS 010
119 #define TARGET_TAB 011
120 #define TARGET_NEWLINE 012
121 #define TARGET_VT 013
122 #define TARGET_FF 014
123 #define TARGET_CR 015
125 /* Standard register usage. */
127 /* Number of actual hardware registers.
128 The hardware registers are assigned numbers for the compiler
129 from 0 to just below FIRST_PSEUDO_REGISTER.
131 All registers that the compiler knows about must be given numbers,
132 even those that are not normally considered general registers. */
134 #define FIRST_PSEUDO_REGISTER 10
136 /* 1 for registers that have pervasive standard uses
137 and are not available for the register allocator. */
139 #define FIXED_REGISTERS \
140 { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}
142 /* 1 for registers not available across function calls.
143 These must include the FIXED_REGISTERS and also any
144 registers that can be used without being saved.
145 The latter must include the registers where values are returned
146 and the register where structure-value addresses are passed.
147 Aside from that, you can include as many other registers as you
148 like. */
150 #define CALL_USED_REGISTERS \
151 { 1, 1, 0, 0, 1, 1, 0, 0, 1, 1}
153 #define REG_ALLOC_ORDER \
154 { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9}
156 /* Return number of consecutive hard regs needed starting at reg REGNO
157 to hold something of mode MODE.
159 This is ordinarily the length in words of a value of mode MODE
160 but can be less for certain modes in special long registers. */
162 #define HARD_REGNO_NREGS(REGNO, MODE) \
163 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
165 /* Value is 1 if hard register REGNO can hold a value of machine-mode
166 MODE. */
168 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
169 (REGNO_REG_CLASS (REGNO) == DATA_REGS \
170 ? ((REGNO) & 1) == 0 || GET_MODE_SIZE (MODE) <= 4 \
171 : ((REGNO) & 1) == 0 || GET_MODE_SIZE (MODE) == 4)
173 /* Value is 1 if it is a good idea to tie two pseudo registers
174 when one has mode MODE1 and one has mode MODE2.
175 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
176 for any hard reg, then this must be 0 for correct output. */
177 #define MODES_TIEABLE_P(MODE1, MODE2) \
178 (MODE1 == MODE2 || GET_MODE_SIZE (MODE1) <= 4 && GET_MODE_SIZE (MODE2) <= 4)
180 /* 4 data, and effectively 3 address registers is small as far as I'm
181 concerned. */
182 #define SMALL_REGISTER_CLASSES 1
184 /* Define the classes of registers for register constraints in the
185 machine description. Also define ranges of constants.
187 One of the classes must always be named ALL_REGS and include all hard regs.
188 If there is more than one class, another class must be named NO_REGS
189 and contain no registers.
191 The name GENERAL_REGS must be the name of a class (or an alias for
192 another name such as ALL_REGS). This is the class of registers
193 that is allowed by "g" or "r" in a register constraint.
194 Also, registers outside this class are allocated only when
195 instructions express preferences for them.
197 The classes must be numbered in nondecreasing order; that is,
198 a larger-numbered class must never be contained completely
199 in a smaller-numbered class.
201 For any two classes, it is very desirable that there be another
202 class that represents their union. */
204 enum reg_class {
205 NO_REGS, DATA_REGS, ADDRESS_REGS, SP_REGS, DATA_OR_ADDRESS_REGS, SP_OR_ADDRESS_REGS, GENERAL_REGS, ALL_REGS, LIM_REG_CLASSES
208 #define N_REG_CLASSES (int) LIM_REG_CLASSES
210 /* Give names of register classes as strings for dump file. */
212 #define REG_CLASS_NAMES \
213 { "NO_REGS", "DATA_REGS", "ADDRESS_REGS", \
214 "SP_REGS", "DATA_OR_ADDRESS_REGS", "SP_OR_ADDRESS_REGS", \
215 "GENERAL_REGS", "ALL_REGS", "LIM_REGS" }
217 /* Define which registers fit in which classes.
218 This is an initializer for a vector of HARD_REG_SET
219 of length N_REG_CLASSES. */
221 #define REG_CLASS_CONTENTS \
222 { 0, /* No regs */ \
223 0x00f, /* DATA_REGS */ \
224 0x1f0, /* ADDRESS_REGS */ \
225 0x200, /* SP_REGS */ \
226 0x1ff, /* DATA_OR_ADDRESS_REGS */\
227 0x1f0, /* SP_OR_ADDRESS_REGS */\
228 0x1ff, /* GENERAL_REGS */ \
229 0x3ff, /* ALL_REGS */ \
232 /* The same information, inverted:
233 Return the class number of the smallest class containing
234 reg number REGNO. This could be a conditional expression
235 or could index an array. */
237 #define REGNO_REG_CLASS(REGNO) \
238 ((REGNO) < 4 ? DATA_REGS : \
239 (REGNO) < 9 ? ADDRESS_REGS : \
240 (REGNO) == 9 ? SP_REGS: 0)
242 /* The class value for index registers, and the one for base regs. */
244 #define INDEX_REG_CLASS DATA_REGS
245 #define BASE_REG_CLASS SP_OR_ADDRESS_REGS
247 /* Get reg_class from a letter such as appears in the machine description. */
249 #define REG_CLASS_FROM_LETTER(C) \
250 ((C) == 'd' ? DATA_REGS : \
251 (C) == 'a' ? ADDRESS_REGS : \
252 (C) == 'x' ? SP_REGS : NO_REGS)
254 /* Macros to check register numbers against specific register classes. */
256 /* These assume that REGNO is a hard or pseudo reg number.
257 They give nonzero only if REGNO is a hard reg of the suitable class
258 or a pseudo reg currently allocated to a suitable hard reg.
259 Since they use reg_renumber, they are safe only once reg_renumber
260 has been allocated, which happens in local-alloc.c. */
262 #define REGNO_OK_FOR_BASE_P(regno) \
263 (((regno) > 3 && regno < FIRST_PSEUDO_REGISTER) \
264 || (reg_renumber[regno] > 3 && reg_renumber[regno] < FIRST_PSEUDO_REGISTER))
266 #define REGNO_OK_FOR_INDEX_P(regno) \
267 (((regno) >= 0 && regno < 4) \
268 || (reg_renumber[regno] >= 0 && reg_renumber[regno] < 4))
271 /* Given an rtx X being reloaded into a reg required to be
272 in class CLASS, return the class of reg to actually use.
273 In general this is just CLASS; but on some machines
274 in some cases it is preferable to use a more restrictive class. */
276 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
277 (X == stack_pointer_rtx && CLASS != SP_REGS ? ADDRESS_REGS : CLASS)
279 #define PREFERRED_OUTPUT_RELOAD_CLASS(X,CLASS) \
280 (X == stack_pointer_rtx && CLASS != SP_REGS ? ADDRESS_REGS : CLASS)
282 #define LIMIT_RELOAD_CLASS(MODE, CLASS) \
283 ((MODE == QImode || MODE == HImode) ? DATA_REGS : CLASS)
285 #define SECONDARY_RELOAD_CLASS(CLASS,MODE,IN) \
286 secondary_reload_class(CLASS,MODE,IN)
288 /* Return the maximum number of consecutive registers
289 needed to represent mode MODE in a register of class CLASS. */
291 #define CLASS_MAX_NREGS(CLASS, MODE) \
292 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
294 /* The letters I, J, K, L, M, N, O, P in a register constraint string
295 can be used to stand for particular ranges of immediate operands.
296 This macro defines what the ranges are.
297 C is the letter, and VALUE is a constant value.
298 Return 1 if VALUE is in the range specified by C. */
300 #define INT_8_BITS(VALUE) ((unsigned) (VALUE) + 0x80 < 0x100)
301 #define INT_16_BITS(VALUE) ((unsigned) (VALUE) + 0x8000 < 0x10000)
303 #define CONST_OK_FOR_I(VALUE) ((VALUE) == 0)
304 #define CONST_OK_FOR_J(VALUE) ((VALUE) == 1)
305 #define CONST_OK_FOR_K(VALUE) ((VALUE) == 2)
306 #define CONST_OK_FOR_L(VALUE) ((VALUE) == 4)
307 #define CONST_OK_FOR_M(VALUE) ((VALUE) == 3)
308 #define CONST_OK_FOR_N(VALUE) ((VALUE) == 255 || (VALUE) == 65535)
310 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
311 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) : \
312 (C) == 'J' ? CONST_OK_FOR_J (VALUE) : \
313 (C) == 'K' ? CONST_OK_FOR_K (VALUE) : \
314 (C) == 'L' ? CONST_OK_FOR_L (VALUE) : \
315 (C) == 'M' ? CONST_OK_FOR_M (VALUE) : \
316 (C) == 'N' ? CONST_OK_FOR_N (VALUE) : 0)
319 /* Similar, but for floating constants, and defining letters G and H.
320 Here VALUE is the CONST_DOUBLE rtx itself.
322 `G' is a floating-point zero. */
324 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
325 ((C) == 'G' ? (GET_MODE_CLASS (GET_MODE (VALUE)) == MODE_FLOAT \
326 && (VALUE) == CONST0_RTX (GET_MODE (VALUE))) : 0)
329 /* Stack layout; function entry, exit and calling. */
331 /* Define this if pushing a word on the stack
332 makes the stack pointer a smaller address. */
334 #define STACK_GROWS_DOWNWARD
336 /* Define this if the nominal address of the stack frame
337 is at the high-address end of the local variables;
338 that is, each additional local variable allocated
339 goes at a more negative offset in the frame. */
341 #define FRAME_GROWS_DOWNWARD
343 /* Offset within stack frame to start allocating local variables at.
344 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
345 first local allocated. Otherwise, it is the offset to the BEGINNING
346 of the first local allocated. */
348 #define STARTING_FRAME_OFFSET 0
350 /* Offset of first parameter from the argument pointer register value. */
351 /* Is equal to the size of the saved fp + pc, even if an fp isn't
352 saved since the value is used before we know. */
354 #define FIRST_PARM_OFFSET(FNDECL) 4
356 /* Specify the registers used for certain standard purposes.
357 The values of these macros are register numbers. */
359 /* Register to use for pushing function arguments. */
360 #define STACK_POINTER_REGNUM 9
362 /* Base register for access to local variables of the function. */
363 #define FRAME_POINTER_REGNUM 7
365 /* Base register for access to arguments of the function. This
366 is a fake register and will be eliminated into either the frame
367 pointer or stack pointer. */
368 #define ARG_POINTER_REGNUM 8
370 /* Register in which static-chain is passed to a function. */
371 #define STATIC_CHAIN_REGNUM 5
373 /* Value should be nonzero if functions must have frame pointers.
374 Zero means the frame pointer need not be set up (and parms
375 may be accessed via the stack pointer) in functions that seem suitable.
376 This is computed in `reload', in reload1.c.
378 We allow frame pointers to be eliminated when not having one will
379 not interfere with debugging.
381 * If this is a leaf function, then we can keep the stack pointer
382 constant throughout the function, and therefore gdb can easily
383 find the base of the current frame.
385 * If this function never allocates stack space for outgoing
386 args (ie calls functions with either no args, or args only
387 in registers), then the stack pointer will be constant and
388 gdb can easily find the base of the current frame.
390 We'd really like to define ACCUMULATE_OUTGOING_ARGS and eliminate
391 all frame pointer, but currently we can't.
393 We probably also want a -m option to eliminate frame pointer, even
394 if the resulting executable can not be debugged. */
396 #define ELIMINABLE_REGS \
397 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
398 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
399 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
401 #define CAN_ELIMINATE(FROM, TO) 1
403 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
404 OFFSET = initial_offset (FROM, TO)
406 #define FRAME_POINTER_REQUIRED \
407 !(leaf_function_p ())
409 #define CAN_DEBUG_WITHOUT_FP
411 /* A guess for the MN10300. */
412 #define PROMOTE_PROTOTYPES 1
414 /* Value is the number of bytes of arguments automatically
415 popped when returning from a subroutine call.
416 FUNDECL is the declaration node of the function (as a tree),
417 FUNTYPE is the data type of the function (as a tree),
418 or for a library call it is an identifier node for the subroutine name.
419 SIZE is the number of bytes of arguments passed on the stack. */
421 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
423 /* We use d0/d1 for passing parameters, so allocate 8 bytes of space
424 for a register flushback area. */
425 #define REG_PARM_STACK_SPACE(DECL) 8
426 #define OUTGOING_REG_PARM_STACK_SPACE
428 /* 1 if N is a possible register number for function argument passing.
429 On the MN10300, no registers are used in this way. */
431 #define FUNCTION_ARG_REGNO_P(N) ((N) <= 1)
434 /* Define a data type for recording info about an argument list
435 during the scan of that argument list. This data type should
436 hold all necessary information about the function itself
437 and about the args processed so far, enough to enable macros
438 such as FUNCTION_ARG to determine where the next arg should go.
440 On the MN10300, this is a single integer, which is a number of bytes
441 of arguments scanned so far. */
443 #define CUMULATIVE_ARGS struct cum_arg
444 struct cum_arg {int nbytes; };
446 /* Initialize a variable CUM of type CUMULATIVE_ARGS
447 for a call to a function whose data type is FNTYPE.
448 For a library call, FNTYPE is 0.
450 On the MN10300, the offset starts at 0. */
452 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
453 ((CUM).nbytes = 0)
455 /* Update the data in CUM to advance over an argument
456 of mode MODE and data type TYPE.
457 (TYPE is null for libcalls where that information may not be available.) */
459 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
460 ((CUM).nbytes += ((MODE) != BLKmode \
461 ? (GET_MODE_SIZE (MODE) + 3) & ~3 \
462 : (int_size_in_bytes (TYPE) + 3) & ~3))
464 /* Define where to put the arguments to a function.
465 Value is zero to push the argument on the stack,
466 or a hard register in which to store the argument.
468 MODE is the argument's machine mode.
469 TYPE is the data type of the argument (as a tree).
470 This is null for libcalls where that information may
471 not be available.
472 CUM is a variable of type CUMULATIVE_ARGS which gives info about
473 the preceding args and about the function being called.
474 NAMED is nonzero if this argument is a named parameter
475 (otherwise it is an extra parameter matching an ellipsis). */
477 /* On the MN10300 all args are pushed. */
479 extern struct rtx_def *function_arg ();
480 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
481 function_arg (&CUM, MODE, TYPE, NAMED)
483 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
484 function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED)
487 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
488 ((TYPE) && int_size_in_bytes (TYPE) > 8)
490 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \
491 ((TYPE) && int_size_in_bytes (TYPE) > 8)
493 /* Define how to find the value returned by a function.
494 VALTYPE is the data type of the value (as a tree).
495 If the precise function being called is known, FUNC is its FUNCTION_DECL;
496 otherwise, FUNC is 0. */
498 #define FUNCTION_VALUE(VALTYPE, FUNC) gen_rtx (REG, TYPE_MODE (VALTYPE), 0)
500 /* Define how to find the value returned by a library function
501 assuming the value has mode MODE. */
503 #define LIBCALL_VALUE(MODE) gen_rtx (REG, MODE, 0)
505 /* 1 if N is a possible register number for a function value. */
507 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
509 /* Return values > 8 bytes in length in memory. */
510 #define DEFAULT_PCC_STRUCT_RETURN 0
511 #define RETURN_IN_MEMORY(TYPE) \
512 (int_size_in_bytes (TYPE) > 8 || TYPE_MODE (TYPE) == BLKmode)
514 /* Register in which address to store a structure value
515 is passed to a function. On the MN10300 it's passed as
516 the first parameter. */
518 #define STRUCT_VALUE 0
520 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
521 the stack pointer does not matter. The value is tested only in
522 functions that have frame pointers.
523 No definition is equivalent to always zero. */
525 #define EXIT_IGNORE_STACK 1
527 /* Output assembler code to FILE to increment profiler label # LABELNO
528 for profiling a function entry. */
530 #define FUNCTION_PROFILER(FILE, LABELNO) ;
532 #define TRAMPOLINE_TEMPLATE(FILE) \
533 do { \
534 fprintf (FILE, "\tadd -4,sp\n"); \
535 fprintf (FILE, "\t.long 0x0004fffa\n"); \
536 fprintf (FILE, "\tmov (0,sp),a0\n"); \
537 fprintf (FILE, "\tadd 4,sp\n"); \
538 fprintf (FILE, "\tmov (13,a0),a1\n"); \
539 fprintf (FILE, "\tmov (17,a0),a0\n"); \
540 fprintf (FILE, "\tjmp (a0)\n"); \
541 fprintf (FILE, "\t.long 0\n"); \
542 fprintf (FILE, "\t.long 0\n"); \
543 } while (0)
545 /* Length in units of the trampoline for entering a nested function. */
547 #define TRAMPOLINE_SIZE 0x1b
549 #define TRAMPOLINE_ALIGNMENT 32
551 /* Emit RTL insns to initialize the variable parts of a trampoline.
552 FNADDR is an RTX for the address of the function's pure code.
553 CXT is an RTX for the static chain value for the function. */
555 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
557 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 0x14)), \
558 (CXT)); \
559 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 0x18)), \
560 (FNADDR)); \
562 /* Emit code for a call to builtin_saveregs. We must emit USE insns which
563 reference the 2 integer arg registers.
564 Ordinarily they are not call used registers, but they are for
565 _builtin_saveregs, so we must make this explicit. */
567 extern struct rtx_def *mn10300_builtin_saveregs ();
568 #define EXPAND_BUILTIN_SAVEREGS(ARGLIST) mn10300_builtin_saveregs (ARGLIST)
570 /* Addressing modes, and classification of registers for them. */
573 /* 1 if X is an rtx for a constant that is a valid address. */
575 #define CONSTANT_ADDRESS_P(X) CONSTANT_P (X)
577 /* Extra constraints. */
579 #define OK_FOR_R(OP) \
580 (GET_CODE (OP) == MEM \
581 && GET_MODE (OP) == QImode \
582 && (CONSTANT_ADDRESS_P (XEXP (OP, 0)) \
583 || (GET_CODE (XEXP (OP, 0)) == REG \
584 && REG_OK_FOR_BASE_P (XEXP (OP, 0)) \
585 && XEXP (OP, 0) != stack_pointer_rtx) \
586 || (GET_CODE (XEXP (OP, 0)) == PLUS \
587 && GET_CODE (XEXP (XEXP (OP, 0), 0)) == REG \
588 && REG_OK_FOR_BASE_P (XEXP (XEXP (OP, 0), 0)) \
589 && XEXP (XEXP (OP, 0), 0) != stack_pointer_rtx \
590 && GET_CODE (XEXP (XEXP (OP, 0), 1)) == CONST_INT \
591 && INT_8_BITS (INTVAL (XEXP (XEXP (OP, 0), 1))))))
593 #define EXTRA_CONSTRAINT(OP, C) \
594 ((C) == 'R' ? OK_FOR_R (OP) : (C) == 'S' ? GET_CODE (OP) == SYMBOL_REF : 0)
596 /* Maximum number of registers that can appear in a valid memory address. */
598 #define MAX_REGS_PER_ADDRESS 2
600 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
601 and check its validity for a certain class.
602 We have two alternate definitions for each of them.
603 The usual definition accepts all pseudo regs; the other rejects
604 them unless they have been allocated suitable hard regs.
605 The symbol REG_OK_STRICT causes the latter definition to be used.
607 Most source files want to accept pseudo regs in the hope that
608 they will get allocated to the class that the insn wants them to be in.
609 Source files for reload pass need to be strict.
610 After reload, it makes no difference, since pseudo regs have
611 been eliminated by then. */
613 #ifndef REG_OK_STRICT
614 /* Nonzero if X is a hard reg that can be used as an index
615 or if it is a pseudo reg. */
616 #define REG_OK_FOR_INDEX_P(X) \
617 ((REGNO (X) >= 0 && REGNO(X) <= 3) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
618 /* Nonzero if X is a hard reg that can be used as a base reg
619 or if it is a pseudo reg. */
620 #define REG_OK_FOR_BASE_P(X) \
621 ((REGNO (X) >= 4 && REGNO(X) <= 9) || REGNO (X) >= FIRST_PSEUDO_REGISTER)
622 #else
623 /* Nonzero if X is a hard reg that can be used as an index. */
624 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
625 /* Nonzero if X is a hard reg that can be used as a base reg. */
626 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
627 #endif
630 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
631 that is a valid memory address for an instruction.
632 The MODE argument is the machine mode for the MEM expression
633 that wants to use this address.
635 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
636 except for CONSTANT_ADDRESS_P which is actually
637 machine-independent. */
639 /* Accept either REG or SUBREG where a register is valid. */
641 #define RTX_OK_FOR_BASE_P(X) \
642 ((REG_P (X) && REG_OK_FOR_BASE_P (X)) \
643 || (GET_CODE (X) == SUBREG && REG_P (SUBREG_REG (X)) \
644 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
646 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
648 if (CONSTANT_ADDRESS_P (X)) \
649 goto ADDR; \
650 if (RTX_OK_FOR_BASE_P (X)) \
651 goto ADDR; \
652 if (GET_CODE (X) == PLUS) \
654 rtx base = 0, index = 0; \
655 if (REG_P (XEXP (X, 0)) \
656 && REG_OK_FOR_BASE_P (XEXP (X, 0))) \
657 base = XEXP (X, 0), index = XEXP (X, 1); \
658 if (REG_P (XEXP (X, 1)) \
659 && REG_OK_FOR_BASE_P (XEXP (X, 1))) \
660 base = XEXP (X, 1), index = XEXP (X, 0); \
661 if (base != 0 && index != 0) \
663 if (CONSTANT_ADDRESS_P (index)) \
664 goto ADDR; \
665 if (REG_P (index) \
666 && REG_OK_FOR_INDEX_P (index) \
667 && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (word_mode)) \
668 goto ADDR; \
674 /* Try machine-dependent ways of modifying an illegitimate address
675 to be legitimate. If we find one, return the new, valid address.
676 This macro is used in only one place: `memory_address' in explow.c.
678 OLDX is the address as it was before break_out_memory_refs was called.
679 In some cases it is useful to look at this to decide what needs to be done.
681 MODE and WIN are passed so that this macro can use
682 GO_IF_LEGITIMATE_ADDRESS.
684 It is always safe for this macro to do nothing. It exists to recognize
685 opportunities to optimize the output. */
687 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) {}
689 /* Go to LABEL if ADDR (a legitimate address expression)
690 has an effect that depends on the machine mode it is used for. */
692 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) {}
694 /* Nonzero if the constant value X is a legitimate general operand.
695 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
697 #define LEGITIMATE_CONSTANT_P(X) 1
700 /* Tell final.c how to eliminate redundant test instructions. */
702 /* Here we define machine-dependent flags and fields in cc_status
703 (see `conditions.h'). No extra ones are needed for the vax. */
705 /* Store in cc_status the expressions
706 that the condition codes will describe
707 after execution of an instruction whose pattern is EXP.
708 Do not alter them if the instruction would not alter the cc's. */
710 #define CC_OVERFLOW_UNUSABLE 0x200
711 #define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc(EXP, INSN)
713 /* Compute the cost of computing a constant rtl expression RTX
714 whose rtx-code is CODE. The body of this macro is a portion
715 of a switch statement. If the code is computed here,
716 return it with a return statement. Otherwise, break from the switch. */
718 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
719 case CONST_INT: \
720 /* Zeros are extremely cheap. */ \
721 if (INTVAL (RTX) == 0 && OUTER_CODE == SET) \
722 return 0; \
723 /* If it fits in 8 bits, then it's still relatively cheap. */ \
724 if (INT_8_BITS (INTVAL (RTX))) \
725 return 1; \
726 /* This is the "base" cost, includes constants where either the \
727 upper or lower 16bits are all zeros. */ \
728 if (INT_16_BITS (INTVAL (RTX)) \
729 || (INTVAL (RTX) & 0xffff) == 0 \
730 || (INTVAL (RTX) & 0xffff0000) == 0) \
731 return 2; \
732 return 4; \
733 /* These are more costly than a CONST_INT, but we can relax them, \
734 so they're less costly than a CONST_DOUBLE. */ \
735 case CONST: \
736 case LABEL_REF: \
737 case SYMBOL_REF: \
738 return 6; \
739 /* We don't optimize CONST_DOUBLEs well nor do we relax them well, \
740 so their cost is very high. */ \
741 case CONST_DOUBLE: \
742 return 8;
745 #define REGISTER_MOVE_COST(CLASS1, CLASS2) (CLASS1 != CLASS2 ? 4 : 0)
747 /* A crude cut at RTX_COSTS for the MN10300. */
749 /* Provide the costs of a rtl expression. This is in the body of a
750 switch on CODE. */
751 #define RTX_COSTS(RTX,CODE,OUTER_CODE) \
752 case MOD: \
753 case DIV: \
754 return 8; \
755 case MULT: \
756 return 8;
758 /* Nonzero if access to memory by bytes or half words is no faster
759 than accessing full words. */
760 #define SLOW_BYTE_ACCESS 1
762 /* Dispatch tables on the mn10300 are extremely expensive in terms of code
763 and readonly data size. So we crank up the case threshold value to
764 encourage a series of if/else comparisons to implement many small switch
765 statements. In theory, this value could be increased much more if we
766 were solely optimizing for space, but we keep it "reasonable" to avoid
767 serious code efficiency lossage. */
768 #define CASE_VALUES_THRESHOLD 6
770 #define NO_FUNCTION_CSE
772 /* According expr.c, a value of around 6 should minimize code size, and
773 for the MN10300 series, that's our primary concern. */
774 #define MOVE_RATIO 6
776 #define TEXT_SECTION_ASM_OP "\t.section .text"
777 #define DATA_SECTION_ASM_OP "\t.section .data"
778 #define BSS_SECTION_ASM_OP "\t.section .bss"
780 /* Output at beginning/end of assembler file. */
781 #undef ASM_FILE_START
782 #define ASM_FILE_START(FILE) asm_file_start(FILE)
784 #define ASM_COMMENT_START "#"
786 /* Output to assembler file text saying following lines
787 may contain character constants, extra white space, comments, etc. */
789 #define ASM_APP_ON "#APP\n"
791 /* Output to assembler file text saying following lines
792 no longer contain unusual constructs. */
794 #define ASM_APP_OFF "#NO_APP\n"
796 /* This is how to output an assembler line defining a `double' constant.
797 It is .dfloat or .gfloat, depending. */
799 #define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
800 do { char dstr[30]; \
801 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
802 fprintf (FILE, "\t.double %s\n", dstr); \
803 } while (0)
806 /* This is how to output an assembler line defining a `float' constant. */
807 #define ASM_OUTPUT_FLOAT(FILE, VALUE) \
808 do { char dstr[30]; \
809 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
810 fprintf (FILE, "\t.float %s\n", dstr); \
811 } while (0)
813 /* This is how to output an assembler line defining an `int' constant. */
815 #define ASM_OUTPUT_INT(FILE, VALUE) \
816 ( fprintf (FILE, "\t.long "), \
817 output_addr_const (FILE, (VALUE)), \
818 fprintf (FILE, "\n"))
820 /* Likewise for `char' and `short' constants. */
822 #define ASM_OUTPUT_SHORT(FILE, VALUE) \
823 ( fprintf (FILE, "\t.hword "), \
824 output_addr_const (FILE, (VALUE)), \
825 fprintf (FILE, "\n"))
827 #define ASM_OUTPUT_CHAR(FILE, VALUE) \
828 ( fprintf (FILE, "\t.byte "), \
829 output_addr_const (FILE, (VALUE)), \
830 fprintf (FILE, "\n"))
832 /* This is how to output an assembler line for a numeric constant byte. */
833 #define ASM_OUTPUT_BYTE(FILE, VALUE) \
834 fprintf (FILE, "\t.byte 0x%x\n", (VALUE))
836 /* Define the parentheses used to group arithmetic operations
837 in assembler code. */
839 #define ASM_OPEN_PAREN "("
840 #define ASM_CLOSE_PAREN ")"
842 /* This says how to output the assembler to define a global
843 uninitialized but not common symbol.
844 Try to use asm_output_bss to implement this macro. */
846 #define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED) \
847 asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED))
849 /* This is how to output the definition of a user-level label named NAME,
850 such as the label on a static function or variable NAME. */
852 #define ASM_OUTPUT_LABEL(FILE, NAME) \
853 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
855 /* This is how to output a command to make the user-level label named NAME
856 defined for reference from other files. */
858 #define ASM_GLOBALIZE_LABEL(FILE, NAME) \
859 do { fputs ("\t.global ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
861 /* This is how to output a reference to a user-level label named NAME.
862 `assemble_name' uses this. */
864 #undef ASM_OUTPUT_LABELREF
865 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
866 do { \
867 char* real_name; \
868 STRIP_NAME_ENCODING (real_name, (NAME)); \
869 fprintf (FILE, "_%s", real_name); \
870 } while (0)
872 /* Store in OUTPUT a string (made with alloca) containing
873 an assembler-name for a local static variable named NAME.
874 LABELNO is an integer which is different for each call. */
876 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
877 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
878 sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO)))
880 /* This is how we tell the assembler that two symbols have the same value. */
882 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
883 do { assemble_name(FILE, NAME1); \
884 fputs(" = ", FILE); \
885 assemble_name(FILE, NAME2); \
886 fputc('\n', FILE); } while (0)
889 /* How to refer to registers in assembler output.
890 This sequence is indexed by compiler's hard-register-number (see above). */
892 #define REGISTER_NAMES \
893 { "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3", "ap", "sp" }
895 /* Print an instruction operand X on file FILE.
896 look in mn10300.c for details */
898 #define PRINT_OPERAND(FILE, X, CODE) print_operand(FILE,X,CODE)
900 /* Print a memory operand whose address is X, on file FILE.
901 This uses a function in output-vax.c. */
903 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
905 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO)
906 #define ASM_OUTPUT_REG_POP(FILE,REGNO)
908 /* This is how to output an element of a case-vector that is absolute. */
910 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
911 asm_fprintf (FILE, "\t%s .L%d\n", ".long", VALUE)
913 /* This is how to output an element of a case-vector that is relative. */
915 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
916 fprintf (FILE, "\t%s .L%d-.L%d\n", ".long", VALUE, REL)
918 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
919 if ((LOG) != 0) \
920 fprintf (FILE, "\t.align %d\n", (LOG))
922 /* We don't have to worry about dbx compatability for the mn10300. */
923 #define DEFAULT_GDB_EXTENSIONS 1
925 /* Use stabs debugging info by default. */
926 #undef PREFERRED_DEBUGGING_TYPE
927 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
929 #define DBX_REGISTER_NUMBER(REGNO) REGNO
931 /* Define to use software floating point emulator for REAL_ARITHMETIC and
932 decimal <-> binary conversion. */
933 #define REAL_ARITHMETIC
935 /* Specify the machine mode that this machine uses
936 for the index in the tablejump instruction. */
937 #define CASE_VECTOR_MODE Pmode
939 /* Define this if the case instruction drops through after the table
940 when the index is out of range. Don't define it if the case insn
941 jumps to the default label instead. */
942 #define CASE_DROPS_THROUGH
944 /* Define if operations between registers always perform the operation
945 on the full register even if a narrower mode is specified. */
946 #define WORD_REGISTER_OPERATIONS
948 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
950 /* Specify the tree operation to be used to convert reals to integers. */
951 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
953 /* This flag, if defined, says the same insns that convert to a signed fixnum
954 also convert validly to an unsigned one. */
955 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
957 /* This is the kind of divide that is easiest to do in the general case. */
958 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
960 /* Max number of bytes we can move from memory to memory
961 in one reasonably fast instruction. */
962 #define MOVE_MAX 4
964 /* Define if shifts truncate the shift count
965 which implies one can omit a sign-extension or zero-extension
966 of a shift count. */
967 #define SHIFT_COUNT_TRUNCATED 1
969 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
970 is done just by pretending it is already truncated. */
971 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
973 #define STORE_FLAG_VALUE 1
975 /* Specify the machine mode that pointers have.
976 After generation of rtl, the compiler makes no further distinction
977 between pointers and any other objects of this machine mode. */
978 #define Pmode SImode
980 /* A function address in a call instruction
981 is a byte address (for indexing purposes)
982 so give the MEM rtx a byte's mode. */
983 #define FUNCTION_MODE QImode
985 /* The assembler op to get a word. */
987 #define FILE_ASM_OP "\t.file\n"
989 extern void asm_file_start ();
990 extern int const_costs ();
991 extern void print_operand ();
992 extern void print_operand_address ();
993 extern void expand_prologue ();
994 extern void expand_epilogue ();
995 extern void notice_update_cc ();
996 extern int call_address_operand ();
997 extern enum reg_class secondary_reload_class ();
998 extern int initial_offset ();
999 extern char *output_tst ();