Fix copyrights.
[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, 1997, 1998, 1999, 2000
3 Free Software Foundation, Inc.
4 Contributed by Jan Stein (jan@cd.chalmers.se).
5 Modified for OS/390 LanguageEnvironment C by Dave Pitts (dpitts@cozx.com)
6 Hacked for Linux-ELF/390 by Linas Vepstas (linas@linas.org)
7
8 This file is part of GNU CC.
9
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
24
25 #ifndef __I370_H__
26 #define __I370_H__
27 /* Run-time compilation parameters selecting different hardware subsets. */
28
29 extern int target_flags;
30
31 /* The sizes of the code and literals on the current page. */
32
33 extern int mvs_page_code, mvs_page_lit;
34
35 /* The current page number and the base page number for the function. */
36
37 extern int mvs_page_num, function_base_page;
38
39 /* The name of the current function. */
40
41 extern char *mvs_function_name;
42
43 /* The length of the function name malloc'd area. */
44
45 extern int mvs_function_name_length;
46
47 /* Compile using char instructions (mvc, nc, oc, xc). On 4341 use this since
48 these are more than twice as fast as load-op-store.
49 On 3090 don't use this since load-op-store is much faster. */
50
51 #define TARGET_CHAR_INSTRUCTIONS (target_flags & 1)
52
53 /* Default target switches */
54
55 #define TARGET_DEFAULT 1
56
57 /* Macro to define tables used to set the flags. This is a list in braces
58 of pairs in braces, each pair being { "NAME", VALUE }
59 where VALUE is the bits to set or minus the bits to clear.
60 An empty string NAME is used to identify the default VALUE. */
61
62 #define TARGET_SWITCHES \
63 { { "char-instructions", 1, "Generate char instructions"}, \
64 { "no-char-instructions", -1, "Do not generate char instructions"}, \
65 { "", TARGET_DEFAULT, 0} }
66
67 /* To use IBM supplied macro function prologue and epilogue, define the
68 following to 1. Should only be needed if IBM changes the definition
69 of their prologue and epilogue. */
70
71 #define MACROPROLOGUE 0
72 #define MACROEPILOGUE 0
73
74 /* Target machine storage layout */
75
76 /* Define this if most significant bit is lowest numbered in instructions
77 that operate on numbered bit-fields. */
78
79 #define BITS_BIG_ENDIAN 1
80
81 /* Define this if most significant byte of a word is the lowest numbered. */
82
83 #define BYTES_BIG_ENDIAN 1
84
85 /* Define this if MS word of a multiword is the lowest numbered. */
86
87 #define WORDS_BIG_ENDIAN 1
88
89 /* Number of bits in an addressable storage unit. */
90
91 #define BITS_PER_UNIT 8
92
93 /* Width in bits of a "word", which is the contents of a machine register. */
94
95 #define BITS_PER_WORD 32
96
97 /* Width of a word, in units (bytes). */
98
99 #define UNITS_PER_WORD 4
100
101 /* Width in bits of a pointer. See also the macro `Pmode' defined below. */
102
103 #define POINTER_SIZE 32
104
105 /* Allocation boundary (in *bits*) for storing pointers in memory. */
106
107 #define POINTER_BOUNDARY 32
108
109 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
110
111 #define PARM_BOUNDARY 32
112
113 /* Boundary (in *bits*) on which stack pointer should be aligned. */
114
115 #define STACK_BOUNDARY 32
116
117 /* Allocation boundary (in *bits*) for the code of a function. */
118
119 #define FUNCTION_BOUNDARY 32
120
121 /* There is no point aligning anything to a rounder boundary than this. */
122
123 #define BIGGEST_ALIGNMENT 64
124
125 /* Alignment of field after `int : 0' in a structure. */
126
127 #define EMPTY_FIELD_BOUNDARY 32
128
129 /* Define this if move instructions will actually fail to work when given
130 unaligned data. */
131
132 #define STRICT_ALIGNMENT 0
133
134 /* Define target floating point format. */
135
136 #define TARGET_FLOAT_FORMAT IBM_FLOAT_FORMAT
137
138 /* Define character mapping for cross-compiling. */
139 /* but only define it if really needed, since otherwise it will break builds */
140
141 #ifdef TARGET_EBCDIC
142 #ifdef HOST_EBCDIC
143 #define MAP_CHARACTER(c) ((char)(c))
144 #else
145 #define MAP_CHARACTER(c) ((char)mvs_map_char (c))
146 #endif
147 #endif
148
149 #ifdef TARGET_HLASM
150 /* Define this macro if you want to implement any pragmas. If defined, it
151 is a C expression to be executed when #pragma is seen. The
152 argument FILE is the stdio input stream from which the source
153 text can be read. CH is the first character after the #pragma. The
154 result of the expression is the terminating character found
155 (newline or EOF). */
156 #define HANDLE_PRAGMA(GETC, UNGETC, NAME) \
157 handle_pragma ((GETC), (UNGETC), (NAME))
158 #endif /* TARGET_HLASM */
159
160 /* Define maximum length of page minus page escape overhead. */
161
162 #define MAX_MVS_PAGE_LENGTH 4080
163
164 /* Define special register allocation order desired.
165 Don't fiddle with this. I did, and I got all sorts of register
166 spill errors when compiling even relatively simple programs...
167 I have no clue why ...
168 E.g. this one is bad:
169 { 0, 1, 2, 9, 8, 7, 6, 5, 10, 15, 14, 12, 3, 4, 16, 17, 18, 19, 11, 13 }
170 */
171
172 #define REG_ALLOC_ORDER \
173 { 0, 1, 2, 3, 14, 15, 12, 10, 9, 8, 7, 6, 5, 4, 16, 17, 18, 19, 11, 13 }
174
175 /* Standard register usage. */
176
177 /* Number of actual hardware registers. The hardware registers are
178 assigned numbers for the compiler from 0 to just below
179 FIRST_PSEUDO_REGISTER.
180 All registers that the compiler knows about must be given numbers,
181 even those that are not normally considered general registers.
182 For the 370, we give the data registers numbers 0-15,
183 and the floating point registers numbers 16-19. */
184
185 #define FIRST_PSEUDO_REGISTER 20
186
187 /* Define base and page registers. */
188
189 #define BASE_REGISTER 3
190 #define PAGE_REGISTER 4
191
192 #ifdef TARGET_HLASM
193 /* 1 for registers that have pervasive standard uses and are not available
194 for the register allocator. These are registers that must have fixed,
195 valid values stored in them for the entire length of the subroutine call,
196 and must not in any way be moved around, jiggered with, etc. That is,
197 they must never be clobbered, and, if clobbered, the register allocator
198 will never restore them back.
199
200 We use five registers in this special way:
201 -- R3 which is used as the base register
202 -- R4 the page origin table pointer used to load R3,
203 -- R11 the arg pointer.
204 -- R12 the TCA pointer
205 -- R13 the stack (DSA) pointer
206
207 A fifth register is also exceptional: R14 is used in many branch
208 instructions to hold the target of the branch. Technically, this
209 does not qualify R14 as a register with a long-term meaning; it should
210 be enough, theoretically, to note that these instructions clobber
211 R14, and let the compiler deal with that. In practice, however,
212 the "clobber" directive acts as a barrier to optimization, and the
213 optimizer appears to be unable to perform optimizations around branches.
214 Thus, a much better strategy appears to give R14 a pervasive use;
215 this eliminates it from the register pool witout hurting optimization.
216
217 There are other registers which have special meanings, but its OK
218 for them to get clobbered, since other allocator config below will
219 make sure that they always have the right value. These are for
220 example:
221 -- R1 the returned structure pointer.
222 -- R10 the static chain reg.
223 -- R15 holds the value a subroutine returns.
224
225 Notice that it is *almost* safe to mark R11 as available to the allocator.
226 By marking it as a call_used_register, in most cases, the compiler
227 can handle it being clobbered. However, there are a few rare
228 circumstances where the register allocator will allocate r11 and
229 also try to use it as the arg pointer ... thus it must be marked fixed.
230 I think this is a bug, but I can't track it down...
231 */
232
233 #define FIXED_REGISTERS \
234 { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0 }
235 /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19*/
236
237 /* 1 for registers not available across function calls. These must include
238 the FIXED_REGISTERS and also any registers that can be used without being
239 saved.
240 The latter must include the registers where values are returned
241 and the register where structure-value addresses are passed.
242 NOTE: all floating registers are undefined across calls.
243 */
244
245 #define CALL_USED_REGISTERS \
246 { 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
247 /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19*/
248
249 /* Return number of consecutive hard regs needed starting at reg REGNO
250 to hold something of mode MODE.
251 This is ordinarily the length in words of a value of mode MODE
252 but can be less for certain modes in special long registers.
253 Note that DCmode (complex double) needs two regs.
254 */
255 #endif /* TARGET_HLASM */
256
257 /* ================= */
258 #ifdef TARGET_ELF_ABI
259 /* The Linux/ELF ABI uses the same register layout as the
260 * the MVS/OE version, with the following exceptions:
261 * -- r12 (rtca) is not used.
262 */
263
264 #define FIXED_REGISTERS \
265 { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 }
266 /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19*/
267
268 #define CALL_USED_REGISTERS \
269 { 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1 }
270 /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19*/
271
272 #endif /* TARGET_ELF_ABI */
273 /* ================= */
274
275
276 #define HARD_REGNO_NREGS(REGNO, MODE) \
277 ((REGNO) > 15 ? \
278 ((GET_MODE_SIZE (MODE) + 2*UNITS_PER_WORD - 1) / (2*UNITS_PER_WORD)) : \
279 (GET_MODE_SIZE(MODE)+UNITS_PER_WORD-1) / UNITS_PER_WORD)
280
281 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
282 On the 370, the cpu registers can hold QI, HI, SI, SF and DF. The
283 even registers can hold DI. The floating point registers can hold
284 either SF, DF, SC or DC. */
285
286 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
287 ((REGNO) < 16 ? (((REGNO) & 1) == 0 || \
288 (((MODE) != DImode) && ((MODE) != DFmode))) \
289 : ((MODE) == SFmode || (MODE) == DFmode) || \
290 (MODE) == SCmode || (MODE) == DCmode)
291
292 /* Value is 1 if it is a good idea to tie two pseudo registers when one has
293 mode MODE1 and one has mode MODE2.
294 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
295 for any hard reg, then this must be 0 for correct output. */
296
297 #define MODES_TIEABLE_P(MODE1, MODE2) \
298 (((MODE1) == SFmode || (MODE1) == DFmode) \
299 == ((MODE2) == SFmode || (MODE2) == DFmode))
300
301 /* Mark external references. */
302
303 #define ENCODE_SECTION_INFO(decl) \
304 if (DECL_EXTERNAL (decl) && TREE_PUBLIC (decl)) \
305 SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
306
307 /* Specify the registers used for certain standard purposes.
308 The values of these macros are register numbers. */
309
310 /* 370 PC isn't overloaded on a register. */
311
312 /* #define PC_REGNUM */
313
314 /* Register to use for pushing function arguments. */
315
316 #define STACK_POINTER_REGNUM 13
317
318 /* Base register for access to local variables of the function. */
319
320 #define FRAME_POINTER_REGNUM 13
321
322 /* Value should be nonzero if functions must have frame pointers.
323 Zero means the frame pointer need not be set up (and parms may be
324 accessed via the stack pointer) in functions that seem suitable.
325 This is computed in `reload', in reload1.c. */
326
327 #define FRAME_POINTER_REQUIRED 1
328
329 /* Base register for access to arguments of the function. */
330
331 #define ARG_POINTER_REGNUM 11
332
333 /* R10 is register in which static-chain is passed to a function.
334 Static-chaining is done when a nested function references as a global
335 a stack variable of its parent: e.g.
336 int parent_func (int arg) {
337 int x; // x is in parents stack
338 void child_func (void) { x++: } // child references x as global var
339 ...
340 }
341 */
342
343 #define STATIC_CHAIN_REGNUM 10
344
345 /* R1 is register in which address to store a structure value is passed to
346 a function. This is used only when returning 64-bit long-long in a 32-bit arch
347 and when calling functions that return structs by value. e.g.
348 typedef struct A_s { int a,b,c; } A_t;
349 A_t fun_returns_value (void) {
350 A_t a; a.a=1; a.b=2 a.c=3;
351 return a;
352 }
353 In the above, the storage for the return value is in the callers stack, and
354 the R1 points at that mem location.
355 */
356
357 #define STRUCT_VALUE_REGNUM 1
358
359 /* Define the classes of registers for register constraints in the
360 machine description. Also define ranges of constants.
361
362 One of the classes must always be named ALL_REGS and include all hard regs.
363 If there is more than one class, another class must be named NO_REGS
364 and contain no registers.
365
366 The name GENERAL_REGS must be the name of a class (or an alias for
367 another name such as ALL_REGS). This is the class of registers
368 that is allowed by "g" or "r" in a register constraint.
369 Also, registers outside this class are allocated only when
370 instructions express preferences for them.
371
372 The classes must be numbered in nondecreasing order; that is,
373 a larger-numbered class must never be contained completely
374 in a smaller-numbered class.
375
376 For any two classes, it is very desirable that there be another
377 class that represents their union. */
378
379 enum reg_class
380 {
381 NO_REGS, ADDR_REGS, DATA_REGS,
382 FP_REGS, ALL_REGS, LIM_REG_CLASSES
383 };
384
385 #define GENERAL_REGS DATA_REGS
386 #define N_REG_CLASSES (int) LIM_REG_CLASSES
387
388 /* Give names of register classes as strings for dump file. */
389
390 #define REG_CLASS_NAMES \
391 { "NO_REGS", "ADDR_REGS", "DATA_REGS", "FP_REGS", "ALL_REGS" }
392
393 /* Define which registers fit in which classes. This is an initializer for
394 a vector of HARD_REG_SET of length N_REG_CLASSES. */
395
396 #define REG_CLASS_CONTENTS {{0}, {0x0fffe}, {0x0ffff}, {0xf0000}, {0xfffff}}
397
398 /* The same information, inverted:
399 Return the class number of the smallest class containing
400 reg number REGNO. This could be a conditional expression
401 or could index an array. */
402
403 #define REGNO_REG_CLASS(REGNO) \
404 ((REGNO) >= 16 ? FP_REGS : (REGNO) != 0 ? ADDR_REGS : DATA_REGS)
405
406 /* The class value for index registers, and the one for base regs. */
407
408 #define INDEX_REG_CLASS ADDR_REGS
409 #define BASE_REG_CLASS ADDR_REGS
410
411 /* Get reg_class from a letter such as appears in the machine description. */
412
413 #define REG_CLASS_FROM_LETTER(C) \
414 ((C) == 'a' ? ADDR_REGS : \
415 ((C) == 'd' ? DATA_REGS : \
416 ((C) == 'f' ? FP_REGS : NO_REGS)))
417
418 /* The letters I, J, K, L and M in a register constraint string can be used
419 to stand for particular ranges of immediate operands.
420 This macro defines what the ranges are.
421 C is the letter, and VALUE is a constant value.
422 Return 1 if VALUE is in the range specified by C. */
423
424 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
425 ((C) == 'I' ? (unsigned) (VALUE) < 256 : \
426 (C) == 'J' ? (unsigned) (VALUE) < 4096 : \
427 (C) == 'K' ? (VALUE) >= -32768 && (VALUE) < 32768 : 0)
428
429 /* Similar, but for floating constants, and defining letters G and H.
430 Here VALUE is the CONST_DOUBLE rtx itself. */
431
432 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 1
433
434 /* see recog.c for details */
435 #define EXTRA_CONSTRAINT(OP,C) \
436 ((C) == 'R' ? r_or_s_operand (OP, GET_MODE(OP)) : \
437 (C) == 'S' ? s_operand (OP, GET_MODE(OP)) : 0) \
438
439 /* Given an rtx X being reloaded into a reg required to be in class CLASS,
440 return the class of reg to actually use. In general this is just CLASS;
441 but on some machines in some cases it is preferable to use a more
442 restrictive class.
443
444 XXX We reload CONST_INT's into ADDR not DATA regs because on certain
445 rare occasions when lots of egisters are spilled, reload() will try
446 to put a const int into r0 and then use r0 as an index register.
447 */
448
449 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
450 (GET_CODE(X) == CONST_DOUBLE ? FP_REGS : \
451 GET_CODE(X) == CONST_INT ? (reload_in_progress ? ADDR_REGS : DATA_REGS) : \
452 GET_CODE(X) == LABEL_REF || \
453 GET_CODE(X) == SYMBOL_REF || \
454 GET_CODE(X) == CONST ? ADDR_REGS : (CLASS))
455
456 /* Return the maximum number of consecutive registers needed to represent
457 mode MODE in a register of class CLASS.
458 Note that DCmode (complex double) needs two regs.
459 */
460
461 #define CLASS_MAX_NREGS(CLASS, MODE) \
462 ((CLASS) == FP_REGS ? \
463 ((GET_MODE_SIZE (MODE) + 2*UNITS_PER_WORD - 1) / (2*UNITS_PER_WORD)) : \
464 (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
465
466 /* Stack layout; function entry, exit and calling. */
467
468 /* Define this if pushing a word on the stack makes the stack pointer a
469 smaller address. */
470 /* ------------------------------------------------------------------- */
471
472 /* ================= */
473 #ifdef TARGET_HLASM
474 /* #define STACK_GROWS_DOWNWARD */
475
476 /* Define this if the nominal address of the stack frame is at the
477 high-address end of the local variables; that is, each additional local
478 variable allocated goes at a more negative offset in the frame. */
479
480 /* #define FRAME_GROWS_DOWNWARD */
481
482 /* Offset within stack frame to start allocating local variables at.
483 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
484 first local allocated. Otherwise, it is the offset to the BEGINNING
485 of the first local allocated. */
486
487 #define STARTING_FRAME_OFFSET \
488 (STACK_POINTER_OFFSET + current_function_outgoing_args_size)
489
490 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = STARTING_FRAME_OFFSET
491
492 /* If we generate an insn to push BYTES bytes, this says how many the stack
493 pointer really advances by. On the 370, we have no push instruction. */
494
495 #endif /* TARGET_HLASM */
496
497 /* ================= */
498 #ifdef TARGET_ELF_ABI
499
500 /* With ELF/Linux, stack is placed at large virtual addrs and grows down.
501 But we want the compiler to generate posistive displacements from the
502 stack pointer, and so we make the frame lie above the stack. */
503
504 #define STACK_GROWS_DOWNWARD
505 /* #define FRAME_GROWS_DOWNWARD */
506
507 /* Offset within stack frame to start allocating local variables at.
508 This is the offset to the BEGINNING of the first local allocated. */
509
510 #define STARTING_FRAME_OFFSET \
511 (STACK_POINTER_OFFSET + current_function_outgoing_args_size)
512
513 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = STARTING_FRAME_OFFSET
514
515 #endif /* TARGET_ELF_ABI */
516 /* ================= */
517
518 /* #define PUSH_ROUNDING(BYTES) */
519
520 /* Accumulate the outgoing argument count so we can request the right
521 DSA size and determine stack offset. */
522
523 #define ACCUMULATE_OUTGOING_ARGS
524
525 /* Define offset from stack pointer, to location where a parm can be
526 pushed. */
527
528 #define STACK_POINTER_OFFSET 148
529
530 /* Offset of first parameter from the argument pointer register value. */
531
532 #define FIRST_PARM_OFFSET(FNDECL) 0
533
534 /* 1 if N is a possible register number for function argument passing.
535 On the 370, no registers are used in this way. */
536
537 #define FUNCTION_ARG_REGNO_P(N) 0
538
539 /* Define a data type for recording info about an argument list during
540 the scan of that argument list. This data type should hold all
541 necessary information about the function itself and about the args
542 processed so far, enough to enable macros such as FUNCTION_ARG to
543 determine where the next arg should go. */
544
545 #define CUMULATIVE_ARGS int
546
547 /* Initialize a variable CUM of type CUMULATIVE_ARGS for a call to
548 a function whose data type is FNTYPE.
549 For a library call, FNTYPE is 0. */
550
551 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) ((CUM) = 0)
552
553 /* Update the data in CUM to advance over an argument of mode MODE and
554 data type TYPE. (TYPE is null for libcalls where that information
555 may not be available.) */
556
557 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
558 ((CUM) += ((MODE) == DFmode || (MODE) == SFmode \
559 ? 256 \
560 : (MODE) != BLKmode \
561 ? (GET_MODE_SIZE (MODE) + 3) / 4 \
562 : (int_size_in_bytes (TYPE) + 3) / 4))
563
564 /* Define where to put the arguments to a function. Value is zero to push
565 the argument on the stack, or a hard register in which to store the
566 argument. */
567
568 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) 0
569
570 /* For an arg passed partly in registers and partly in memory, this is the
571 number of registers used. For args passed entirely in registers or
572 entirely in memory, zero. */
573
574 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0
575
576 /* Define if returning from a function call automatically pops the
577 arguments described by the number-of-args field in the call. */
578
579 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
580
581 /* The FUNCTION_VALUE macro defines how to find the value returned by a
582 function. VALTYPE is the data type of the value (as a tree).
583 If the precise function being called is known, FUNC is its FUNCTION_DECL;
584 otherwise, FUNC is NULL.
585
586 On the 370 the return value is in R15 or R16. However,
587 DImode (64-bit ints) scalars need to get returned on the stack,
588 with r15 pointing to the location. To accomplish this, we define
589 the RETURN_IN_MEMORY macro to be true for both blockmode (structures)
590 and the DImode scalars.
591 */
592
593 #define RET_REG(MODE) \
594 (((MODE) == DCmode || (MODE) == SCmode || (MODE) == TFmode || (MODE) == DFmode || (MODE) == SFmode) ? 16 : 15)
595
596 #define FUNCTION_VALUE(VALTYPE, FUNC) \
597 gen_rtx_REG (TYPE_MODE (VALTYPE), RET_REG (TYPE_MODE (VALTYPE)))
598
599 #define RETURN_IN_MEMORY(VALTYPE) \
600 ((DImode == TYPE_MODE (VALTYPE)) || (BLKmode == TYPE_MODE (VALTYPE)))
601
602 /* Define how to find the value returned by a library function assuming
603 the value has mode MODE. */
604
605 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, RET_REG (MODE))
606
607 /* 1 if N is a possible register number for a function value.
608 On the 370 under C/370, R15 and R16 are thus used. */
609
610 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 15 || (N) == 16)
611
612 /* This macro definition sets up a default value for `main' to return. */
613
614 #define DEFAULT_MAIN_RETURN c_expand_return (integer_zero_node)
615
616
617 /* Output assembler code for a block containing the constant parts of a
618 trampoline, leaving space for the variable parts.
619
620 On the 370, the trampoline contains these instructions:
621
622 BALR 14,0
623 USING *,14
624 L STATIC_CHAIN_REGISTER,X
625 L 15,Y
626 BR 15
627 X DS 0F
628 Y DS 0F */
629 /*
630 I am confused as to why this emitting raw binary, instead of instructions ...
631 see for example, rs6000/rs000.c for an example of a different way to
632 do this ... especially since BASR should probably be substituted for BALR.
633 */
634
635 #define TRAMPOLINE_TEMPLATE(FILE) \
636 { \
637 ASM_OUTPUT_SHORT (FILE, GEN_INT (0x05E0)); \
638 ASM_OUTPUT_SHORT (FILE, GEN_INT (0x5800 | STATIC_CHAIN_REGNUM << 4)); \
639 ASM_OUTPUT_SHORT (FILE, GEN_INT (0xE00A)); \
640 ASM_OUTPUT_SHORT (FILE, GEN_INT (0x58F0)); \
641 ASM_OUTPUT_SHORT (FILE, GEN_INT (0xE00E)); \
642 ASM_OUTPUT_SHORT (FILE, GEN_INT (0x07FF)); \
643 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
644 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
645 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
646 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
647 }
648
649 /* Length in units of the trampoline for entering a nested function. */
650
651 #define TRAMPOLINE_SIZE 20
652
653 /* Emit RTL insns to initialize the variable parts of a trampoline. */
654
655 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
656 { \
657 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 12)), CXT); \
658 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 16)), FNADDR); \
659 }
660
661 /* Define EXIT_IGNORE_STACK if, when returning from a function, the stack
662 pointer does not matter (provided there is a frame pointer). */
663
664 #define EXIT_IGNORE_STACK 1
665
666 /* Addressing modes, and classification of registers for them. */
667
668 /* #define HAVE_POST_INCREMENT */
669 /* #define HAVE_POST_DECREMENT */
670
671 /* #define HAVE_PRE_DECREMENT */
672 /* #define HAVE_PRE_INCREMENT */
673
674 /* These assume that REGNO is a hard or pseudo reg number. They give
675 nonzero only if REGNO is a hard reg of the suitable class or a pseudo
676 reg currently allocated to a suitable hard reg.
677 These definitions are NOT overridden anywhere. */
678
679 #define REGNO_OK_FOR_INDEX_P(REGNO) \
680 (((REGNO) > 0 && (REGNO) < 16) \
681 || (reg_renumber[REGNO] > 0 && reg_renumber[REGNO] < 16))
682
683 #define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_INDEX_P(REGNO)
684
685 #define REGNO_OK_FOR_DATA_P(REGNO) \
686 ((REGNO) < 16 || (unsigned) reg_renumber[REGNO] < 16)
687
688 #define REGNO_OK_FOR_FP_P(REGNO) \
689 ((unsigned) ((REGNO) - 16) < 4 || (unsigned) (reg_renumber[REGNO] - 16) < 4)
690
691 /* Now macros that check whether X is a register and also,
692 strictly, whether it is in a specified class. */
693
694 /* 1 if X is a data register. */
695
696 #define DATA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_DATA_P (REGNO (X)))
697
698 /* 1 if X is an fp register. */
699
700 #define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X)))
701
702 /* 1 if X is an address register. */
703
704 #define ADDRESS_REG_P(X) (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X)))
705
706 /* Maximum number of registers that can appear in a valid memory address. */
707
708 #define MAX_REGS_PER_ADDRESS 2
709
710 /* Recognize any constant value that is a valid address. */
711
712 #define CONSTANT_ADDRESS_P(X) \
713 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
714 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST_DOUBLE \
715 || (GET_CODE (X) == CONST \
716 && GET_CODE (XEXP (XEXP (X, 0), 0)) == LABEL_REF) \
717 || (GET_CODE (X) == CONST \
718 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF \
719 && !SYMBOL_REF_FLAG (XEXP (XEXP (X, 0), 0))))
720
721 /* Nonzero if the constant value X is a legitimate general operand.
722 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
723
724 #define LEGITIMATE_CONSTANT_P(X) 1
725
726 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx and check
727 its validity for a certain class. We have two alternate definitions
728 for each of them. The usual definition accepts all pseudo regs; the
729 other rejects them all. The symbol REG_OK_STRICT causes the latter
730 definition to be used.
731
732 Most source files want to accept pseudo regs in the hope that they will
733 get allocated to the class that the insn wants them to be in.
734 Some source files that are used after register allocation
735 need to be strict. */
736
737 #ifndef REG_OK_STRICT
738
739 /* Nonzero if X is a hard reg that can be used as an index or if it is
740 a pseudo reg. */
741
742 #define REG_OK_FOR_INDEX_P(X) \
743 ((REGNO(X) > 0 && REGNO(X) < 16) || REGNO(X) >= 20)
744
745 /* Nonzero if X is a hard reg that can be used as a base reg or if it is
746 a pseudo reg. */
747
748 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_INDEX_P(X)
749
750 #else /* REG_OK_STRICT */
751
752 /* Nonzero if X is a hard reg that can be used as an index. */
753
754 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P(REGNO(X))
755
756 /* Nonzero if X is a hard reg that can be used as a base reg. */
757
758 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P(REGNO(X))
759
760 #endif /* REG_OK_STRICT */
761
762 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression that is a
763 valid memory address for an instruction.
764 The MODE argument is the machine mode for the MEM expression
765 that wants to use this address.
766
767 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
768 except for CONSTANT_ADDRESS_P which is actually machine-independent.
769 */
770
771 #define COUNT_REGS(X, REGS, FAIL) \
772 if (REG_P (X)) { \
773 if (REG_OK_FOR_BASE_P (X)) REGS += 1; \
774 else goto FAIL; \
775 } \
776 else if (GET_CODE (X) != CONST_INT || (unsigned) INTVAL (X) >= 4096) \
777 goto FAIL;
778
779 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
780 { \
781 if (REG_P (X) && REG_OK_FOR_BASE_P (X)) \
782 goto ADDR; \
783 if (GET_CODE (X) == PLUS) \
784 { \
785 int regs = 0; \
786 rtx x0 = XEXP (X, 0); \
787 rtx x1 = XEXP (X, 1); \
788 if (GET_CODE (x0) == PLUS) \
789 { \
790 COUNT_REGS (XEXP (x0, 0), regs, FAIL); \
791 COUNT_REGS (XEXP (x0, 1), regs, FAIL); \
792 COUNT_REGS (x1, regs, FAIL); \
793 if (regs == 2) \
794 goto ADDR; \
795 } \
796 else if (GET_CODE (x1) == PLUS) \
797 { \
798 COUNT_REGS (x0, regs, FAIL); \
799 COUNT_REGS (XEXP (x1, 0), regs, FAIL); \
800 COUNT_REGS (XEXP (x1, 1), regs, FAIL); \
801 if (regs == 2) \
802 goto ADDR; \
803 } \
804 else \
805 { \
806 COUNT_REGS (x0, regs, FAIL); \
807 COUNT_REGS (x1, regs, FAIL); \
808 if (regs != 0) \
809 goto ADDR; \
810 } \
811 } \
812 FAIL: ; \
813 }
814
815 /* The 370 has no mode dependent addresses. */
816
817 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)
818
819 /* Macro: LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)
820 Try machine-dependent ways of modifying an illegitimate address
821 to be legitimate. If we find one, return the new, valid address.
822 This macro is used in only one place: `memory_address' in explow.c.
823
824 Several comments:
825 (1) It's not obvious that this macro results in better code
826 than its omission does. For historical reasons we leave it in.
827
828 (2) This macro may be (???) implicated in the accidental promotion
829 or RS operand to RX operands, which bombs out any RS, SI, SS
830 instruction that was expecting a simple address. Note that
831 this occurs fairly rarely ...
832
833 (3) There is a bug somewhere that causes either r4 to be spilled,
834 or causes r0 to be used as a base register. Changeing the macro
835 below will make the bug move around, but will not make it go away
836 ... Note that this is a rare bug ...
837
838 */
839
840 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
841 { \
842 if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
843 (X) = gen_rtx_PLUS (SImode, XEXP (X, 0), \
844 copy_to_mode_reg (SImode, XEXP (X, 1))); \
845 if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \
846 (X) = gen_rtx_PLUS (SImode, XEXP (X, 1), \
847 copy_to_mode_reg (SImode, XEXP (X, 0))); \
848 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT) \
849 (X) = gen_rtx_PLUS (SImode, XEXP (X, 1), \
850 force_operand (XEXP (X, 0), 0)); \
851 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT) \
852 (X) = gen_rtx_PLUS (SImode, XEXP (X, 0), \
853 force_operand (XEXP (X, 1), 0)); \
854 if (memory_address_p (MODE, X)) \
855 goto WIN; \
856 }
857
858 /* Specify the machine mode that this machine uses for the index in the
859 tablejump instruction. */
860
861 #define CASE_VECTOR_MODE SImode
862
863 /* Define this if the tablejump instruction expects the table to contain
864 offsets from the address of the table.
865 Do not define this if the table should contain absolute addresses. */
866
867 /* #define CASE_VECTOR_PC_RELATIVE */
868
869 /* Specify the tree operation to be used to convert reals to integers. */
870
871 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
872
873 /* Define this if fixuns_trunc is the same as fix_trunc. */
874
875 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
876
877 /* We use "unsigned char" as default. */
878
879 #define DEFAULT_SIGNED_CHAR 0
880
881 /* This is the kind of divide that is easiest to do in the general case. */
882
883 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
884
885 /* Max number of bytes we can move from memory to memory in one reasonably
886 fast instruction. */
887
888 #define MOVE_MAX 256
889
890 /* Define this if zero-extension is slow (more than one real instruction). */
891
892 #define SLOW_ZERO_EXTEND 1
893
894 /* Nonzero if access to memory by bytes is slow and undesirable. */
895
896 #define SLOW_BYTE_ACCESS 1
897
898 /* Define if shifts truncate the shift count which implies one can omit
899 a sign-extension or zero-extension of a shift count. */
900
901 /* #define SHIFT_COUNT_TRUNCATED */
902
903 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
904 is done just by pretending it is already truncated. */
905
906 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) (OUTPREC != 16)
907
908 /* We assume that the store-condition-codes instructions store 0 for false
909 and some other value for true. This is the value stored for true. */
910
911 /* #define STORE_FLAG_VALUE -1 */
912
913 /* When a prototype says `char' or `short', really pass an `int'. */
914
915 #define PROMOTE_PROTOTYPES 1
916
917 /* Don't perform CSE on function addresses. */
918
919 #define NO_FUNCTION_CSE
920
921 /* Specify the machine mode that pointers have.
922 After generation of rtl, the compiler makes no further distinction
923 between pointers and any other objects of this machine mode. */
924
925 #define Pmode SImode
926
927 /* A function address in a call instruction is a byte address (for
928 indexing purposes) so give the MEM rtx a byte's mode. */
929
930 #define FUNCTION_MODE QImode
931
932 /* Compute the cost of computing a constant rtl expression RTX whose
933 rtx-code is CODE. The body of this macro is a portion of a switch
934 statement. If the code is computed here, return it with a return
935 statement. Otherwise, break from the switch. */
936
937 #define CONST_COSTS(RTX, CODE, OUTERCODE) \
938 case CONST_INT: \
939 if ((unsigned) INTVAL (RTX) < 0xfff) return 1; \
940 case CONST: \
941 case LABEL_REF: \
942 case SYMBOL_REF: \
943 return 2; \
944 case CONST_DOUBLE: \
945 return 4;
946
947 /* A C statement (sans semicolon) to update the integer variable COST
948 based on the relationship between INSN that is dependent on
949 DEP_INSN through the dependence LINK. The default is to make no
950 adjustment to COST. This can be used for example to specify to
951 the scheduler that an output- or anti-dependence does not incur
952 the same cost as a data-dependence.
953
954 We will want to use this to indicate that there is a cost associated
955 with the loading, followed by use of base registers ...
956 #define ADJUST_COST (INSN, LINK, DEP_INSN, COST)
957 */
958
959 /* Tell final.c how to eliminate redundant test instructions. */
960
961 /* Here we define machine-dependent flags and fields in cc_status
962 (see `conditions.h'). */
963
964 /* Store in cc_status the expressions that the condition codes will
965 describe after execution of an instruction whose pattern is EXP.
966 Do not alter them if the instruction would not alter the cc's.
967
968 On the 370, load insns do not alter the cc's. However, in some
969 cases these instructions can make it possibly invalid to use the
970 saved cc's. In those cases we clear out some or all of the saved
971 cc's so they won't be used.
972
973 Note that only some arith instructions set the CC. These include
974 add, subtract, complement, various shifts. Note that multiply
975 and divide do *not* set set the CC. Therefore, in the code below,
976 don't set the status for MUL, DIV, etc.
977
978 Note that the bitwise ops set the condition code, but not in a
979 way that we can make use of it. So we treat these as clobbering,
980 rather than setting the CC. These are clobbered in the individual
981 instruction patterns that use them. Use CC_STATUS_INIT to clobber.
982 */
983
984 #define NOTICE_UPDATE_CC(EXP, INSN) \
985 { \
986 rtx exp = (EXP); \
987 if (GET_CODE (exp) == PARALLEL) /* Check this */ \
988 exp = XVECEXP (exp, 0, 0); \
989 if (GET_CODE (exp) != SET) \
990 CC_STATUS_INIT; \
991 else \
992 { \
993 if (XEXP (exp, 0) == cc0_rtx) \
994 { \
995 cc_status.value1 = XEXP (exp, 0); \
996 cc_status.value2 = XEXP (exp, 1); \
997 cc_status.flags = 0; \
998 } \
999 else \
1000 { \
1001 if (cc_status.value1 \
1002 && reg_mentioned_p (XEXP (exp, 0), cc_status.value1)) \
1003 cc_status.value1 = 0; \
1004 if (cc_status.value2 \
1005 && reg_mentioned_p (XEXP (exp, 0), cc_status.value2)) \
1006 cc_status.value2 = 0; \
1007 switch (GET_CODE (XEXP (exp, 1))) \
1008 { \
1009 case PLUS: case MINUS: case NEG: \
1010 case NOT: case ABS: \
1011 CC_STATUS_SET (XEXP (exp, 0), XEXP (exp, 1)); \
1012 \
1013 /* mult and div don't set any cc codes !! */ \
1014 case MULT: /* case UMULT: */ case DIV: case UDIV: \
1015 /* and, or and xor set the cc's the wrong way !! */ \
1016 case AND: case IOR: case XOR: \
1017 /* some shifts set the CC some don't. */ \
1018 case ASHIFT: case ASHIFTRT: \
1019 do {} while (0); \
1020 default: \
1021 break; \
1022 } \
1023 } \
1024 } \
1025 }
1026
1027
1028 #define CC_STATUS_SET(V1, V2) \
1029 { \
1030 cc_status.flags = 0; \
1031 cc_status.value1 = (V1); \
1032 cc_status.value2 = (V2); \
1033 if (cc_status.value1 \
1034 && reg_mentioned_p (cc_status.value1, cc_status.value2)) \
1035 cc_status.value2 = 0; \
1036 }
1037
1038 #define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \
1039 { if (cc_status.flags & CC_NO_OVERFLOW) return NO_OV; return NORMAL; }
1040
1041 /* ------------------------------------------ */
1042 /* Control the assembler format that we output. */
1043
1044 /* Define the parentheses used to group arithmetic operations
1045 in assembler code. */
1046
1047 #define ASM_OPEN_PAREN "("
1048 #define ASM_CLOSE_PAREN ")"
1049
1050 /* Define results of standard character escape sequences. */
1051
1052 #ifdef TARGET_EBCDIC
1053 #define TARGET_ESC 39
1054 #define TARGET_BELL 47
1055 #define TARGET_BS 22
1056 #define TARGET_TAB 5
1057 #define TARGET_NEWLINE 21
1058 #define TARGET_VT 11
1059 #define TARGET_FF 12
1060 #define TARGET_CR 13
1061 #else
1062 #define TARGET_BELL 007
1063 #define TARGET_BS 010
1064 #define TARGET_TAB 011
1065 #define TARGET_NEWLINE 012
1066 #define TARGET_VT 013
1067 #define TARGET_FF 014
1068 #define TARGET_CR 015
1069 #endif
1070
1071 /* ======================================================== */
1072
1073 #ifdef TARGET_HLASM
1074 #define TEXT_SECTION_ASM_OP "* Program text area"
1075 #define DATA_SECTION_ASM_OP "* Program data area"
1076 #define INIT_SECTION_ASM_OP "* Program initialization area"
1077 #define SHARED_SECTION_ASM_OP "* Program shared data"
1078 #define CTOR_LIST_BEGIN /* NO OP */
1079 #define CTOR_LIST_END /* NO OP */
1080 #define MAX_MVS_LABEL_SIZE 8
1081
1082 /* How to refer to registers in assembler output. This sequence is
1083 indexed by compiler's hard-register-number (see above). */
1084
1085 #define REGISTER_NAMES \
1086 { "0", "1", "2", "3", "4", "5", "6", "7", \
1087 "8", "9", "10", "11", "12", "13", "14", "15", \
1088 "0", "2", "4", "6" \
1089 }
1090
1091 /* How to renumber registers for dbx and gdb. */
1092 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
1093
1094 #define ASM_FILE_START(FILE) \
1095 { fputs ("\tRMODE\tANY\n", FILE); \
1096 fputs ("\tCSECT\n", FILE); }
1097
1098 #define ASM_FILE_END(FILE) fputs ("\tEND\n", FILE);
1099 #define ASM_IDENTIFY_GCC(FILE)
1100 #define ASM_COMMENT_START "*"
1101 #define ASM_APP_OFF ""
1102 #define ASM_APP_ON ""
1103
1104 #define ASM_OUTPUT_LABEL(FILE, NAME) \
1105 { assemble_name (FILE, NAME); fputs ("\tEQU\t*\n", FILE); }
1106
1107 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
1108 { \
1109 char temp[MAX_MVS_LABEL_SIZE + 1]; \
1110 if (mvs_check_alias (NAME, temp) == 2) \
1111 { \
1112 fprintf (FILE, "%s\tALIAS\tC'%s'\n", temp, NAME); \
1113 } \
1114 }
1115
1116 #define ASM_GLOBALIZE_LABEL(FILE, NAME) \
1117 { \
1118 char temp[MAX_MVS_LABEL_SIZE + 1]; \
1119 if (mvs_check_alias (NAME, temp) == 2) \
1120 { \
1121 fprintf (FILE, "%s\tALIAS\tC'%s'\n", temp, NAME); \
1122 } \
1123 fputs ("\tENTRY\t", FILE); \
1124 assemble_name (FILE, NAME); \
1125 fputs ("\n", FILE); \
1126 }
1127
1128 /* MVS externals are limited to 8 characters, upper case only.
1129 The '_' is mapped to '@', except for MVS functions, then '#'. */
1130
1131
1132 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
1133 { \
1134 char *bp, ch, temp[MAX_MVS_LABEL_SIZE + 1]; \
1135 if (!mvs_get_alias (NAME, temp)) \
1136 strcpy (temp, NAME); \
1137 if (!strcmp (temp,"main")) \
1138 strcpy (temp,"gccmain"); \
1139 if (mvs_function_check (temp)) \
1140 ch = '#'; \
1141 else \
1142 ch = '@'; \
1143 for (bp = temp; *bp; bp++) \
1144 *bp = (*bp == '_' ? ch : TOUPPER (*bp)); \
1145 fprintf (FILE, "%s", temp); \
1146 }
1147
1148 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
1149 sprintf (LABEL, "*%s%d", PREFIX, NUM)
1150
1151 /* Generate internal label. Since we can branch here from off page, we
1152 must reload the base register. */
1153
1154 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
1155 { \
1156 if (!strcmp (PREFIX,"L")) \
1157 { \
1158 mvs_add_label(NUM); \
1159 } \
1160 fprintf (FILE, "%s%d\tEQU\t*\n", PREFIX, NUM); \
1161 }
1162
1163 /* Generate case label. */
1164 /* hack alert -- I don't get it ... what if its a really big case label?
1165 * wouldn't we have to say label_emitted also ?? */
1166
1167 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
1168 fprintf (FILE, "%s%d\tEQU\t*\n", PREFIX, NUM)
1169
1170 /* This is how to output an element of a case-vector that is absolute. */
1171
1172 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1173 mvs_check_page (FILE, 4, 0); \
1174 fprintf (FILE, "\tDC\tA(L%d)\n", VALUE)
1175
1176 /* This is how to output an element of a case-vector that is relative. */
1177
1178 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
1179 mvs_check_page (FILE, 4, 0); \
1180 fprintf (FILE, "\tDC\tA(L%d-L%d)\n", VALUE, REL)
1181
1182 /* This is how to output an insn to push a register on the stack.
1183 It need not be very fast code.
1184 Right now, PUSH & POP are used only when profiling is enabled,
1185 and then, only to push the static chain reg and the function struct
1186 value reg, and only if those are used. Since profiling is not
1187 supported anyway, punt on this. */
1188
1189 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO) \
1190 mvs_check_page (FILE, 8, 4); \
1191 fprintf (FILE, "\tSXXX\t13,=F'4'\n\tST\t%s,%d(13)\n", \
1192 reg_names[REGNO], STACK_POINTER_OFFSET)
1193
1194 /* This is how to output an insn to pop a register from the stack.
1195 It need not be very fast code. */
1196
1197 #define ASM_OUTPUT_REG_POP(FILE, REGNO) \
1198 mvs_check_page (FILE, 8, 0); \
1199 fprintf (FILE, "\tL\t%s,%d(13)\n\tLAXXX\t13,4(13)\n", \
1200 reg_names[REGNO], STACK_POINTER_OFFSET)
1201
1202 /* TBD: hack alert XXX these two float point macros print horribly
1203 incorrect things when run in cross-compiler mode. Thats's because
1204 in cross-compiler mode, the VALUE is not really a double. See below,
1205 in the ELF section, for the correct implementation. */
1206 /* This is how to output an assembler line defining a `double' constant. */
1207 #define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
1208 fprintf (FILE, "\tDC\tD'%.18G'\n", (VALUE))
1209
1210 /* This is how to output an assembler line defining a `float' constant. */
1211 #define ASM_OUTPUT_FLOAT(FILE, VALUE) \
1212 fprintf (FILE, "\tDC\tE'%.9G'\n", (VALUE))
1213
1214 /* This outputs an integer, if not a CONST_INT must be address constant. */
1215
1216 #define ASM_OUTPUT_INT(FILE, EXP) \
1217 { \
1218 if (GET_CODE (EXP) == CONST_INT) \
1219 { \
1220 fprintf (FILE, "\tDC\tF'"); \
1221 output_addr_const (FILE, EXP); \
1222 fprintf (FILE, "'\n"); \
1223 } \
1224 else \
1225 { \
1226 fprintf (FILE, "\tDC\tA("); \
1227 output_addr_const (FILE, EXP); \
1228 fprintf (FILE, ")\n"); \
1229 } \
1230 }
1231
1232 /* This outputs a short integer. */
1233
1234 #define ASM_OUTPUT_SHORT(FILE, EXP) \
1235 { \
1236 fprintf (FILE, "\tDC\tX'%04X'\n", INTVAL(EXP) & 0xFFFF); \
1237 }
1238
1239 /* This outputs a byte sized integer. */
1240
1241 #define ASM_OUTPUT_CHAR(FILE, EXP) \
1242 fprintf (FILE, "\tDC\tX'%02X'\n", INTVAL (EXP) )
1243
1244 #define ASM_OUTPUT_BYTE(FILE, VALUE) \
1245 fprintf (FILE, "\tDC\tX'%02X'\n", VALUE)
1246
1247 /* This outputs a text string. The string are chopped up to fit into
1248 an 80 byte record. Also, control and special characters, interpreted
1249 by the IBM assembler, are output numerically. */
1250
1251 #define MVS_ASCII_TEXT_LENGTH 48
1252
1253 #define ASM_OUTPUT_ASCII(FILE, PTR, LEN) \
1254 { \
1255 int i, j; \
1256 int c; \
1257 for (j = 0, i = 0; i < LEN; j++, i++) \
1258 { \
1259 c = PTR[i]; \
1260 if (ISCNTRL (c) || c == '&') \
1261 { \
1262 if (j % MVS_ASCII_TEXT_LENGTH != 0 ) \
1263 fprintf (FILE, "'\n"); \
1264 j = -1; \
1265 if (c == '&') c = MAP_CHARACTER (c); \
1266 fprintf (FILE, "\tDC\tX'%X'\n", c ); \
1267 } \
1268 else \
1269 { \
1270 if (j % MVS_ASCII_TEXT_LENGTH == 0) \
1271 fprintf (FILE, "\tDC\tC'"); \
1272 if ( c == '\'' ) \
1273 fprintf (FILE, "%c%c", c, c); \
1274 else \
1275 fprintf (FILE, "%c", c); \
1276 if (j % MVS_ASCII_TEXT_LENGTH == MVS_ASCII_TEXT_LENGTH - 1) \
1277 fprintf (FILE, "'\n" ); \
1278 } \
1279 } \
1280 if (j % MVS_ASCII_TEXT_LENGTH != 0) \
1281 fprintf (FILE, "'\n"); \
1282 }
1283
1284 /* This is how to output an assembler line that says to advance the
1285 location counter to a multiple of 2**LOG bytes. */
1286
1287 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
1288 if (LOG) \
1289 { \
1290 if ((LOG) == 1) \
1291 fprintf (FILE, "\tDS\t0H\n" ); \
1292 else \
1293 fprintf (FILE, "\tDS\t0F\n" ); \
1294 } \
1295
1296 /* The maximum length of memory that the IBM assembler will allow in one
1297 DS operation. */
1298
1299 #define MAX_CHUNK 32767
1300
1301 /* A C statement to output to the stdio stream FILE an assembler
1302 instruction to advance the location counter by SIZE bytes. Those
1303 bytes should be zero when loaded. */
1304
1305 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
1306 { \
1307 int s, k; \
1308 for (s = (SIZE); s > 0; s -= MAX_CHUNK) \
1309 { \
1310 if (s > MAX_CHUNK) \
1311 k = MAX_CHUNK; \
1312 else \
1313 k = s; \
1314 fprintf (FILE, "\tDS\tXL%d\n", k); \
1315 } \
1316 }
1317
1318 /* A C statement (sans semicolon) to output to the stdio stream
1319 FILE the assembler definition of a common-label named NAME whose
1320 size is SIZE bytes. The variable ROUNDED is the size rounded up
1321 to whatever alignment the caller wants. */
1322
1323 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1324 { \
1325 char temp[MAX_MVS_LABEL_SIZE + 1]; \
1326 if (mvs_check_alias(NAME, temp) == 2) \
1327 { \
1328 fprintf (FILE, "%s\tALIAS\tC'%s'\n", temp, NAME); \
1329 } \
1330 fputs ("\tENTRY\t", FILE); \
1331 assemble_name (FILE, NAME); \
1332 fputs ("\n", FILE); \
1333 fprintf (FILE, "\tDS\t0F\n"); \
1334 ASM_OUTPUT_LABEL (FILE,NAME); \
1335 ASM_OUTPUT_SKIP (FILE,SIZE); \
1336 }
1337
1338 /* A C statement (sans semicolon) to output to the stdio stream
1339 FILE the assembler definition of a local-common-label named NAME
1340 whose size is SIZE bytes. The variable ROUNDED is the size
1341 rounded up to whatever alignment the caller wants. */
1342
1343 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
1344 { \
1345 fprintf (FILE, "\tDS\t0F\n"); \
1346 ASM_OUTPUT_LABEL (FILE,NAME); \
1347 ASM_OUTPUT_SKIP (FILE,SIZE); \
1348 }
1349
1350 /* Store in OUTPUT a string (made with alloca) containing an
1351 assembler-name for a local static variable named NAME.
1352 LABELNO is an integer which is different for each call. */
1353
1354 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1355 { \
1356 (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10); \
1357 sprintf ((OUTPUT), "%s%d", (NAME), (LABELNO)); \
1358 }
1359
1360 /* Print operand XV (an rtx) in assembler syntax to file FILE.
1361 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1362 For `%' followed by punctuation, CODE is the punctuation and XV is null. */
1363
1364 #define PRINT_OPERAND(FILE, XV, CODE) \
1365 { \
1366 switch (GET_CODE (XV)) \
1367 { \
1368 static char curreg[4]; \
1369 case REG: \
1370 if (CODE == 'N') \
1371 strcpy (curreg, reg_names[REGNO (XV) + 1]); \
1372 else \
1373 strcpy (curreg, reg_names[REGNO (XV)]); \
1374 fprintf (FILE, "%s", curreg); \
1375 break; \
1376 case MEM: \
1377 { \
1378 rtx addr = XEXP (XV, 0); \
1379 if (CODE == 'O') \
1380 { \
1381 if (GET_CODE (addr) == PLUS) \
1382 fprintf (FILE, "%d", INTVAL (XEXP (addr, 1))); \
1383 else \
1384 fprintf (FILE, "0"); \
1385 } \
1386 else if (CODE == 'R') \
1387 { \
1388 if (GET_CODE (addr) == PLUS) \
1389 fprintf (FILE, "%s", reg_names[REGNO (XEXP (addr, 0))]);\
1390 else \
1391 fprintf (FILE, "%s", reg_names[REGNO (addr)]); \
1392 } \
1393 else \
1394 output_address (XEXP (XV, 0)); \
1395 } \
1396 break; \
1397 case SYMBOL_REF: \
1398 case LABEL_REF: \
1399 mvs_page_lit += 4; \
1400 if (SYMBOL_REF_FLAG (XV)) fprintf (FILE, "=V("); \
1401 else fprintf (FILE, "=A("); \
1402 output_addr_const (FILE, XV); \
1403 fprintf (FILE, ")"); \
1404 break; \
1405 case CONST_INT: \
1406 if (CODE == 'B') \
1407 fprintf (FILE, "%d", INTVAL (XV) & 0xff); \
1408 else if (CODE == 'X') \
1409 fprintf (FILE, "%02X", INTVAL (XV) & 0xff); \
1410 else if (CODE == 'h') \
1411 fprintf (FILE, "%d", (INTVAL (XV) << 16) >> 16); \
1412 else if (CODE == 'H') \
1413 { \
1414 mvs_page_lit += 2; \
1415 fprintf (FILE, "=H'%d'", (INTVAL (XV) << 16) >> 16); \
1416 } \
1417 else if (CODE == 'K') \
1418 { \
1419 /* auto sign-extension of signed 16-bit to signed 32-bit */ \
1420 mvs_page_lit += 4; \
1421 fprintf (FILE, "=F'%d'", (INTVAL (XV) << 16) >> 16); \
1422 } \
1423 else if (CODE == 'W') \
1424 { \
1425 /* hand-built sign-extension of signed 32-bit to 64-bit */ \
1426 mvs_page_lit += 8; \
1427 if (0 <= INTVAL (XV)) { \
1428 fprintf (FILE, "=XL8'00000000"); \
1429 } else { \
1430 fprintf (FILE, "=XL8'FFFFFFFF"); \
1431 } \
1432 fprintf (FILE, "%08X'", INTVAL (XV)); \
1433 } \
1434 else \
1435 { \
1436 mvs_page_lit += 4; \
1437 fprintf (FILE, "=F'%d'", INTVAL (XV)); \
1438 } \
1439 break; \
1440 case CONST_DOUBLE: \
1441 if (GET_MODE (XV) == DImode) \
1442 { \
1443 if (CODE == 'M') \
1444 { \
1445 mvs_page_lit += 4; \
1446 fprintf (FILE, "=XL4'%08X'", CONST_DOUBLE_LOW (XV)); \
1447 } \
1448 else if (CODE == 'L') \
1449 { \
1450 mvs_page_lit += 4; \
1451 fprintf (FILE, "=XL4'%08X'", CONST_DOUBLE_HIGH (XV)); \
1452 } \
1453 else \
1454 { \
1455 mvs_page_lit += 8; \
1456 fprintf (FILE, "=XL8'%08X%08X'", CONST_DOUBLE_LOW (XV), \
1457 CONST_DOUBLE_HIGH (XV)); \
1458 } \
1459 } \
1460 else \
1461 { \
1462 /* hack alert -- this prints wildly incorrect values */ \
1463 /* when run in cross-compiler mode. See ELF section */ \
1464 /* for suggested fix */ \
1465 union { double d; int i[2]; } u; \
1466 u.i[0] = CONST_DOUBLE_LOW (XV); \
1467 u.i[1] = CONST_DOUBLE_HIGH (XV); \
1468 if (GET_MODE (XV) == SFmode) \
1469 { \
1470 mvs_page_lit += 4; \
1471 fprintf (FILE, "=E'%.9G'", u.d); \
1472 } \
1473 else \
1474 { \
1475 mvs_page_lit += 8; \
1476 fprintf (FILE, "=D'%.18G'", u.d); \
1477 } \
1478 } \
1479 break; \
1480 case CONST: \
1481 if (GET_CODE (XEXP (XV, 0)) == PLUS \
1482 && GET_CODE (XEXP (XEXP (XV, 0), 0)) == SYMBOL_REF) \
1483 { \
1484 mvs_page_lit += 4; \
1485 if (SYMBOL_REF_FLAG (XEXP (XEXP (XV, 0), 0))) \
1486 { \
1487 fprintf (FILE, "=V("); \
1488 ASM_OUTPUT_LABELREF (FILE, \
1489 XSTR (XEXP (XEXP (XV, 0), 0), 0)); \
1490 fprintf (FILE, ")\n\tA\t%s,=F'%d'", curreg, \
1491 INTVAL (XEXP (XEXP (XV, 0), 1))); \
1492 } \
1493 else \
1494 { \
1495 fprintf (FILE, "=A("); \
1496 output_addr_const (FILE, XV); \
1497 fprintf (FILE, ")"); \
1498 } \
1499 } \
1500 else \
1501 { \
1502 mvs_page_lit += 4; \
1503 fprintf (FILE, "=F'"); \
1504 output_addr_const (FILE, XV); \
1505 fprintf (FILE, "'"); \
1506 } \
1507 break; \
1508 default: \
1509 abort(); \
1510 } \
1511 }
1512
1513 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1514 { \
1515 rtx breg, xreg, offset, plus; \
1516 \
1517 switch (GET_CODE (ADDR)) \
1518 { \
1519 case REG: \
1520 fprintf (FILE, "0(%s)", reg_names[REGNO (ADDR)]); \
1521 break; \
1522 case PLUS: \
1523 breg = 0; \
1524 xreg = 0; \
1525 offset = 0; \
1526 if (GET_CODE (XEXP (ADDR, 0)) == PLUS) \
1527 { \
1528 if (GET_CODE (XEXP (ADDR, 1)) == REG) \
1529 breg = XEXP (ADDR, 1); \
1530 else \
1531 offset = XEXP (ADDR, 1); \
1532 plus = XEXP (ADDR, 0); \
1533 } \
1534 else \
1535 { \
1536 if (GET_CODE (XEXP (ADDR, 0)) == REG) \
1537 breg = XEXP (ADDR, 0); \
1538 else \
1539 offset = XEXP (ADDR, 0); \
1540 plus = XEXP (ADDR, 1); \
1541 } \
1542 if (GET_CODE (plus) == PLUS) \
1543 { \
1544 if (GET_CODE (XEXP (plus, 0)) == REG) \
1545 { \
1546 if (breg) \
1547 xreg = XEXP (plus, 0); \
1548 else \
1549 breg = XEXP (plus, 0); \
1550 } \
1551 else \
1552 { \
1553 offset = XEXP (plus, 0); \
1554 } \
1555 if (GET_CODE (XEXP (plus, 1)) == REG) \
1556 { \
1557 if (breg) \
1558 xreg = XEXP (plus, 1); \
1559 else \
1560 breg = XEXP (plus, 1); \
1561 } \
1562 else \
1563 { \
1564 offset = XEXP (plus, 1); \
1565 } \
1566 } \
1567 else if (GET_CODE (plus) == REG) \
1568 { \
1569 if (breg) \
1570 xreg = plus; \
1571 else \
1572 breg = plus; \
1573 } \
1574 else \
1575 { \
1576 offset = plus; \
1577 } \
1578 if (offset) \
1579 { \
1580 if (GET_CODE (offset) == LABEL_REF) \
1581 fprintf (FILE, "L%d", \
1582 CODE_LABEL_NUMBER (XEXP (offset, 0))); \
1583 else \
1584 output_addr_const (FILE, offset); \
1585 } \
1586 else \
1587 fprintf (FILE, "0"); \
1588 if (xreg) \
1589 fprintf (FILE, "(%s,%s)", \
1590 reg_names[REGNO (xreg)], reg_names[REGNO (breg)]); \
1591 else \
1592 fprintf (FILE, "(%s)", reg_names[REGNO (breg)]); \
1593 break; \
1594 default: \
1595 mvs_page_lit += 4; \
1596 if (SYMBOL_REF_FLAG (ADDR)) fprintf (FILE, "=V("); \
1597 else fprintf (FILE, "=A("); \
1598 output_addr_const (FILE, ADDR); \
1599 fprintf (FILE, ")"); \
1600 break; \
1601 } \
1602 }
1603
1604 /* This macro generates the assembly code for function entry.
1605 All of the C/370 environment is preserved. */
1606 #define FUNCTION_PROLOGUE(FILE, LSIZE) i370_function_prolog ((FILE), (LSIZE));
1607
1608 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
1609 { \
1610 if (strlen (NAME) + 1 > mvs_function_name_length) \
1611 { \
1612 if (mvs_function_name) \
1613 free (mvs_function_name); \
1614 mvs_function_name = 0; \
1615 } \
1616 if (!mvs_function_name) \
1617 { \
1618 mvs_function_name_length = strlen (NAME) * 2 + 1; \
1619 mvs_function_name = (char *) xmalloc (mvs_function_name_length); \
1620 } \
1621 if (!strcmp (NAME, "main")) \
1622 strcpy (mvs_function_name, "gccmain"); \
1623 else \
1624 strcpy (mvs_function_name, NAME); \
1625 fprintf (FILE, "\tDS\t0F\n"); \
1626 assemble_name (FILE, mvs_function_name); \
1627 fputs ("\tRMODE\tANY\n", FILE); \
1628 assemble_name (FILE, mvs_function_name); \
1629 fputs ("\tCSECT\n", FILE); \
1630 }
1631
1632 /* This macro generates the assembly code for function exit, on machines
1633 that need it. If FUNCTION_EPILOGUE is not defined then individual
1634 return instructions are generated for each return statement. Args are
1635 same as for FUNCTION_PROLOGUE.
1636
1637 The function epilogue should not depend on the current stack pointer!
1638 It should use the frame pointer only. This is mandatory because
1639 of alloca; we also take advantage of it to omit stack adjustments
1640 before returning. */
1641
1642 #if MACROEPILOGUE == 1
1643 #define FUNCTION_EPILOGUE(FILE, LSIZE) \
1644 { \
1645 int i; \
1646 check_label_emit(); \
1647 mvs_check_page (FILE,14,0); \
1648 fprintf (FILE, "* Function %s epilogue\n", mvs_function_name); \
1649 fprintf (FILE, "\tEDCEPIL\n"); \
1650 mvs_page_num++; \
1651 fprintf (FILE, "* Function %s literal pool\n", mvs_function_name); \
1652 fprintf (FILE, "\tDS\t0F\n" ); \
1653 fprintf (FILE, "\tLTORG\n"); \
1654 fprintf (FILE, "* Function %s page table\n", mvs_function_name); \
1655 fprintf (FILE, "\tDS\t0F\n"); \
1656 fprintf (FILE, "PGT%d\tEQU\t*\n", function_base_page); \
1657 mvs_free_label_list(); \
1658 for ( i = function_base_page; i < mvs_page_num; i++ ) \
1659 fprintf (FILE, "\tDC\tA(PG%d)\n", i); \
1660 }
1661 #else /* MACROEPILOGUE != 1 */
1662 #define FUNCTION_EPILOGUE(FILE, LSIZE) \
1663 { \
1664 int i; \
1665 check_label_emit(); \
1666 mvs_check_page (FILE,14,0); \
1667 fprintf (FILE, "* Function %s epilogue\n", mvs_function_name); \
1668 fprintf (FILE, "\tL\t13,4(,13)\n"); \
1669 fprintf (FILE, "\tL\t14,12(,13)\n"); \
1670 fprintf (FILE, "\tLM\t2,12,28(13)\n"); \
1671 fprintf (FILE, "\tBALR\t1,14\n"); \
1672 fprintf (FILE, "\tDC\tA("); \
1673 mvs_page_num++; \
1674 assemble_name (FILE, mvs_function_name); \
1675 fprintf (FILE, ")\n" ); \
1676 fprintf (FILE, "* Function %s literal pool\n", mvs_function_name); \
1677 fprintf (FILE, "\tDS\t0F\n" ); \
1678 fprintf (FILE, "\tLTORG\n"); \
1679 fprintf (FILE, "* Function %s page table\n", mvs_function_name); \
1680 fprintf (FILE, "\tDS\t0F\n"); \
1681 fprintf (FILE, "PGT%d\tEQU\t*\n", function_base_page); \
1682 mvs_free_label_list(); \
1683 for ( i = function_base_page; i < mvs_page_num; i++ ) \
1684 fprintf (FILE, "\tDC\tA(PG%d)\n", i); \
1685 }
1686 #endif /* MACROEPILOGUE */
1687
1688 /* Output assembler code to FILE to increment profiler label # LABELNO
1689 for profiling a function entry. */
1690
1691 #define FUNCTION_PROFILER(FILE, LABELNO) \
1692 fprintf (FILE, "Error: No profiling available.\n")
1693
1694 #endif /* TARGET_HLASM */
1695
1696 /* ======================================================== */
1697
1698 #ifdef TARGET_ELF_ABI
1699
1700 /* How to refer to registers in assembler output. This sequence is
1701 indexed by compiler's hard-register-number (see above). */
1702
1703 #define REGISTER_NAMES \
1704 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
1705 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
1706 "f0", "f2", "f4", "f6" \
1707 }
1708
1709 /* How to renumber registers for dbx and gdb. */
1710 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
1711
1712 /* Print operand XV (an rtx) in assembler syntax to file FILE.
1713 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1714 For `%' followed by punctuation, CODE is the punctuation and XV is null. */
1715
1716 #define PRINT_OPERAND(FILE, XV, CODE) \
1717 { \
1718 switch (GET_CODE (XV)) \
1719 { \
1720 static char curreg[4]; \
1721 case REG: \
1722 if (CODE == 'N') \
1723 strcpy (curreg, reg_names[REGNO (XV) + 1]); \
1724 else \
1725 strcpy (curreg, reg_names[REGNO (XV)]); \
1726 fprintf (FILE, "%s", curreg); \
1727 break; \
1728 case MEM: \
1729 { \
1730 rtx addr = XEXP (XV, 0); \
1731 if (CODE == 'O') \
1732 { \
1733 if (GET_CODE (addr) == PLUS) \
1734 fprintf (FILE, "%d", INTVAL (XEXP (addr, 1))); \
1735 else \
1736 fprintf (FILE, "0"); \
1737 } \
1738 else if (CODE == 'R') \
1739 { \
1740 if (GET_CODE (addr) == PLUS) \
1741 fprintf (FILE, "%s", reg_names[REGNO (XEXP (addr, 0))]);\
1742 else \
1743 fprintf (FILE, "%s", reg_names[REGNO (addr)]); \
1744 } \
1745 else \
1746 output_address (XEXP (XV, 0)); \
1747 } \
1748 break; \
1749 case SYMBOL_REF: \
1750 case LABEL_REF: \
1751 mvs_page_lit += 4; \
1752 if (SYMBOL_REF_FLAG (XV)) fprintf (FILE, "=V("); \
1753 else fprintf (FILE, "=A("); \
1754 output_addr_const (FILE, XV); \
1755 fprintf (FILE, ")"); \
1756 break; \
1757 case CONST_INT: \
1758 if (CODE == 'B') \
1759 fprintf (FILE, "%d", INTVAL (XV) & 0xff); \
1760 else if (CODE == 'X') \
1761 fprintf (FILE, "%02X", INTVAL (XV) & 0xff); \
1762 else if (CODE == 'h') \
1763 fprintf (FILE, "%d", (INTVAL (XV) << 16) >> 16); \
1764 else if (CODE == 'H') \
1765 { \
1766 mvs_page_lit += 2; \
1767 fprintf (FILE, "=H'%d'", (INTVAL (XV) << 16) >> 16); \
1768 } \
1769 else if (CODE == 'K') \
1770 { \
1771 /* auto sign-extension of signed 16-bit to signed 32-bit */ \
1772 mvs_page_lit += 4; \
1773 fprintf (FILE, "=F'%d'", (INTVAL (XV) << 16) >> 16); \
1774 } \
1775 else if (CODE == 'W') \
1776 { \
1777 /* hand-built sign-extension of signed 32-bit to 64-bit */ \
1778 mvs_page_lit += 8; \
1779 if (0 <= INTVAL (XV)) { \
1780 fprintf (FILE, "=XL8'00000000"); \
1781 } else { \
1782 fprintf (FILE, "=XL8'FFFFFFFF"); \
1783 } \
1784 fprintf (FILE, "%08X'", INTVAL (XV)); \
1785 } \
1786 else \
1787 { \
1788 mvs_page_lit += 4; \
1789 fprintf (FILE, "=F'%d'", INTVAL (XV)); \
1790 } \
1791 break; \
1792 case CONST_DOUBLE: \
1793 if (GET_MODE (XV) == DImode) \
1794 { \
1795 if (CODE == 'M') \
1796 { \
1797 mvs_page_lit += 4; \
1798 fprintf (FILE, "=XL4'%08X'", CONST_DOUBLE_LOW (XV)); \
1799 } \
1800 else if (CODE == 'L') \
1801 { \
1802 mvs_page_lit += 4; \
1803 fprintf (FILE, "=XL4'%08X'", CONST_DOUBLE_HIGH (XV)); \
1804 } \
1805 else \
1806 { \
1807 mvs_page_lit += 8; \
1808 fprintf (FILE, "=yyyyXL8'%08X%08X'", \
1809 CONST_DOUBLE_HIGH (XV), CONST_DOUBLE_LOW (XV)); \
1810 } \
1811 } \
1812 else \
1813 { \
1814 char buf[50]; \
1815 REAL_VALUE_TYPE rval; \
1816 REAL_VALUE_FROM_CONST_DOUBLE(rval, XV); \
1817 REAL_VALUE_TO_DECIMAL (rval, HOST_WIDE_INT_PRINT_DEC, buf); \
1818 if (GET_MODE (XV) == SFmode) \
1819 { \
1820 mvs_page_lit += 4; \
1821 fprintf (FILE, "=E'%s'", buf); \
1822 } \
1823 else \
1824 if (GET_MODE (XV) == DFmode) \
1825 { \
1826 mvs_page_lit += 8; \
1827 fprintf (FILE, "=D'%s'", buf); \
1828 } \
1829 else /* VOIDmode !?!? strange but true ... */ \
1830 { \
1831 mvs_page_lit += 8; \
1832 fprintf (FILE, "=XL8'%08X%08X'", \
1833 CONST_DOUBLE_HIGH (XV), CONST_DOUBLE_LOW (XV)); \
1834 } \
1835 } \
1836 break; \
1837 case CONST: \
1838 if (GET_CODE (XEXP (XV, 0)) == PLUS \
1839 && GET_CODE (XEXP (XEXP (XV, 0), 0)) == SYMBOL_REF) \
1840 { \
1841 mvs_page_lit += 4; \
1842 if (SYMBOL_REF_FLAG (XEXP (XEXP (XV, 0), 0))) \
1843 { \
1844 fprintf (FILE, "=V("); \
1845 ASM_OUTPUT_LABELREF (FILE, \
1846 XSTR (XEXP (XEXP (XV, 0), 0), 0)); \
1847 fprintf (FILE, ")\n\tA\t%s,=F'%d'", curreg, \
1848 INTVAL (XEXP (XEXP (XV, 0), 1))); \
1849 } \
1850 else \
1851 { \
1852 fprintf (FILE, "=A("); \
1853 output_addr_const (FILE, XV); \
1854 fprintf (FILE, ")"); \
1855 } \
1856 } \
1857 else \
1858 { \
1859 mvs_page_lit += 4; \
1860 fprintf (FILE, "=bogus_bad_F'"); \
1861 output_addr_const (FILE, XV); \
1862 fprintf (FILE, "'"); \
1863 /* XXX hack alert this gets gen'd in -fPIC code in relation to a tablejump */ \
1864 /* but its somehow fundamentally broken, I can't make any sense out of it */ \
1865 debug_rtx (XV); \
1866 abort(); \
1867 } \
1868 break; \
1869 default: \
1870 abort(); \
1871 } \
1872 }
1873
1874 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1875 { \
1876 rtx breg, xreg, offset, plus; \
1877 \
1878 switch (GET_CODE (ADDR)) \
1879 { \
1880 case REG: \
1881 fprintf (FILE, "0(%s)", reg_names[REGNO (ADDR)]); \
1882 break; \
1883 case PLUS: \
1884 breg = 0; \
1885 xreg = 0; \
1886 offset = 0; \
1887 if (GET_CODE (XEXP (ADDR, 0)) == PLUS) \
1888 { \
1889 if (GET_CODE (XEXP (ADDR, 1)) == REG) \
1890 breg = XEXP (ADDR, 1); \
1891 else \
1892 offset = XEXP (ADDR, 1); \
1893 plus = XEXP (ADDR, 0); \
1894 } \
1895 else \
1896 { \
1897 if (GET_CODE (XEXP (ADDR, 0)) == REG) \
1898 breg = XEXP (ADDR, 0); \
1899 else \
1900 offset = XEXP (ADDR, 0); \
1901 plus = XEXP (ADDR, 1); \
1902 } \
1903 if (GET_CODE (plus) == PLUS) \
1904 { \
1905 if (GET_CODE (XEXP (plus, 0)) == REG) \
1906 { \
1907 if (breg) \
1908 xreg = XEXP (plus, 0); \
1909 else \
1910 breg = XEXP (plus, 0); \
1911 } \
1912 else \
1913 { \
1914 offset = XEXP (plus, 0); \
1915 } \
1916 if (GET_CODE (XEXP (plus, 1)) == REG) \
1917 { \
1918 if (breg) \
1919 xreg = XEXP (plus, 1); \
1920 else \
1921 breg = XEXP (plus, 1); \
1922 } \
1923 else \
1924 { \
1925 offset = XEXP (plus, 1); \
1926 } \
1927 } \
1928 else if (GET_CODE (plus) == REG) \
1929 { \
1930 if (breg) \
1931 xreg = plus; \
1932 else \
1933 breg = plus; \
1934 } \
1935 else \
1936 { \
1937 offset = plus; \
1938 } \
1939 if (offset) \
1940 { \
1941 if (GET_CODE (offset) == LABEL_REF) \
1942 fprintf (FILE, "L%d", \
1943 CODE_LABEL_NUMBER (XEXP (offset, 0))); \
1944 else \
1945 output_addr_const (FILE, offset); \
1946 } \
1947 else \
1948 fprintf (FILE, "0"); \
1949 if (xreg) \
1950 fprintf (FILE, "(%s,%s)", \
1951 reg_names[REGNO (xreg)], reg_names[REGNO (breg)]); \
1952 else \
1953 fprintf (FILE, "(%s)", reg_names[REGNO (breg)]); \
1954 break; \
1955 default: \
1956 mvs_page_lit += 4; \
1957 if (SYMBOL_REF_FLAG (ADDR)) fprintf (FILE, "=V("); \
1958 else fprintf (FILE, "=A("); \
1959 output_addr_const (FILE, ADDR); \
1960 fprintf (FILE, ")"); \
1961 break; \
1962 } \
1963 }
1964
1965 /* This macro generates the assembly code for function exit, on machines
1966 that need it. If FUNCTION_EPILOGUE is not defined then individual
1967 return instructions are generated for each return statement. Args are
1968 same as for FUNCTION_PROLOGUE.
1969
1970 The function epilogue should not depend on the current stack pointer!
1971 It should use the frame pointer only. This is mandatory because
1972 of alloca; we also take advantage of it to omit stack adjustments
1973 before returning. */
1974
1975 #define FUNCTION_EPILOGUE(FILE, LSIZE) \
1976 { \
1977 int i; \
1978 check_label_emit(); \
1979 mvs_check_page (FILE,14,0); \
1980 fprintf (FILE, "# Function epilogue\n"); \
1981 fprintf (FILE, "\tL\tsp,4(0,sp)\n"); \
1982 fprintf (FILE, "\tL\tlr,12(0,sp)\n"); \
1983 fprintf (FILE, "\tLM\t2,12,28(sp)\n"); \
1984 fprintf (FILE, "\tBASR\t1,lr\n"); \
1985 mvs_page_num++; \
1986 fprintf (FILE, "# Function literal pool\n"); \
1987 fprintf (FILE, "\t.balign\t4\n"); \
1988 fprintf (FILE, "\t.ltorg\n"); \
1989 fprintf (FILE, "# Function page table\n"); \
1990 fprintf (FILE, "\t.balign\t4\n"); \
1991 fprintf (FILE, ".LPGT%d:\n", function_base_page); \
1992 mvs_free_label_list(); \
1993 for ( i = function_base_page; i < mvs_page_num; i++ ) \
1994 fprintf (FILE, "\t.long\t.LPG%d\n", i); \
1995 }
1996
1997 #define FUNCTION_PROLOGUE(FILE, LSIZE) i370_function_prolog ((FILE), (LSIZE));
1998
1999 /* Output assembler code to FILE to increment profiler label # LABELNO
2000 for profiling a function entry. */
2001 /* Make it a no-op for now, so we can at least compile glibc */
2002 #define FUNCTION_PROFILER(FILE, LABELNO) { \
2003 mvs_check_page (FILE, 24, 4); \
2004 fprintf (FILE, "\tSTM\tr1,r2,%d(sp)\n", STACK_POINTER_OFFSET-8); \
2005 fprintf (FILE, "\tLA\tr1,1(0,0)\n"); \
2006 fprintf (FILE, "\tL\tr2,=A(.LP%d)\n", LABELNO); \
2007 fprintf (FILE, "\tA\tr1,0(r2)\n"); \
2008 fprintf (FILE, "\tST\tr1,0(r2)\n"); \
2009 fprintf (FILE, "\tLM\tr1,r2,%d(sp)\n", STACK_POINTER_OFFSET-8); \
2010 }
2011
2012 /* Don't bother to output .extern pseudo-ops. They are not needed by
2013 ELF assemblers. */
2014
2015 #undef ASM_OUTPUT_EXTERNAL
2016
2017 #define ASM_DOUBLE "\t.double"
2018 #define ASM_LONG "\t.long"
2019 #define ASM_SHORT "\t.short"
2020 #define ASM_BYTE "\t.byte"
2021
2022 /* Argument to the flt pt. macros is a REAL_VALUE_TYPE which
2023 may or may not be a float/double, depending on whther we
2024 are running in cross-compiler mode. */
2025 /* This is how to output an assembler line defining a `double' constant. */
2026 #define ASM_OUTPUT_DOUBLE(FILE, RVAL) { \
2027 char buf[50]; \
2028 REAL_VALUE_TO_DECIMAL (RVAL, HOST_WIDE_INT_PRINT_DOUBLE_HEX, buf); \
2029 fprintf (FILE, "\tDC\tD'%s'\n", buf); \
2030 }
2031
2032 /* This is how to output an assembler line defining a `float' constant. */
2033 #define ASM_OUTPUT_FLOAT(FILE, RVAL) { \
2034 char buf[50]; \
2035 REAL_VALUE_TO_DECIMAL (RVAL, HOST_WIDE_INT_PRINT_DEC, buf); \
2036 fprintf (FILE, "\tDC\tE'%s'\n", buf); \
2037 }
2038
2039
2040 /* This is how to output an assembler line defining an `int' constant. */
2041 #define ASM_OUTPUT_INT(FILE,VALUE) \
2042 ( fprintf (FILE, "%s ", ASM_LONG), \
2043 output_addr_const (FILE,(VALUE)), \
2044 putc('\n',FILE))
2045
2046 /* Likewise for `char' and `short' constants. */
2047 #define ASM_OUTPUT_SHORT(FILE,VALUE) \
2048 ( fprintf (FILE, "%s ", ASM_SHORT), \
2049 output_addr_const (FILE,(VALUE)), \
2050 putc('\n',FILE))
2051
2052
2053 #define ASM_OUTPUT_CHAR(FILE,VALUE) \
2054 ( fprintf (FILE, "%s ", ASM_BYTE_OP), \
2055 output_addr_const (FILE, (VALUE)), \
2056 putc ('\n', FILE))
2057
2058 /* This is how to output an assembler line for a numeric constant byte. */
2059 #define ASM_OUTPUT_BYTE(FILE,VALUE) \
2060 fprintf ((FILE), "%s 0x%x\n", ASM_BYTE_OP, (VALUE))
2061
2062 /* This is how to output the definition of a user-level label named NAME,
2063 such as the label on a static function or variable NAME. */
2064 #define ASM_OUTPUT_LABEL(FILE,NAME) \
2065 (assemble_name (FILE, NAME), fputs (":\n", FILE))
2066
2067 /* #define ASM_OUTPUT_LABELREF(FILE, NAME) */ /* use gas -- defaults.h */
2068
2069 /* Generate internal label. Since we can branch here from off page, we
2070 must reload the base register. Note that internal labels are generated
2071 for loops, goto's and case labels. */
2072 #undef ASM_OUTPUT_INTERNAL_LABEL
2073 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
2074 { \
2075 if (!strcmp (PREFIX,"L")) \
2076 { \
2077 mvs_add_label(NUM); \
2078 } \
2079 fprintf (FILE, ".%s%d:\n", PREFIX, NUM); \
2080 }
2081
2082 /* let config/svr4.h define this ...
2083 * #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, TABLE)
2084 * fprintf (FILE, "%s%d:\n", PREFIX, NUM)
2085 */
2086
2087 /* This is how to output an element of a case-vector that is absolute. */
2088 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
2089 mvs_check_page (FILE, 4, 0); \
2090 fprintf (FILE, "\t.long\t.L%d\n", VALUE)
2091
2092 /* This is how to output an element of a case-vector that is relative. */
2093 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
2094 mvs_check_page (FILE, 4, 0); \
2095 fprintf (FILE, "\t.long\t.L%d-.L%d\n", VALUE, REL)
2096
2097 /* Right now, PUSH & POP are used only when profiling is enabled,
2098 and then, only to push the static chain reg and the function struct
2099 value reg, and only if those are used by the function being profiled.
2100 We don't need this for profiling, so punt. */
2101 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO)
2102 #define ASM_OUTPUT_REG_POP(FILE, REGNO)
2103
2104
2105 /* Indicate that jump tables go in the text section. This is
2106 necessary when compiling PIC code. */
2107 #define JUMP_TABLES_IN_TEXT_SECTION 1
2108
2109 /* Define macro used to output shift-double opcodes when the shift
2110 count is in %cl. Some assemblers require %cl as an argument;
2111 some don't.
2112
2113 GAS requires the %cl argument, so override i386/unix.h. */
2114
2115 #undef SHIFT_DOUBLE_OMITS_COUNT
2116 #define SHIFT_DOUBLE_OMITS_COUNT 0
2117
2118 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
2119 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
2120 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
2121
2122 /* Allow #sccs in preprocessor. */
2123 #define SCCS_DIRECTIVE
2124
2125 /* Implicit library calls should use memcpy, not bcopy, etc. */
2126 #define TARGET_MEM_FUNCTIONS
2127
2128 /* Output before read-only data. */
2129 #define TEXT_SECTION_ASM_OP ".text"
2130
2131 /* Output before writable (initialized) data. */
2132 #define DATA_SECTION_ASM_OP ".data"
2133
2134 /* Output before writable (uninitialized) data. */
2135 #define BSS_SECTION_ASM_OP ".bss"
2136
2137 /* In the past there was confusion as to what the argument to .align was
2138 in GAS. For the last several years the rule has been this: for a.out
2139 file formats that argument is LOG, and for all other file formats the
2140 argument is 1<<LOG.
2141
2142 However, GAS now has .p2align and .balign pseudo-ops so to remove any
2143 doubt or guess work, and since this file is used for both a.out and other
2144 file formats, we use one of them. */
2145
2146 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
2147 if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG))
2148
2149 /* This is how to output a command to make the user-level label named NAME
2150 defined for reference from other files. */
2151
2152 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
2153 (fputs (".globl ", FILE), assemble_name (FILE, NAME), fputs ("\n", FILE))
2154
2155 /* This says how to output an assembler line
2156 to define a global common symbol. */
2157
2158 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
2159 ( fputs (".comm ", (FILE)), \
2160 assemble_name ((FILE), (NAME)), \
2161 fprintf ((FILE), ",%u\n", (ROUNDED)))
2162
2163 /* This says how to output an assembler line
2164 to define a local common symbol. */
2165
2166 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
2167 ( fputs (".lcomm ", (FILE)), \
2168 assemble_name ((FILE), (NAME)), \
2169 fprintf ((FILE), ",%u\n", (ROUNDED)))
2170
2171 #endif /* TARGET_ELF_ABI */
2172 #endif /* __I370_H__ */