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