3a660a7557579baa8b0a425556a2ea20e5c5a230
[gcc.git] / gcc / config / i370 / i370.h
1 /* Definitions of target machine for GNU compiler. System/370 version.
2 Copyright (C) 1989, 1993, 1995, 1996 Free Software Foundation, Inc.
3 Contributed by Jan Stein (jan@cd.chalmers.se).
4 Modified for C/370 MVS by Dave Pitts (dpitts@nyx.cs.du.edu)
5
6 This file is part of GNU CC.
7
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.
12
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.
17
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. */
22
23 #ifdef sun
24 #include <sys/types.h>
25 #include <ctype.h>
26 #endif
27 #include <time.h>
28
29 #define TARGET_VERSION printf (" (370/MVS)");
30
31 /* Options for the preprocessor for this target machine. */
32
33 #define CPP_SPEC "-trigraphs"
34
35 /* Names to predefine in the preprocessor for this target machine. */
36
37 #define CPP_PREDEFINES "-DGCC -Dgcc -DMVS -Dmvs -Asystem(mvs) -Acpu(i370) -Amachine(i370)"
38
39 /* Run-time compilation parameters selecting different hardware subsets. */
40
41 extern int target_flags;
42
43 /* The sizes of the code and literals on the current page. */
44
45 extern int mvs_page_code, mvs_page_lit;
46
47 /* The current page number and the base page number for the function. */
48
49 extern int mvs_page_num, function_base_page;
50
51 /* True if a label has been emitted. */
52
53 extern int mvs_label_emitted;
54
55 /* The name of the current function. */
56
57 extern char *mvs_function_name;
58
59 /* The length of the function name malloc'd area. */
60
61 extern int mvs_function_name_length;
62
63 /* The amount of space used for outgoing arguments. */
64
65 extern int current_function_outgoing_args_size;
66
67 /* Compile using char instructions (mvc, nc, oc, xc). On 4341 use this since
68 these are more than twice as fast as load-op-store.
69 On 3090 don't use this since load-op-store is much faster. */
70
71 #define TARGET_CHAR_INSTRUCTIONS (target_flags & 1)
72
73 /* Default target switches */
74
75 #define TARGET_DEFAULT 1
76
77 /* Macro to define tables used to set the flags. This is a list in braces
78 of pairs in braces, each pair being { "NAME", VALUE }
79 where VALUE is the bits to set or minus the bits to clear.
80 An empty string NAME is used to identify the default VALUE. */
81
82 #define TARGET_SWITCHES \
83 { { "char-instructions", 1}, \
84 { "no-char-instructions", -1}, \
85 { "", TARGET_DEFAULT} }
86
87 /* To use IBM supplied macro function prologue and epilogue, define the
88 following to 1. Should only be needed if IBM changes the definition
89 of their prologue and epilogue. */
90
91 #define MACROPROLOGUE 0
92 #define MACROEPILOGUE 0
93
94 /* Target machine storage layout */
95
96 /* Define this if most significant bit is lowest numbered in instructions
97 that operate on numbered bit-fields. */
98
99 #define BITS_BIG_ENDIAN 1
100
101 /* Define this if most significant byte of a word is the lowest numbered. */
102
103 #define BYTES_BIG_ENDIAN 1
104
105 /* Define this if MS word of a multiword is the lowest numbered. */
106
107 #define WORDS_BIG_ENDIAN 1
108
109 /* Number of bits in an addressable storage unit. */
110
111 #define BITS_PER_UNIT 8
112
113 /* Width in bits of a "word", which is the contents of a machine register. */
114
115 #define BITS_PER_WORD 32
116
117 /* Width of a word, in units (bytes). */
118
119 #define UNITS_PER_WORD 4
120
121 /* Width in bits of a pointer. See also the macro `Pmode' defined below. */
122
123 #define POINTER_SIZE 32
124
125 /* Allocation boundary (in *bits*) for storing pointers in memory. */
126
127 #define POINTER_BOUNDARY 32
128
129 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
130
131 #define PARM_BOUNDARY 32
132
133 /* Boundary (in *bits*) on which stack pointer should be aligned. */
134
135 #define STACK_BOUNDARY 32
136
137 /* Allocation boundary (in *bits*) for the code of a function. */
138
139 #define FUNCTION_BOUNDARY 32
140
141 /* There is no point aligning anything to a rounder boundary than this. */
142
143 #define BIGGEST_ALIGNMENT 64
144
145 /* Alignment of field after `int : 0' in a structure. */
146
147 #define EMPTY_FIELD_BOUNDARY 32
148
149 /* Define this if move instructions will actually fail to work when given
150 unaligned data. */
151
152 #define STRICT_ALIGNMENT 0
153
154 /* Define target floating point format. */
155
156 #define TARGET_FLOAT_FORMAT IBM_FLOAT_FORMAT
157
158 /* Define character mapping for cross-compiling. */
159
160 #define TARGET_EBCDIC 1
161
162 #ifdef HOST_EBCDIC
163 #define MAP_CHARACTER(c) ((char)(c))
164 #else
165 #define MAP_CHARACTER(c) ((char)mvs_map_char (c))
166 #endif
167
168 /* Define maximum length of page minus page escape overhead. */
169
170 #define MAX_MVS_PAGE_LENGTH 4080
171
172 /* Define if special allocation order desired. */
173
174 #define REG_ALLOC_ORDER \
175 { 0, 1, 2, 3, 14, 15, 12, 10, 9, 8, 7, 6, 5, 4, 16, 17, 18, 19, 11, 13 }
176
177 /* Standard register usage. */
178
179 /* Number of actual hardware registers. The hardware registers are
180 assigned numbers for the compiler from 0 to just below
181 FIRST_PSEUDO_REGISTER.
182 All registers that the compiler knows about must be given numbers,
183 even those that are not normally considered general registers.
184 For the 370, we give the data registers numbers 0-15,
185 and the floating point registers numbers 16-19. */
186
187 #define FIRST_PSEUDO_REGISTER 20
188
189 /* Define base and page registers. */
190
191 #define BASE_REGISTER 3
192 #define PAGE_REGISTER 4
193
194 /* 1 for registers that have pervasive standard uses and are not available
195 for the register allocator. On the 370 under C/370, R13 is stack (DSA)
196 pointer, R12 is the TCA pointer, R3 is the base register, R4 is the page
197 origin table pointer and R11 is the arg pointer. */
198
199 #define FIXED_REGISTERS \
200 { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0 }
201 /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19*/
202
203 /* 1 for registers not available across function calls. These must include
204 the FIXED_REGISTERS and also any registers that can be used without being
205 saved.
206 The latter must include the registers where values are returned
207 and the register where structure-value addresses are passed.
208 NOTE: all floating registers are undefined across calls. */
209
210 #define CALL_USED_REGISTERS \
211 { 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
212 /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19*/
213
214 /* Return number of consecutive hard regs needed starting at reg REGNO
215 to hold something of mode MODE.
216 This is ordinarily the length in words of a value of mode MODE
217 but can be less for certain modes in special long registers. */
218
219 #define HARD_REGNO_NREGS(REGNO, MODE) \
220 ((REGNO) > 15 ? 1 : (GET_MODE_SIZE(MODE)+UNITS_PER_WORD-1) / UNITS_PER_WORD)
221
222 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
223 On the 370, the cpu registers can hold QI, HI, SI, SF and DF. The
224 even registers can hold DI. The floating point registers can hold
225 either SF or DF. */
226
227 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
228 ((REGNO) < 16 ? ((REGNO) & 1) == 0 || (MODE) != DImode \
229 : (MODE) == SFmode || (MODE) == DFmode)
230
231 /* Value is 1 if it is a good idea to tie two pseudo registers when one has
232 mode MODE1 and one has mode MODE2.
233 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
234 for any hard reg, then this must be 0 for correct output. */
235
236 #define MODES_TIEABLE_P(MODE1, MODE2) \
237 (((MODE1) == SFmode || (MODE1) == DFmode) \
238 == ((MODE2) == SFmode || (MODE2) == DFmode))
239
240 /* Mark external references. */
241
242 #define ENCODE_SECTION_INFO(decl) \
243 if (DECL_EXTERNAL (decl) && TREE_PUBLIC (decl)) \
244 SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
245
246 /* Specify the registers used for certain standard purposes.
247 The values of these macros are register numbers. */
248
249 /* 370 PC isn't overloaded on a register. */
250
251 /* #define PC_REGNUM */
252
253 /* Register to use for pushing function arguments. */
254
255 #define STACK_POINTER_REGNUM 13
256
257 /* Base register for access to local variables of the function. */
258
259 #define FRAME_POINTER_REGNUM 13
260
261 /* Value should be nonzero if functions must have frame pointers.
262 Zero means the frame pointer need not be set up (and parms may be
263 accessed via the stack pointer) in functions that seem suitable.
264 This is computed in `reload', in reload1.c. */
265
266 #define FRAME_POINTER_REQUIRED 1
267
268 /* Base register for access to arguments of the function. */
269
270 #define ARG_POINTER_REGNUM 11
271
272 /* Register in which static-chain is passed to a function. */
273
274 #define STATIC_CHAIN_REGNUM 10
275
276 /* Register in which address to store a structure value is passed to
277 a function. */
278
279 #define STRUCT_VALUE_REGNUM 1
280
281 /* Define the classes of registers for register constraints in the
282 machine description. Also define ranges of constants.
283
284 One of the classes must always be named ALL_REGS and include all hard regs.
285 If there is more than one class, another class must be named NO_REGS
286 and contain no registers.
287
288 The name GENERAL_REGS must be the name of a class (or an alias for
289 another name such as ALL_REGS). This is the class of registers
290 that is allowed by "g" or "r" in a register constraint.
291 Also, registers outside this class are allocated only when
292 instructions express preferences for them.
293
294 The classes must be numbered in nondecreasing order; that is,
295 a larger-numbered class must never be contained completely
296 in a smaller-numbered class.
297
298 For any two classes, it is very desirable that there be another
299 class that represents their union. */
300
301 enum reg_class
302 {
303 NO_REGS, ADDR_REGS, DATA_REGS,
304 FP_REGS, ALL_REGS, LIM_REG_CLASSES
305 };
306
307 #define GENERAL_REGS DATA_REGS
308 #define N_REG_CLASSES (int) LIM_REG_CLASSES
309
310 /* Give names of register classes as strings for dump file. */
311
312 #define REG_CLASS_NAMES \
313 { "NO_REGS", "ADDR_REGS", "DATA_REGS", "FP_REGS", "ALL_REGS" }
314
315 /* Define which registers fit in which classes. This is an initializer for
316 a vector of HARD_REG_SET of length N_REG_CLASSES. */
317
318 #define REG_CLASS_CONTENTS {0, 0x0fffe, 0x0ffff, 0xf0000, 0xfffff}
319
320 /* The same information, inverted:
321 Return the class number of the smallest class containing
322 reg number REGNO. This could be a conditional expression
323 or could index an array. */
324
325 #define REGNO_REG_CLASS(REGNO) \
326 ((REGNO) >= 16 ? FP_REGS : (REGNO) != 0 ? ADDR_REGS : DATA_REGS)
327
328 /* The class value for index registers, and the one for base regs. */
329
330 #define INDEX_REG_CLASS ADDR_REGS
331 #define BASE_REG_CLASS ADDR_REGS
332
333 /* Get reg_class from a letter such as appears in the machine description. */
334
335 #define REG_CLASS_FROM_LETTER(C) \
336 ((C) == 'a' ? ADDR_REGS : \
337 ((C) == 'd' ? DATA_REGS : \
338 ((C) == 'f' ? FP_REGS : NO_REGS)))
339
340 /* The letters I, J, K, L and M in a register constraint string can be used
341 to stand for particular ranges of immediate operands.
342 This macro defines what the ranges are.
343 C is the letter, and VALUE is a constant value.
344 Return 1 if VALUE is in the range specified by C. */
345
346 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
347 ((C) == 'I' ? (unsigned) (VALUE) < 256 : \
348 (C) == 'J' ? (unsigned) (VALUE) < 4096 : \
349 (C) == 'K' ? (VALUE) >= -32768 && (VALUE) < 32768 : 0)
350
351 /* Similar, but for floating constants, and defining letters G and H.
352 Here VALUE is the CONST_DOUBLE rtx itself. */
353
354 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 1
355
356 /* Given an rtx X being reloaded into a reg required to be in class CLASS,
357 return the class of reg to actually use. In general this is just CLASS;
358 but on some machines in some cases it is preferable to use a more
359 restrictive class. */
360
361 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
362 (GET_CODE(X) == CONST_DOUBLE ? FP_REGS : \
363 GET_CODE(X) == CONST_INT ? DATA_REGS : \
364 GET_CODE(X) == LABEL_REF || \
365 GET_CODE(X) == SYMBOL_REF || \
366 GET_CODE(X) == CONST ? ADDR_REGS : (CLASS))
367
368 /* Return the maximum number of consecutive registers needed to represent
369 mode MODE in a register of class CLASS. */
370
371 #define CLASS_MAX_NREGS(CLASS, MODE) \
372 ((CLASS) == FP_REGS ? 1 : \
373 (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
374
375 /* Stack layout; function entry, exit and calling. */
376
377 /* Define this if pushing a word on the stack makes the stack pointer a
378 smaller address. */
379
380 /* #define STACK_GROWS_DOWNWARD */
381
382 /* Define this if the nominal address of the stack frame is at the
383 high-address end of the local variables; that is, each additional local
384 variable allocated goes at a more negative offset in the frame. */
385
386 /* #define FRAME_GROWS_DOWNWARD */
387
388 /* Offset within stack frame to start allocating local variables at.
389 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
390 first local allocated. Otherwise, it is the offset to the BEGINNING
391 of the first local allocated. */
392
393 #define STARTING_FRAME_OFFSET \
394 (STACK_POINTER_OFFSET + current_function_outgoing_args_size)
395
396 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = STARTING_FRAME_OFFSET
397
398 /* If we generate an insn to push BYTES bytes, this says how many the stack
399 pointer really advances by. On the 370, we have no push instruction. */
400
401 /* #define PUSH_ROUNDING(BYTES) */
402
403 /* Accumulate the outgoing argument count so we can request the right
404 DSA size and determine stack offset. */
405
406 #define ACCUMULATE_OUTGOING_ARGS
407
408 /* Define offset from stack pointer, to location where a parm can be
409 pushed. */
410
411 #define STACK_POINTER_OFFSET 148
412
413 /* Offset of first parameter from the argument pointer register value. */
414
415 #define FIRST_PARM_OFFSET(FNDECL) 0
416
417 /* 1 if N is a possible register number for function argument passing.
418 On the 370, no registers are used in this way. */
419
420 #define FUNCTION_ARG_REGNO_P(N) 0
421
422 /* Define a data type for recording info about an argument list during
423 the scan of that argument list. This data type should hold all
424 necessary information about the function itself and about the args
425 processed so far, enough to enable macros such as FUNCTION_ARG to
426 determine where the next arg should go. */
427
428 #define CUMULATIVE_ARGS int
429
430 /* Initialize a variable CUM of type CUMULATIVE_ARGS for a call to
431 a function whose data type is FNTYPE.
432 For a library call, FNTYPE is 0. */
433
434 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME) ((CUM) = 0)
435
436 /* Update the data in CUM to advance over an argument of mode MODE and
437 data type TYPE. (TYPE is null for libcalls where that information
438 may not be available.) */
439
440 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
441 ((CUM) += ((MODE) == DFmode || (MODE) == SFmode \
442 ? 256 \
443 : (MODE) != BLKmode \
444 ? (GET_MODE_SIZE (MODE) + 3) / 4 \
445 : (int_size_in_bytes (TYPE) + 3) / 4))
446
447 /* Define where to put the arguments to a function. Value is zero to push
448 the argument on the stack, or a hard register in which to store the
449 argument. */
450
451 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) 0
452
453 /* For an arg passed partly in registers and partly in memory, this is the
454 number of registers used. For args passed entirely in registers or
455 entirely in memory, zero. */
456
457 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0
458
459 /* Define if returning from a function call automatically pops the
460 arguments described by the number-of-args field in the call. */
461
462 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
463
464 /* Define how to find the value returned by a function. VALTYPE is the
465 data type of the value (as a tree).
466 If the precise function being called is known, FUNC is its FUNCTION_DECL;
467 otherwise, FUNC is 15. */
468
469 #define RET_REG(MODE) ((MODE) == DFmode || (MODE) == SFmode ? 16 : 15)
470
471 /* On the 370 the return value is in R15 or R16. */
472
473 #define FUNCTION_VALUE(VALTYPE, FUNC) \
474 gen_rtx(REG, TYPE_MODE (VALTYPE), RET_REG(TYPE_MODE(VALTYPE)))
475
476 /* Define how to find the value returned by a library function assuming
477 the value has mode MODE. */
478
479 #define LIBCALL_VALUE(MODE) gen_rtx(REG, MODE, RET_REG(MODE))
480
481 /* 1 if N is a possible register number for a function value.
482 On the 370 under C/370, R15 and R16 are thus used. */
483
484 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 15 || (N) == 16)
485
486 /* This macro definition sets up a default value for `main' to return. */
487
488 #define DEFAULT_MAIN_RETURN c_expand_return (integer_zero_node)
489
490 /* This macro generates the assembly code for function entry.
491 All of the C/370 environment is preserved. */
492
493 #if MACROPROLOGUE == 1
494 #define FUNCTION_PROLOGUE(FILE, LSIZE) \
495 { \
496 fprintf (FILE, "\tEDCPRLG USRDSAL=%d,BASEREG=%d\n", \
497 STACK_POINTER_OFFSET + LSIZE - 120 + \
498 current_function_outgoing_args_size, BASE_REGISTER); \
499 fprintf (FILE, "PG%d\tEQU\t*\n", mvs_page_num ); \
500 fprintf (FILE, "\tLR\t11,1\n"); \
501 fprintf (FILE, "\tL\t%d,=A(PGT%d)\n", PAGE_REGISTER, mvs_page_num); \
502 mvs_page_code = 6; \
503 mvs_page_lit = 4; \
504 mvs_check_page (FILE, 0, 0); \
505 function_base_page = mvs_page_num; \
506 }
507 #else /* MACROPROLOGUE != 1 */
508 #define FUNCTION_PROLOGUE(FILE, LSIZE) \
509 { \
510 static int function_label_index = 1; \
511 static int function_first = 0; \
512 static int function_year, function_month, function_day; \
513 static int function_hour, function_minute, function_second; \
514 int i; \
515 if (!function_first) \
516 { \
517 struct tm *function_time; \
518 time_t lcltime; \
519 time (&lcltime); \
520 function_time = localtime (&lcltime); \
521 function_year = function_time->tm_year + 1900; \
522 function_month = function_time->tm_mon + 1; \
523 function_day = function_time->tm_mday; \
524 function_hour = function_time->tm_hour; \
525 function_minute = function_time->tm_min; \
526 function_second = function_time->tm_sec; \
527 fprintf (FILE, "PPA2\tDS\t0F\n"); \
528 fprintf (FILE, "\tDC\tX'03',X'00',X'33',X'00'\n"); \
529 fprintf (FILE, "\tDC\tV(CEESTART),A(0)\n"); \
530 fprintf (FILE, "\tDC\tA(CEETIMES)\n"); \
531 fprintf (FILE, "CEETIMES\tDS\t0F\n"); \
532 fprintf (FILE, "\tDC\tCL4'%d',CL4'%02d%02d',CL6'%02d%02d00'\n", \
533 function_year, function_month, function_day, \
534 function_hour, function_minute, function_second); \
535 fprintf (FILE, "\tDC\tCL2'01',CL4'0100'\n"); \
536 } \
537 fprintf (FILE, "$DSD%03d\tDSECT\n", function_label_index); \
538 fprintf (FILE, "\tDS\tD\n"); \
539 fprintf (FILE, "\tDS\tCL(%d)\n", STACK_POINTER_OFFSET + LSIZE \
540 + current_function_outgoing_args_size); \
541 fprintf (FILE, "\tORG\t$DSD%03d\n", function_label_index); \
542 fprintf (FILE, "\tDS\tCL(120+8)\n"); \
543 fprintf (FILE, "\tORG\n"); \
544 fprintf (FILE, "\tDS\t0D\n"); \
545 fprintf (FILE, "$DSL%03d\tEQU\t*-$DSD%03d-8\n", function_label_index, \
546 function_label_index); \
547 fprintf (FILE, "\tDS\t0H\n"); \
548 assemble_name (FILE, mvs_function_name); \
549 fprintf (FILE, "\tEQU\t*\n"); \
550 fprintf (FILE, "\tUSING\t*,15\n"); \
551 fprintf (FILE, "\tB\tFPL%03d\n", function_label_index); \
552 fprintf (FILE, "\tDC\tAL1(FPL%03d+4-*)\n", function_label_index + 1); \
553 fprintf (FILE, "\tDC\tX'CE',X'A0',AL1(16)\n"); \
554 fprintf (FILE, "\tDC\tAL4(PPA2)\n"); \
555 fprintf (FILE, "\tDC\tAL4(0)\n"); \
556 fprintf (FILE, "\tDC\tAL4($DSL%03d)\n", function_label_index); \
557 fprintf (FILE, "FPL%03d\tEQU\t*\n", function_label_index + 1); \
558 fprintf (FILE, "\tDC\tAL2(%d),C'%s'\n", strlen (mvs_function_name), \
559 mvs_function_name); \
560 fprintf (FILE, "FPL%03d\tDS\t0H\n", function_label_index); \
561 fprintf (FILE, "\tSTM\t14,12,12(13)\n"); \
562 fprintf (FILE, "\tL\t2,76(,13)\n"); \
563 fprintf (FILE, "\tL\t0,16(,15)\n"); \
564 fprintf (FILE, "\tALR\t0,2\n"); \
565 fprintf (FILE, "\tCL\t0,12(,12)\n"); \
566 fprintf (FILE, "\tBNH\t*+10\n"); \
567 fprintf (FILE, "\tL\t15,116(,12)\n"); \
568 fprintf (FILE, "\tBALR\t14,15\n"); \
569 fprintf (FILE, "\tL\t15,72(,13)\n"); \
570 fprintf (FILE, "\tSTM\t15,0,72(2)\n"); \
571 fprintf (FILE, "\tMVI\t0(2),X'10'\n"); \
572 fprintf (FILE, "\tST\t2,8(,13)\n "); \
573 fprintf (FILE, "\tST\t13,4(,2)\n "); \
574 fprintf (FILE, "\tLR\t13,2\n"); \
575 fprintf (FILE, "\tDROP\t15\n"); \
576 fprintf (FILE, "\tBALR\t%d,0\n", BASE_REGISTER); \
577 fprintf (FILE, "PG%d\tEQU\t*\n", mvs_page_num ); \
578 fprintf (FILE, "\tUSING\t*,%d\n", BASE_REGISTER); \
579 fprintf (FILE, "\tLR\t11,1\n"); \
580 fprintf (FILE, "\tL\t%d,=A(PGT%d)\n", PAGE_REGISTER, mvs_page_num); \
581 mvs_page_code = 4; \
582 mvs_page_lit = 4; \
583 mvs_check_page (FILE, 0, 0); \
584 function_base_page = mvs_page_num; \
585 function_first = 1; \
586 function_label_index += 2; \
587 }
588 #endif /* MACROPROLOGUE */
589
590 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
591 { \
592 if (strlen (NAME) * 2 > mvs_function_name_length) \
593 { \
594 if (mvs_function_name) \
595 free (mvs_function_name); \
596 mvs_function_name = 0; \
597 } \
598 if (!mvs_function_name) \
599 { \
600 mvs_function_name_length = strlen (NAME) * 2; \
601 mvs_function_name = (char *) malloc (mvs_function_name_length); \
602 if (mvs_function_name == 0) \
603 { \
604 fatal ("virtual memory exceeded"); \
605 abort (); \
606 } \
607 } \
608 if (!strcmp (NAME, "main")) \
609 strcpy (mvs_function_name, "gccmain"); \
610 else \
611 strcpy (mvs_function_name, NAME); \
612 fprintf (FILE, "\tDS\t0F\n"); \
613 assemble_name (FILE, mvs_function_name); \
614 fputs ("\tEQU\t*\n", FILE); \
615 fputs ("\tENTRY\t", FILE); \
616 assemble_name (FILE, mvs_function_name); \
617 fputc ('\n', FILE); \
618 }
619
620 /* This macro generates the assembly code for function exit, on machines
621 that need it. If FUNCTION_EPILOGUE is not defined then individual
622 return instructions are generated for each return statement. Args are
623 same as for FUNCTION_PROLOGUE.
624
625 The function epilogue should not depend on the current stack pointer!
626 It should use the frame pointer only. This is mandatory because
627 of alloca; we also take advantage of it to omit stack adjustments
628 before returning. */
629
630 #if MACROEPILOGUE == 1
631 #define FUNCTION_EPILOGUE(FILE, LSIZE) \
632 { \
633 int i; \
634 check_label_emit(); \
635 mvs_check_page (FILE,14,0); \
636 fprintf (FILE, "\tEDCEPIL\n"); \
637 mvs_page_num++; \
638 fprintf (FILE, "\tDS\t0F\n" ); \
639 fprintf (FILE, "\tLTORG\n"); \
640 fprintf (FILE, "\tDS\t0F\n"); \
641 fprintf (FILE, "PGT%d\tEQU\t*\n", function_base_page); \
642 mvs_free_label(); \
643 for ( i = function_base_page; i < mvs_page_num; i++ ) \
644 fprintf (FILE, "\tDC\tA(PG%d)\n", i); \
645 }
646 #else /* MACROEPILOGUE != 1 */
647 #define FUNCTION_EPILOGUE(FILE, LSIZE) \
648 { \
649 int i; \
650 check_label_emit(); \
651 mvs_check_page (FILE,14,0); \
652 fprintf (FILE, "\tL\t13,4(,13)\n"); \
653 fprintf (FILE, "\tL\t14,12(,13)\n"); \
654 fprintf (FILE, "\tLM\t2,12,28(13)\n"); \
655 fprintf (FILE, "\tBALR\t1,14\n"); \
656 fprintf (FILE, "\tDC\tA("); \
657 mvs_page_num++; \
658 assemble_name (FILE, mvs_function_name); \
659 fprintf (FILE, ")\n" ); \
660 fprintf (FILE, "\tDS\t0F\n" ); \
661 fprintf (FILE, "\tLTORG\n"); \
662 fprintf (FILE, "\tDS\t0F\n"); \
663 fprintf (FILE, "PGT%d\tEQU\t*\n", function_base_page); \
664 mvs_free_label(); \
665 for ( i = function_base_page; i < mvs_page_num; i++ ) \
666 fprintf (FILE, "\tDC\tA(PG%d)\n", i); \
667 }
668 #endif /* MACROEPILOGUE */
669
670
671 /* Output assembler code for a block containing the constant parts of a
672 trampoline, leaving space for the variable parts.
673
674 On the 370, the trampoline contains these instructions:
675
676 BALR 14,0
677 USING *,14
678 L STATIC_CHAIN_REGISTER,X
679 L 15,Y
680 BR 15
681 X DS 0F
682 Y DS 0F */
683
684 #define TRAMPOLINE_TEMPLATE(FILE) \
685 { \
686 ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x05E0)); \
687 ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x5800 | \
688 STATIC_CHAIN_REGNUM << 4)); \
689 ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0xE00A)); \
690 ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x58F0)); \
691 ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0xE00E)); \
692 ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x07FF)); \
693 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
694 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
695 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
696 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
697 }
698
699 /* Length in units of the trampoline for entering a nested function. */
700
701 #define TRAMPOLINE_SIZE 20
702
703 /* Emit RTL insns to initialize the variable parts of a trampoline. */
704
705 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
706 { \
707 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 12)), CXT); \
708 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 16)), FNADDR); \
709 }
710
711 /* Output assembler code to FILE to increment profiler label # LABELNO
712 for profiling a function entry. */
713
714 #define FUNCTION_PROFILER(FILE, LABELNO) \
715 fprintf (FILE, "Error: No profiling available.\n")
716
717 /* Define EXIT_IGNORE_STACK if, when returning from a function, the stack
718 pointer does not matter (provided there is a frame pointer). */
719
720 #define EXIT_IGNORE_STACK 1
721
722 /* Addressing modes, and classification of registers for them. */
723
724 /* #define HAVE_POST_INCREMENT */
725 /* #define HAVE_POST_DECREMENT */
726
727 /* #define HAVE_PRE_DECREMENT */
728 /* #define HAVE_PRE_INCREMENT */
729
730 /* These assume that REGNO is a hard or pseudo reg number. They give
731 nonzero only if REGNO is a hard reg of the suitable class or a pseudo
732 reg currently allocated to a suitable hard reg.
733 These definitions are NOT overridden anywhere. */
734
735 #define REGNO_OK_FOR_INDEX_P(REGNO) \
736 (((REGNO) > 0 && (REGNO) < 16) \
737 || (reg_renumber[REGNO] > 0 && reg_renumber[REGNO] < 16))
738
739 #define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_INDEX_P(REGNO)
740
741 #define REGNO_OK_FOR_DATA_P(REGNO) \
742 ((REGNO) < 16 || (unsigned) reg_renumber[REGNO] < 16)
743
744 #define REGNO_OK_FOR_FP_P(REGNO) \
745 ((unsigned) ((REGNO) - 16) < 4 || (unsigned) (reg_renumber[REGNO] - 16) < 4)
746
747 /* Now macros that check whether X is a register and also,
748 strictly, whether it is in a specified class. */
749
750 /* 1 if X is a data register. */
751
752 #define DATA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_DATA_P (REGNO (X)))
753
754 /* 1 if X is an fp register. */
755
756 #define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X)))
757
758 /* 1 if X is an address register. */
759
760 #define ADDRESS_REG_P(X) (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X)))
761
762 /* Maximum number of registers that can appear in a valid memory address. */
763
764 #define MAX_REGS_PER_ADDRESS 2
765
766 /* Recognize any constant value that is a valid address. */
767
768 #define CONSTANT_ADDRESS_P(X) \
769 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
770 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST_DOUBLE \
771 || (GET_CODE (X) == CONST \
772 && GET_CODE (XEXP (XEXP (X, 0), 0)) == LABEL_REF) \
773 || (GET_CODE (X) == CONST \
774 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF \
775 && !SYMBOL_REF_FLAG (XEXP (XEXP (X, 0), 0))))
776
777 /* Nonzero if the constant value X is a legitimate general operand.
778 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
779
780 #define LEGITIMATE_CONSTANT_P(X) 1
781
782 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx and check
783 its validity for a certain class. We have two alternate definitions
784 for each of them. The usual definition accepts all pseudo regs; the
785 other rejects them all. The symbol REG_OK_STRICT causes the latter
786 definition to be used.
787
788 Most source files want to accept pseudo regs in the hope that they will
789 get allocated to the class that the insn wants them to be in.
790 Some source files that are used after register allocation
791 need to be strict. */
792
793 #ifndef REG_OK_STRICT
794
795 /* Nonzero if X is a hard reg that can be used as an index or if it is
796 a pseudo reg. */
797
798 #define REG_OK_FOR_INDEX_P(X) \
799 ((REGNO(X) > 0 && REGNO(X) < 16) || REGNO(X) >= 20)
800
801 /* Nonzero if X is a hard reg that can be used as a base reg or if it is
802 a pseudo reg. */
803
804 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_INDEX_P(X)
805
806 #else /* REG_OK_STRICT */
807
808 /* Nonzero if X is a hard reg that can be used as an index. */
809
810 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P(REGNO(X))
811
812 /* Nonzero if X is a hard reg that can be used as a base reg. */
813
814 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P(REGNO(X))
815
816 #endif /* REG_OK_STRICT */
817
818 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression that is a
819 valid memory address for an instruction.
820 The MODE argument is the machine mode for the MEM expression
821 that wants to use this address.
822
823 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
824 except for CONSTANT_ADDRESS_P which is actually machine-independent. */
825
826 #define COUNT_REGS(X, REGS, FAIL) \
827 if (REG_P (X) && REG_OK_FOR_BASE_P (X)) \
828 REGS += 1; \
829 else if (GET_CODE (X) != CONST_INT || (unsigned) INTVAL (X) >= 4096) \
830 goto FAIL;
831
832 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
833 { \
834 if (REG_P (X) && REG_OK_FOR_BASE_P (X)) \
835 goto ADDR; \
836 if (GET_CODE (X) == PLUS) \
837 { \
838 int regs = 0; \
839 rtx x0 = XEXP (X, 0); \
840 rtx x1 = XEXP (X, 1); \
841 if (GET_CODE (x0) == PLUS) \
842 { \
843 COUNT_REGS (XEXP (x0, 0), regs, FAIL); \
844 COUNT_REGS (XEXP (x0, 1), regs, FAIL); \
845 COUNT_REGS (x1, regs, FAIL); \
846 if (regs == 2) \
847 goto ADDR; \
848 } \
849 else if (GET_CODE (x1) == PLUS) \
850 { \
851 COUNT_REGS (x0, regs, FAIL); \
852 COUNT_REGS (XEXP (x1, 0), regs, FAIL); \
853 COUNT_REGS (XEXP (x1, 1), regs, FAIL); \
854 if (regs == 2) \
855 goto ADDR; \
856 } \
857 else \
858 { \
859 COUNT_REGS (x0, regs, FAIL); \
860 COUNT_REGS (x1, regs, FAIL); \
861 if (regs != 0) \
862 goto ADDR; \
863 } \
864 } \
865 FAIL: ; \
866 }
867
868 /* The 370 has no mode dependent addresses. */
869
870 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)
871
872 /* Try machine-dependent ways of modifying an illegitimate address
873 to be legitimate. If we find one, return the new, valid address.
874 This macro is used in only one place: `memory_address' in explow.c. */
875
876 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
877 { \
878 if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
879 (X) = gen_rtx (PLUS, SImode, XEXP (X, 0), \
880 copy_to_mode_reg (SImode, XEXP (X, 1))); \
881 if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \
882 (X) = gen_rtx (PLUS, SImode, XEXP (X, 1), \
883 copy_to_mode_reg (SImode, XEXP (X, 0))); \
884 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT) \
885 (X) = gen_rtx (PLUS, SImode, XEXP (X, 1), \
886 force_operand (XEXP (X, 0), 0)); \
887 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT) \
888 (X) = gen_rtx (PLUS, SImode, XEXP (X, 0), \
889 force_operand (XEXP (X, 1), 0)); \
890 if (memory_address_p (MODE, X)) \
891 goto WIN; \
892 }
893
894 /* Specify the machine mode that this machine uses for the index in the
895 tablejump instruction. */
896
897 #define CASE_VECTOR_MODE SImode
898
899 /* Define this if the tablejump instruction expects the table to contain
900 offsets from the address of the table.
901 Do not define this if the table should contain absolute addresses. */
902
903 /* #define CASE_VECTOR_PC_RELATIVE */
904
905 /* Specify the tree operation to be used to convert reals to integers. */
906
907 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
908
909 /* Define this if fixuns_trunc is the same as fix_trunc. */
910
911 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
912
913 /* We use "unsigned char" as default. */
914
915 #define DEFAULT_SIGNED_CHAR 0
916
917 /* This is the kind of divide that is easiest to do in the general case. */
918
919 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
920
921 /* Max number of bytes we can move from memory to memory in one reasonably
922 fast instruction. */
923
924 #define MOVE_MAX 256
925
926 /* Define this if zero-extension is slow (more than one real instruction). */
927
928 #define SLOW_ZERO_EXTEND
929
930 /* Nonzero if access to memory by bytes is slow and undesirable. */
931
932 #define SLOW_BYTE_ACCESS 1
933
934 /* Define if shifts truncate the shift count which implies one can omit
935 a sign-extension or zero-extension of a shift count. */
936
937 /* #define SHIFT_COUNT_TRUNCATED */
938
939 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
940 is done just by pretending it is already truncated. */
941
942 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) (OUTPREC != 16)
943
944 /* We assume that the store-condition-codes instructions store 0 for false
945 and some other value for true. This is the value stored for true. */
946
947 /* #define STORE_FLAG_VALUE -1 */
948
949 /* When a prototype says `char' or `short', really pass an `int'. */
950
951 #define PROMOTE_PROTOTYPES
952
953 /* Don't perform CSE on function addresses. */
954
955 #define NO_FUNCTION_CSE
956
957 /* Specify the machine mode that pointers have.
958 After generation of rtl, the compiler makes no further distinction
959 between pointers and any other objects of this machine mode. */
960
961 #define Pmode SImode
962
963 /* A function address in a call instruction is a byte address (for
964 indexing purposes) so give the MEM rtx a byte's mode. */
965
966 #define FUNCTION_MODE QImode
967
968 /* Compute the cost of computing a constant rtl expression RTX whose
969 rtx-code is CODE. The body of this macro is a portion of a switch
970 statement. If the code is computed here, return it with a return
971 statement. Otherwise, break from the switch. */
972
973 #define CONST_COSTS(RTX, CODE, OUTERCODE) \
974 case CONST_INT: \
975 if ((unsigned) INTVAL (RTX) < 0xfff) return 1; \
976 case CONST: \
977 case LABEL_REF: \
978 case SYMBOL_REF: \
979 return 2; \
980 case CONST_DOUBLE: \
981 return 4;
982
983 /* Tell final.c how to eliminate redundant test instructions. */
984
985 /* Here we define machine-dependent flags and fields in cc_status
986 (see `conditions.h'). */
987
988 /* Store in cc_status the expressions that the condition codes will
989 describe after execution of an instruction whose pattern is EXP.
990 Do not alter them if the instruction would not alter the cc's.
991
992 On the 370, load insns do not alter the cc's. However, in some
993 cases these instructions can make it possibly invalid to use the
994 saved cc's. In those cases we clear out some or all of the saved
995 cc's so they won't be used. */
996
997 #define NOTICE_UPDATE_CC(EXP, INSN) \
998 { \
999 rtx exp = (EXP); \
1000 if (GET_CODE (exp) == PARALLEL) /* Check this */ \
1001 exp = XVECEXP (exp, 0, 0); \
1002 if (GET_CODE (exp) != SET) \
1003 CC_STATUS_INIT; \
1004 else \
1005 { \
1006 if (XEXP (exp, 0) == cc0_rtx) \
1007 { \
1008 cc_status.value1 = XEXP (exp, 0); \
1009 cc_status.value2 = XEXP (exp, 1); \
1010 cc_status.flags = 0; \
1011 } \
1012 else \
1013 { \
1014 if (cc_status.value1 \
1015 && reg_mentioned_p (XEXP (exp, 0), cc_status.value1)) \
1016 cc_status.value1 = 0; \
1017 if (cc_status.value2 \
1018 && reg_mentioned_p (XEXP (exp, 0), cc_status.value2)) \
1019 cc_status.value2 = 0; \
1020 switch (GET_CODE (XEXP (exp, 1))) \
1021 { \
1022 case PLUS: case MINUS: case MULT: /* case UMULT: */ \
1023 case DIV: case UDIV: case NEG: case ASHIFT: \
1024 case ASHIFTRT: case AND: case IOR: case XOR: \
1025 case ABS: case NOT: \
1026 CC_STATUS_SET (XEXP (exp, 0), XEXP (exp, 1)); \
1027 } \
1028 } \
1029 } \
1030 }
1031
1032
1033 #define CC_STATUS_SET(V1, V2) \
1034 { \
1035 cc_status.flags = 0; \
1036 cc_status.value1 = (V1); \
1037 cc_status.value2 = (V2); \
1038 if (cc_status.value1 \
1039 && reg_mentioned_p (cc_status.value1, cc_status.value2)) \
1040 cc_status.value2 = 0; \
1041 }
1042
1043 #define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \
1044 { if (cc_status.flags & CC_NO_OVERFLOW) return NO_OV; return NORMAL; }
1045
1046 /* Control the assembler format that we output. */
1047
1048 #define TEXT_SECTION_ASM_OP "* Program text area"
1049 #define DATA_SECTION_ASM_OP "* Program data area"
1050 #define INIT_SECTION_ASM_OP "* Program initialization area"
1051 #define CTOR_LIST_BEGIN /* NO OP */
1052 #define CTOR_LIST_END /* NO OP */
1053
1054 /* How to refer to registers in assembler output. This sequence is
1055 indexed by compiler's hard-register-number (see above). */
1056
1057 #define REGISTER_NAMES \
1058 { "0", "1", "2", "3", "4", "5", "6", "7", \
1059 "8", "9", "10", "11", "12", "13", "14", "15", \
1060 "0", "2", "4", "6" \
1061 }
1062
1063 /* How to renumber registers for dbx and gdb. */
1064
1065 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
1066
1067 #define ASM_FILE_START(FILE) fputs ("\tCSECT\n", FILE);
1068 #define ASM_FILE_END(FILE) fputs ("\tEND\n", FILE);
1069 #define ASM_IDENTIFY_GCC(FILE)
1070 #define ASM_COMMENT_START "*"
1071 #define ASM_APP_OFF ""
1072 #define ASM_APP_ON ""
1073
1074 #define ASM_OUTPUT_LABEL(FILE, NAME) \
1075 { assemble_name (FILE, NAME); fputs ("\tEQU\t*\n", FILE); }
1076
1077 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) /* NO OP */
1078
1079 #define ASM_GLOBALIZE_LABEL(FILE, NAME) \
1080 { fputs ("\tENTRY\t", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE); }
1081
1082 /* MVS externals are limited to 8 characters, upper case only.
1083 The '_' is mapped to '@', except for MVS functions, then '#'. */
1084
1085 #define MAX_MVS_LABEL_SIZE 8
1086
1087 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
1088 { \
1089 char *bp, ch, temp[MAX_MVS_LABEL_SIZE + 1]; \
1090 if (strlen (NAME) > MAX_MVS_LABEL_SIZE) \
1091 { \
1092 strncpy (temp, NAME, MAX_MVS_LABEL_SIZE); \
1093 temp[MAX_MVS_LABEL_SIZE] = '\0'; \
1094 } \
1095 else \
1096 strcpy (temp,NAME); \
1097 if (!strcmp (temp,"main")) \
1098 strcpy (temp,"gccmain"); \
1099 if (mvs_function_check (temp)) \
1100 ch = '#'; \
1101 else \
1102 ch = '@'; \
1103 for (bp = temp; *bp; bp++) \
1104 { \
1105 if (islower (*bp)) *bp = toupper (*bp); \
1106 if (*bp == '_') *bp = ch; \
1107 } \
1108 fprintf (FILE, "%s", temp); \
1109 }
1110
1111 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
1112 sprintf (LABEL, "*%s%d", PREFIX, NUM)
1113
1114 /* Generate internal label. Since we can branch here from off page, we
1115 must reload the base register. */
1116
1117 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
1118 { \
1119 if (!strcmp (PREFIX,"L")) \
1120 { \
1121 mvs_add_label(NUM); \
1122 mvs_label_emitted = 1; \
1123 } \
1124 fprintf (FILE, "%s%d\tEQU\t*\n", PREFIX, NUM); \
1125 }
1126
1127 /* Generate case label. */
1128
1129 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
1130 fprintf (FILE, "%s%d\tEQU\t*\n", PREFIX, NUM)
1131
1132 /* This is how to output an element of a case-vector that is absolute. */
1133
1134 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1135 mvs_check_page (FILE, 4, 0); \
1136 fprintf (FILE, "\tDC\tA(L%d)\n", VALUE)
1137
1138 /* This is how to output an element of a case-vector that is relative. */
1139
1140 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
1141 mvs_check_page (FILE, 4, 0); \
1142 fprintf (FILE, "\tDC\tA(L%d-L%d)\n", VALUE, REL)
1143
1144 /* This is how to output an insn to push a register on the stack.
1145 It need not be very fast code. */
1146
1147 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO) \
1148 mvs_check_page (FILE, 8, 4); \
1149 fprintf (FILE, "\tS\t13,=F'4'\n\tST\t%s,%d(13)\n", \
1150 reg_names[REGNO], STACK_POINTER_OFFSET)
1151
1152 /* This is how to output an insn to pop a register from the stack.
1153 It need not be very fast code. */
1154
1155 #define ASM_OUTPUT_REG_POP(FILE, REGNO) \
1156 mvs_check_page (FILE, 8, 0); \
1157 fprintf (FILE, "\tL\t%s,%d(13)\n\tLA\t13,4(13)\n", \
1158 reg_names[REGNO], STACK_POINTER_OFFSET)
1159
1160 /* This is how to output an assembler line defining a `double' constant. */
1161
1162 #define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
1163 fprintf (FILE, "\tDC\tD'%.18G'\n", (VALUE))
1164
1165 /* This is how to output an assembler line defining a `float' constant. */
1166
1167 #define ASM_OUTPUT_FLOAT(FILE, VALUE) \
1168 fprintf (FILE, "\tDC\tE'%.9G'\n", (VALUE))
1169
1170 /* This outputs an integer, if not a CONST_INT must be address constant. */
1171
1172 #define ASM_OUTPUT_INT(FILE, EXP) \
1173 { \
1174 if (GET_CODE (EXP) == CONST_INT) \
1175 { \
1176 fprintf (FILE, "\tDC\tF'"); \
1177 output_addr_const (FILE, EXP); \
1178 fprintf (FILE, "'\n"); \
1179 } \
1180 else \
1181 { \
1182 fprintf (FILE, "\tDC\tA("); \
1183 output_addr_const (FILE, EXP); \
1184 fprintf (FILE, ")\n"); \
1185 } \
1186 }
1187
1188 /* This outputs a short integer. */
1189
1190 #define ASM_OUTPUT_SHORT(FILE, EXP) \
1191 { \
1192 fprintf (FILE, "\tDC\tX'%04X'\n", INTVAL(EXP) & 0xFFFF); \
1193 }
1194
1195 /* This outputs a byte sized integer. */
1196
1197 #define ASM_OUTPUT_CHAR(FILE, EXP) \
1198 fprintf (FILE, "\tDC\tX'%02X'\n", INTVAL (EXP) )
1199
1200 #define ASM_OUTPUT_BYTE(FILE, VALUE) \
1201 fprintf (FILE, "\tDC\tX'%02X'\n", VALUE)
1202
1203 /* This outputs a text string. The string are chopped up to fit into
1204 an 80 byte record. Also, control and special characters, interpreted
1205 by the IBM assembler, are output numerically. */
1206
1207 #define MVS_ASCII_TEXT_LENGTH 48
1208
1209 #define ASM_OUTPUT_ASCII(FILE, PTR, LEN) \
1210 { \
1211 int i, j; \
1212 int c; \
1213 for (j = 0, i = 0; i < LEN; j++, i++) \
1214 { \
1215 c = PTR[i]; \
1216 if (iscntrl (c) || c == '&') \
1217 { \
1218 if (j % MVS_ASCII_TEXT_LENGTH != 0 ) \
1219 fprintf (FILE, "'\n"); \
1220 j = -1; \
1221 if (c == '&') c = MAP_CHARACTER (c); \
1222 fprintf (FILE, "\tDC\tX'%X'\n", c ); \
1223 } \
1224 else \
1225 { \
1226 if (j % MVS_ASCII_TEXT_LENGTH == 0) \
1227 fprintf (FILE, "\tDC\tC'"); \
1228 if ( c == '\'' ) \
1229 fprintf (FILE, "%c%c", c, c); \
1230 else \
1231 fprintf (FILE, "%c", c); \
1232 if (j % MVS_ASCII_TEXT_LENGTH == MVS_ASCII_TEXT_LENGTH - 1) \
1233 fprintf (FILE, "'\n" ); \
1234 } \
1235 } \
1236 if (j % MVS_ASCII_TEXT_LENGTH != 0) \
1237 fprintf (FILE, "'\n"); \
1238 }
1239
1240 /* This is how to output an assembler line that says to advance the
1241 location counter to a multiple of 2**LOG bytes. */
1242
1243 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
1244 if (LOG) \
1245 { \
1246 if ((LOG) == 1) \
1247 fprintf (FILE, "\tDS\t0H\n" ); \
1248 else \
1249 fprintf (FILE, "\tDS\t0F\n" ); \
1250 } \
1251
1252 /* The maximum length of memory that the IBM assembler will allow in one
1253 DS operation. */
1254
1255 #define MAX_CHUNK 32767
1256
1257 /* A C statement to output to the stdio stream FILE an assembler
1258 instruction to advance the location counter by SIZE bytes. Those
1259 bytes should be zero when loaded. */
1260
1261 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
1262 { \
1263 int s, k; \
1264 for (s = (SIZE); s > 0; s -= MAX_CHUNK) \
1265 { \
1266 if (s > MAX_CHUNK) \
1267 k = MAX_CHUNK; \
1268 else \
1269 k = s; \
1270 fprintf (FILE, "\tDS\tXL%d\n", k); \
1271 } \
1272 }
1273
1274 /* A C statement (sans semicolon) to output to the stdio stream
1275 FILE the assembler definition of a common-label named NAME whose
1276 size is SIZE bytes. The variable ROUNDED is the size rounded up
1277 to whatever alignment the caller wants. */
1278
1279 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1280 { \
1281 fputs ("\tENTRY\t", FILE); \
1282 assemble_name (FILE, NAME); \
1283 fputs ("\n", FILE); \
1284 fprintf (FILE, "\tDS\t0F\n"); \
1285 ASM_OUTPUT_LABEL (FILE,NAME); \
1286 ASM_OUTPUT_SKIP (FILE,SIZE); \
1287 }
1288
1289 /* A C statement (sans semicolon) to output to the stdio stream
1290 FILE the assembler definition of a local-common-label named NAME
1291 whose size is SIZE bytes. The variable ROUNDED is the size
1292 rounded up to whatever alignment the caller wants. */
1293
1294 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
1295 { \
1296 fprintf (FILE, "\tDS\t0F\n"); \
1297 ASM_OUTPUT_LABEL (FILE,NAME); \
1298 ASM_OUTPUT_SKIP (FILE,SIZE); \
1299 }
1300
1301 /* Store in OUTPUT a string (made with alloca) containing an
1302 assembler-name for a local static variable named NAME.
1303 LABELNO is an integer which is different for each call. */
1304
1305 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1306 { \
1307 (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10); \
1308 sprintf ((OUTPUT), "%s%d", (NAME), (LABELNO)); \
1309 }
1310
1311 /* Define the parentheses used to group arithmetic operations
1312 in assembler code. */
1313
1314 #define ASM_OPEN_PAREN "("
1315 #define ASM_CLOSE_PAREN ")"
1316
1317 /* Define results of standard character escape sequences. */
1318
1319 #define TARGET_BELL 47
1320 #define TARGET_BS 22
1321 #define TARGET_TAB 5
1322 #define TARGET_NEWLINE 21
1323 #define TARGET_VT 11
1324 #define TARGET_FF 12
1325 #define TARGET_CR 13
1326
1327 /* Print operand X (an rtx) in assembler syntax to file FILE.
1328 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1329 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1330
1331 #define PRINT_OPERAND(FILE, X, CODE) \
1332 { \
1333 switch (GET_CODE (X)) \
1334 { \
1335 static char curreg[4]; \
1336 case REG: \
1337 if (CODE == 'N') \
1338 strcpy (curreg, reg_names[REGNO (X) + 1]); \
1339 else \
1340 strcpy (curreg, reg_names[REGNO (X)]); \
1341 fprintf (FILE, "%s", curreg); \
1342 break; \
1343 case MEM: \
1344 { \
1345 rtx addr = XEXP (X, 0); \
1346 if (CODE == 'O') \
1347 { \
1348 if (GET_CODE (addr) == PLUS) \
1349 fprintf (FILE, "%d", INTVAL (XEXP (addr, 1))); \
1350 else \
1351 fprintf (FILE, "0"); \
1352 } \
1353 else if (CODE == 'R') \
1354 { \
1355 if (GET_CODE (addr) == PLUS) \
1356 fprintf (FILE, "%s", reg_names[REGNO (XEXP (addr, 0))]);\
1357 else \
1358 fprintf (FILE, "%s", reg_names[REGNO (addr)]); \
1359 } \
1360 else \
1361 output_address (XEXP (X, 0)); \
1362 } \
1363 break; \
1364 case SYMBOL_REF: \
1365 case LABEL_REF: \
1366 mvs_page_lit += 4; \
1367 if (SYMBOL_REF_FLAG (X)) fprintf (FILE, "=V("); \
1368 else fprintf (FILE, "=A("); \
1369 output_addr_const (FILE, X); \
1370 fprintf (FILE, ")"); \
1371 break; \
1372 case CONST_INT: \
1373 if (CODE == 'B') \
1374 fprintf (FILE, "%d", INTVAL (X) & 0xff); \
1375 else if (CODE == 'X') \
1376 fprintf (FILE, "%02X", INTVAL (X) & 0xff); \
1377 else if (CODE == 'h') \
1378 fprintf (FILE, "%d", (INTVAL (X) << 16) >> 16); \
1379 else if (CODE == 'H') \
1380 { \
1381 mvs_page_lit += 2; \
1382 fprintf (FILE, "=H'%d'", (INTVAL (X) << 16) >> 16); \
1383 } \
1384 else \
1385 { \
1386 mvs_page_lit += 4; \
1387 fprintf (FILE, "=F'%d'", INTVAL (X)); \
1388 } \
1389 break; \
1390 case CONST_DOUBLE: \
1391 if (GET_MODE (X) == DImode) \
1392 { \
1393 if (CODE == 'M') \
1394 { \
1395 mvs_page_lit += 4; \
1396 fprintf (FILE, "=XL4'%08X'", CONST_DOUBLE_LOW (X)); \
1397 } \
1398 else if (CODE == 'L') \
1399 { \
1400 mvs_page_lit += 4; \
1401 fprintf (FILE, "=XL4'%08X'", CONST_DOUBLE_HIGH (X)); \
1402 } \
1403 else \
1404 { \
1405 mvs_page_lit += 8; \
1406 fprintf (FILE, "=XL8'%08X%08X'", CONST_DOUBLE_LOW (X), \
1407 CONST_DOUBLE_HIGH (X)); \
1408 } \
1409 } \
1410 else \
1411 { \
1412 union { double d; int i[2]; } u; \
1413 u.i[0] = CONST_DOUBLE_LOW (X); \
1414 u.i[1] = CONST_DOUBLE_HIGH (X); \
1415 if (GET_MODE (X) == SFmode) \
1416 { \
1417 mvs_page_lit += 4; \
1418 fprintf (FILE, "=E'%.9G'", u.d); \
1419 } \
1420 else \
1421 { \
1422 mvs_page_lit += 8; \
1423 fprintf (FILE, "=D'%.18G'", u.d); \
1424 } \
1425 } \
1426 break; \
1427 case CONST: \
1428 if (GET_CODE (XEXP (X, 0)) == PLUS \
1429 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
1430 { \
1431 mvs_page_lit += 4; \
1432 if (SYMBOL_REF_FLAG (XEXP (XEXP (X, 0), 0))) \
1433 { \
1434 fprintf (FILE, "=V("); \
1435 ASM_OUTPUT_LABELREF (FILE, \
1436 XSTR (XEXP (XEXP (X, 0), 0), 0)); \
1437 fprintf (FILE, ")\n\tA\t%s,=F'%d'", curreg, \
1438 INTVAL (XEXP (XEXP (X, 0), 1))); \
1439 } \
1440 else \
1441 { \
1442 fprintf (FILE, "=A("); \
1443 output_addr_const (FILE, X); \
1444 fprintf (FILE, ")"); \
1445 } \
1446 } \
1447 else \
1448 { \
1449 mvs_page_lit += 4; \
1450 fprintf (FILE, "=F'"); \
1451 output_addr_const (FILE, X); \
1452 fprintf (FILE, "'"); \
1453 } \
1454 break; \
1455 default: \
1456 abort(); \
1457 } \
1458 }
1459
1460 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1461 { \
1462 rtx breg, xreg, offset, plus; \
1463 \
1464 switch (GET_CODE (ADDR)) \
1465 { \
1466 case REG: \
1467 fprintf (FILE, "0(%s)", reg_names[REGNO (ADDR)]); \
1468 break; \
1469 case PLUS: \
1470 breg = 0; \
1471 xreg = 0; \
1472 offset = 0; \
1473 if (GET_CODE (XEXP (ADDR, 0)) == PLUS) \
1474 { \
1475 if (GET_CODE (XEXP (ADDR, 1)) == REG) \
1476 breg = XEXP (ADDR, 1); \
1477 else \
1478 offset = XEXP (ADDR, 1); \
1479 plus = XEXP (ADDR, 0); \
1480 } \
1481 else \
1482 { \
1483 if (GET_CODE (XEXP (ADDR, 0)) == REG) \
1484 breg = XEXP (ADDR, 0); \
1485 else \
1486 offset = XEXP (ADDR, 0); \
1487 plus = XEXP (ADDR, 1); \
1488 } \
1489 if (GET_CODE (plus) == PLUS) \
1490 { \
1491 if (GET_CODE (XEXP (plus, 0)) == REG) \
1492 { \
1493 if (breg) \
1494 xreg = XEXP (plus, 0); \
1495 else \
1496 breg = XEXP (plus, 0); \
1497 } \
1498 else \
1499 { \
1500 offset = XEXP (plus, 0); \
1501 } \
1502 if (GET_CODE (XEXP (plus, 1)) == REG) \
1503 { \
1504 if (breg) \
1505 xreg = XEXP (plus, 1); \
1506 else \
1507 breg = XEXP (plus, 1); \
1508 } \
1509 else \
1510 { \
1511 offset = XEXP (plus, 1); \
1512 } \
1513 } \
1514 else if (GET_CODE (plus) == REG) \
1515 { \
1516 if (breg) \
1517 xreg = plus; \
1518 else \
1519 breg = plus; \
1520 } \
1521 else \
1522 { \
1523 offset = plus; \
1524 } \
1525 if (offset) \
1526 { \
1527 if (GET_CODE (offset) == LABEL_REF) \
1528 fprintf (FILE, "L%d", \
1529 CODE_LABEL_NUMBER (XEXP (offset, 0))); \
1530 else \
1531 output_addr_const (FILE, offset); \
1532 } \
1533 else \
1534 fprintf (FILE, "0"); \
1535 if (xreg) \
1536 fprintf (FILE, "(%s,%s)", \
1537 reg_names[REGNO (xreg)], reg_names[REGNO (breg)]); \
1538 else \
1539 fprintf (FILE, "(%s)", reg_names[REGNO (breg)]); \
1540 break; \
1541 default: \
1542 mvs_page_lit += 4; \
1543 if (SYMBOL_REF_FLAG (ADDR)) fprintf (FILE, "=V("); \
1544 else fprintf (FILE, "=A("); \
1545 output_addr_const (FILE, ADDR); \
1546 fprintf (FILE, ")"); \
1547 break; \
1548 } \
1549 }