1 /* Definitions of target machine for GNU compiler. Matsushita MN10200 series
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 Contributed by Jeff Law (law@cygnus.com).
5 This file is part of GNU CC.
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)
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.
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. */
24 /* Get rid of svr4.h stuff we don't want/need. */
32 /* Names to predefine in the preprocessor for this target machine. */
34 #define CPP_PREDEFINES "-D__mn10200__ -D__MN10200__ -D__LONG_MAX__=2147483647L -D__LONG_LONG_MAX__=2147483647L -D__INT_MAX__=32767"
36 /* Run-time compilation parameters selecting different hardware subsets. */
38 /* We don't have any switched on the mn10200. Though there are some things
39 that might be worth a switch:
41 -mspace to optimize even more for space.
43 -mrelax to enable the relaxing linker. */
45 extern int target_flags
;
47 /* Macros used in the machine description to test the flags. */
49 /* Macro to define tables used to set the flags.
50 This is a list in braces of pairs in braces,
51 each pair being { "NAME", VALUE }
52 where VALUE is the bits to set or minus the bits to clear.
53 An empty string NAME is used to identify the default VALUE. */
55 #define TARGET_SWITCHES \
56 {{ "", TARGET_DEFAULT}}
58 #ifndef TARGET_DEFAULT
59 #define TARGET_DEFAULT 0
62 /* Print subsidiary information on the compiler version in use. */
64 #define TARGET_VERSION fprintf (stderr, " (MN10200)");
67 /* Target machine storage layout */
69 /* Define this if most significant bit is lowest numbered
70 in instructions that operate on numbered bit-fields.
71 This is not true on the Matsushita MN10300. */
72 #define BITS_BIG_ENDIAN 0
74 /* Define this if most significant byte of a word is the lowest numbered. */
75 /* This is not true on the Matsushita MN10200. */
76 #define BYTES_BIG_ENDIAN 0
78 /* Define this if most significant word of a multiword number is lowest
80 This is not true on the Matsushita MN10200. */
81 #define WORDS_BIG_ENDIAN 0
83 /* Number of bits in an addressable storage unit */
84 #define BITS_PER_UNIT 8
86 /* Width in bits of a "word", which is the contents of a machine register.
87 Note that this is not necessarily the width of data type `int';
88 if using 16-bit ints on a 68000, this would still be 32.
89 But on a machine with 16-bit registers, this would be 16.
91 This is a white lie. Registers are really 24bits, but most operations
92 only operate on 16 bits. GCC chokes badly if we set this to a value
93 that is not a power of two. */
94 #define BITS_PER_WORD 16
96 /* Width of a word, in units (bytes). */
97 #define UNITS_PER_WORD 2
99 /* Width in bits of a pointer.
100 See also the macro `Pmode' defined below.
102 This differs from Pmode because we need to allocate 32bits of space
103 to hold the 24bit pointers on this machine. */
104 #define POINTER_SIZE 32
106 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
107 #define PARM_BOUNDARY 16
109 /* The stack goes in 16 bit lumps. */
110 #define STACK_BOUNDARY 16
112 /* Allocation boundary (in *bits*) for the code of a function.
113 8 is the minimum boundary; it's unclear if bigger alignments
114 would improve performance. */
115 #define FUNCTION_BOUNDARY 8
117 /* No data type wants to be aligned rounder than this. */
118 #define BIGGEST_ALIGNMENT 16
120 /* Alignment of field after `int : 0' in a structure. */
121 #define EMPTY_FIELD_BOUNDARY 16
123 /* Seems to be how the Matsushita compiler does things, and there's
124 no real reason to be different. */
125 #define STRUCTURE_SIZE_BOUNDARY 16
126 #undef PCC_BITFIELD_TYPE_MATTERS
128 /* Define this if move instructions will actually fail to work
129 when given unaligned data. */
130 #define STRICT_ALIGNMENT 1
132 /* Define this as 1 if `char' should by default be signed; else as 0. */
133 #define DEFAULT_SIGNED_CHAR 0
135 /* Define results of standard character escape sequences. */
136 #define TARGET_BELL 007
137 #define TARGET_BS 010
138 #define TARGET_TAB 011
139 #define TARGET_NEWLINE 012
140 #define TARGET_VT 013
141 #define TARGET_FF 014
142 #define TARGET_CR 015
144 /* Standard register usage. */
146 /* Number of actual hardware registers.
147 The hardware registers are assigned numbers for the compiler
148 from 0 to just below FIRST_PSEUDO_REGISTER.
150 All registers that the compiler knows about must be given numbers,
151 even those that are not normally considered general registers.
153 XXX Long term we should probably expose the MDR register, we use
154 it for division, multiplication, and some extension operations. */
156 #define FIRST_PSEUDO_REGISTER 8
158 /* 1 for registers that have pervasive standard uses
159 and are not available for the register allocator. */
161 #define FIXED_REGISTERS \
162 { 0, 0, 0, 0, 0, 0, 0, 1}
164 /* 1 for registers not available across function calls.
165 These must include the FIXED_REGISTERS and also any
166 registers that can be used without being saved.
167 The latter must include the registers where values are returned
168 and the register where structure-value addresses are passed.
169 Aside from that, you can include as many other registers as you
172 #define CALL_USED_REGISTERS \
173 { 1, 1, 0, 0, 1, 0, 0, 1}
175 #define REG_ALLOC_ORDER \
176 { 0, 1, 4, 2, 3, 5, 6, 7}
178 /* Return number of consecutive hard regs needed starting at reg REGNO
179 to hold something of mode MODE.
181 This is ordinarily the length in words of a value of mode MODE
182 but can be less for certain modes in special long registers. */
184 #define HARD_REGNO_NREGS(REGNO, MODE) \
185 ((MODE) == PSImode ? 1 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
188 /* Value is 1 if hard register REGNO can hold a value of machine-mode
191 We allow any register to hold a PSImode value. We allow any register
192 to hold values <= 16 bits. For values > 16 bits we require aligned
194 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
195 ((MODE) == PSImode ? 1 : ((REGNO) & 1) == 0 || GET_MODE_SIZE (MODE) <= 2)
197 /* Value is 1 if it is a good idea to tie two pseudo registers
198 when one has mode MODE1 and one has mode MODE2.
199 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
200 for any hard reg, then this must be 0 for correct output. */
201 #define MODES_TIEABLE_P(MODE1, MODE2) \
202 (MODE1 == MODE2 || (GET_MODE_SIZE (MODE1) <= 2 && GET_MODE_SIZE (MODE2) <= 2))
204 /* 4 data, and effectively 2 address registers is small as far as I'm
205 concerned. Especially since we use 2 data registers for argument
206 passing and return values.
208 We used to define CLASS_LIKELY_SPILLED_P as true for DATA_REGS too,
209 but we've made improvements to the port which greatly reduce register
210 pressure. As a result we no longer need to define CLASS_LIKELY_SPILLED_P
211 for DATA_REGS (and by not defining it we get significantly better code). */
212 #define SMALL_REGISTER_CLASSES 1
213 #define CLASS_LIKELY_SPILLED_P(CLASS) (CLASS == ADDRESS_REGS)
215 /* Define the classes of registers for register constraints in the
216 machine description. Also define ranges of constants.
218 One of the classes must always be named ALL_REGS and include all hard regs.
219 If there is more than one class, another class must be named NO_REGS
220 and contain no registers.
222 The name GENERAL_REGS must be the name of a class (or an alias for
223 another name such as ALL_REGS). This is the class of registers
224 that is allowed by "g" or "r" in a register constraint.
225 Also, registers outside this class are allocated only when
226 instructions express preferences for them.
228 The classes must be numbered in nondecreasing order; that is,
229 a larger-numbered class must never be contained completely
230 in a smaller-numbered class.
232 For any two classes, it is very desirable that there be another
233 class that represents their union. */
236 NO_REGS
, DATA_REGS
, ADDRESS_REGS
, GENERAL_REGS
, ALL_REGS
, LIM_REG_CLASSES
239 #define N_REG_CLASSES (int) LIM_REG_CLASSES
241 /* Give names of register classes as strings for dump file. */
243 #define REG_CLASS_NAMES \
244 { "NO_REGS", "DATA_REGS", "ADDRESS_REGS", \
245 "GENERAL_REGS", "ALL_REGS", "LIM_REGS" }
247 /* Define which registers fit in which classes.
248 This is an initializer for a vector of HARD_REG_SET
249 of length N_REG_CLASSES. */
251 #define REG_CLASS_CONTENTS \
253 0x0f, /* DATA_REGS */ \
254 0xf0, /* ADDRESS_REGS */ \
255 0xff, /* GENERAL_REGS */ \
256 0xff, /* ALL_REGS */ \
259 /* The same information, inverted:
260 Return the class number of the smallest class containing
261 reg number REGNO. This could be a conditional expression
262 or could index an array. */
264 #define REGNO_REG_CLASS(REGNO) \
265 ((REGNO) < 4 ? DATA_REGS : ADDRESS_REGS)
267 /* The class value for index registers, and the one for base regs. */
269 #define INDEX_REG_CLASS DATA_REGS
270 #define BASE_REG_CLASS ADDRESS_REGS
272 /* Get reg_class from a letter such as appears in the machine description. */
274 #define REG_CLASS_FROM_LETTER(C) \
275 ((C) == 'd' ? DATA_REGS : \
276 (C) == 'a' ? ADDRESS_REGS : NO_REGS)
278 /* Macros to check register numbers against specific register classes. */
280 /* These assume that REGNO is a hard or pseudo reg number.
281 They give nonzero only if REGNO is a hard reg of the suitable class
282 or a pseudo reg currently allocated to a suitable hard reg.
283 Since they use reg_renumber, they are safe only once reg_renumber
284 has been allocated, which happens in local-alloc.c. */
286 #define REGNO_OK_FOR_BASE_P(regno) \
287 (((regno) > 3 && regno < FIRST_PSEUDO_REGISTER) \
288 || (reg_renumber[regno] > 3 && reg_renumber[regno] < FIRST_PSEUDO_REGISTER))
290 #define REGNO_OK_FOR_INDEX_P(regno) \
291 (((regno) >= 0 && regno < 4) \
292 || (reg_renumber[regno] >= 0 && reg_renumber[regno] < 4))
295 /* Given an rtx X being reloaded into a reg required to be
296 in class CLASS, return the class of reg to actually use.
297 In general this is just CLASS; but on some machines
298 in some cases it is preferable to use a more restrictive class. */
300 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
301 ((GET_MODE (X) != PSImode) ? DATA_REGS : CLASS)
303 /* We want to use DATA_REGS for anything that is not PSImode. */
304 #define LIMIT_RELOAD_CLASS(MODE, CLASS) \
305 ((MODE != PSImode) ? DATA_REGS : CLASS)
307 /* We have/need secondary reloads on the mn10200. Mostly to deal
308 with problems using address registers. */
309 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,IN) \
310 secondary_reload_class(CLASS,MODE,IN, 1)
312 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,IN) \
313 secondary_reload_class(CLASS,MODE,IN, 0)
315 /* Return the maximum number of consecutive registers
316 needed to represent mode MODE in a register of class CLASS. */
318 #define CLASS_MAX_NREGS(CLASS, MODE) \
319 ((MODE) == PSImode ? 1 : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
321 /* The letters I, J, K, L, M, N, O, P in a register constraint string
322 can be used to stand for particular ranges of immediate operands.
323 This macro defines what the ranges are.
324 C is the letter, and VALUE is a constant value.
325 Return 1 if VALUE is in the range specified by C. */
327 #define INT_8_BITS(VALUE) ((unsigned) (VALUE) + 0x80 < 0x100)
328 #define INT_16_BITS(VALUE) ((unsigned) (VALUE) + 0x8000 < 0x10000)
330 #define CONST_OK_FOR_I(VALUE) ((VALUE) == 0)
331 #define CONST_OK_FOR_J(VALUE) ((VALUE) >= 1 && (VALUE) <= 3)
332 #define CONST_OK_FOR_K(VALUE) ((VALUE) >= 1 && (VALUE) <= 4)
333 #define CONST_OK_FOR_L(VALUE) ((VALUE) == 15)
334 #define CONST_OK_FOR_M(VALUE) ((VALUE) == 255)
336 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
337 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) : \
338 (C) == 'J' ? CONST_OK_FOR_J (VALUE) : \
339 (C) == 'K' ? CONST_OK_FOR_K (VALUE) : \
340 (C) == 'L' ? CONST_OK_FOR_L (VALUE) : \
341 (C) == 'M' ? CONST_OK_FOR_M (VALUE) : 0)
343 /* Similar, but for floating constants, and defining letters G and H.
344 Here VALUE is the CONST_DOUBLE rtx itself.
346 `G' is a floating-point zero. */
348 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
349 ((C) == 'G' ? (GET_MODE_CLASS (GET_MODE (VALUE)) == MODE_FLOAT \
350 && (VALUE) == CONST0_RTX (GET_MODE (VALUE))) \
355 /* Stack layout; function entry, exit and calling. */
357 /* Define this if pushing a word on the stack
358 makes the stack pointer a smaller address. */
360 #define STACK_GROWS_DOWNWARD
362 /* Define this if the nominal address of the stack frame
363 is at the high-address end of the local variables;
364 that is, each additional local variable allocated
365 goes at a more negative offset in the frame. */
367 #define FRAME_GROWS_DOWNWARD
369 /* Offset within stack frame to start allocating local variables at.
370 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
371 first local allocated. Otherwise, it is the offset to the BEGINNING
372 of the first local allocated. */
374 #define STARTING_FRAME_OFFSET 0
376 /* Offset of first parameter from the argument pointer register value. */
377 /* Is equal to the size of the saved fp + pc, even if an fp isn't
378 saved since the value is used before we know. */
380 #define FIRST_PARM_OFFSET(FNDECL) (current_function_needs_context ? 8 : 4)
382 /* Specify the registers used for certain standard purposes.
383 The values of these macros are register numbers. */
385 /* Register to use for pushing function arguments. */
386 #define STACK_POINTER_REGNUM 7
388 /* Base register for access to local variables of the function. */
389 #define FRAME_POINTER_REGNUM 6
391 /* Base register for access to arguments of the function. */
392 #define ARG_POINTER_REGNUM 6
394 /* Register in which static-chain is passed to a function. */
395 #define STATIC_CHAIN_REGNUM 4
397 /* Value should be nonzero if functions must have frame pointers.
398 Zero means the frame pointer need not be set up (and parms
399 may be accessed via the stack pointer) in functions that seem suitable.
400 This is computed in `reload', in reload1.c.
402 We allow frame pointers to be eliminated when not having one will
403 not interfere with debugging. */
404 #define ACCUMULATE_OUTGOING_ARGS
405 #define FRAME_POINTER_REQUIRED 0
406 #define CAN_DEBUG_WITHOUT_FP
408 /* Store in the variable DEPTH the initial difference between the
409 frame pointer reg contents and the stack pointer reg contents,
410 as of the start of the function body. This depends on the layout
411 of the fixed parts of the stack frame and on how registers are saved. */
413 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = total_frame_size()
415 /* Various type size information.
417 The mn10200 has a limited number of small registers. Sizes of basic
418 data types are adjusted accordingly. */
419 #define SHORT_TYPE_SIZE 16
420 #define INT_TYPE_SIZE 16
421 #define LONG_TYPE_SIZE 32
422 #define LONG_LONG_TYPE_SIZE 32
423 #define FLOAT_TYPE_SIZE 32
424 #define DOUBLE_TYPE_SIZE 32
425 #define LONG_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
427 /* Any size less than 64bits will work; but a smarter definition
428 can make G++ code smaller and faster. Most operations on the
429 mn10200 occur on 16bit hunks, so the best size for a boolean
431 #define BOOL_TYPE_SIZE 16
433 /* The difference of two pointers must be at least 24bits since pointers
434 are 24bits; however, no basic data type is 24bits, so we have to round
435 up to a 32bits for the difference of pointers. */
438 #define SIZE_TYPE "long unsigned int"
439 #define PTRDIFF_TYPE "long unsigned int"
441 /* Note sizeof (WCHAR_TYPE) must be equal to the value of WCHAR_TYPE_SIZE! */
443 #define WCHAR_TYPE "int"
445 #undef WCHAR_TYPE_SIZE
446 #define WCHAR_TYPE_SIZE BITS_PER_WORD
448 #define MAX_FIXED_MODE_SIZE 32
450 /* A guess for the MN10200. */
451 #define PROMOTE_PROTOTYPES 1
453 /* Value is the number of bytes of arguments automatically
454 popped when returning from a subroutine call.
455 FUNDECL is the declaration node of the function (as a tree),
456 FUNTYPE is the data type of the function (as a tree),
457 or for a library call it is an identifier node for the subroutine name.
458 SIZE is the number of bytes of arguments passed on the stack. */
460 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
462 /* 1 if N is a possible register number for function argument passing. */
464 #define FUNCTION_ARG_REGNO_P(N) ((N) <= 1)
466 /* Define a data type for recording info about an argument list
467 during the scan of that argument list. This data type should
468 hold all necessary information about the function itself
469 and about the args processed so far, enough to enable macros
470 such as FUNCTION_ARG to determine where the next arg should go. */
472 #define CUMULATIVE_ARGS struct cum_arg
473 struct cum_arg
{ int nbytes
; };
475 /* Initialize a variable CUM of type CUMULATIVE_ARGS
476 for a call to a function whose data type is FNTYPE.
477 For a library call, FNTYPE is 0.
479 On the MN10200, the offset starts at 0. */
481 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
484 /* Update the data in CUM to advance over an argument
485 of mode MODE and data type TYPE.
486 (TYPE is null for libcalls where that information may not be available.) */
488 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
489 ((CUM).nbytes += ((MODE) != BLKmode \
490 ? (MODE) == PSImode ? 2 : \
491 (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) & -UNITS_PER_WORD \
492 : (int_size_in_bytes (TYPE) + UNITS_PER_WORD - 1) & -UNITS_PER_WORD))
494 /* Define where to put the arguments to a function.
495 Value is zero to push the argument on the stack,
496 or a hard register in which to store the argument.
498 MODE is the argument's machine mode.
499 TYPE is the data type of the argument (as a tree).
500 This is null for libcalls where that information may
502 CUM is a variable of type CUMULATIVE_ARGS which gives info about
503 the preceding args and about the function being called.
504 NAMED is nonzero if this argument is a named parameter
505 (otherwise it is an extra parameter matching an ellipsis). */
507 extern struct rtx_def
*function_arg();
508 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
509 function_arg (&CUM, MODE, TYPE, NAMED)
512 /* For "large" items, we pass them by invisible reference, and the
513 callee is responsible for copying the data item if it might be
515 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
516 ((TYPE) && int_size_in_bytes (TYPE) > 8)
518 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \
519 ((TYPE) && int_size_in_bytes (TYPE) > 8)
521 /* Define how to find the value returned by a function.
522 VALTYPE is the data type of the value (as a tree).
523 If the precise function being called is known, FUNC is its FUNCTION_DECL;
524 otherwise, FUNC is 0. */
526 #define FUNCTION_VALUE(VALTYPE, FUNC) \
527 gen_rtx (REG, TYPE_MODE (VALTYPE), TYPE_MODE (VALTYPE) == PSImode ? 4 : 0)
529 /* Define how to find the value returned by a library function
530 assuming the value has mode MODE. */
532 #define LIBCALL_VALUE(MODE) gen_rtx (REG, MODE, (MODE) == PSImode ? 4 : 0)
534 /* 1 if N is a possible register number for a function value. */
536 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0 || (N) == 4)
538 /* Return values > 8 bytes in length in memory. */
539 #define DEFAULT_PCC_STRUCT_RETURN 0
540 #define RETURN_IN_MEMORY(TYPE) \
541 (int_size_in_bytes (TYPE) > 8 || TYPE_MODE (TYPE) == BLKmode)
543 /* Register in which address to store a structure value
544 is passed to a function. On the MN10200 it's passed as
545 the first parameter. */
547 #define STRUCT_VALUE 0
549 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
550 the stack pointer does not matter. The value is tested only in
551 functions that have frame pointers.
552 No definition is equivalent to always zero. */
554 #define EXIT_IGNORE_STACK 1
556 /* Output assembler code to FILE to increment profiler label # LABELNO
557 for profiling a function entry.
559 ?!? Profiling is not currently supported. */
561 #define FUNCTION_PROFILER(FILE, LABELNO) ;
563 /* Yes, we actually support trampolines on this machine, even though
564 nobody is likely to ever use them. */
565 #define TRAMPOLINE_TEMPLATE(FILE) \
567 fprintf (FILE, "\t.byte 0xfd\n"); \
568 fprintf (FILE, "\t.byte 0x00\n"); \
569 fprintf (FILE, "\t.byte 0x00\n"); \
570 fprintf (FILE, "\tmov (a3),a0\n"); \
571 fprintf (FILE, "\tadd -4,a3\n"); \
572 fprintf (FILE, "\tmov a0,(0,a3)\n"); \
573 fprintf (FILE, "\tmov (21,a0),a0\n"); \
574 fprintf (FILE, "\tmov a0,(4,a3)\n"); \
575 fprintf (FILE, "\tmov (0,a3),a0\n"); \
576 fprintf (FILE, "\tmov (17,a0),a0\n"); \
577 fprintf (FILE, "\tadd 4,a3\n"); \
578 fprintf (FILE, "\trts\n"); \
579 fprintf (FILE, "\t.long 0\n"); \
580 fprintf (FILE, "\t.long 0\n"); \
583 /* Length in units of the trampoline for entering a nested function. */
585 #define TRAMPOLINE_SIZE 0x1c
587 /* Emit RTL insns to initialize the variable parts of a trampoline.
588 FNADDR is an RTX for the address of the function's pure code.
589 CXT is an RTX for the static chain value for the function. */
591 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
593 emit_move_insn (gen_rtx (MEM, PSImode, plus_constant ((TRAMP), 20)), \
595 emit_move_insn (gen_rtx (MEM, PSImode, plus_constant ((TRAMP), 24)), \
599 /* A C expression whose value is RTL representing the value of the return
600 address for the frame COUNT steps up from the current frame. */
602 #define RETURN_ADDR_RTX(COUNT, FRAME) \
604 ? gen_rtx (MEM, Pmode, frame_pointer_rtx) \
608 /* Addressing modes, and classification of registers for them. */
611 /* 1 if X is an rtx for a constant that is a valid address. */
613 #define CONSTANT_ADDRESS_P(X) CONSTANT_P (X)
615 /* Extra constraints. */
616 #define OK_FOR_R(OP) \
617 (GET_CODE (OP) == MEM \
618 && GET_MODE (OP) == QImode \
619 && REG_P (XEXP (OP, 0)))
621 /* Q is used for sp + <something> in the {zero,sign}_extendpsisi2 patterns. */
622 #define EXTRA_CONSTRAINT(OP, C) \
623 ((C) == 'R' ? OK_FOR_R (OP) : \
624 (C) == 'S' ? GET_CODE (OP) == SYMBOL_REF : \
625 (C) == 'Q' ? GET_CODE (OP) == PLUS : 0)
627 /* Maximum number of registers that can appear in a valid memory address. */
629 #define MAX_REGS_PER_ADDRESS 2
631 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
632 and check its validity for a certain class.
633 We have two alternate definitions for each of them.
634 The usual definition accepts all pseudo regs; the other rejects
635 them unless they have been allocated suitable hard regs.
636 The symbol REG_OK_STRICT causes the latter definition to be used.
638 Most source files want to accept pseudo regs in the hope that
639 they will get allocated to the class that the insn wants them to be in.
640 Source files for reload pass need to be strict.
641 After reload, it makes no difference, since pseudo regs have
642 been eliminated by then. */
644 #ifndef REG_OK_STRICT
645 /* Nonzero if X is a hard reg that can be used as an index
646 or if it is a pseudo reg. */
647 #define REG_OK_FOR_INDEX_P(X) \
648 (GET_MODE (X) == PSImode \
649 && ((REGNO (X) >= 0 && REGNO(X) <= 3) || REGNO (X) >= FIRST_PSEUDO_REGISTER))
650 /* Nonzero if X is a hard reg that can be used as a base reg
651 or if it is a pseudo reg. */
652 #define REG_OK_FOR_BASE_P(X) \
653 (GET_MODE (X) == PSImode \
654 && ((REGNO (X) >= 4 && REGNO(X) <= 8) || REGNO (X) >= FIRST_PSEUDO_REGISTER))
656 /* Nonzero if X is a hard reg that can be used as an index. */
657 #define REG_OK_FOR_INDEX_P(X) \
658 (GET_MODE (X) == PSImode) && REGNO_OK_FOR_INDEX_P (REGNO (X))
659 /* Nonzero if X is a hard reg that can be used as a base reg. */
660 #define REG_OK_FOR_BASE_P(X) \
661 (GET_MODE (X) == PSImode) && REGNO_OK_FOR_BASE_P (REGNO (X))
665 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
666 that is a valid memory address for an instruction.
667 The MODE argument is the machine mode for the MEM expression
668 that wants to use this address.
670 We used to allow reg+reg addresses for QImode and HImode; however,
671 they tended to cause the register allocator to run out of registers.
672 Basically, an indexed load/store always keeps 2 data and one address
673 register live, which is just too many for this machine.
675 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
676 except for CONSTANT_ADDRESS_P which is actually machine-independent. */
678 /* Accept either REG or SUBREG where a register is valid. */
680 #define RTX_OK_FOR_BASE_P(X) \
681 ((REG_P (X) && REG_OK_FOR_BASE_P (X)) \
682 || (GET_CODE (X) == SUBREG && REG_P (SUBREG_REG (X)) \
683 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
685 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
687 if ((MODE != PSImode) && CONSTANT_ADDRESS_P (X)) \
689 if (RTX_OK_FOR_BASE_P (X)) \
691 if (GET_CODE (X) == PLUS) \
693 rtx base = 0, index = 0; \
694 if (REG_P (XEXP (X, 0)) \
695 && REG_OK_FOR_BASE_P (XEXP (X, 0))) \
696 base = XEXP (X, 0), index = XEXP (X, 1); \
697 if (REG_P (XEXP (X, 1)) \
698 && REG_OK_FOR_BASE_P (XEXP (X, 1))) \
699 base = XEXP (X, 1), index = XEXP (X, 0); \
700 if (base != 0 && index != 0) \
702 if (GET_CODE (index) == CONST_INT) \
709 /* Try machine-dependent ways of modifying an illegitimate address
710 to be legitimate. If we find one, return the new, valid address.
711 This macro is used in only one place: `memory_address' in explow.c.
713 OLDX is the address as it was before break_out_memory_refs was called.
714 In some cases it is useful to look at this to decide what needs to be done.
716 MODE and WIN are passed so that this macro can use
717 GO_IF_LEGITIMATE_ADDRESS.
719 It is always safe for this macro to do nothing. It exists to recognize
720 opportunities to optimize the output. */
722 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) {}
724 /* Go to LABEL if ADDR (a legitimate address expression)
725 has an effect that depends on the machine mode it is used for. */
727 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) {}
729 /* Nonzero if the constant value X is a legitimate general operand.
730 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
732 #define LEGITIMATE_CONSTANT_P(X) 1
735 /* Tell final.c how to eliminate redundant test instructions. */
737 /* Here we define machine-dependent flags and fields in cc_status
738 (see `conditions.h'). No extra ones are needed for the vax. */
740 /* Store in cc_status the expressions
741 that the condition codes will describe
742 after execution of an instruction whose pattern is EXP.
743 Do not alter them if the instruction would not alter the cc's. */
745 #define CC_OVERFLOW_UNUSABLE 0x200
746 #define CC_NO_CARRY CC_NO_OVERFLOW
747 #define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc(EXP, INSN)
749 /* The mn10200 has a limited number of registers, so CSE of function
750 addresses generally makes code worse due to register pressure. */
751 #define NO_FUNCTION_CSE
753 /* Compute the cost of computing a constant rtl expression RTX
754 whose rtx-code is CODE. The body of this macro is a portion
755 of a switch statement. If the code is computed here,
756 return it with a return statement. Otherwise, break from the switch. */
758 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
760 /* Zeros are extremely cheap. */ \
761 if (INTVAL (RTX) == 0) \
763 /* If it fits in 8 bits, then it's still relatively cheap. */ \
764 if (INT_8_BITS (INTVAL (RTX))) \
766 /* This is the "base" cost, includes constants where either the \
767 upper or lower 16bits are all zeros. */ \
768 if (INT_16_BITS (INTVAL (RTX)) \
769 || (INTVAL (RTX) & 0xffff) == 0 \
770 || (INTVAL (RTX) & 0xffff0000) == 0) \
773 /* These are more costly than a CONST_INT, but we can relax them, \
774 so they're less costly than a CONST_DOUBLE. */ \
779 /* We don't optimize CONST_DOUBLEs well nor do we relax them well, \
780 so their cost is very high. */ \
784 /* Make moves between different classes more expensive than moves
785 within the same class. */
786 #define REGISTER_MOVE_COST(CLASS1, CLASS2) (CLASS1 != CLASS2 ? 4 : 2)
788 /* Provide the costs of a rtl expression. This is in the body of a
791 ?!? This probably needs more work. The definitions below were first
792 taken from the H8 port, then tweaked slightly to improve code density
793 on various sample codes. */
795 #define RTX_COSTS(RTX,CODE,OUTER_CODE) \
800 return (GET_MODE (RTX) == SImode ? 20 : 8);
802 /* Nonzero if access to memory by bytes or half words is no faster
803 than accessing full words. */
804 #define SLOW_BYTE_ACCESS 1
806 /* According expr.c, a value of around 6 should minimize code size, and
807 for the MN10200 series, code size our primary concern. */
810 #define TEXT_SECTION_ASM_OP "\t.section .text"
811 #define DATA_SECTION_ASM_OP "\t.section .data"
812 #define BSS_SECTION_ASM_OP "\t.section .bss"
814 /* Output at beginning/end of assembler file. */
815 #undef ASM_FILE_START
816 #define ASM_FILE_START(FILE) asm_file_start(FILE)
818 #define ASM_COMMENT_START "#"
820 /* Output to assembler file text saying following lines
821 may contain character constants, extra white space, comments, etc. */
823 #define ASM_APP_ON "#APP\n"
825 /* Output to assembler file text saying following lines
826 no longer contain unusual constructs. */
828 #define ASM_APP_OFF "#NO_APP\n"
830 /* This is how to output an assembler line defining a `double' constant.
831 It is .dfloat or .gfloat, depending. */
833 #define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
834 do { char dstr[30]; \
835 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
836 fprintf (FILE, "\t.double %s\n", dstr); \
840 /* This is how to output an assembler line defining a `float' constant. */
841 #define ASM_OUTPUT_FLOAT(FILE, VALUE) \
842 do { char dstr[30]; \
843 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
844 fprintf (FILE, "\t.float %s\n", dstr); \
847 /* This is how to output an assembler line defining an `int' constant. */
849 #define ASM_OUTPUT_INT(FILE, VALUE) \
850 ( fprintf (FILE, "\t.long "), \
851 output_addr_const (FILE, (VALUE)), \
852 fprintf (FILE, "\n"))
854 /* Likewise for `char' and `short' constants. */
856 #define ASM_OUTPUT_SHORT(FILE, VALUE) \
857 ( fprintf (FILE, "\t.hword "), \
858 output_addr_const (FILE, (VALUE)), \
859 fprintf (FILE, "\n"))
861 #define ASM_OUTPUT_CHAR(FILE, VALUE) \
862 ( fprintf (FILE, "\t.byte "), \
863 output_addr_const (FILE, (VALUE)), \
864 fprintf (FILE, "\n"))
866 /* This is how to output an assembler line for a numeric constant byte. */
867 #define ASM_OUTPUT_BYTE(FILE, VALUE) \
868 fprintf (FILE, "\t.byte 0x%x\n", (VALUE))
870 /* Define the parentheses used to group arithmetic operations
871 in assembler code. */
873 #define ASM_OPEN_PAREN "("
874 #define ASM_CLOSE_PAREN ")"
876 /* This says how to output the assembler to define a global
877 uninitialized but not common symbol.
878 Try to use asm_output_bss to implement this macro. */
880 #define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED) \
881 asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED))
883 /* This is how to output the definition of a user-level label named NAME,
884 such as the label on a static function or variable NAME. */
886 #define ASM_OUTPUT_LABEL(FILE, NAME) \
887 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
889 /* This is how to output a command to make the user-level label named NAME
890 defined for reference from other files. */
892 #define ASM_GLOBALIZE_LABEL(FILE, NAME) \
893 do { fputs ("\t.global ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
895 /* This is how to output a reference to a user-level label named NAME.
896 `assemble_name' uses this. */
898 #undef ASM_OUTPUT_LABELREF
899 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
902 STRIP_NAME_ENCODING (real_name, (NAME)); \
903 fprintf (FILE, "_%s", real_name); \
906 /* Store in OUTPUT a string (made with alloca) containing
907 an assembler-name for a local static variable named NAME.
908 LABELNO is an integer which is different for each call. */
910 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
911 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
912 sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO)))
914 /* This is how we tell the assembler that two symbols have the same value. */
916 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
917 do { assemble_name(FILE, NAME1); \
918 fputs(" = ", FILE); \
919 assemble_name(FILE, NAME2); \
920 fputc('\n', FILE); } while (0)
923 /* How to refer to registers in assembler output.
924 This sequence is indexed by compiler's hard-register-number (see above). */
926 #define REGISTER_NAMES \
927 { "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3"}
929 /* Print an instruction operand X on file FILE.
930 look in mn10200.c for details */
932 #define PRINT_OPERAND(FILE, X, CODE) print_operand(FILE,X,CODE)
934 /* Print a memory operand whose address is X, on file FILE.
935 This uses a function in output-vax.c. */
937 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
939 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO)
940 #define ASM_OUTPUT_REG_POP(FILE,REGNO)
942 /* This is how to output an element of a case-vector that is absolute. */
944 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
945 asm_fprintf (FILE, "\t%s .L%d\n", ".long", VALUE)
947 /* This is how to output an element of a case-vector that is relative. */
949 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
950 fprintf (FILE, "\t%s .L%d-.L%d\n", ".long", VALUE, REL)
952 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
954 fprintf (FILE, "\t.align %d\n", (LOG))
956 /* We don't have to worry about dbx compatibility for the mn10200. */
957 #define DEFAULT_GDB_EXTENSIONS 1
959 /* Use stabs debugging info by default. */
960 #undef PREFERRED_DEBUGGING_TYPE
961 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
963 #define DBX_REGISTER_NUMBER(REGNO) REGNO
965 /* GDB always assumes the current function's frame begins at the value
966 of the stack pointer upon entry to the current function. Accessing
967 local variables and parameters passed on the stack is done using the
968 base of the frame + an offset provided by GCC.
970 For functions which have frame pointers this method works fine;
971 the (frame pointer) == (stack pointer at function entry) and GCC provides
972 an offset relative to the frame pointer.
974 This loses for functions without a frame pointer; GCC provides an offset
975 which is relative to the stack pointer after adjusting for the function's
976 frame size. GDB would prefer the offset to be relative to the value of
977 the stack pointer at the function's entry. Yuk! */
978 #define DEBUGGER_AUTO_OFFSET(X) \
979 ((GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0) \
980 + (frame_pointer_needed ? 0 : -total_frame_size ()))
982 #define DEBUGGER_ARG_OFFSET(OFFSET, X) \
983 ((GET_CODE (X) == PLUS ? OFFSET : 0) \
984 + (frame_pointer_needed ? 0 : -total_frame_size ()))
986 /* Define to use software floating point emulator for REAL_ARITHMETIC and
987 decimal <-> binary conversion. */
988 #define REAL_ARITHMETIC
990 /* Specify the machine mode that this machine uses
991 for the index in the tablejump instruction. */
992 #define CASE_VECTOR_MODE Pmode
994 /* Define this if the case instruction drops through after the table
995 when the index is out of range. Don't define it if the case insn
996 jumps to the default label instead. */
997 #define CASE_DROPS_THROUGH
999 /* Dispatch tables on the mn10200 are extremely expensive in terms of code
1000 and readonly data size. So we crank up the case threshold value to
1001 encourage a series of if/else comparisons to implement many small switch
1002 statements. In theory, this value could be increased much more if we
1003 were solely optimizing for space, but we keep it "reasonable" to avoid
1004 serious code efficiency lossage. */
1005 #define CASE_VALUES_THRESHOLD 8
1007 /* Define if operations between registers always perform the operation
1008 on the full register even if a narrower mode is specified. */
1009 #define WORD_REGISTER_OPERATIONS
1011 /* We could define this either way. Using ZERO_EXTEND for QImode makes slightly
1012 fast and more compact code. */
1013 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
1015 /* Specify the tree operation to be used to convert reals to integers. */
1016 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1018 /* This flag, if defined, says the same insns that convert to a signed fixnum
1019 also convert validly to an unsigned one. */
1020 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
1022 /* This is the kind of divide that is easiest to do in the general case. */
1023 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1025 /* Max number of bytes we can move from memory to memory
1026 in one reasonably fast instruction. */
1029 /* Define if shifts truncate the shift count
1030 which implies one can omit a sign-extension or zero-extension
1031 of a shift count. */
1032 #define SHIFT_COUNT_TRUNCATED 1
1034 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1035 is done just by pretending it is already truncated. */
1036 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) (OUTPREC != 32)
1038 /* Specify the machine mode that pointers have.
1039 After generation of rtl, the compiler makes no further distinction
1040 between pointers and any other objects of this machine mode. */
1041 #define Pmode PSImode
1043 /* A function address in a call instruction
1044 is a byte address (for indexing purposes)
1045 so give the MEM rtx a byte's mode. */
1046 #define FUNCTION_MODE QImode
1048 /* Perform target dependent optabs initialization. */
1049 #define MODHI3_LIBCALL "__modhi3"
1050 #define DIVHI3_LIBCALL "__divhi3"
1052 #define INIT_TARGET_OPTABS \
1054 sdiv_optab->handlers[(int) HImode].libfunc \
1055 = gen_rtx (SYMBOL_REF, Pmode, DIVHI3_LIBCALL); \
1056 smod_optab->handlers[(int) HImode].libfunc \
1057 = gen_rtx (SYMBOL_REF, Pmode, MODHI3_LIBCALL); \
1060 /* The assembler op to get a word. */
1062 #define FILE_ASM_OP "\t.file\n"
1064 extern void asm_file_start ();
1065 extern void print_operand ();
1066 extern void print_operand_address ();
1067 extern void expand_prologue ();
1068 extern void expand_epilogue ();
1069 extern void notice_update_cc ();
1070 extern int call_address_operand ();
1071 extern enum reg_class
secondary_reload_class ();
1072 extern char *emit_a_shift ();
1073 extern int current_function_needs_context
;
1074 extern char *output_tst ();
1075 extern int extendpsi_operand ();
1076 extern int rtx_equal_function_value_matters
;
1077 extern struct rtx_def
*zero_dreg
;
1078 extern struct rtx_def
*zero_areg
;