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