1/* Definitions of target machine for GNU compiler.  VAX version.
2   Copyright (C) 1987, 1988, 1991, 1993, 1994, 1995, 1996, 1997, 1998,
3   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING.  If not, write to
19the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20Boston, MA 02110-1301, USA.  */
21
22
23/* Target CPU builtins.  */
24#define TARGET_CPU_CPP_BUILTINS()		\
25  do						\
26    {						\
27      builtin_define ("__vax__");		\
28      builtin_assert ("cpu=vax");		\
29      builtin_assert ("machine=vax");		\
30      if (TARGET_G_FLOAT)			\
31	{					\
32	  builtin_define ("__GFLOAT");		\
33	  builtin_define ("__GFLOAT__");	\
34	}					\
35    }						\
36  while (0)
37
38#define VMS_TARGET 0
39
40/* Use -J option for long branch support with Unix assembler.  */
41
42#define ASM_SPEC "-J"
43
44/* Choose proper libraries depending on float format.
45   Note that there are no profiling libraries for g-format.
46   Also use -lg for the sake of dbx.  */
47
48#define LIB_SPEC "%{g:-lg}\
49 %{mg:%{lm:-lmg} -lcg \
50  %{p:%eprofiling not supported with -mg\n}\
51  %{pg:%eprofiling not supported with -mg\n}}\
52 %{!mg:%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
53
54/* Print subsidiary information on the compiler version in use.  */
55
56#ifndef TARGET_NAME	/* A more specific value might be supplied via -D.  */
57#define TARGET_NAME "vax"
58#endif
59#define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME)
60
61/* Run-time compilation parameters selecting different hardware subsets.  */
62
63/* Nonzero if ELF.  Redefined by vax/elf.h.  */
64#define TARGET_ELF 0
65
66/* Default target_flags if no switches specified.  */
67
68#ifndef TARGET_DEFAULT
69#define TARGET_DEFAULT (MASK_UNIX_ASM)
70#endif
71
72#define OVERRIDE_OPTIONS override_options ()
73
74
75/* Target machine storage layout */
76
77/* Define this if most significant bit is lowest numbered
78   in instructions that operate on numbered bit-fields.
79   This is not true on the VAX.  */
80#define BITS_BIG_ENDIAN 0
81
82/* Define this if most significant byte of a word is the lowest numbered.  */
83/* That is not true on the VAX.  */
84#define BYTES_BIG_ENDIAN 0
85
86/* Define this if most significant word of a multiword number is the lowest
87   numbered.  */
88/* This is not true on the VAX.  */
89#define WORDS_BIG_ENDIAN 0
90
91/* Width of a word, in units (bytes).  */
92#define UNITS_PER_WORD 4
93
94/* Allocation boundary (in *bits*) for storing arguments in argument list.  */
95#define PARM_BOUNDARY 32
96
97/* Allocation boundary (in *bits*) for the code of a function.  */
98#define FUNCTION_BOUNDARY 16
99
100/* Alignment of field after `int : 0' in a structure.  */
101#define EMPTY_FIELD_BOUNDARY (TARGET_VAXC_ALIGNMENT ? 8 : 32)
102
103/* Every structure's size must be a multiple of this.  */
104#define STRUCTURE_SIZE_BOUNDARY 8
105
106/* A bit-field declared as `int' forces `int' alignment for the struct.  */
107#define PCC_BITFIELD_TYPE_MATTERS (!TARGET_VAXC_ALIGNMENT)
108
109/* No data type wants to be aligned rounder than this.  */
110#define BIGGEST_ALIGNMENT 32
111
112/* No structure field wants to be aligned rounder than this.  */
113#define BIGGEST_FIELD_ALIGNMENT (TARGET_VAXC_ALIGNMENT ? 8 : 32)
114
115/* Set this nonzero if move instructions will actually fail to work
116   when given unaligned data.  */
117#define STRICT_ALIGNMENT 0
118
119/* Let's keep the stack somewhat aligned.  */
120#define STACK_BOUNDARY 32
121
122/* The table of an ADDR_DIFF_VEC must be contiguous with the case
123   opcode, it is part of the case instruction.  */
124#define ADDR_VEC_ALIGN(ADDR_VEC) 0
125
126/* Standard register usage.  */
127
128/* Number of actual hardware registers.
129   The hardware registers are assigned numbers for the compiler
130   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.  */
133#define FIRST_PSEUDO_REGISTER 16
134
135/* 1 for registers that have pervasive standard uses
136   and are not available for the register allocator.
137   On the VAX, these are the AP, FP, SP and PC.  */
138#define FIXED_REGISTERS {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
139
140/* 1 for registers not available across function calls.
141   These must include the FIXED_REGISTERS and also any
142   registers that can be used without being saved.
143   The latter must include the registers where values are returned
144   and the register where structure-value addresses are passed.
145   Aside from that, you can include as many other registers as you like.  */
146#define CALL_USED_REGISTERS {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
147
148/* Return number of consecutive hard regs needed starting at reg REGNO
149   to hold something of mode MODE.
150   This is ordinarily the length in words of a value of mode MODE
151   but can be less for certain modes in special long registers.
152   On the VAX, all registers are one word long.  */
153#define HARD_REGNO_NREGS(REGNO, MODE)	\
154  ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
155
156/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
157   On the VAX, all registers can hold all modes.  */
158#define HARD_REGNO_MODE_OK(REGNO, MODE) 1
159
160/* Value is 1 if it is a good idea to tie two pseudo registers
161   when one has mode MODE1 and one has mode MODE2.
162   If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
163   for any hard reg, then this must be 0 for correct output.  */
164#define MODES_TIEABLE_P(MODE1, MODE2)  1
165
166/* Specify the registers used for certain standard purposes.
167   The values of these macros are register numbers.  */
168
169/* VAX pc is overloaded on a register.  */
170#define PC_REGNUM VAX_PC_REGNUM
171
172/* Register to use for pushing function arguments.  */
173#define STACK_POINTER_REGNUM VAX_SP_REGNUM
174
175/* Base register for access to local variables of the function.  */
176#define FRAME_POINTER_REGNUM VAX_FP_REGNUM
177
178/* Value should be nonzero if functions must have frame pointers.
179   Zero means the frame pointer need not be set up (and parms
180   may be accessed via the stack pointer) in functions that seem suitable.
181   This is computed in `reload', in reload1.c.  */
182#define FRAME_POINTER_REQUIRED 1
183
184/* Base register for access to arguments of the function.  */
185#define ARG_POINTER_REGNUM VAX_AP_REGNUM
186
187/* Register in which static-chain is passed to a function.  */
188#define STATIC_CHAIN_REGNUM 0
189
190/* Register in which address to store a structure value
191   is passed to a function.  */
192#define VAX_STRUCT_VALUE_REGNUM 1
193
194/* Define the classes of registers for register constraints in the
195   machine description.  Also define ranges of constants.
196
197   One of the classes must always be named ALL_REGS and include all hard regs.
198   If there is more than one class, another class must be named NO_REGS
199   and contain no registers.
200
201   The name GENERAL_REGS must be the name of a class (or an alias for
202   another name such as ALL_REGS).  This is the class of registers
203   that is allowed by "g" or "r" in a register constraint.
204   Also, registers outside this class are allocated only when
205   instructions express preferences for them.
206
207   The classes must be numbered in nondecreasing order; that is,
208   a larger-numbered class must never be contained completely
209   in a smaller-numbered class.
210
211   For any two classes, it is very desirable that there be another
212   class that represents their union.  */
213
214/* The VAX has only one kind of registers, so NO_REGS and ALL_REGS
215   are the only classes.  */
216
217enum reg_class { NO_REGS, ALL_REGS, LIM_REG_CLASSES };
218
219#define N_REG_CLASSES (int) LIM_REG_CLASSES
220
221/* Since GENERAL_REGS is the same class as ALL_REGS,
222   don't give it a different class number; just make it an alias.  */
223
224#define GENERAL_REGS ALL_REGS
225
226/* Give names of register classes as strings for dump file.  */
227
228#define REG_CLASS_NAMES	\
229  { "NO_REGS", "ALL_REGS" }
230
231/* Define which registers fit in which classes.
232   This is an initializer for a vector of HARD_REG_SET
233   of length N_REG_CLASSES.  */
234
235#define REG_CLASS_CONTENTS {{0}, {0xffff}}
236
237/* The same information, inverted:
238   Return the class number of the smallest class containing
239   reg number REGNO.  This could be a conditional expression
240   or could index an array.  */
241
242#define REGNO_REG_CLASS(REGNO) ALL_REGS
243
244/* The class value for index registers, and the one for base regs.  */
245
246#define INDEX_REG_CLASS ALL_REGS
247#define BASE_REG_CLASS ALL_REGS
248
249/* Get reg_class from a letter such as appears in the machine description.  */
250
251#define REG_CLASS_FROM_LETTER(C) NO_REGS
252
253/* The letters I, J, K, L, M, N, and O in a register constraint string
254   can be used to stand for particular ranges of immediate operands.
255   This macro defines what the ranges are.
256   C is the letter, and VALUE is a constant value.
257   Return 1 if VALUE is in the range specified by C.
258
259   `I' is the constant zero.
260   `J' is a value between 0 .. 63 (inclusive)
261   `K' is a value between -128 and 127 (inclusive)
262   'L' is a value between -32768 and 32767 (inclusive)
263   `M' is a value between 0 and 255 (inclusive)
264   'N' is a value between 0 and 65535 (inclusive)
265   `O' is a value between -63 and -1 (inclusive)  */
266
267#define CONST_OK_FOR_LETTER_P(VALUE, C)				\
268  (  (C) == 'I' ?	(VALUE) == 0				\
269   : (C) == 'J' ?	0 <= (VALUE) && (VALUE) < 64		\
270   : (C) == 'O' ?	-63 <= (VALUE) && (VALUE) < 0		\
271   : (C) == 'K' ?	-128 <= (VALUE) && (VALUE) < 128	\
272   : (C) == 'M' ?	0 <= (VALUE) && (VALUE) < 256		\
273   : (C) == 'L' ?	-32768 <= (VALUE) && (VALUE) < 32768	\
274   : (C) == 'N' ?	0 <= (VALUE) && (VALUE) < 65536		\
275   : 0)
276
277/* Similar, but for floating constants, and defining letters G and H.
278   Here VALUE is the CONST_DOUBLE rtx itself.
279
280   `G' is a floating-point zero.  */
281
282#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)		\
283  ((C) == 'G' ? ((VALUE) == CONST0_RTX (DFmode)		\
284		 || (VALUE) == CONST0_RTX (SFmode))	\
285   : 0)
286
287/* Optional extra constraints for this machine.
288
289   For the VAX, `Q' means that OP is a MEM that does not have a mode-dependent
290   address.  */
291
292#define EXTRA_CONSTRAINT(OP, C)					\
293  ((C) == 'Q'							\
294   ? MEM_P (OP) && !mode_dependent_address_p (XEXP (OP, 0))	\
295   : 0)
296
297/* Given an rtx X being reloaded into a reg required to be
298   in class CLASS, return the class of reg to actually use.
299   In general this is just CLASS; but on some machines
300   in some cases it is preferable to use a more restrictive class.  */
301
302#define PREFERRED_RELOAD_CLASS(X,CLASS)  (CLASS)
303
304/* Return the maximum number of consecutive registers
305   needed to represent mode MODE in a register of class CLASS.  */
306/* On the VAX, this is always the size of MODE in words,
307   since all registers are the same size.  */
308#define CLASS_MAX_NREGS(CLASS, MODE)	\
309 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
310
311/* Stack layout; function entry, exit and calling.  */
312
313/* Define this if pushing a word on the stack
314   makes the stack pointer a smaller address.  */
315#define STACK_GROWS_DOWNWARD
316
317/* Define this to nonzero if the nominal address of the stack frame
318   is at the high-address end of the local variables;
319   that is, each additional local variable allocated
320   goes at a more negative offset in the frame.  */
321#define FRAME_GROWS_DOWNWARD 1
322
323/* Offset within stack frame to start allocating local variables at.
324   If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
325   first local allocated.  Otherwise, it is the offset to the BEGINNING
326   of the first local allocated.  */
327#define STARTING_FRAME_OFFSET 0
328
329/* Given an rtx for the address of a frame,
330   return an rtx for the address of the word in the frame
331   that holds the dynamic chain--the previous frame's address.  */
332#define DYNAMIC_CHAIN_ADDRESS(FRAME) plus_constant ((FRAME), 12)
333
334/* If we generate an insn to push BYTES bytes,
335   this says how many the stack pointer really advances by.
336   On the VAX, -(sp) pushes only the bytes of the operands.  */
337#define PUSH_ROUNDING(BYTES) (BYTES)
338
339/* Offset of first parameter from the argument pointer register value.  */
340#define FIRST_PARM_OFFSET(FNDECL) 4
341
342/* Value is the number of bytes of arguments automatically
343   popped when returning from a subroutine call.
344   FUNDECL is the declaration node of the function (as a tree),
345   FUNTYPE is the data type of the function (as a tree),
346   or for a library call it is an identifier node for the subroutine name.
347   SIZE is the number of bytes of arguments passed on the stack.
348
349   On the VAX, the RET insn pops a maximum of 255 args for any function.  */
350
351#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE)	\
352  ((SIZE) > 255 * 4 ? 0 : (SIZE))
353
354/* Define how to find the value returned by a function.
355   VALTYPE is the data type of the value (as a tree).
356   If the precise function being called is known, FUNC is its FUNCTION_DECL;
357   otherwise, FUNC is 0.  */
358
359/* On the VAX the return value is in R0 regardless.  */
360
361#define FUNCTION_VALUE(VALTYPE, FUNC)	\
362  gen_rtx_REG (TYPE_MODE (VALTYPE), 0)
363
364/* Define how to find the value returned by a library function
365   assuming the value has mode MODE.  */
366
367/* On the VAX the return value is in R0 regardless.  */
368
369#define LIBCALL_VALUE(MODE)  gen_rtx_REG (MODE, 0)
370
371/* Define this if PCC uses the nonreentrant convention for returning
372   structure and union values.  */
373
374#define PCC_STATIC_STRUCT_RETURN
375
376/* 1 if N is a possible register number for a function value.
377   On the VAX, R0 is the only register thus used.  */
378
379#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
380
381/* 1 if N is a possible register number for function argument passing.
382   On the VAX, no registers are used in this way.  */
383
384#define FUNCTION_ARG_REGNO_P(N) 0
385
386/* Define a data type for recording info about an argument list
387   during the scan of that argument list.  This data type should
388   hold all necessary information about the function itself
389   and about the args processed so far, enough to enable macros
390   such as FUNCTION_ARG to determine where the next arg should go.
391
392   On the VAX, this is a single integer, which is a number of bytes
393   of arguments scanned so far.  */
394
395#define CUMULATIVE_ARGS int
396
397/* Initialize a variable CUM of type CUMULATIVE_ARGS
398   for a call to a function whose data type is FNTYPE.
399   For a library call, FNTYPE is 0.
400
401   On the VAX, the offset starts at 0.  */
402
403#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
404 ((CUM) = 0)
405
406/* Update the data in CUM to advance over an argument
407   of mode MODE and data type TYPE.
408   (TYPE is null for libcalls where that information may not be available.)  */
409
410#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)	\
411  ((CUM) += ((MODE) != BLKmode				\
412	     ? (GET_MODE_SIZE (MODE) + 3) & ~3		\
413	     : (int_size_in_bytes (TYPE) + 3) & ~3))
414
415/* Define where to put the arguments to a function.
416   Value is zero to push the argument on the stack,
417   or a hard register in which to store the argument.
418
419   MODE is the argument's machine mode.
420   TYPE is the data type of the argument (as a tree).
421    This is null for libcalls where that information may
422    not be available.
423   CUM is a variable of type CUMULATIVE_ARGS which gives info about
424    the preceding args and about the function being called.
425   NAMED is nonzero if this argument is a named parameter
426    (otherwise it is an extra parameter matching an ellipsis).  */
427
428/* On the VAX all args are pushed.  */
429
430#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) 0
431
432/* Output assembler code to FILE to increment profiler label # LABELNO
433   for profiling a function entry.  */
434
435#define VAX_FUNCTION_PROFILER_NAME "mcount"
436#define FUNCTION_PROFILER(FILE, LABELNO)			\
437  do								\
438    {								\
439      char label[256];						\
440      ASM_GENERATE_INTERNAL_LABEL (label, "LP", (LABELNO));	\
441      fprintf (FILE, "\tmovab ");				\
442      assemble_name (FILE, label);				\
443      asm_fprintf (FILE, ",%Rr0\n\tjsb %s\n",			\
444		   VAX_FUNCTION_PROFILER_NAME);			\
445    }								\
446  while (0)
447
448/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
449   the stack pointer does not matter.  The value is tested only in
450   functions that have frame pointers.
451   No definition is equivalent to always zero.  */
452
453#define EXIT_IGNORE_STACK 1
454
455/* Store in the variable DEPTH the initial difference between the
456   frame pointer reg contents and the stack pointer reg contents,
457   as of the start of the function body.  This depends on the layout
458   of the fixed parts of the stack frame and on how registers are saved.
459
460   On the VAX, FRAME_POINTER_REQUIRED is always 1, so the definition of this
461   macro doesn't matter.  But it must be defined.  */
462
463#define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = 0;
464
465/* Output assembler code for a block containing the constant parts
466   of a trampoline, leaving space for the variable parts.  */
467
468/* On the VAX, the trampoline contains an entry mask and two instructions:
469     .word NN
470     movl $STATIC,r0   (store the functions static chain)
471     jmp  *$FUNCTION   (jump to function code at address FUNCTION)  */
472
473#define TRAMPOLINE_TEMPLATE(FILE)					\
474{									\
475  assemble_aligned_integer (2, const0_rtx);				\
476  assemble_aligned_integer (2, GEN_INT (0x8fd0));			\
477  assemble_aligned_integer (4, const0_rtx);				\
478  assemble_aligned_integer (1, GEN_INT (0x50 + STATIC_CHAIN_REGNUM));	\
479  assemble_aligned_integer (2, GEN_INT (0x9f17));			\
480  assemble_aligned_integer (4, const0_rtx);				\
481}
482
483/* Length in units of the trampoline for entering a nested function.  */
484
485#define TRAMPOLINE_SIZE 15
486
487/* Emit RTL insns to initialize the variable parts of a trampoline.
488   FNADDR is an RTX for the address of the function's pure code.
489   CXT is an RTX for the static chain value for the function.  */
490
491/* We copy the register-mask from the function's pure code
492   to the start of the trampoline.  */
493#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)			\
494{									\
495  emit_move_insn (gen_rtx_MEM (HImode, TRAMP),				\
496		  gen_rtx_MEM (HImode, FNADDR));			\
497  emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 4)), CXT);	\
498  emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 11)),	\
499		  plus_constant (FNADDR, 2));				\
500  emit_insn (gen_sync_istream ());					\
501}
502
503/* Byte offset of return address in a stack frame.  The "saved PC" field
504   is in element [4] when treating the frame as an array of longwords.  */
505
506#define RETURN_ADDRESS_OFFSET	(4 * UNITS_PER_WORD)	/* 16 */
507
508/* A C expression whose value is RTL representing the value of the return
509   address for the frame COUNT steps up from the current frame.
510   FRAMEADDR is already the frame pointer of the COUNT frame, so we
511   can ignore COUNT.  */
512
513#define RETURN_ADDR_RTX(COUNT, FRAME)					\
514  ((COUNT == 0)								\
515   ? gen_rtx_MEM (Pmode, plus_constant (FRAME, RETURN_ADDRESS_OFFSET))	\
516   : (rtx) 0)
517
518
519/* Addressing modes, and classification of registers for them.  */
520
521#define HAVE_POST_INCREMENT 1
522
523#define HAVE_PRE_DECREMENT 1
524
525/* Macros to check register numbers against specific register classes.  */
526
527/* These assume that REGNO is a hard or pseudo reg number.
528   They give nonzero only if REGNO is a hard reg of the suitable class
529   or a pseudo reg currently allocated to a suitable hard reg.
530   Since they use reg_renumber, they are safe only once reg_renumber
531   has been allocated, which happens in local-alloc.c.  */
532
533#define REGNO_OK_FOR_INDEX_P(regno)	\
534  ((regno) < FIRST_PSEUDO_REGISTER || reg_renumber[regno] >= 0)
535#define REGNO_OK_FOR_BASE_P(regno)	\
536  ((regno) < FIRST_PSEUDO_REGISTER || reg_renumber[regno] >= 0)
537
538/* Maximum number of registers that can appear in a valid memory address.  */
539
540#define MAX_REGS_PER_ADDRESS 2
541
542/* 1 if X is an rtx for a constant that is a valid address.  */
543
544#define CONSTANT_ADDRESS_P(X) legitimate_constant_address_p (X)
545
546/* Nonzero if the constant value X is a legitimate general operand.
547   It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.  */
548
549#define LEGITIMATE_CONSTANT_P(X) legitimate_constant_p (X)
550
551/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
552   and check its validity for a certain class.
553   We have two alternate definitions for each of them.
554   The usual definition accepts all pseudo regs; the other rejects
555   them unless they have been allocated suitable hard regs.
556   The symbol REG_OK_STRICT causes the latter definition to be used.
557
558   Most source files want to accept pseudo regs in the hope that
559   they will get allocated to the class that the insn wants them to be in.
560   Source files for reload pass need to be strict.
561   After reload, it makes no difference, since pseudo regs have
562   been eliminated by then.  */
563
564#ifndef REG_OK_STRICT
565
566/* Nonzero if X is a hard reg that can be used as an index
567   or if it is a pseudo reg.  */
568#define REG_OK_FOR_INDEX_P(X) 1
569
570/* Nonzero if X is a hard reg that can be used as a base reg
571   or if it is a pseudo reg.  */
572#define REG_OK_FOR_BASE_P(X) 1
573
574/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
575   that is a valid memory address for an instruction.  */
576#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
577  { if (legitimate_address_p ((MODE), (X), 0)) goto ADDR; }
578
579#else
580
581/* Nonzero if X is a hard reg that can be used as an index.  */
582#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
583
584/* Nonzero if X is a hard reg that can be used as a base reg.  */
585#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
586
587/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
588   that is a valid memory address for an instruction.  */
589#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
590  { if (legitimate_address_p ((MODE), (X), 1)) goto ADDR; }
591
592#endif
593
594/* Go to LABEL if ADDR (a legitimate address expression)
595   has an effect that depends on the machine mode it is used for.  */
596#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
597  { if (vax_mode_dependent_address_p (ADDR)) goto LABEL; }
598
599/* Specify the machine mode that this machine uses
600   for the index in the tablejump instruction.  */
601#define CASE_VECTOR_MODE HImode
602
603/* Define as C expression which evaluates to nonzero if the tablejump
604   instruction expects the table to contain offsets from the address of the
605   table.
606   Do not define this if the table should contain absolute addresses.  */
607#define CASE_VECTOR_PC_RELATIVE 1
608
609/* Indicate that jump tables go in the text section.  This is
610   necessary when compiling PIC code.  */
611#define JUMP_TABLES_IN_TEXT_SECTION 1
612
613/* Define this as 1 if `char' should by default be signed; else as 0.  */
614#define DEFAULT_SIGNED_CHAR 1
615
616/* This flag, if defined, says the same insns that convert to a signed fixnum
617   also convert validly to an unsigned one.  */
618#define FIXUNS_TRUNC_LIKE_FIX_TRUNC
619
620/* Max number of bytes we can move from memory to memory
621   in one reasonably fast instruction.  */
622#define MOVE_MAX 8
623
624/* Nonzero if access to memory by bytes is slow and undesirable.  */
625#define SLOW_BYTE_ACCESS 0
626
627/* Define if shifts truncate the shift count
628   which implies one can omit a sign-extension or zero-extension
629   of a shift count.  */
630/* #define SHIFT_COUNT_TRUNCATED */
631
632/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
633   is done just by pretending it is already truncated.  */
634#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
635
636/* Specify the machine mode that pointers have.
637   After generation of rtl, the compiler makes no further distinction
638   between pointers and any other objects of this machine mode.  */
639#define Pmode SImode
640
641/* A function address in a call instruction
642   is a byte address (for indexing purposes)
643   so give the MEM rtx a byte's mode.  */
644#define FUNCTION_MODE QImode
645
646/* This machine doesn't use IEEE floats.  */
647
648#define TARGET_FLOAT_FORMAT VAX_FLOAT_FORMAT
649
650/* Specify the cost of a branch insn; roughly the number of extra insns that
651   should be added to avoid a branch.
652
653   Branches are extremely cheap on the VAX while the shift insns often
654   used to replace branches can be expensive.  */
655
656#define BRANCH_COST 0
657
658/* Tell final.c how to eliminate redundant test instructions.  */
659
660/* Here we define machine-dependent flags and fields in cc_status
661   (see `conditions.h').  No extra ones are needed for the VAX.  */
662
663/* Store in cc_status the expressions
664   that the condition codes will describe
665   after execution of an instruction whose pattern is EXP.
666   Do not alter them if the instruction would not alter the cc's.  */
667
668#define NOTICE_UPDATE_CC(EXP, INSN)	\
669  vax_notice_update_cc ((EXP), (INSN))
670
671#define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV)	\
672  { if (cc_status.flags & CC_NO_OVERFLOW)	\
673      return NO_OV;				\
674    return NORMAL;				\
675  }
676
677/* Control the assembler format that we output.  */
678
679/* A C string constant describing how to begin a comment in the target
680   assembler language.  The compiler assumes that the comment will end at
681   the end of the line.  */
682
683#define ASM_COMMENT_START "#"
684
685/* Output to assembler file text saying following lines
686   may contain character constants, extra white space, comments, etc.  */
687
688#define ASM_APP_ON "#APP\n"
689
690/* Output to assembler file text saying following lines
691   no longer contain unusual constructs.  */
692
693#define ASM_APP_OFF "#NO_APP\n"
694
695/* Output before read-only data.  */
696
697#define TEXT_SECTION_ASM_OP "\t.text"
698
699/* Output before writable data.  */
700
701#define DATA_SECTION_ASM_OP "\t.data"
702
703/* How to refer to registers in assembler output.
704   This sequence is indexed by compiler's hard-register-number (see above).
705   The register names will be prefixed by REGISTER_PREFIX, if any.  */
706
707#define REGISTER_PREFIX ""
708#define REGISTER_NAMES					\
709  { "r0", "r1",  "r2",  "r3", "r4", "r5", "r6", "r7",	\
710    "r8", "r9", "r10", "r11", "ap", "fp", "sp", "pc", }
711
712/* This is BSD, so it wants DBX format.  */
713
714#define DBX_DEBUGGING_INFO 1
715
716/* Do not break .stabs pseudos into continuations.  */
717
718#define DBX_CONTIN_LENGTH 0
719
720/* This is the char to use for continuation (in case we need to turn
721   continuation back on).  */
722
723#define DBX_CONTIN_CHAR '?'
724
725/* Don't use the `xsfoo;' construct in DBX output; this system
726   doesn't support it.  */
727
728#define DBX_NO_XREFS
729
730/* Output the .stabs for a C `static' variable in the data section.  */
731#define DBX_STATIC_STAB_DATA_SECTION
732
733/* VAX specific: which type character is used for type double?  */
734
735#define ASM_DOUBLE_CHAR (TARGET_G_FLOAT ? 'g' : 'd')
736
737/* This is how to output a command to make the user-level label named NAME
738   defined for reference from other files.  */
739
740/* Globalizing directive for a label.  */
741#define GLOBAL_ASM_OP ".globl "
742
743/* The prefix to add to user-visible assembler symbols.  */
744
745#define USER_LABEL_PREFIX "_"
746
747/* This is how to store into the string LABEL
748   the symbol_ref name of an internal numbered label where
749   PREFIX is the class of label and NUM is the number within the class.
750   This is suitable for output with `assemble_name'.  */
751
752#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)	\
753  sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM))
754
755/* This is how to output an insn to push a register on the stack.
756   It need not be very fast code.  */
757
758#define ASM_OUTPUT_REG_PUSH(FILE,REGNO)  \
759  fprintf (FILE, "\tpushl %s\n", reg_names[REGNO])
760
761/* This is how to output an insn to pop a register from the stack.
762   It need not be very fast code.  */
763
764#define ASM_OUTPUT_REG_POP(FILE,REGNO)					\
765  fprintf (FILE, "\tmovl (%s)+,%s\n", reg_names[STACK_POINTER_REGNUM],	\
766	   reg_names[REGNO])
767
768/* This is how to output an element of a case-vector that is absolute.
769   (The VAX does not use such vectors,
770   but we must define this macro anyway.)  */
771
772#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE)		\
773  do							\
774    {							\
775      char label[256];					\
776      ASM_GENERATE_INTERNAL_LABEL (label, "L", (VALUE));\
777      fprintf (FILE, "\t.long ");			\
778      assemble_name (FILE, label);			\
779      fprintf (FILE, "\n");				\
780    }							\
781  while (0)
782
783/* This is how to output an element of a case-vector that is relative.  */
784
785#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL)	\
786  do								\
787    {								\
788      char label[256];						\
789      ASM_GENERATE_INTERNAL_LABEL (label, "L", (VALUE));	\
790      fprintf (FILE, "\t.word ");				\
791      assemble_name (FILE, label);				\
792      ASM_GENERATE_INTERNAL_LABEL (label, "L", (REL));		\
793      fprintf (FILE, "-");					\
794      assemble_name (FILE, label);				\
795      fprintf (FILE, "\n");					\
796    }								\
797  while (0)
798
799/* This is how to output an assembler line
800   that says to advance the location counter
801   to a multiple of 2**LOG bytes.  */
802
803#define ASM_OUTPUT_ALIGN(FILE,LOG)  \
804  fprintf (FILE, "\t.align %d\n", (LOG))
805
806/* This is how to output an assembler line
807   that says to advance the location counter by SIZE bytes.  */
808
809#define ASM_OUTPUT_SKIP(FILE,SIZE)  \
810  fprintf (FILE, "\t.space %u\n", (int)(SIZE))
811
812/* This says how to output an assembler line
813   to define a global common symbol.  */
814
815#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)	\
816  ( fputs (".comm ", (FILE)),				\
817    assemble_name ((FILE), (NAME)),			\
818    fprintf ((FILE), ",%u\n", (int)(ROUNDED)))
819
820/* This says how to output an assembler line
821   to define a local common symbol.  */
822
823#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)	\
824  ( fputs (".lcomm ", (FILE)),				\
825    assemble_name ((FILE), (NAME)),			\
826    fprintf ((FILE), ",%u\n", (int)(ROUNDED)))
827
828/* Store in OUTPUT a string (made with alloca) containing
829   an assembler-name for a local static variable named NAME.
830   LABELNO is an integer which is different for each call.  */
831
832#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)	\
833  ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10),	\
834    sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
835
836/* Print an instruction operand X on file FILE.
837   CODE is the code from the %-spec that requested printing this operand;
838   if `%z3' was used to print operand 3, then CODE is 'z'.
839
840VAX operand formatting codes:
841
842 letter	   print
843   C	reverse branch condition
844   D	64-bit immediate operand
845   B	the low 8 bits of the complement of a constant operand
846   H	the low 16 bits of the complement of a constant operand
847   M	a mask for the N highest bits of a word
848   N	the complement of a constant integer operand
849   P	constant operand plus 1
850   R	32 - constant operand
851   b	the low 8 bits of a negated constant operand
852   h	the low 16 bits of a negated constant operand
853   #	'd' or 'g' depending on whether dfloat or gfloat is used
854   |	register prefix  */
855
856/* The purpose of D is to get around a quirk or bug in VAX assembler
857   whereby -1 in a 64-bit immediate operand means 0x00000000ffffffff,
858   which is not a 64-bit minus one.  As a workaround, we output negative
859   values in hex.  */
860#if HOST_BITS_PER_WIDE_INT == 64
861#  define NEG_HWI_PRINT_HEX16 HOST_WIDE_INT_PRINT_HEX
862#else
863#  define NEG_HWI_PRINT_HEX16 "0xffffffff%08lx"
864#endif
865
866#define PRINT_OPERAND_PUNCT_VALID_P(CODE)				\
867  ((CODE) == '#' || (CODE) == '|')
868
869#define PRINT_OPERAND(FILE, X, CODE)					\
870{ if (CODE == '#') fputc (ASM_DOUBLE_CHAR, FILE);			\
871  else if (CODE == '|')							\
872    fputs (REGISTER_PREFIX, FILE);					\
873  else if (CODE == 'C')							\
874    fputs (rev_cond_name (X), FILE);					\
875  else if (CODE == 'D' && CONST_INT_P (X) && INTVAL (X) < 0)		\
876    fprintf (FILE, "$" NEG_HWI_PRINT_HEX16, INTVAL (X));		\
877  else if (CODE == 'P' && CONST_INT_P (X))				\
878    fprintf (FILE, "$" HOST_WIDE_INT_PRINT_DEC, INTVAL (X) + 1);	\
879  else if (CODE == 'N' && CONST_INT_P (X))				\
880    fprintf (FILE, "$" HOST_WIDE_INT_PRINT_DEC, ~ INTVAL (X));		\
881  /* rotl instruction cannot deal with negative arguments.  */		\
882  else if (CODE == 'R' && CONST_INT_P (X))				\
883    fprintf (FILE, "$" HOST_WIDE_INT_PRINT_DEC, 32 - INTVAL (X));	\
884  else if (CODE == 'H' && CONST_INT_P (X))				\
885    fprintf (FILE, "$%d", (int) (0xffff & ~ INTVAL (X)));		\
886  else if (CODE == 'h' && CONST_INT_P (X))				\
887    fprintf (FILE, "$%d", (short) - INTVAL (x));			\
888  else if (CODE == 'B' && CONST_INT_P (X))				\
889    fprintf (FILE, "$%d", (int) (0xff & ~ INTVAL (X)));			\
890  else if (CODE == 'b' && CONST_INT_P (X))				\
891    fprintf (FILE, "$%d", (int) (0xff & - INTVAL (X)));			\
892  else if (CODE == 'M' && CONST_INT_P (X))				\
893    fprintf (FILE, "$%d", ~((1 << INTVAL (x)) - 1));			\
894  else if (REG_P (X))							\
895    fprintf (FILE, "%s", reg_names[REGNO (X)]);				\
896  else if (MEM_P (X))							\
897    output_address (XEXP (X, 0));					\
898  else if (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == SFmode)	\
899    { char dstr[30];							\
900      real_to_decimal (dstr, CONST_DOUBLE_REAL_VALUE (X),		\
901		       sizeof (dstr), 0, 1);				\
902      fprintf (FILE, "$0f%s", dstr); }					\
903  else if (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == DFmode)	\
904    { char dstr[30];							\
905      real_to_decimal (dstr, CONST_DOUBLE_REAL_VALUE (X),		\
906		       sizeof (dstr), 0, 1);				\
907      fprintf (FILE, "$0%c%s", ASM_DOUBLE_CHAR, dstr); }		\
908  else { putc ('$', FILE); output_addr_const (FILE, X); }}
909
910/* Print a memory operand whose address is X, on file FILE.
911   This uses a function in output-vax.c.  */
912
913#define PRINT_OPERAND_ADDRESS(FILE, ADDR)  \
914  print_operand_address (FILE, ADDR)
915
916/* This is a blatent lie.  However, it's good enough, since we don't
917   actually have any code whatsoever for which this isn't overridden
918   by the proper FDE definition.  */
919#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, PC_REGNUM)
920
921