1 /* Target Definitions for moxie.
2 Copyright (C) 2008, 2009, 2010 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/>. */
24 /* This is defined by svr4.h, which is included prior to this file.
25 However, we should undefine it for moxie-elf, since we don't provide
26 functions like access() and mkdir() in newlib. This will have to
27 be defined again for a Linux port. */
28 #undef TARGET_POSIX_IO
30 /* Another C string constant used much like `LINK_SPEC'. The difference
31 between the two is that `STARTFILE_SPEC' is used at the very beginning of
32 the command given to the linker.
34 If this macro is not defined, a default is provided that loads the standard
35 C startup file from the usual place. See `gcc.c'.
39 #define STARTFILE_SPEC "crt0%O%s crti.o%s crtbegin.o%s"
41 /* Provide an ENDFILE_SPEC appropriate for svr4. Here we tack on our own
42 magical crtend.o file (see crtstuff.c) which provides part of the
43 support for getting C++ file-scope static object constructed before
44 entering `main', followed by the normal svr3/svr4 "finalizer" file,
45 which is either `gcrtn.o' or `crtn.o'. */
48 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
50 /* Provide a LIB_SPEC appropriate for svr4. Here we tack on the default
51 standard C library (unless we are building a shared library) and
52 the simulator BSP code. */
55 #define LIB_SPEC "%{!shared:%{!symbolic:-lc}}"
57 /* Layout of Source Language Data Types */
59 #define INT_TYPE_SIZE 32
60 #define SHORT_TYPE_SIZE 16
61 #define LONG_TYPE_SIZE 32
62 #define LONG_LONG_TYPE_SIZE 64
64 #define FLOAT_TYPE_SIZE 32
65 #define DOUBLE_TYPE_SIZE 64
66 #define LONG_DOUBLE_TYPE_SIZE 64
68 #define DEFAULT_SIGNED_CHAR 1
74 $r0 - general purpose 32-bit register.
75 $r1 - general purpose 32-bit register.
76 $r2 - general purpose 32-bit register.
77 $r3 - general purpose 32-bit register.
78 $r4 - general purpose 32-bit register.
79 $r5 - general purpose 32-bit register.
80 $r6 - general purpose 32-bit register.
81 $r7 - general purpose 32-bit register.
82 $r8 - general purpose 32-bit register.
83 $r9 - general purpose 32-bit register.
84 $r10 - general purpose 32-bit register.
85 $r11 - general purpose 32-bit register.
86 $r12 - general purpose 32-bit register.
87 $r13 - reserved for execution environment.
91 $pc - 32-bit program counter.
95 #define REGISTER_NAMES { \
96 "$fp", "$sp", "$r0", "$r1", \
97 "$r2", "$r3", "$r4", "$r5", \
98 "$r6", "$r7", "$r8", "$r9", \
99 "$r10", "$r11", "$r12", "$r13", \
100 "?fp", "?ap", "$pc", "?cc" }
123 #define FIRST_PSEUDO_REGISTER 20
136 /* The following macro defines cover classes for Integrated Register
137 Allocator. Cover classes is a set of non-intersected register
138 classes covering all hard registers used for register allocation
139 purpose. Any move between two registers of a cover class should be
140 cheaper than load or store of the registers. The macro value is
141 array of register classes with LIM_REG_CLASSES used as the end
143 #define IRA_COVER_CLASSES { GENERAL_REGS, LIM_REG_CLASSES }
145 #define REG_CLASS_CONTENTS \
146 { { 0x00000000 }, /* Empty */ \
147 { 0x0003FFFF }, /* $fp, $sp, $r0 to $r13, ?fp */ \
148 { 0x00040000 }, /* $pc */ \
149 { 0x00080000 }, /* ?cc */ \
150 { 0x000FFFFF } /* All registers */ \
153 #define N_REG_CLASSES LIM_REG_CLASSES
155 #define REG_CLASS_NAMES {\
162 #define FIXED_REGISTERS { 1, 1, 0, 0, \
168 #define CALL_USED_REGISTERS { 1, 1, 1, 1, \
174 /* We can't copy to or from our CC register. */
175 #define AVOID_CCMODE_COPIES 1
177 /* A C expression that is nonzero if it is permissible to store a
178 value of mode MODE in hard register number REGNO (or in several
179 registers starting with that one). All gstore registers are
180 equivalent, so we can set this to 1. */
181 #define HARD_REGNO_MODE_OK(R,M) 1
183 /* A C expression whose value is a register class containing hard
185 #define REGNO_REG_CLASS(R) ((R < MOXIE_PC) ? GENERAL_REGS : \
186 (R == MOXIE_CC ? CC_REGS : SPECIAL_REGS))
188 /* A C expression for the number of consecutive hard registers,
189 starting at register number REGNO, required to hold a value of mode
191 #define HARD_REGNO_NREGS(REGNO, MODE) \
192 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
195 /* A C expression that is nonzero if a value of mode MODE1 is
196 accessible in mode MODE2 without copying. */
197 #define MODES_TIEABLE_P(MODE1, MODE2) 1
199 /* A C expression for the maximum number of consecutive registers of
200 class CLASS needed to hold a value of mode MODE. */
201 #define CLASS_MAX_NREGS(CLASS, MODE) \
202 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
204 /* The Overall Framework of an Assembler File */
207 #define ASM_COMMENT_START "#"
208 #define ASM_APP_ON ""
209 #define ASM_APP_OFF ""
211 #define FILE_ASM_OP "\t.file\n"
213 /* Switch to the text or data segment. */
214 #define TEXT_SECTION_ASM_OP "\t.text"
215 #define DATA_SECTION_ASM_OP "\t.data"
217 /* Assembler Commands for Alignment */
219 #define ASM_OUTPUT_ALIGN(STREAM,POWER) \
220 fprintf (STREAM, "\t.p2align\t%d\n", POWER);
222 /* A C compound statement to output to stdio stream STREAM the
223 assembler syntax for an instruction operand X. */
224 #define PRINT_OPERAND(STREAM, X, CODE) moxie_print_operand (STREAM, X, CODE)
226 #define PRINT_OPERAND_ADDRESS(STREAM ,X) moxie_print_operand_address (STREAM, X)
228 /* Output and Generation of Labels */
230 #define GLOBAL_ASM_OP "\t.global\t"
232 /* Passing Arguments in Registers */
234 /* A C type for declaring a variable that is used as the first
235 argument of `FUNCTION_ARG' and other related values. */
236 #define CUMULATIVE_ARGS unsigned int
238 /* If defined, the maximum amount of space required for outgoing arguments
239 will be computed and placed into the variable
240 `current_function_outgoing_args_size'. No space will be pushed
241 onto the stack for each call; instead, the function prologue should
242 increase the stack frame size by this amount. */
243 #define ACCUMULATE_OUTGOING_ARGS 1
245 /* A C statement (sans semicolon) for initializing the variable CUM
246 for the state at the beginning of the argument list.
247 For moxie, the first arg is passed in register 2 (aka $r0). */
248 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,FNDECL,N_NAMED_ARGS) \
251 /* How Scalar Function Values Are Returned */
253 /* STACK AND CALLING */
255 /* Define this macro if pushing a word onto the stack moves the stack
256 pointer to a smaller address. */
257 #define STACK_GROWS_DOWNWARD
259 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = 0
261 /* Offset from the frame pointer to the first local variable slot to
263 #define STARTING_FRAME_OFFSET 0
265 /* Define this if the above stack space is to be considered part of the
266 space allocated by the caller. */
267 #define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
268 #define STACK_PARMS_IN_REG_PARM_AREA
270 /* Define this if it is the responsibility of the caller to allocate
271 the area reserved for arguments passed in registers. */
272 #define REG_PARM_STACK_SPACE(FNDECL) (6 * UNITS_PER_WORD)
274 /* Offset from the argument pointer register to the first argument's
275 address. On some machines it may depend on the data type of the
277 #define FIRST_PARM_OFFSET(F) 12
279 /* Define this macro to nonzero value if the addresses of local variable slots
280 are at negative offsets from the frame pointer. */
281 #define FRAME_GROWS_DOWNWARD 1
283 /* Define this macro as a C expression that is nonzero for registers that are
284 used by the epilogue or the return pattern. The stack and frame
285 pointer registers are already assumed to be used as needed. */
286 #define EPILOGUE_USES(R) (R == MOXIE_R5)
290 #define BITS_BIG_ENDIAN 0
291 #define BYTES_BIG_ENDIAN 1
292 #define WORDS_BIG_ENDIAN 1
294 /* Alignment required for a function entry point, in bits. */
295 #define FUNCTION_BOUNDARY 16
297 /* Define this macro as a C expression which is nonzero if accessing
298 less than a word of memory (i.e. a `char' or a `short') is no
299 faster than accessing a word of memory. */
300 #define SLOW_BYTE_ACCESS 1
302 /* Number of storage units in a word; normally the size of a
303 general-purpose register, a power of two from 1 or 8. */
304 #define UNITS_PER_WORD 4
306 /* Define this macro to the minimum alignment enforced by hardware
307 for the stack pointer on this machine. The definition is a C
308 expression for the desired alignment (measured in bits). */
309 #define STACK_BOUNDARY 32
311 /* Normal alignment required for function parameters on the stack, in
312 bits. All stack parameters receive at least this much alignment
313 regardless of data type. */
314 #define PARM_BOUNDARY 32
316 /* Alignment of field after `int : 0' in a structure. */
317 #define EMPTY_FIELD_BOUNDARY 32
319 /* No data type wants to be aligned rounder than this. */
320 #define BIGGEST_ALIGNMENT 32
322 /* The best alignment to use in cases where we have a choice. */
323 #define FASTEST_ALIGNMENT 32
325 /* Every structures size must be a multiple of 8 bits. */
326 #define STRUCTURE_SIZE_BOUNDARY 8
328 /* Look at the fundamental type that is used for a bit-field and use
329 that to impose alignment on the enclosing structure.
330 struct s {int a:8}; should have same alignment as "int", not "char". */
331 #define PCC_BITFIELD_TYPE_MATTERS 1
333 /* Largest integer machine mode for structures. If undefined, the default
334 is GET_MODE_SIZE(DImode). */
335 #define MAX_FIXED_MODE_SIZE 32
337 /* Make strings word-aligned so strcpy from constants will be faster. */
338 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
339 ((TREE_CODE (EXP) == STRING_CST \
340 && (ALIGN) < FASTEST_ALIGNMENT) \
341 ? FASTEST_ALIGNMENT : (ALIGN))
343 /* Make arrays of chars word-aligned for the same reasons. */
344 #define DATA_ALIGNMENT(TYPE, ALIGN) \
345 (TREE_CODE (TYPE) == ARRAY_TYPE \
346 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
347 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
349 /* Set this nonzero if move instructions will actually fail to work
350 when given unaligned data. */
351 #define STRICT_ALIGNMENT 1
353 /* Generating Code for Profiling */
354 #define FUNCTION_PROFILER(FILE,LABELNO) (abort (), 0)
356 /* Trampolines for Nested Functions. */
357 #define TRAMPOLINE_SIZE (2 + 6 + 6 + 2 + 2 + 6)
359 /* Alignment required for trampolines, in bits. */
360 #define TRAMPOLINE_ALIGNMENT 32
362 /* An alias for the machine mode for pointers. */
365 /* An alias for the machine mode used for memory references to
366 functions being called, in `call' RTL expressions. */
367 #define FUNCTION_MODE QImode
369 /* The register number of the stack pointer register, which must also
370 be a fixed register according to `FIXED_REGISTERS'. */
371 #define STACK_POINTER_REGNUM MOXIE_SP
373 /* The register number of the frame pointer register, which is used to
374 access automatic variables in the stack frame. */
375 #define FRAME_POINTER_REGNUM MOXIE_QFP
377 /* The register number of the arg pointer register, which is used to
378 access the function's argument list. */
379 #define ARG_POINTER_REGNUM MOXIE_QAP
381 #define HARD_FRAME_POINTER_REGNUM MOXIE_FP
383 #define ELIMINABLE_REGS \
384 {{ FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
385 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }}
387 /* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It
388 specifies the initial difference between the specified pair of
389 registers. This macro must be defined if `ELIMINABLE_REGS' is
391 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
393 (OFFSET) = moxie_initial_elimination_offset ((FROM), (TO)); \
396 /* A C expression that is nonzero if REGNO is the number of a hard
397 register in which function arguments are sometimes passed. */
398 #define FUNCTION_ARG_REGNO_P(r) (r >= MOXIE_R0 && r <= MOXIE_R5)
400 /* A macro whose definition is the name of the class to which a valid
401 base register must belong. A base register is one used in an
402 address which is the register value plus a displacement. */
403 #define BASE_REG_CLASS GENERAL_REGS
405 #define INDEX_REG_CLASS NO_REGS
407 #define HARD_REGNO_OK_FOR_BASE_P(NUM) \
408 ((unsigned) (NUM) < FIRST_PSEUDO_REGISTER \
409 && (REGNO_REG_CLASS(NUM) == GENERAL_REGS \
410 || (NUM) == HARD_FRAME_POINTER_REGNUM))
412 /* A C expression which is nonzero if register number NUM is suitable
413 for use as a base register in operand addresses. */
415 #define REGNO_OK_FOR_BASE_P(NUM) \
416 (HARD_REGNO_OK_FOR_BASE_P(NUM) \
417 || HARD_REGNO_OK_FOR_BASE_P(reg_renumber[(NUM)]))
419 #define REGNO_OK_FOR_BASE_P(NUM) \
420 ((NUM) >= FIRST_PSEUDO_REGISTER || HARD_REGNO_OK_FOR_BASE_P(NUM))
423 /* A C expression which is nonzero if register number NUM is suitable
424 for use as an index register in operand addresses. */
425 #define REGNO_OK_FOR_INDEX_P(NUM) MOXIE_FP
427 /* The maximum number of bytes that a single instruction can move
428 quickly between memory and registers or between two memory
431 #define TRULY_NOOP_TRUNCATION(op,ip) 1
433 /* All load operations zero extend. */
434 #define LOAD_EXTEND_OP(MEM) ZERO_EXTEND
436 /* A C expression that is nonzero if X is a legitimate constant for
437 an immediate operand on the target machine. */
438 #define LEGITIMATE_CONSTANT_P(X) 1
440 /* A number, the maximum number of registers that can appear in a
441 valid memory address. */
442 #define MAX_REGS_PER_ADDRESS 1
444 #define TRULY_NOOP_TRUNCATION(op,ip) 1
446 /* An alias for a machine mode name. This is the machine mode that
447 elements of a jump-table should have. */
448 #define CASE_VECTOR_MODE SImode
450 /* A C compound statement with a conditional `goto LABEL;' executed
451 if X (an RTX) is a legitimate memory address on the target machine
452 for a memory operand of mode MODE. */
453 #define GO_IF_LEGITIMATE_ADDRESS(MODE,X,LABEL) \
455 if (GET_CODE(X) == PLUS) \
460 if (GET_CODE(op1) == REG \
461 && CONSTANT_ADDRESS_P(op2) \
462 && REGNO_OK_FOR_BASE_P(REGNO(op1))) \
465 if (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X))) \
467 if (GET_CODE (X) == SYMBOL_REF \
468 || GET_CODE (X) == LABEL_REF \
469 || GET_CODE (X) == CONST) \
473 /* Run-time Target Specification */
475 #define TARGET_CPU_CPP_BUILTINS() \
477 builtin_define_std ("moxie"); \
478 builtin_define_std ("MOXIE"); \
481 #define HAS_LONG_UNCOND_BRANCH true
483 #endif /* GCC_MOXIE_H */