]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/config/fr30/tm-fr30.h
import gdb-1999-07-07 post reformat
[thirdparty/binutils-gdb.git] / gdb / config / fr30 / tm-fr30.h
1 /* Parameters for execution on a Fujitsu FR30 processor.
2 Copyright 1999, Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 #define FR30_GENREGS 16
22 #define FR30_DEDICATEDREGS 8
23 #define FR30_REGSIZE 4 /* bytes */
24
25 #define NUM_REGS (FR30_GENREGS + FR30_DEDICATEDREGS)
26 #define REGISTER_BYTES ((FR30_GENREGS + FR30_DEDICATEDREGS)*FR30_REGSIZE)
27
28 /* Index within `registers' of the first byte of the space for
29 register N. */
30 #define REGISTER_BYTE(N) ((N) * FR30_REGSIZE)
31
32 /* Initializer for an array of names of registers.
33 There should be NUM_REGS strings in this initializer. */
34 #define REGISTER_NAMES \
35 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", \
36 "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
37 "pc", "ps", "tbr", "rp", "ssp", "usp", "mdh", "mdl" }
38
39 /* Offset from address of function to start of its code.
40 Zero on most machines. */
41 #define FUNCTION_START_OFFSET 0
42
43 /* Amount PC must be decremented by after a breakpoint.
44 This is often the number of bytes in BREAKPOINT
45 but not always. */
46
47 #define DECR_PC_AFTER_BREAK 0
48
49 /* Stack grows downward. */
50
51 #define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
52
53 #define TARGET_BYTE_ORDER BIG_ENDIAN
54
55 #define R0_REGNUM 0
56 #define R1_REGNUM 1
57 #define R2_REGNUM 2
58 #define R3_REGNUM 3
59 #define R4_REGNUM 4
60 #define R5_REGNUM 5
61 #define R6_REGNUM 6
62 #define R7_REGNUM 7
63 #define R8_REGNUM 8
64 #define R9_REGNUM 9
65 #define R10_REGNUM 10
66 #define R11_REGNUM 11
67 #define R12_REGNUM 12
68 #define R13_REGNUM 13
69 #define FP_REGNUM 14 /* Frame pointer */
70 #define SP_REGNUM 15 /* Stack pointer */
71 #define PC_REGNUM 16 /* Program counter */
72 #define RP_REGNUM 19 /* Return pointer */
73
74 #define FIRST_ARGREG R4_REGNUM /* first arg (or struct ret val addr) */
75 #define LAST_ARGREG R7_REGNUM /* fourth (or third arg) */
76 #define RETVAL_REG R4_REGNUM /* return vaue */
77
78 /* Say how long (ordinary) registers are. This is a piece of bogosity
79 used in push_word and a few other places; REGISTER_RAW_SIZE is the
80 real way to know how big a register is. */
81 #define REGISTER_SIZE FR30_REGSIZE
82
83 /* Number of bytes of storage in the actual machine representation
84 for register N. */
85 #define REGISTER_RAW_SIZE(N) FR30_REGSIZE
86
87 /* Largest value REGISTER_RAW_SIZE can have. */
88 #define MAX_REGISTER_RAW_SIZE FR30_REGSIZE
89
90 /* Number of bytes of storage in the program's representation
91 for register N. */
92 #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
93
94 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
95 #define MAX_REGISTER_VIRTUAL_SIZE FR30_REGSIZE
96
97 extern void fr30_pop_frame PARAMS ((void));
98 #define POP_FRAME fr30_pop_frame()
99
100 #define USE_GENERIC_DUMMY_FRAMES 1
101 #define CALL_DUMMY {0}
102 #define CALL_DUMMY_START_OFFSET (0)
103 #define CALL_DUMMY_BREAKPOINT_OFFSET (0)
104 #define CALL_DUMMY_LOCATION AT_ENTRY_POINT
105 #define FIX_CALL_DUMMY(DUMMY, START, FUNADDR, NARGS, ARGS, TYPE, GCCP)
106 #define CALL_DUMMY_ADDRESS() entry_point_address ()
107 #define PUSH_RETURN_ADDRESS(PC, SP) (write_register(RP_REGNUM, CALL_DUMMY_ADDRESS()), SP)
108 #define PUSH_DUMMY_FRAME generic_push_dummy_frame ()
109
110 /* Number of bytes at start of arglist that are not really args. */
111 #define FRAME_ARGS_SKIP 0
112
113 /* Return the GDB type object for the "standard" data type
114 of data in register N. */
115 #define REGISTER_VIRTUAL_TYPE(REG) builtin_type_int
116
117 /* Extract from an array REGBUF containing the (raw) register state
118 a function return value of type TYPE, and copy that, in virtual format,
119 into VALBUF. */
120 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
121 memcpy (VALBUF, REGBUF + REGISTER_BYTE(RETVAL_REG) + \
122 (TYPE_LENGTH(TYPE) < 4 ? 4 - TYPE_LENGTH(TYPE) : 0), TYPE_LENGTH (TYPE))
123
124 /* Extract from an array REGBUF containing the (raw) register state
125 the address in which a function should return its structure value,
126 as a CORE_ADDR (or an expression that can be used as one). */
127 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
128 extract_address (REGBUF + REGISTER_BYTE (RETVAL_REG), \
129 REGISTER_RAW_SIZE (RETVAL_REG))
130
131 #define STORE_STRUCT_RETURN(ADDR, SP) \
132 { write_register (RETVAL_REG, (ADDR)); }
133
134 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
135 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
136
137 /* Return number of args passed to a frame.
138 Can return -1, meaning no way to tell. */
139 #define FRAME_NUM_ARGS(fi) (-1)
140
141 #ifdef __STDC__ /* Forward decls for prototypes */
142 struct frame_info;
143 struct frame_saved_regs;
144 struct type;
145 struct value;
146 #endif
147
148 #define EXTRA_FRAME_INFO \
149 struct frame_saved_regs fsr; \
150 int framesize; \
151 int frameoffset; \
152 int framereg;
153
154 extern CORE_ADDR fr30_frame_chain PARAMS ((struct frame_info * fi));
155 #define FRAME_CHAIN(fi) fr30_frame_chain (fi)
156
157 extern CORE_ADDR fr30_frame_saved_pc PARAMS ((struct frame_info *));
158 #define FRAME_SAVED_PC(fi) (fr30_frame_saved_pc (fi))
159
160 #define SAVED_PC_AFTER_CALL(fi) read_register (RP_REGNUM)
161
162 extern CORE_ADDR fr30_skip_prologue PARAMS ((CORE_ADDR pc));
163 #define SKIP_PROLOGUE(pc) (fr30_skip_prologue (pc))
164
165 /* Write into appropriate registers a function return value of type
166 TYPE, given in virtual format. VALBUF is in the target byte order;
167 it's typically the VALUE_CONTENTS of some struct value, and those
168 are in the target's byte order. */
169 extern void fr30_store_return_value PARAMS ((struct type * type, char *valbuf));
170
171 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
172 (fr30_store_return_value ((TYPE), (VALBUF)))
173
174 /* Put here the code to store, into a struct frame_saved_regs,
175 the addresses of the saved registers of frame described by FRAME_INFO.
176 This includes special registers such as pc and fp saved in special
177 ways in the stack frame. sp is even more special:
178 the address we return for it IS the sp for the next frame. */
179 #define FRAME_FIND_SAVED_REGS(fi, regaddr) regaddr = fi->fsr
180
181 /* Use INT #BREAKPOINT_INTNUM instruction for breakpoint */
182 #define FR30_BREAKOP 0x1f /* opcode, type D instruction */
183 #define BREAKPOINT_INTNUM 9 /* one of the reserved traps */
184 #define BREAKPOINT {FR30_BREAKOP, BREAKPOINT_INTNUM}
185
186 /* Define this for Wingdb */
187 #define TARGET_FR30
188
189 /* IEEE format floating point */
190 #define IEEE_FLOAT
191
192 /* Define other aspects of the stack frame. */
193
194 /* An expression that tells us whether the function invocation represented
195 by FI does not have a frame on the stack associated with it. */
196 extern int fr30_frameless_function_invocation PARAMS ((struct frame_info * frame));
197 #define FRAMELESS_FUNCTION_INVOCATION(FI) (fr30_frameless_function_invocation (FI));
198
199 extern void fr30_init_extra_frame_info PARAMS ((struct frame_info * fi));
200 #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) fr30_init_extra_frame_info (fi)
201
202 #define FRAME_CHAIN_VALID(FP, FI) generic_frame_chain_valid (FP, FI)
203
204 extern CORE_ADDR
205 fr30_push_arguments PARAMS ((int nargs, struct value ** args, CORE_ADDR sp,
206 int struct_return,
207 CORE_ADDR struct_addr));
208 #define PUSH_ARGUMENTS(NARGS, ARGS, SP, STRUCT_RETURN, STRUCT_ADDR) \
209 (fr30_push_arguments (NARGS, ARGS, SP, STRUCT_RETURN, STRUCT_ADDR))
210
211 #define PC_IN_CALL_DUMMY(PC, SP, FP) generic_pc_in_call_dummy (PC, SP, FP)
212
213 /* Fujitsu's ABI requires all structs to be passed using a pointer.
214 That is obviously not very efficient, so I am leaving the definitions
215 to make gdb work with GCC style struct passing, in case we decide
216 to go for better performance, rather than for compatibility with
217 Fujitsu (just change STRUCT_ALWAYS_BY_ADDR to 0) */
218
219 #define STRUCT_ALWAYS_BY_ADDR 1
220
221 #if(STRUCT_ALWAYS_BY_ADDR)
222 #define REG_STRUCT_HAS_ADDR(gcc_p,type) 1
223 #else
224 /* more standard GCC (optimized) */
225 #define REG_STRUCT_HAS_ADDR(gcc_p,type) \
226 ((TYPE_LENGTH(type) > 4) && (TYPE_LENGTH(type) & 0x3))
227 #endif
228 /* alway return struct by value by input pointer */
229 #define USE_STRUCT_CONVENTION(GCC_P, TYPE) 1
230
231 /* The stack should always be aligned on a four-word boundary. */
232 #define STACK_ALIGN(len) (((len) + 3) & ~3)
233
234 /* I think the comment about this in value_arg_coerce is wrong; this
235 should be true on any system where you can rely on the prototyping
236 information. When this is true, value_arg_coerce will promote
237 floats to doubles iff the function is not prototyped. */
238 #define COERCE_FLOAT_TO_DOUBLE 1