Daily bump.
[official-gcc.git] / gcc / config / moxie / moxie.h
blob3a01dbab46d6f7ec54af8f41421ecf7292ad63a4
1 /* Target Definitions for moxie.
2 Copyright (C) 2008-2014 Free Software Foundation, Inc.
3 Contributed by Anthony Green.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 3, or (at your
10 option) any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 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 #ifndef GCC_MOXIE_H
22 #define GCC_MOXIE_H
24 #undef STARTFILE_SPEC
25 #define STARTFILE_SPEC "%{!mno-crt0:crt0%O%s} crti.o%s crtbegin.o%s"
27 /* Provide an ENDFILE_SPEC appropriate for svr4. Here we tack on our own
28 magical crtend.o file (see crtstuff.c) which provides part of the
29 support for getting C++ file-scope static object constructed before
30 entering `main', followed by the normal svr3/svr4 "finalizer" file,
31 which is either `gcrtn.o' or `crtn.o'. */
33 #undef ENDFILE_SPEC
34 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
36 /* Provide a LIB_SPEC appropriate for svr4. Here we tack on the default
37 standard C library (unless we are building a shared library) and
38 the simulator BSP code. */
40 #undef LIB_SPEC
41 #define LIB_SPEC "%{!shared:%{!symbolic:-lc}}"
43 #undef LINK_SPEC
44 #define LINK_SPEC "%{h*} %{v:-V} %{!mel:-EB} %{mel:-EL}\
45 %{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic}"
47 #ifndef MULTILIB_DEFAULTS
48 #define MULTILIB_DEFAULTS { "meb" }
49 #endif
51 /* Layout of Source Language Data Types */
53 #define INT_TYPE_SIZE 32
54 #define SHORT_TYPE_SIZE 16
55 #define LONG_TYPE_SIZE 32
56 #define LONG_LONG_TYPE_SIZE 64
58 #define FLOAT_TYPE_SIZE 32
59 #define DOUBLE_TYPE_SIZE 64
60 #define LONG_DOUBLE_TYPE_SIZE 64
62 #define DEFAULT_SIGNED_CHAR 0
64 #undef SIZE_TYPE
65 #define SIZE_TYPE "unsigned int"
67 #undef PTRDIFF_TYPE
68 #define PTRDIFF_TYPE "int"
70 #undef WCHAR_TYPE
71 #define WCHAR_TYPE "unsigned int"
73 #undef WCHAR_TYPE_SIZE
74 #define WCHAR_TYPE_SIZE BITS_PER_WORD
76 /* Registers...
78 $fp - frame pointer
79 $sp - stack pointer
80 $r0 - general purpose 32-bit register.
81 $r1 - general purpose 32-bit register.
82 $r2 - general purpose 32-bit register.
83 $r3 - general purpose 32-bit register.
84 $r4 - general purpose 32-bit register.
85 $r5 - general purpose 32-bit register.
86 $r6 - general purpose 32-bit register.
87 $r7 - general purpose 32-bit register.
88 $r8 - general purpose 32-bit register.
89 $r9 - general purpose 32-bit register.
90 $r10 - general purpose 32-bit register.
91 $r11 - general purpose 32-bit register.
92 $r12 - general purpose 32-bit register.
93 $r13 - reserved for execution environment.
95 Special Registers...
97 $pc - 32-bit program counter.
101 #define REGISTER_NAMES { \
102 "$fp", "$sp", "$r0", "$r1", \
103 "$r2", "$r3", "$r4", "$r5", \
104 "$r6", "$r7", "$r8", "$r9", \
105 "$r10", "$r11", "$r12", "$r13", \
106 "?fp", "?ap", "$pc", "?cc" }
108 #define MOXIE_FP 0
109 #define MOXIE_SP 1
110 #define MOXIE_R0 2
111 #define MOXIE_R1 3
112 #define MOXIE_R2 4
113 #define MOXIE_R3 5
114 #define MOXIE_R4 6
115 #define MOXIE_R5 7
116 #define MOXIE_R6 8
117 #define MOXIE_R7 9
118 #define MOXIE_R8 10
119 #define MOXIE_R9 11
120 #define MOXIE_R10 12
121 #define MOXIE_R11 13
122 #define MOXIE_R12 14
123 #define MOXIE_R13 15
124 #define MOXIE_QFP 16
125 #define MOXIE_QAP 17
126 #define MOXIE_PC 18
127 #define MOXIE_CC 19
129 #define FIRST_PSEUDO_REGISTER 20
131 enum reg_class
133 NO_REGS,
134 GENERAL_REGS,
135 SPECIAL_REGS,
136 CC_REGS,
137 ALL_REGS,
138 LIM_REG_CLASSES
142 #define REG_CLASS_CONTENTS \
143 { { 0x00000000 }, /* Empty */ \
144 { 0x0003FFFF }, /* $fp, $sp, $r0 to $r13, ?fp */ \
145 { 0x00040000 }, /* $pc */ \
146 { 0x00080000 }, /* ?cc */ \
147 { 0x000FFFFF } /* All registers */ \
150 #define N_REG_CLASSES LIM_REG_CLASSES
152 #define REG_CLASS_NAMES {\
153 "NO_REGS", \
154 "GENERAL_REGS", \
155 "SPECIAL_REGS", \
156 "CC_REGS", \
157 "ALL_REGS" }
159 #define FIXED_REGISTERS { 1, 1, 0, 0, \
160 0, 0, 0, 0, \
161 0, 0, 0, 0, \
162 0, 0, 0, 1, \
163 1, 1, 1, 1 }
165 #define CALL_USED_REGISTERS { 1, 1, 1, 1, \
166 1, 1, 1, 1, \
167 0, 0, 0, 0, \
168 0, 0, 1, 1, \
169 1, 1, 1, 1 }
171 /* We can't copy to or from our CC register. */
172 #define AVOID_CCMODE_COPIES 1
174 /* A C expression that is nonzero if it is permissible to store a
175 value of mode MODE in hard register number REGNO (or in several
176 registers starting with that one). All gstore registers are
177 equivalent, so we can set this to 1. */
178 #define HARD_REGNO_MODE_OK(R,M) 1
180 /* A C expression whose value is a register class containing hard
181 register REGNO. */
182 #define REGNO_REG_CLASS(R) ((R < MOXIE_PC) ? GENERAL_REGS : \
183 (R == MOXIE_CC ? CC_REGS : SPECIAL_REGS))
185 /* A C expression for the number of consecutive hard registers,
186 starting at register number REGNO, required to hold a value of mode
187 MODE. */
188 #define HARD_REGNO_NREGS(REGNO, MODE) \
189 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
190 / UNITS_PER_WORD)
192 /* A C expression that is nonzero if a value of mode MODE1 is
193 accessible in mode MODE2 without copying. */
194 #define MODES_TIEABLE_P(MODE1, MODE2) 1
196 /* The Overall Framework of an Assembler File */
198 #undef ASM_SPEC
199 #define ASM_SPEC "%{!mel:-EB} %{mel:-EL}"
200 #define ASM_COMMENT_START "#"
201 #define ASM_APP_ON ""
202 #define ASM_APP_OFF ""
204 #define FILE_ASM_OP "\t.file\n"
206 /* Switch to the text or data segment. */
207 #define TEXT_SECTION_ASM_OP "\t.text"
208 #define DATA_SECTION_ASM_OP "\t.data"
210 /* Assembler Commands for Alignment */
212 #define ASM_OUTPUT_ALIGN(STREAM,POWER) \
213 fprintf (STREAM, "\t.p2align\t%d\n", POWER);
215 /* A C compound statement to output to stdio stream STREAM the
216 assembler syntax for an instruction operand X. */
217 #define PRINT_OPERAND(STREAM, X, CODE) moxie_print_operand (STREAM, X, CODE)
219 #define PRINT_OPERAND_ADDRESS(STREAM ,X) moxie_print_operand_address (STREAM, X)
221 /* Output and Generation of Labels */
223 #define GLOBAL_ASM_OP "\t.global\t"
225 /* Passing Arguments in Registers */
227 /* A C type for declaring a variable that is used as the first
228 argument of `FUNCTION_ARG' and other related values. */
229 #define CUMULATIVE_ARGS unsigned int
231 /* If defined, the maximum amount of space required for outgoing arguments
232 will be computed and placed into the variable
233 `current_function_outgoing_args_size'. No space will be pushed
234 onto the stack for each call; instead, the function prologue should
235 increase the stack frame size by this amount. */
236 #define ACCUMULATE_OUTGOING_ARGS 1
238 /* A C statement (sans semicolon) for initializing the variable CUM
239 for the state at the beginning of the argument list.
240 For moxie, the first arg is passed in register 2 (aka $r0). */
241 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,FNDECL,N_NAMED_ARGS) \
242 (CUM = MOXIE_R0)
244 /* How Scalar Function Values Are Returned */
246 /* STACK AND CALLING */
248 /* Define this macro if pushing a word onto the stack moves the stack
249 pointer to a smaller address. */
250 #define STACK_GROWS_DOWNWARD
252 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = 0
254 /* Offset from the frame pointer to the first local variable slot to
255 be allocated. */
256 #define STARTING_FRAME_OFFSET 0
258 /* Define this if the above stack space is to be considered part of the
259 space allocated by the caller. */
260 #define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
261 #define STACK_PARMS_IN_REG_PARM_AREA
263 /* Define this if it is the responsibility of the caller to allocate
264 the area reserved for arguments passed in registers. */
265 #define REG_PARM_STACK_SPACE(FNDECL) (6 * UNITS_PER_WORD)
267 /* Offset from the argument pointer register to the first argument's
268 address. On some machines it may depend on the data type of the
269 function. */
270 #define FIRST_PARM_OFFSET(F) 12
272 /* Define this macro to nonzero value if the addresses of local variable slots
273 are at negative offsets from the frame pointer. */
274 #define FRAME_GROWS_DOWNWARD 1
276 /* Define this macro as a C expression that is nonzero for registers that are
277 used by the epilogue or the return pattern. The stack and frame
278 pointer registers are already assumed to be used as needed. */
279 #define EPILOGUE_USES(R) (R == MOXIE_R5)
281 /* A C expression whose value is RTL representing the location of the
282 incoming return address at the beginning of any function, before
283 the prologue. */
284 #define INCOMING_RETURN_ADDR_RTX \
285 gen_frame_mem (Pmode, \
286 plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD))
288 /* Describe how we implement __builtin_eh_return. */
289 #define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N+2) : INVALID_REGNUM)
291 /* Store the return handler into the call frame. */
292 #define EH_RETURN_HANDLER_RTX \
293 gen_frame_mem (Pmode, \
294 plus_constant (Pmode, frame_pointer_rtx, UNITS_PER_WORD))
296 /* Storage Layout */
298 #define BITS_BIG_ENDIAN 0
299 #define BYTES_BIG_ENDIAN ( ! TARGET_LITTLE_ENDIAN )
300 #define WORDS_BIG_ENDIAN ( ! TARGET_LITTLE_ENDIAN )
302 /* Alignment required for a function entry point, in bits. */
303 #define FUNCTION_BOUNDARY 16
305 /* Define this macro as a C expression which is nonzero if accessing
306 less than a word of memory (i.e. a `char' or a `short') is no
307 faster than accessing a word of memory. */
308 #define SLOW_BYTE_ACCESS 1
310 /* Number of storage units in a word; normally the size of a
311 general-purpose register, a power of two from 1 or 8. */
312 #define UNITS_PER_WORD 4
314 /* Define this macro to the minimum alignment enforced by hardware
315 for the stack pointer on this machine. The definition is a C
316 expression for the desired alignment (measured in bits). */
317 #define STACK_BOUNDARY 32
319 /* Normal alignment required for function parameters on the stack, in
320 bits. All stack parameters receive at least this much alignment
321 regardless of data type. */
322 #define PARM_BOUNDARY 32
324 /* Alignment of field after `int : 0' in a structure. */
325 #define EMPTY_FIELD_BOUNDARY 32
327 /* No data type wants to be aligned rounder than this. */
328 #define BIGGEST_ALIGNMENT 32
330 /* The best alignment to use in cases where we have a choice. */
331 #define FASTEST_ALIGNMENT 32
333 /* Every structures size must be a multiple of 8 bits. */
334 #define STRUCTURE_SIZE_BOUNDARY 8
336 /* Look at the fundamental type that is used for a bit-field and use
337 that to impose alignment on the enclosing structure.
338 struct s {int a:8}; should have same alignment as "int", not "char". */
339 #define PCC_BITFIELD_TYPE_MATTERS 1
341 /* Largest integer machine mode for structures. If undefined, the default
342 is GET_MODE_SIZE(DImode). */
343 #define MAX_FIXED_MODE_SIZE 32
345 /* Make strings word-aligned so strcpy from constants will be faster. */
346 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
347 ((TREE_CODE (EXP) == STRING_CST \
348 && (ALIGN) < FASTEST_ALIGNMENT) \
349 ? FASTEST_ALIGNMENT : (ALIGN))
351 /* Make arrays of chars word-aligned for the same reasons. */
352 #define DATA_ALIGNMENT(TYPE, ALIGN) \
353 (TREE_CODE (TYPE) == ARRAY_TYPE \
354 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
355 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
357 /* Set this nonzero if move instructions will actually fail to work
358 when given unaligned data. */
359 #define STRICT_ALIGNMENT 1
361 /* Generating Code for Profiling */
362 #define FUNCTION_PROFILER(FILE,LABELNO) (abort (), 0)
364 /* Trampolines for Nested Functions. */
365 #define TRAMPOLINE_SIZE (2 + 6 + 6 + 2 + 2 + 6)
367 /* Alignment required for trampolines, in bits. */
368 #define TRAMPOLINE_ALIGNMENT 32
370 /* An alias for the machine mode for pointers. */
371 #define Pmode SImode
373 /* An alias for the machine mode used for memory references to
374 functions being called, in `call' RTL expressions. */
375 #define FUNCTION_MODE QImode
377 /* The register number of the stack pointer register, which must also
378 be a fixed register according to `FIXED_REGISTERS'. */
379 #define STACK_POINTER_REGNUM MOXIE_SP
381 /* The register number of the frame pointer register, which is used to
382 access automatic variables in the stack frame. */
383 #define FRAME_POINTER_REGNUM MOXIE_QFP
385 /* The register number of the arg pointer register, which is used to
386 access the function's argument list. */
387 #define ARG_POINTER_REGNUM MOXIE_QAP
389 #define HARD_FRAME_POINTER_REGNUM MOXIE_FP
391 #define ELIMINABLE_REGS \
392 {{ FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
393 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }}
395 /* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It
396 specifies the initial difference between the specified pair of
397 registers. This macro must be defined if `ELIMINABLE_REGS' is
398 defined. */
399 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
400 do { \
401 (OFFSET) = moxie_initial_elimination_offset ((FROM), (TO)); \
402 } while (0)
404 /* A C expression that is nonzero if REGNO is the number of a hard
405 register in which function arguments are sometimes passed. */
406 #define FUNCTION_ARG_REGNO_P(r) (r >= MOXIE_R0 && r <= MOXIE_R5)
408 /* A macro whose definition is the name of the class to which a valid
409 base register must belong. A base register is one used in an
410 address which is the register value plus a displacement. */
411 #define BASE_REG_CLASS GENERAL_REGS
413 #define INDEX_REG_CLASS NO_REGS
415 #define HARD_REGNO_OK_FOR_BASE_P(NUM) \
416 ((unsigned) (NUM) < FIRST_PSEUDO_REGISTER \
417 && (REGNO_REG_CLASS(NUM) == GENERAL_REGS \
418 || (NUM) == HARD_FRAME_POINTER_REGNUM))
420 /* A C expression which is nonzero if register number NUM is suitable
421 for use as a base register in operand addresses. */
422 #ifdef REG_OK_STRICT
423 #define REGNO_OK_FOR_BASE_P(NUM) \
424 (HARD_REGNO_OK_FOR_BASE_P(NUM) \
425 || HARD_REGNO_OK_FOR_BASE_P(reg_renumber[(NUM)]))
426 #else
427 #define REGNO_OK_FOR_BASE_P(NUM) \
428 ((NUM) >= FIRST_PSEUDO_REGISTER || HARD_REGNO_OK_FOR_BASE_P(NUM))
429 #endif
431 /* A C expression which is nonzero if register number NUM is suitable
432 for use as an index register in operand addresses. */
433 #define REGNO_OK_FOR_INDEX_P(NUM) MOXIE_FP
435 /* The maximum number of bytes that a single instruction can move
436 quickly between memory and registers or between two memory
437 locations. */
438 #define MOVE_MAX 4
439 #define TRULY_NOOP_TRUNCATION(op,ip) 1
441 /* All load operations zero extend. */
442 #define LOAD_EXTEND_OP(MEM) ZERO_EXTEND
444 /* A number, the maximum number of registers that can appear in a
445 valid memory address. */
446 #define MAX_REGS_PER_ADDRESS 1
448 #define TRULY_NOOP_TRUNCATION(op,ip) 1
450 /* An alias for a machine mode name. This is the machine mode that
451 elements of a jump-table should have. */
452 #define CASE_VECTOR_MODE SImode
454 /* A C compound statement with a conditional `goto LABEL;' executed
455 if X (an RTX) is a legitimate memory address on the target machine
456 for a memory operand of mode MODE. */
457 #define GO_IF_LEGITIMATE_ADDRESS(MODE,X,LABEL) \
458 do { \
459 if (GET_CODE(X) == PLUS) \
461 rtx op1,op2; \
462 op1 = XEXP(X,0); \
463 op2 = XEXP(X,1); \
464 if (GET_CODE(op1) == REG \
465 && CONSTANT_ADDRESS_P(op2) \
466 && REGNO_OK_FOR_BASE_P(REGNO(op1))) \
467 goto LABEL; \
469 if (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X))) \
470 goto LABEL; \
471 if (GET_CODE (X) == SYMBOL_REF \
472 || GET_CODE (X) == LABEL_REF \
473 || GET_CODE (X) == CONST) \
474 goto LABEL; \
475 } while (0)
477 /* Run-time Target Specification */
479 #define TARGET_CPU_CPP_BUILTINS() \
481 builtin_define_std ("moxie"); \
482 builtin_define_std ("MOXIE"); \
483 if (TARGET_LITTLE_ENDIAN) \
484 builtin_define ("__MOXIE_LITTLE_ENDIAN__"); \
485 else \
486 builtin_define ("__MOXIE_BIG_ENDIAN__"); \
489 #define HAS_LONG_UNCOND_BRANCH true
491 #endif /* GCC_MOXIE_H */