]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/pdp11/pdp11.h
Fix insn length for pdp11 shift patterns.
[thirdparty/gcc.git] / gcc / config / pdp11 / pdp11.h
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).
4
5 This file is part of GCC.
6
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.
11
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.
16
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/>. */
20
21 #define CONSTANT_POOL_BEFORE_FUNCTION 0
22
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)
28
29 /* Names to predefine in the preprocessor for this target machine. */
30
31 #define TARGET_CPU_CPP_BUILTINS() \
32 do \
33 { \
34 builtin_define_std ("pdp11"); \
35 } \
36 while (0)
37
38
39 /* Generate DBX debugging information. */
40
41 #define DBX_DEBUGGING_INFO
42
43 #define TARGET_40_PLUS (TARGET_40 || TARGET_45)
44 #define TARGET_10 (! TARGET_40_PLUS)
45
46 #define TARGET_UNIX_ASM_DEFAULT 0
47
48 #define ASSEMBLER_DIALECT (TARGET_UNIX_ASM ? 1 : 0)
49
50 \f
51
52 /* TYPE SIZES */
53 #define SHORT_TYPE_SIZE 16
54 #define INT_TYPE_SIZE (TARGET_INT16 ? 16 : 32)
55 #define LONG_TYPE_SIZE 32
56 #define LONG_LONG_TYPE_SIZE 64
57
58 /* if we set FLOAT_TYPE_SIZE to 32, we could have the benefit
59 of saving core for huge arrays - the definitions are
60 already in md - but floats can never reside in
61 an FPU register - we keep the FPU in double float mode
62 all the time !! */
63 #define FLOAT_TYPE_SIZE (TARGET_FLOAT32 ? 32 : 64)
64 #define DOUBLE_TYPE_SIZE 64
65 #define LONG_DOUBLE_TYPE_SIZE 64
66
67 /* machine types from ansi */
68 #define SIZE_TYPE "short unsigned int" /* definition of size_t */
69 #define WCHAR_TYPE "short int" /* or long int???? */
70 #define WCHAR_TYPE_SIZE 16
71
72 #define PTRDIFF_TYPE "short int"
73
74 /* target machine storage layout */
75
76 /* Define this if most significant bit is lowest numbered
77 in instructions that operate on numbered bit-fields. */
78 #define BITS_BIG_ENDIAN 0
79
80 /* Define this if most significant byte of a word is the lowest numbered. */
81 #define BYTES_BIG_ENDIAN 0
82
83 /* Define this if most significant word of a multiword number is first. */
84 #define WORDS_BIG_ENDIAN 1
85
86 /* Define that floats are in VAX order, not high word first as for ints. */
87 #define FLOAT_WORDS_BIG_ENDIAN 0
88
89 /* Width of a word, in units (bytes).
90
91 UNITS OR BYTES - seems like units */
92 #define UNITS_PER_WORD 2
93
94 /* This machine doesn't use IEEE floats. */
95 /* Because the pdp11 (at least Unix) convention for 32-bit ints is
96 big endian, opposite for what you need for float, the vax float
97 conversion routines aren't actually used directly. But the underlying
98 format is indeed the vax/pdp11 float format. */
99 extern const struct real_format pdp11_f_format;
100 extern const struct real_format pdp11_d_format;
101
102 /* Maximum sized of reasonable data type -- DImode ...*/
103 #define MAX_FIXED_MODE_SIZE 64
104
105 /* Allocation boundary (in *bits*) for storing pointers in memory. */
106 #define POINTER_BOUNDARY 16
107
108 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
109 #define PARM_BOUNDARY 16
110
111 /* Boundary (in *bits*) on which stack pointer should be aligned. */
112 #define STACK_BOUNDARY 16
113
114 /* Allocation boundary (in *bits*) for the code of a function. */
115 #define FUNCTION_BOUNDARY 16
116
117 /* Alignment of field after `int : 0' in a structure. */
118 #define EMPTY_FIELD_BOUNDARY 16
119
120 /* No data type wants to be aligned rounder than this. */
121 #define BIGGEST_ALIGNMENT 16
122
123 /* Define this if move instructions will actually fail to work
124 when given unaligned data. */
125 #define STRICT_ALIGNMENT 1
126 \f
127 /* Standard register usage. */
128
129 /* Number of actual hardware registers.
130 The hardware registers are assigned numbers for the compiler
131 from 0 to just below FIRST_PSEUDO_REGISTER.
132 All registers that the compiler knows about must be given numbers,
133 even those that are not normally considered general registers.
134
135 we have 8 integer registers, plus 6 float
136 (don't use scratch float !) */
137
138 /* 1 for registers that have pervasive standard uses
139 and are not available for the register allocator.
140
141 On the pdp, these are:
142 Reg 7 = pc;
143 reg 6 = sp;
144 reg 5 = fp; not necessarily!
145 */
146
147 #define FIXED_REGISTERS \
148 {0, 0, 0, 0, 0, 0, 1, 1, \
149 0, 0, 0, 0, 0, 0, 1, 1, \
150 1, 1 }
151
152
153
154 /* 1 for registers not available across function calls.
155 These must include the FIXED_REGISTERS and also any
156 registers that can be used without being saved.
157 The latter must include the registers where values are returned
158 and the register where structure-value addresses are passed.
159 Aside from that, you can include as many other registers as you like. */
160
161 /* don't know about fp */
162 #define CALL_USED_REGISTERS \
163 {1, 1, 0, 0, 0, 0, 1, 1, \
164 0, 0, 0, 0, 0, 0, 1, 1, \
165 1, 1 }
166
167
168 /* Specify the registers used for certain standard purposes.
169 The values of these macros are register numbers. */
170
171 /* Register in which static-chain is passed to a function. */
172 /* ??? - i don't want to give up a reg for this! */
173 #define STATIC_CHAIN_REGNUM 4
174 \f
175 /* Define the classes of registers for register constraints in the
176 machine description. Also define ranges of constants.
177
178 One of the classes must always be named ALL_REGS and include all hard regs.
179 If there is more than one class, another class must be named NO_REGS
180 and contain no registers.
181
182 The name GENERAL_REGS must be the name of a class (or an alias for
183 another name such as ALL_REGS). This is the class of registers
184 that is allowed by "g" or "r" in a register constraint.
185 Also, registers outside this class are allocated only when
186 instructions express preferences for them.
187
188 The classes must be numbered in nondecreasing order; that is,
189 a larger-numbered class must never be contained completely
190 in a smaller-numbered class.
191
192 For any two classes, it is very desirable that there be another
193 class that represents their union. */
194
195 /* The pdp has a couple of classes:
196
197 MUL_REGS are used for odd numbered regs, to use in 16-bit multiplication
198 (even numbered do 32-bit multiply)
199 LMUL_REGS long multiply registers (even numbered regs )
200 (don't need them, all 32-bit regs are even numbered!)
201 GENERAL_REGS is all cpu
202 LOAD_FPU_REGS is the first four cpu regs, they are easier to load
203 NO_LOAD_FPU_REGS is ac4 and ac5, currently - difficult to load them
204 FPU_REGS is all fpu regs
205 */
206
207 enum reg_class
208 { NO_REGS,
209 MUL_REGS,
210 GENERAL_REGS,
211 LOAD_FPU_REGS,
212 NO_LOAD_FPU_REGS,
213 FPU_REGS,
214 CC_REGS,
215 ALL_REGS,
216 LIM_REG_CLASSES };
217
218 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
219
220 /* have to allow this till cmpsi/tstsi are fixed in a better way !! */
221 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
222
223 /* Give names of register classes as strings for dump file. */
224
225 #define REG_CLASS_NAMES \
226 { "NO_REGS", \
227 "MUL_REGS", \
228 "GENERAL_REGS", \
229 "LOAD_FPU_REGS", \
230 "NO_LOAD_FPU_REGS", \
231 "FPU_REGS", \
232 "CC_REGS", \
233 "ALL_REGS" }
234
235 /* Define which registers fit in which classes.
236 This is an initializer for a vector of HARD_REG_SET
237 of length N_REG_CLASSES. */
238
239 #define REG_CLASS_CONTENTS \
240 { {0x00000}, /* NO_REGS */ \
241 {0x000aa}, /* MUL_REGS */ \
242 {0x0c0ff}, /* GENERAL_REGS */ \
243 {0x00f00}, /* LOAD_FPU_REGS */ \
244 {0x03000}, /* NO_LOAD_FPU_REGS */ \
245 {0x03f00}, /* FPU_REGS */ \
246 {0x30000}, /* CC_REGS */ \
247 {0x3ffff}} /* ALL_REGS */
248
249 /* The same information, inverted:
250 Return the class number of the smallest class containing
251 reg number REGNO. This could be a conditional expression
252 or could index an array. */
253
254 #define REGNO_REG_CLASS(REGNO) pdp11_regno_reg_class (REGNO)
255
256 /* The class value for index registers, and the one for base regs. */
257 #define INDEX_REG_CLASS GENERAL_REGS
258 #define BASE_REG_CLASS GENERAL_REGS
259
260 /* Return the maximum number of consecutive registers
261 needed to represent mode MODE in a register of class CLASS. */
262 #define CLASS_MAX_NREGS(CLASS, MODE) \
263 ((CLASS == GENERAL_REGS || CLASS == MUL_REGS)? \
264 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD): \
265 1 \
266 )
267 \f
268 /* Stack layout; function entry, exit and calling. */
269
270 /* Define this if pushing a word on the stack
271 makes the stack pointer a smaller address. */
272 #define STACK_GROWS_DOWNWARD 1
273
274 /* Define this to nonzero if the nominal address of the stack frame
275 is at the high-address end of the local variables;
276 that is, each additional local variable allocated
277 goes at a more negative offset in the frame.
278 */
279 #define FRAME_GROWS_DOWNWARD 1
280
281 #define PUSH_ROUNDING(BYTES) pdp11_push_rounding (BYTES)
282
283 /* current_first_parm_offset stores the # of registers pushed on the
284 stack */
285 extern int current_first_parm_offset;
286
287 /* Offset of first parameter from the argument pointer register value. */
288 #define FIRST_PARM_OFFSET(FNDECL) 0
289
290 /* Define how to find the value returned by a function.
291 VALTYPE is the data type of the value (as a tree).
292 If the precise function being called is known, FUNC is its FUNCTION_DECL;
293 otherwise, FUNC is 0. */
294 #define BASE_RETURN_VALUE_REG(MODE) \
295 (FLOAT_MODE_P (MODE) ? AC0_REGNUM : RETVAL_REGNUM)
296
297 /* 1 if N is a possible register number for function argument passing.
298 - not used on pdp */
299
300 #define FUNCTION_ARG_REGNO_P(N) 0
301 \f
302 /* Define a data type for recording info about an argument list
303 during the scan of that argument list. This data type should
304 hold all necessary information about the function itself
305 and about the args processed so far, enough to enable macros
306 such as FUNCTION_ARG to determine where the next arg should go.
307
308 */
309
310 #define CUMULATIVE_ARGS int
311
312 /* Initialize a variable CUM of type CUMULATIVE_ARGS
313 for a call to a function whose data type is FNTYPE.
314 For a library call, FNTYPE is 0.
315
316 ...., the offset normally starts at 0, but starts at 1 word
317 when the function gets a structure-value-address as an
318 invisible first argument. */
319
320 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
321 ((CUM) = 0)
322
323 /* Output assembler code to FILE to increment profiler label # LABELNO
324 for profiling a function entry. */
325
326 #define FUNCTION_PROFILER(FILE, LABELNO) \
327 gcc_unreachable ();
328
329 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
330 the stack pointer does not matter. The value is tested only in
331 functions that have frame pointers.
332 No definition is equivalent to always zero. */
333
334 extern int may_call_alloca;
335
336 #define EXIT_IGNORE_STACK 1
337
338 /* Definitions for register eliminations.
339
340 This is an array of structures. Each structure initializes one pair
341 of eliminable registers. The "from" register number is given first,
342 followed by "to". Eliminations of the same "from" register are listed
343 in order of preference.
344
345 There are two registers that can always be eliminated on the pdp11.
346 The frame pointer and the arg pointer can be replaced by either the
347 hard frame pointer or to the stack pointer, depending upon the
348 circumstances. The hard frame pointer is not used before reload and
349 so it is not eligible for elimination. */
350
351 #define ELIMINABLE_REGS \
352 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
353 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
354 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
355 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
356
357 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
358 ((OFFSET) = pdp11_initial_elimination_offset ((FROM), (TO)))
359
360 \f
361 /* Addressing modes, and classification of registers for them. */
362
363 #define HAVE_POST_INCREMENT 1
364
365 #define HAVE_PRE_DECREMENT 1
366
367 /* Macros to check register numbers against specific register classes. */
368
369 /* These assume that REGNO is a hard or pseudo reg number.
370 They give nonzero only if REGNO is a hard reg of the suitable class
371 or a pseudo reg currently allocated to a suitable hard reg.
372 Since they use reg_renumber, they are safe only once reg_renumber
373 has been allocated, which happens in reginfo.c during register
374 allocation. */
375
376 #define REGNO_OK_FOR_BASE_P(REGNO) \
377 ((REGNO) <= PC_REGNUM || (unsigned) reg_renumber[REGNO] <= PC_REGNUM || \
378 (REGNO) == ARG_POINTER_REGNUM || (REGNO) == FRAME_POINTER_REGNUM)
379
380 #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P (REGNO)
381
382 /* Now macros that check whether X is a register and also,
383 strictly, whether it is in a specified class.
384 */
385
386
387 \f
388 /* Maximum number of registers that can appear in a valid memory address. */
389
390 #define MAX_REGS_PER_ADDRESS 1
391
392 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
393 and check its validity for a certain class.
394 We have two alternate definitions for each of them.
395 The usual definition accepts all pseudo regs; the other rejects
396 them unless they have been allocated suitable hard regs.
397 The symbol REG_OK_STRICT causes the latter definition to be used.
398
399 Most source files want to accept pseudo regs in the hope that
400 they will get allocated to the class that the insn wants them to be in.
401 Source files for reload pass need to be strict.
402 After reload, it makes no difference, since pseudo regs have
403 been eliminated by then. */
404
405 #ifndef REG_OK_STRICT
406
407 /* Nonzero if X is a hard reg that can be used as an index
408 or if it is a pseudo reg. */
409 #define REG_OK_FOR_INDEX_P(X) (1)
410 /* Nonzero if X is a hard reg that can be used as a base reg
411 or if it is a pseudo reg. */
412 #define REG_OK_FOR_BASE_P(X) (1)
413
414 #else
415
416 /* Nonzero if X is a hard reg that can be used as an index. */
417 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
418 /* Nonzero if X is a hard reg that can be used as a base reg. */
419 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
420
421 #endif
422 \f
423 /* Specify the machine mode that this machine uses
424 for the index in the tablejump instruction. */
425 #define CASE_VECTOR_MODE HImode
426
427 /* Define this if a raw index is all that is needed for a
428 `tablejump' insn. */
429 #define CASE_TAKES_INDEX_RAW
430
431 /* Define this as 1 if `char' should by default be signed; else as 0. */
432 #define DEFAULT_SIGNED_CHAR 1
433
434 /* Max number of bytes we can move from memory to memory
435 in one reasonably fast instruction.
436 */
437
438 #define MOVE_MAX 2
439
440 /* Nonzero if access to memory by byte is slow and undesirable. -
441 */
442 #define SLOW_BYTE_ACCESS 0
443
444 /* Do not break .stabs pseudos into continuations. */
445 #define DBX_CONTIN_LENGTH 0
446
447 /* Give a comparison code (EQ, NE etc) and the first operand of a COMPARE,
448 return the mode to be used for the comparison. */
449
450 #define SELECT_CC_MODE(OP,X,Y) pdp11_cc_mode (OP, X, Y)
451
452 /* Enable compare elimination pass.
453 FIXME: how can this be enabled for two registers? */
454 #undef TARGET_FLAGS_REGNUM
455 #define TARGET_FLAGS_REGNUM CC_REGNUM
456
457 /* Specify the CC registers. TODO: is this for "type 1" CC handling only? */
458 #undef TARGET_FIXED_CONDITION_CODE_REGS
459 #define TARGET_FIXED_CONDITION_CODE_REGS pdp11_fixed_cc_regs
460
461 /* Specify the machine mode that pointers have.
462 After generation of rtl, the compiler makes no further distinction
463 between pointers and any other objects of this machine mode. */
464 #define Pmode HImode
465
466 /* A function address in a call instruction
467 is a word address (for indexing purposes)
468 so give the MEM rtx a word's mode. */
469 #define FUNCTION_MODE HImode
470
471 /* Define this if addresses of constant functions
472 shouldn't be put through pseudo regs where they can be cse'd.
473 Desirable on machines where ordinary constants are expensive
474 but a CALL with constant address is cheap. */
475 /* #define NO_FUNCTION_CSE */
476
477 \f
478 /* Control the assembler format that we output. */
479
480 /* Output to assembler file text saying following lines
481 may contain character constants, extra white space, comments, etc. */
482
483 #define ASM_APP_ON ""
484
485 /* Output to assembler file text saying following lines
486 no longer contain unusual constructs. */
487
488 #define ASM_APP_OFF ""
489
490 /* Output before read-only data. */
491
492 #define TEXT_SECTION_ASM_OP "\t.text\n"
493
494 /* Output before writable data. */
495
496 #define DATA_SECTION_ASM_OP "\t.data\n"
497
498 /* How to refer to registers in assembler output.
499 This sequence is indexed by compiler's hard-register-number (see above). */
500
501 #define REGISTER_NAMES \
502 {"r0", "r1", "r2", "r3", "r4", "r5", "sp", "pc", \
503 "ac0", "ac1", "ac2", "ac3", "ac4", "ac5", "fp", "ap", \
504 "cc", "fcc" }
505
506 /* Globalizing directive for a label. */
507 #define GLOBAL_ASM_OP "\t.globl "
508
509 /* The prefix to add to user-visible assembler symbols. */
510
511 #define USER_LABEL_PREFIX "_"
512
513 /* This is how to store into the string LABEL
514 the symbol_ref name of an internal numbered label where
515 PREFIX is the class of label and NUM is the number within the class.
516 This is suitable for output with `assemble_name'. */
517
518 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
519 sprintf (LABEL, "*%s_%lu", PREFIX, (unsigned long)(NUM))
520
521 #define ASM_OUTPUT_ASCII(FILE, P, SIZE) \
522 output_ascii (FILE, P, SIZE)
523
524 /* This is how to output an element of a case-vector that is absolute. */
525
526 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
527 fprintf (FILE, "\t%sL_%d\n", TARGET_UNIX_ASM ? "" : ".word ", VALUE)
528
529 /* This is how to output an element of a case-vector that is relative.
530 Don't define this if it is not supported. */
531
532 /* #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) */
533
534 /* This is how to output an assembler line
535 that says to advance the location counter
536 to a multiple of 2**LOG bytes.
537
538 who needs this????
539 */
540
541 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
542 switch (LOG) \
543 { \
544 case 0: \
545 break; \
546 case 1: \
547 fprintf (FILE, "\t.even\n"); \
548 break; \
549 default: \
550 gcc_unreachable (); \
551 }
552
553 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
554 fprintf (FILE, "\t.=.+ %#ho\n", (unsigned short)(SIZE))
555
556 /* This says how to output an assembler line
557 to define a global common symbol. */
558
559 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
560 pdp11_asm_output_var (FILE, NAME, SIZE, ALIGN, true)
561
562
563 /* This says how to output an assembler line
564 to define a local common symbol. */
565
566 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
567 pdp11_asm_output_var (FILE, NAME, SIZE, ALIGN, false)
568
569 /* Print a memory address as an operand to reference that memory location. */
570
571 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
572 print_operand_address (FILE, ADDR)
573
574 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
575 ( \
576 fprintf (FILE, "\tmov %s, -(sp)\n", reg_names[REGNO]) \
577 )
578
579 #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
580 ( \
581 fprintf (FILE, "\tmov (sp)+, %s\n", reg_names[REGNO]) \
582 )
583
584 #define TRAMPOLINE_SIZE 8
585 #define TRAMPOLINE_ALIGNMENT 16
586
587 #define BRANCH_COST(speed_p, predictable_p) 1
588
589 #define COMPARE_FLAG_MODE HImode
590
591 #define TARGET_HAVE_NAMED_SECTIONS false
592
593 /* pdp11-unknown-aout target has no support of C99 runtime */
594 #undef TARGET_LIBC_HAS_FUNCTION
595 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function