Improve code generation for pdp11 target.
[official-gcc.git] / gcc / config / pdp11 / pdp11.h
blobf4c91863b7a2e809d441653ca1845122efacd368
1 /* Definitions of target machine for GNU compiler, for the pdp-11
2 Copyright (C) 1994-2018 Free Software Foundation, Inc.
3 Contributed by Michael K. Gschwind (mike@vlsivie.tuwien.ac.at).
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #define CONSTANT_POOL_BEFORE_FUNCTION 0
23 /* check whether load_fpu_reg or not */
24 #define LOAD_FPU_REG_P(x) ((x) >= AC0_REGNUM && (x) <= AC3_REGNUM)
25 #define NO_LOAD_FPU_REG_P(x) ((x) == AC4_REGNUM || (x) == AC5_REGNUM)
26 #define FPU_REG_P(x) (LOAD_FPU_REG_P(x) || NO_LOAD_FPU_REG_P(x))
27 #define CPU_REG_P(x) ((x) <= PC_REGNUM)
29 /* Names to predefine in the preprocessor for this target machine. */
31 #define TARGET_CPU_CPP_BUILTINS() \
32 do \
33 { \
34 builtin_define_std ("pdp11"); \
35 } \
36 while (0)
39 /* Generate DBX debugging information. */
41 #define DBX_DEBUGGING_INFO
43 #define TARGET_40_PLUS (TARGET_40 || TARGET_45)
44 #define TARGET_10 (! TARGET_40_PLUS)
46 #define TARGET_UNIX_ASM_DEFAULT 0
48 /* "Dialect" just distinguishes between standard DEC mnemonics, which
49 are also used by the GNU assembler, vs. Unix mnemonics and float
50 register names. So it is tied to the -munit-asm option, and treats
51 -mgnu-asm and -mdec-asm as equivalent (both are dialect zero). */
52 #define ASSEMBLER_DIALECT (TARGET_UNIX_ASM ? 1 : 0)
56 /* TYPE SIZES */
57 #define SHORT_TYPE_SIZE 16
58 #define INT_TYPE_SIZE (TARGET_INT16 ? 16 : 32)
59 #define LONG_TYPE_SIZE 32
60 #define LONG_LONG_TYPE_SIZE 64
62 /* if we set FLOAT_TYPE_SIZE to 32, we could have the benefit
63 of saving core for huge arrays - the definitions are
64 already in md - but floats can never reside in
65 an FPU register - we keep the FPU in double float mode
66 all the time !! */
67 #define FLOAT_TYPE_SIZE (TARGET_FLOAT32 ? 32 : 64)
68 #define DOUBLE_TYPE_SIZE 64
69 #define LONG_DOUBLE_TYPE_SIZE 64
71 /* machine types from ansi */
72 #define SIZE_TYPE "short unsigned int" /* definition of size_t */
73 #define WCHAR_TYPE "short int" /* or long int???? */
74 #define WCHAR_TYPE_SIZE 16
76 #define PTRDIFF_TYPE "short int"
78 /* target machine storage layout */
80 /* Define this if most significant bit is lowest numbered
81 in instructions that operate on numbered bit-fields. */
82 #define BITS_BIG_ENDIAN 0
84 /* Define this if most significant byte of a word is the lowest numbered. */
85 #define BYTES_BIG_ENDIAN 0
87 /* Define this if most significant word of a multiword number is first. */
88 #define WORDS_BIG_ENDIAN 1
90 /* Define that floats are in VAX order, not high word first as for ints. */
91 #define FLOAT_WORDS_BIG_ENDIAN 0
93 /* Width of a word, in units (bytes).
95 UNITS OR BYTES - seems like units */
96 #define UNITS_PER_WORD 2
98 /* This machine doesn't use IEEE floats. */
99 /* Because the pdp11 (at least Unix) convention for 32-bit ints is
100 big endian, opposite for what you need for float, the vax float
101 conversion routines aren't actually used directly. But the underlying
102 format is indeed the vax/pdp11 float format. */
103 extern const struct real_format pdp11_f_format;
104 extern const struct real_format pdp11_d_format;
106 /* Maximum sized of reasonable data type -- DImode ...*/
107 #define MAX_FIXED_MODE_SIZE 64
109 /* Allocation boundary (in *bits*) for storing pointers in memory. */
110 #define POINTER_BOUNDARY 16
112 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
113 #define PARM_BOUNDARY 16
115 /* Boundary (in *bits*) on which stack pointer should be aligned. */
116 #define STACK_BOUNDARY 16
118 /* Allocation boundary (in *bits*) for the code of a function. */
119 #define FUNCTION_BOUNDARY 16
121 /* Alignment of field after `int : 0' in a structure. */
122 #define EMPTY_FIELD_BOUNDARY 16
124 /* No data type wants to be aligned rounder than this. */
125 #define BIGGEST_ALIGNMENT 16
127 /* Define this if move instructions will actually fail to work
128 when given unaligned data. */
129 #define STRICT_ALIGNMENT 1
131 /* Standard register usage. */
133 /* Number of actual hardware registers.
134 The hardware registers are assigned numbers for the compiler
135 from 0 to just below FIRST_PSEUDO_REGISTER.
136 All registers that the compiler knows about must be given numbers,
137 even those that are not normally considered general registers.
139 we have 8 integer registers, plus 6 float
140 (don't use scratch float !) */
142 /* 1 for registers that have pervasive standard uses
143 and are not available for the register allocator.
145 On the pdp, these are:
146 Reg 7 = pc;
147 reg 6 = sp;
148 reg 5 = fp; not necessarily!
151 #define FIXED_REGISTERS \
152 {0, 0, 0, 0, 0, 0, 1, 1, \
153 0, 0, 0, 0, 0, 0, 1, 1, \
154 1, 1 }
158 /* 1 for registers not available across function calls.
159 These must include the FIXED_REGISTERS and also any
160 registers that can be used without being saved.
161 The latter must include the registers where values are returned
162 and the register where structure-value addresses are passed.
163 Aside from that, you can include as many other registers as you like. */
165 /* don't know about fp */
166 #define CALL_USED_REGISTERS \
167 {1, 1, 0, 0, 0, 0, 1, 1, \
168 0, 0, 0, 0, 0, 0, 1, 1, \
169 1, 1 }
172 /* Specify the registers used for certain standard purposes.
173 The values of these macros are register numbers. */
175 /* Register in which static-chain is passed to a function. */
176 /* ??? - i don't want to give up a reg for this! */
177 #define STATIC_CHAIN_REGNUM 4
179 /* Define the classes of registers for register constraints in the
180 machine description. Also define ranges of constants.
182 One of the classes must always be named ALL_REGS and include all hard regs.
183 If there is more than one class, another class must be named NO_REGS
184 and contain no registers.
186 The name GENERAL_REGS must be the name of a class (or an alias for
187 another name such as ALL_REGS). This is the class of registers
188 that is allowed by "g" or "r" in a register constraint.
189 Also, registers outside this class are allocated only when
190 instructions express preferences for them.
192 The classes must be numbered in nondecreasing order; that is,
193 a larger-numbered class must never be contained completely
194 in a smaller-numbered class.
196 For any two classes, it is very desirable that there be another
197 class that represents their union. */
199 /* The pdp has a couple of classes:
201 MUL_REGS are used for odd numbered regs, to use in 16-bit multiplication
202 (even numbered do 32-bit multiply)
203 LMUL_REGS long multiply registers (even numbered regs )
204 (don't need them, all 32-bit regs are even numbered!)
205 GENERAL_REGS is all cpu
206 LOAD_FPU_REGS is the first four cpu regs, they are easier to load
207 NO_LOAD_FPU_REGS is ac4 and ac5, currently - difficult to load them
208 FPU_REGS is all fpu regs
211 enum reg_class
212 { NO_REGS,
213 MUL_REGS,
214 GENERAL_REGS,
215 LOAD_FPU_REGS,
216 NO_LOAD_FPU_REGS,
217 FPU_REGS,
218 CC_REGS,
219 ALL_REGS,
220 LIM_REG_CLASSES };
222 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
224 /* have to allow this till cmpsi/tstsi are fixed in a better way !! */
225 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
227 /* Give names of register classes as strings for dump file. */
229 #define REG_CLASS_NAMES \
230 { "NO_REGS", \
231 "MUL_REGS", \
232 "GENERAL_REGS", \
233 "LOAD_FPU_REGS", \
234 "NO_LOAD_FPU_REGS", \
235 "FPU_REGS", \
236 "CC_REGS", \
237 "ALL_REGS" }
239 /* Define which registers fit in which classes.
240 This is an initializer for a vector of HARD_REG_SET
241 of length N_REG_CLASSES. */
243 #define REG_CLASS_CONTENTS \
244 { {0x00000}, /* NO_REGS */ \
245 {0x000aa}, /* MUL_REGS */ \
246 {0x0c0ff}, /* GENERAL_REGS */ \
247 {0x00f00}, /* LOAD_FPU_REGS */ \
248 {0x03000}, /* NO_LOAD_FPU_REGS */ \
249 {0x03f00}, /* FPU_REGS */ \
250 {0x30000}, /* CC_REGS */ \
251 {0x3ffff}} /* ALL_REGS */
253 /* The same information, inverted:
254 Return the class number of the smallest class containing
255 reg number REGNO. This could be a conditional expression
256 or could index an array. */
258 #define REGNO_REG_CLASS(REGNO) pdp11_regno_reg_class (REGNO)
260 /* The class value for index registers, and the one for base regs. */
261 #define INDEX_REG_CLASS GENERAL_REGS
262 #define BASE_REG_CLASS GENERAL_REGS
264 /* Return the maximum number of consecutive registers
265 needed to represent mode MODE in a register of class CLASS. */
266 #define CLASS_MAX_NREGS(CLASS, MODE) \
267 ((CLASS == GENERAL_REGS || CLASS == MUL_REGS)? \
268 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD): \
272 /* Stack layout; function entry, exit and calling. */
274 /* Define this if pushing a word on the stack
275 makes the stack pointer a smaller address. */
276 #define STACK_GROWS_DOWNWARD 1
278 /* Define this to nonzero if the nominal address of the stack frame
279 is at the high-address end of the local variables;
280 that is, each additional local variable allocated
281 goes at a more negative offset in the frame.
283 #define FRAME_GROWS_DOWNWARD 1
285 #define PUSH_ROUNDING(BYTES) pdp11_push_rounding (BYTES)
287 /* current_first_parm_offset stores the # of registers pushed on the
288 stack */
289 extern int current_first_parm_offset;
291 /* Offset of first parameter from the argument pointer register value. */
292 #define FIRST_PARM_OFFSET(FNDECL) 0
294 /* Define how to find the value returned by a function.
295 VALTYPE is the data type of the value (as a tree).
296 If the precise function being called is known, FUNC is its FUNCTION_DECL;
297 otherwise, FUNC is 0. */
298 #define BASE_RETURN_VALUE_REG(MODE) \
299 (FLOAT_MODE_P (MODE) ? AC0_REGNUM : RETVAL_REGNUM)
301 /* 1 if N is a possible register number for function argument passing.
302 - not used on pdp */
304 #define FUNCTION_ARG_REGNO_P(N) 0
306 /* Define a data type for recording info about an argument list
307 during the scan of that argument list. This data type should
308 hold all necessary information about the function itself
309 and about the args processed so far, enough to enable macros
310 such as FUNCTION_ARG to determine where the next arg should go.
314 #define CUMULATIVE_ARGS int
316 /* Initialize a variable CUM of type CUMULATIVE_ARGS
317 for a call to a function whose data type is FNTYPE.
318 For a library call, FNTYPE is 0.
320 ...., the offset normally starts at 0, but starts at 1 word
321 when the function gets a structure-value-address as an
322 invisible first argument. */
324 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
325 ((CUM) = 0)
327 /* Output assembler code to FILE to increment profiler label # LABELNO
328 for profiling a function entry. */
330 #define FUNCTION_PROFILER(FILE, LABELNO) \
331 gcc_unreachable ();
333 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
334 the stack pointer does not matter. The value is tested only in
335 functions that have frame pointers.
336 No definition is equivalent to always zero. */
338 extern int may_call_alloca;
340 #define EXIT_IGNORE_STACK 1
342 /* Definitions for register eliminations.
344 This is an array of structures. Each structure initializes one pair
345 of eliminable registers. The "from" register number is given first,
346 followed by "to". Eliminations of the same "from" register are listed
347 in order of preference.
349 There are two registers that can always be eliminated on the pdp11.
350 The frame pointer and the arg pointer can be replaced by either the
351 hard frame pointer or to the stack pointer, depending upon the
352 circumstances. The hard frame pointer is not used before reload and
353 so it is not eligible for elimination. */
355 #define ELIMINABLE_REGS \
356 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
357 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
358 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
359 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
361 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
362 ((OFFSET) = pdp11_initial_elimination_offset ((FROM), (TO)))
365 /* Addressing modes, and classification of registers for them. */
367 #define HAVE_POST_INCREMENT 1
369 #define HAVE_PRE_DECREMENT 1
371 /* Macros to check register numbers against specific register classes. */
373 /* These assume that REGNO is a hard or pseudo reg number.
374 They give nonzero only if REGNO is a hard reg of the suitable class
375 or a pseudo reg currently allocated to a suitable hard reg.
376 Since they use reg_renumber, they are safe only once reg_renumber
377 has been allocated, which happens in reginfo.c during register
378 allocation. */
380 #define REGNO_OK_FOR_BASE_P(REGNO) \
381 ((REGNO) <= PC_REGNUM || (unsigned) reg_renumber[REGNO] <= PC_REGNUM || \
382 (REGNO) == ARG_POINTER_REGNUM || (REGNO) == FRAME_POINTER_REGNUM)
384 #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P (REGNO)
386 /* Now macros that check whether X is a register and also,
387 strictly, whether it is in a specified class.
392 /* Maximum number of registers that can appear in a valid memory address. */
394 #define MAX_REGS_PER_ADDRESS 1
396 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
397 and check its validity for a certain class.
398 We have two alternate definitions for each of them.
399 The usual definition accepts all pseudo regs; the other rejects
400 them unless they have been allocated suitable hard regs.
401 The symbol REG_OK_STRICT causes the latter definition to be used.
403 Most source files want to accept pseudo regs in the hope that
404 they will get allocated to the class that the insn wants them to be in.
405 Source files for reload pass need to be strict.
406 After reload, it makes no difference, since pseudo regs have
407 been eliminated by then. */
409 #ifndef REG_OK_STRICT
411 /* Nonzero if X is a hard reg that can be used as an index
412 or if it is a pseudo reg. */
413 #define REG_OK_FOR_INDEX_P(X) (1)
414 /* Nonzero if X is a hard reg that can be used as a base reg
415 or if it is a pseudo reg. */
416 #define REG_OK_FOR_BASE_P(X) (1)
418 #else
420 /* Nonzero if X is a hard reg that can be used as an index. */
421 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
422 /* Nonzero if X is a hard reg that can be used as a base reg. */
423 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
425 #endif
427 /* Specify the machine mode that this machine uses
428 for the index in the tablejump instruction. */
429 #define CASE_VECTOR_MODE HImode
431 /* Define this if a raw index is all that is needed for a
432 `tablejump' insn. */
433 #define CASE_TAKES_INDEX_RAW
435 /* Define this as 1 if `char' should by default be signed; else as 0. */
436 #define DEFAULT_SIGNED_CHAR 1
438 /* Max number of bytes we can move from memory to memory
439 in one reasonably fast instruction.
442 #define MOVE_MAX 2
444 /* Nonzero if access to memory by byte is no faster than by word. */
445 #define SLOW_BYTE_ACCESS 1
447 /* Do not break .stabs pseudos into continuations. */
448 #define DBX_CONTIN_LENGTH 0
450 /* Give a comparison code (EQ, NE etc) and the first operand of a COMPARE,
451 return the mode to be used for the comparison. */
453 #define SELECT_CC_MODE(OP,X,Y) pdp11_cc_mode (OP, X, Y)
455 /* Enable compare elimination pass. */
456 #undef TARGET_FLAGS_REGNUM
457 #define TARGET_FLAGS_REGNUM CC_REGNUM
459 /* Specify the CC registers. TODO: is this for "type 1" CC handling only? */
460 #undef TARGET_FIXED_CONDITION_CODE_REGS
461 #define TARGET_FIXED_CONDITION_CODE_REGS pdp11_fixed_cc_regs
463 /* Specify the machine mode that pointers have.
464 After generation of rtl, the compiler makes no further distinction
465 between pointers and any other objects of this machine mode. */
466 #define Pmode HImode
468 /* A function address in a call instruction
469 is a word address (for indexing purposes)
470 so give the MEM rtx a word's mode. */
471 #define FUNCTION_MODE HImode
473 /* Define this if addresses of constant functions
474 shouldn't be put through pseudo regs where they can be cse'd.
475 Desirable on machines where ordinary constants are expensive
476 but a CALL with constant address is cheap. */
477 /* #define NO_FUNCTION_CSE */
480 /* Control the assembler format that we output. */
482 /* Output to assembler file text saying following lines
483 may contain character constants, extra white space, comments, etc. */
485 #define ASM_APP_ON ""
487 /* Output to assembler file text saying following lines
488 no longer contain unusual constructs. */
490 #define ASM_APP_OFF ""
492 /* Output before read-only data. */
494 #define TEXT_SECTION_ASM_OP \
495 ((TARGET_DEC_ASM) ? "\t.psect\tcode,i,ro,con" : "\t.text")
497 /* Output before writable data. */
499 #define DATA_SECTION_ASM_OP \
500 ((TARGET_DEC_ASM) ? "\t.psect\tdata,d,rw,con" : "\t.data")
502 /* Output before read-only data. Same as read-write data for non-DEC
503 assemblers because they don't know about .rodata. */
505 #define READONLY_DATA_SECTION_ASM_OP \
506 ((TARGET_DEC_ASM) ? "\t.psect\trodata,d,ro,con" : "\t.data")
508 /* How to refer to registers in assembler output.
509 This sequence is indexed by compiler's hard-register-number (see above). */
511 #define REGISTER_NAMES \
512 {"r0", "r1", "r2", "r3", "r4", "r5", "sp", "pc", \
513 "ac0", "ac1", "ac2", "ac3", "ac4", "ac5", "fp", "ap", \
514 "cc", "fcc" }
516 /* Globalizing directive for a label. */
517 #define GLOBAL_ASM_OP "\t.globl\t"
519 /* The prefix to add to user-visible assembler symbols. For the DEC
520 assembler case, this is not used. */
522 #define USER_LABEL_PREFIX "_"
524 /* Line separators. */
526 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) \
527 ((C) == '\n' || (!TARGET_DEC_ASM && (C) == ';'))
529 /* This is how to store into the string LABEL
530 the symbol_ref name of an internal numbered label where
531 PREFIX is the class of label and NUM is the number within the class.
532 This is suitable for output with `assemble_name'. */
534 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
535 pdp11_gen_int_label ((LABEL), (PREFIX), (NUM))
537 /* Emit a string. */
539 #define ASM_OUTPUT_ASCII(FILE, P, SIZE) \
540 output_ascii (FILE, P, SIZE)
542 /* Print a label reference, with _ prefix if not DEC. */
544 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
545 pdp11_output_labelref ((STREAM), (NAME))
547 /* Equate a symbol to an expression. */
549 #define ASM_OUTPUT_DEF(STREAM, NAME, VALUE) \
550 pdp11_output_def (STREAM, NAME, VALUE)
552 /* Mark a reference to an external symbol. Needed for DEC assembler. */
554 #define ASM_OUTPUT_EXTERNAL(STREAM, DECL, NAME) \
555 if (TARGET_DEC_ASM) \
556 fprintf ((STREAM), "\t.globl\t%s\n", (NAME))
558 #define ASM_OUTPUT_SOURCE_FILENAME(STREAM, NAME) \
559 if (TARGET_DEC_ASM) \
560 fprintf ((STREAM), ".title\t%s\n", (NAME))
562 /* This is how to output an element of a case-vector that is absolute. */
564 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
565 pdp11_output_addr_vec_elt (FILE, VALUE)
567 /* This is how to output an assembler line
568 that says to advance the location counter
569 to a multiple of 2**LOG bytes.
572 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
573 switch (LOG) \
575 case 0: \
576 break; \
577 case 1: \
578 fprintf (FILE, "\t.even\n"); \
579 break; \
580 default: \
581 gcc_unreachable (); \
584 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
585 if (TARGET_DEC_ASM) \
586 fprintf (FILE, "\t.blkb\t%ho\n", (SIZE) & 0xffff); \
587 else \
588 fprintf (FILE, "\t.=.+ %#ho\n", (SIZE) & 0xffff);
590 /* This says how to output an assembler line
591 to define a global common symbol. */
593 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
594 pdp11_asm_output_var (FILE, NAME, SIZE, ALIGN, true)
597 /* This says how to output an assembler line
598 to define a local common symbol. */
600 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
601 pdp11_asm_output_var (FILE, NAME, SIZE, ALIGN, false)
603 /* Print a memory address as an operand to reference that memory location. */
605 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
606 print_operand_address (FILE, ADDR)
608 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
609 fprintf (FILE, "\tmov\t%s,-(sp)\n", reg_names[REGNO])
611 #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
612 fprintf (FILE, "\tmov\t(sp)+,%s\n", reg_names[REGNO])
614 #define TRAMPOLINE_SIZE 8
615 #define TRAMPOLINE_ALIGNMENT 16
617 #define BRANCH_COST(speed_p, predictable_p) 1
619 #define COMPARE_FLAG_MODE HImode
621 /* May be overridden by command option processing. */
622 #define TARGET_HAVE_NAMED_SECTIONS false
624 /* pdp11-unknown-aout target has no support of C99 runtime */
625 #undef TARGET_LIBC_HAS_FUNCTION
626 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function