]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/config/arc/tm-arc.h
* config/tm-arc.h: Change arc register names.
[thirdparty/binutils-gdb.git] / gdb / config / arc / tm-arc.h
1 /* Parameters for target machine ARC, for GDB, the GNU debugger.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Contributed by Cygnus Support Corporation.
4
5 This file is part of GDB.
6
7 This program 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 2 of the License, or
10 (at your option) any later version.
11
12 This program 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 this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21 /* Byte order is configurable, but this machine runs little-endian. */
22 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
23
24 /* We have IEEE floating point, if we have any float at all. */
25 #define IEEE_FLOAT
26
27 /* Offset from address of function to start of its code.
28 Zero on most machines. */
29 #define FUNCTION_START_OFFSET 0
30
31 /* Advance pc across any function entry prologue instructions
32 to reach some "real" code. */
33
34 #define SKIP_PROLOGUE(pc) { pc = skip_prologue (pc); }
35 extern CORE_ADDR skip_prologue ();
36
37 /* Sequence of bytes for breakpoint instruction. */
38 #define BREAKPOINT {0x01, 0x80, 0xbe, 0x1f}
39
40 #define DECR_PC_AFTER_BREAK 4
41
42 /* Immediately after a function call, return the saved pc.
43 Can't always go through the frames for this because on some machines
44 the new frame is not set up until the new function
45 executes some instructions. */
46
47 #define SAVED_PC_AFTER_CALL(frame) (read_register (BLINK_REGNUM))
48
49 /* Stack grows upward */
50
51 #define INNER_THAN <
52
53 /* Nonzero if instruction at pc is a return instruction. */
54
55 #define ABOUT_TO_RETURN(pc) (read_memory_integer(pc,4) == 0x380f8000)
56
57 /* Say how long (ordinary) registers are. This is a piece of bogosity
58 used in push_word and a few other places; REGISTER_RAW_SIZE is the
59 real way to know how big a register is. */
60 #define REGISTER_SIZE 4
61
62 /* Number of machine registers */
63 #define NUM_REGS 91
64
65 /* Initializer for an array of names of registers.
66 There should be NUM_REGS strings in this initializer. */
67
68 #define REGISTER_NAMES \
69 { \
70 /* 0 */ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
71 /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
72 /* 16 */ "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
73 /* 24 */ "r24", "r25", "r26", "fp", "sp", "ilink1", "ilink2", "blink", \
74 /* 32 */ "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
75 /* 40 */ "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
76 /* 48 */ "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
77 /* 56 */ "r56", "mlo", "mmid", "mhi", "lp_count", \
78 /* 61 */ "status", "sema", "lp_start", "lp_end", "identity", "debug", \
79 /* 67 */ "aux10", "aux11", "aux12", "aux13", "aux14", \
80 /* 72 */ "aux15", "aux16", "aux17", "aux18", "aux19", \
81 /* 77 */ "aux1a", "aux1b", "aux1c", "aux1d", "aux1e", \
82 /* 82 */ "aux1f", "aux20", "aux21", "aux22", \
83 /* 86 */ "aux30", "aux31", "aux32", "aux33", "aux40", \
84 /* 91 */ "pc" \
85 }
86
87 /* Register numbers of various important registers (used to index
88 into arrays of register names and register values). */
89
90 #define R0_REGNUM 0 /* First local register */
91 #define R59_REGNUM 59 /* Last local register */
92 #define FP_REGNUM 27 /* Contains address of executing stack frame */
93 #define SP_REGNUM 28 /* stack pointer */
94 #define BLINK_REGNUM 31 /* link register */
95 #define STA_REGNUM 61 /* processor status word */
96 #define PC_REGNUM 91 /* instruction pointer */
97 #define AUX_BEG_REGNUM 61 /* aux reg begins */
98 #define AUX_END_REGNUM 90 /* aux reg ends, pc not real aux reg */
99
100 #define AUX_REG_MAP \
101 { \
102 { 0, 1, 2, 3, 4, 5, \
103 16, -1, -1, -1, -1, \
104 -1, -1, -1, -1, -1, \
105 -1, -1, -1, -1, 30, \
106 -1, 32, 33, -1, \
107 48, 49, 50, 51, 64, \
108 0 \
109 }, \
110 { 0, 1, 2, 3, 4, 5, \
111 16, -1, -1, -1, -1, \
112 -1, -1, -1, -1, -1, \
113 -1, -1, -1, -1, 30, \
114 31, 32, 33, -1, \
115 -1, -1, -1, -1, -1, \
116 0 \
117 }, \
118 { 0, 1, 2, 3, 4, 5, \
119 16, 17, 18, 19, 20, \
120 21, 22, 23, 24, 25, \
121 26, 27, 28, 29, 30, \
122 31, 32, 33, 34, \
123 -1, -1, -1, -1, -1, \
124 0 \
125 } \
126 }
127
128 #define PFP_REGNUM R0_REGNUM /* Previous frame pointer */
129
130 /* Total amount of space needed to store our copies of the machine's
131 register state, the array `registers'. */
132 #define REGISTER_BYTES (91*4)
133
134 /* Index within `registers' of the first byte of the space for register N. */
135 #define REGISTER_BYTE(N) (4*(N))
136
137 /* Number of bytes of storage in the actual machine representation
138 for register N. */
139 #define REGISTER_RAW_SIZE(N) 4
140
141 /* Number of bytes of storage in the program's representation for register N. */
142 #define REGISTER_VIRTUAL_SIZE(N) 4
143
144 /* Largest value REGISTER_RAW_SIZE can have. */
145 #define MAX_REGISTER_RAW_SIZE 4
146
147 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
148 #define MAX_REGISTER_VIRTUAL_SIZE 4
149
150 /* Return the GDB type object for the "standard" data type
151 of data in register N. */
152 #define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
153
154 \f
155 /* Macros for understanding function return values... */
156
157 /* Does the specified function use the "struct returning" convention
158 or the "value returning" convention? The "value returning" convention
159 almost invariably returns the entire value in registers. The
160 "struct returning" convention often returns the entire value in
161 memory, and passes a pointer (out of or into the function) saying
162 where the value (is or should go).
163
164 Since this sometimes depends on whether it was compiled with GCC,
165 this is also an argument. This is used in call_function to build a
166 stack, and in value_being_returned to print return values.
167
168 On arc, a structure is always retunred with pointer in r??. */
169
170 #define USE_STRUCT_CONVENTION(gcc_p, type) 1
171
172 /* Extract from an array REGBUF containing the (raw) register state
173 a function return value of type TYPE, and copy that, in virtual format,
174 into VALBUF. This is only called if USE_STRUCT_CONVENTION for this
175 type is 0.
176 */
177 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
178 memcpy(VALBUF, REGBUF+REGISTER_BYTE(R0_REGNUM), TYPE_LENGTH (TYPE))
179
180 /* If USE_STRUCT_CONVENTION produces a 1,
181 extract from an array REGBUF containing the (raw) register state
182 the address in which a function should return its structure value,
183 as a CORE_ADDR (or an expression that can be used as one). */
184 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
185 (error("Don't know where large structure is returned on arc"), 0)
186
187 /* Write into appropriate registers a function return value
188 of type TYPE, given in virtual format, for "value returning" functions.
189 For 'return' command: not (yet) implemented for arc. */
190 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
191 error ("Returning values from functions is not implemented in arc gdb")
192
193 /* Store the address of the place in which to copy the structure the
194 subroutine will return. This is called from call_function. */
195 #define STORE_STRUCT_RETURN(ADDR, SP) \
196 error ("Returning values from functions is not implemented in arc gdb")
197
198 \f
199 /* Describe the pointer in each stack frame to the previous stack frame
200 (its caller). */
201
202 /* FRAME_CHAIN takes a frame's nominal address
203 and produces the frame's chain-pointer.
204 However, if FRAME_CHAIN_VALID returns zero,
205 it means the given frame is the outermost one and has no caller. */
206
207 /* We cache information about saved registers in the frame structure,
208 to save us from having to re-scan function prologues every time
209 a register in a non-current frame is accessed. */
210
211 #define EXTRA_FRAME_INFO \
212 struct frame_saved_regs *fsr; \
213 CORE_ADDR arg_pointer;
214
215 /* Zero the frame_saved_regs pointer when the frame is initialized,
216 so that FRAME_FIND_SAVED_REGS () will know to allocate and
217 initialize a frame_saved_regs struct the first time it is called.
218 Set the arg_pointer to -1, which is not valid; 0 and other values
219 indicate real, cached values. */
220
221 #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
222 ((fi)->fsr = 0, (fi)->arg_pointer = -1)
223
224 /* On the arc, we get the chain pointer by reading the PFP saved
225 on the stack. */
226 /* the PFP and RPC is in fp and fp+4. or it is in fp+4 and fp+8 ??? */
227
228 #define FRAME_CHAIN(thisframe) \
229 (read_memory_integer (FRAME_FP(thisframe), 4))
230
231 /* FRAME_CHAIN_VALID returns zero if the given frame is the outermost one
232 and has no caller.
233 #define FRAME_CHAIN_VALID(thisframe) \
234 1
235
236 /* A macro that tells us whether the function invocation represented
237 by FI does not have a frame on the stack associated with it. If it
238 does not, FRAMELESS is set to 1, else 0. */
239
240 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
241 do { \
242 if ((FI)->signal_handler_caller) \
243 (FRAMELESS) = 0; \
244 else \
245 (FRAMELESS) = frameless_look_for_prologue(FI); \
246 } while (0)
247
248 #define FRAME_SAVED_PC(frame) \
249 (read_memory_integer(FRAME_CHAIN(frame)+8,4))
250
251 /* On the ARC, FRAME_ARGS_ADDRESS should return the value of
252 g14 as passed into the frame, if known. We need a function for this.
253 We cache this value in the frame info if we've already looked it up. */
254
255 #define FRAME_ARGS_ADDRESS(fi) \
256 (((fi)->arg_pointer != -1)? (fi)->arg_pointer: (fi)->frame + 4)
257
258 /* This is the same except it should return 0 when
259 it does not really know where the args are, rather than guessing.
260 This value is not cached since it is only used infrequently. */
261
262 #define FRAME_LOCALS_ADDRESS(fi) (fi)->frame + 4
263
264 /* Set NUMARGS to the number of args passed to a frame.
265 Can return -1, meaning no way to tell. */
266
267 #define FRAME_NUM_ARGS(numargs, fi) (numargs = -1)
268
269 /* Return number of bytes at start of arglist that are not really args. */
270
271 #define FRAME_ARGS_SKIP 0
272
273 /* Produce the positions of the saved registers in a stack frame. */
274
275 #define FRAME_FIND_SAVED_REGS(frame_info_addr, sr) \
276 frame_find_saved_regs (frame_info_addr, &sr)
277 extern void frame_find_saved_regs(); /* See arc-tdep.c */
278
279 \f
280 /* Things needed for making calls to functions in the inferior process */
281 #define PUSH_DUMMY_FRAME \
282 push_dummy_frame ()
283
284 /* Discard from the stack the innermost frame, restoring all registers. */
285 #define POP_FRAME \
286 pop_frame ()
287
288 /* This sequence of words is the instructions bl xxxx, flag 1 */
289 #define CALL_DUMMY { 0x28000000, 0x1fbe8001 }
290 #define CALL_DUMMY_LENGTH 8
291
292 /* Start execution at beginning of dummy */
293 #define CALL_DUMMY_START_OFFSET 0
294
295 /* Insert the specified number of args and function address
296 into a call sequence of the above form stored at 'dummyname'.*/
297 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
298 { \
299 int from, to, delta, loc; \
300 loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
301 from = loc + 4; \
302 to = (int)(fun); \
303 delta = (to - from) >> 2; \
304 *((char *)(dummyname) + 1) = (delta & 0x1); \
305 *((char *)(dummyname) + 2) = ((delta >> 1) & 0xff); \
306 *((char *)(dummyname) + 3) = ((delta >> 9) & 0xff); \
307 *((char *)(dummyname) + 4) = ((delta >> 17) & 0x7); \
308 }
309