]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/config/arc/tm-arc.h
import gdb-1999-05-25 snapshot
[thirdparty/binutils-gdb.git] / gdb / config / arc / tm-arc.h
CommitLineData
c906108c
SS
1/* Parameters for target machine ARC, for GDB, the GNU debugger.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
4
5This file is part of GDB.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21/* Used by arc-tdep.c to set the default cpu type. */
22#define DEFAULT_ARC_CPU_TYPE "base"
23
24/* Byte order is selectable. */
25#define TARGET_BYTE_ORDER_SELECTABLE
26
27/* We have IEEE floating point, if we have any float at all. */
28#define IEEE_FLOAT
29
30/* Offset from address of function to start of its code.
31 Zero on most machines. */
32#define FUNCTION_START_OFFSET 0
33
34/* Advance PC across any function entry prologue instructions
35 to reach some "real" code. SKIP_PROLOGUE_FRAMELESS_P advances
36 the PC past some of the prologue, but stops as soon as it
37 knows that the function has a frame. Its result is equal
38 to its input PC if the function is frameless, unequal otherwise. */
39
b83266a0
SS
40#define SKIP_PROLOGUE(pc) (arc_skip_prologue (pc, 0))
41#define SKIP_PROLOGUE_FRAMELESS_P(pc) (arc_skip_prologue (pc, 1))
42extern CORE_ADDR arc_skip_prologue PARAMS ((CORE_ADDR, int));
c906108c
SS
43
44/* Sequence of bytes for breakpoint instruction.
45 ??? The current value is "sr -1,[-1]" and is for the simulator only.
46 The simulator watches for this and does the right thing.
47 The hardware version will have to associate with each breakpoint
48 the sequence "flag 1; nop; nop; nop". IE: The breakpoint insn will not
49 be a fixed set of bits but instead will be a branch to a semi-random
50 address. Presumably this will be cleaned up for "second silicon". */
51#define BIG_BREAKPOINT { 0x12, 0x1f, 0xff, 0xff }
52#define LITTLE_BREAKPOINT { 0xff, 0xff, 0x1f, 0x12 }
53
54/* Given the exposed pipeline, there isn't any one correct value.
55 However, this value must be 4. GDB can't handle any other value (other than
56 zero). See for example infrun.c:
57 "prev_pc != stop_pc - DECR_PC_AFTER_BREAK" */
58/* FIXME */
59#define DECR_PC_AFTER_BREAK 8
60
61/* We don't have a reliable single step facility.
62 ??? We do have a cycle single step facility, but that won't work. */
63#define SOFTWARE_SINGLE_STEP_P 1
64extern void arc_software_single_step PARAMS ((unsigned int, int));
65#define SOFTWARE_SINGLE_STEP(sig,bp_p) arc_software_single_step (sig, bp_p)
66
67/* FIXME: Need to set STEP_SKIPS_DELAY. */
68
69/* Given a pc value as defined by the hardware, return the real address.
70 Remember that on the ARC blink contains that status register which
71 includes PC + flags (so we have to mask out the flags). */
72#define ARC_PC_TO_REAL_ADDRESS(pc) (((pc) & 0xffffff) << 2)
73
74/* Immediately after a function call, return the saved pc.
75 Can't always go through the frames for this because on some machines
76 the new frame is not set up until the new function
77 executes some instructions. */
78
79#define SAVED_PC_AFTER_CALL(frame) \
80 (ARC_PC_TO_REAL_ADDRESS (read_register (BLINK_REGNUM)))
81
82/* Stack grows upward */
83
84#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
85
86/* Say how long (ordinary) registers are. This is a piece of bogosity
87 used in push_word and a few other places; REGISTER_RAW_SIZE is the
88 real way to know how big a register is. */
89#define REGISTER_SIZE 4
90
91/* Number of machine registers */
92#define NUM_REGS 92
93
94/* Initializer for an array of names of registers.
95 There should be NUM_REGS strings in this initializer. */
96
97#define REGISTER_NAMES \
98{ \
99 /* 0 */ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
100 /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
101 /* 16 */ "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
102 /* 24 */ "r24", "r25", "r26", "fp", "sp", "ilink1", "ilink2", "blink", \
103 /* 32 */ "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
104 /* 40 */ "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
105 /* 48 */ "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
106 /* 56 */ "r56", "mlo", "mmid", "mhi", "lp_count", \
107 /* 61 */ "status", "sema", "lp_start", "lp_end", "identity", "debug", \
108 /* 67 */ "aux10", "aux11", "aux12", "aux13", "aux14", \
109 /* 72 */ "aux15", "aux16", "aux17", "aux18", "aux19", \
110 /* 77 */ "aux1a", "aux1b", "aux1c", "aux1d", "aux1e", \
111 /* 82 */ "aux1f", "aux20", "aux21", "aux22", \
112 /* 86 */ "aux30", "aux31", "aux32", "aux33", "aux40", \
113 /* 91 */ "pc" \
114}
115
116/* Register numbers of various important registers (used to index
117 into arrays of register names and register values). */
118
119#define R0_REGNUM 0 /* First local register */
120#define R59_REGNUM 59 /* Last local register */
121#define FP_REGNUM 27 /* Contains address of executing stack frame */
122#define SP_REGNUM 28 /* stack pointer */
123#define BLINK_REGNUM 31 /* link register */
124#define STA_REGNUM 61 /* processor status word */
125#define PC_REGNUM 91 /* instruction pointer */
126#define AUX_BEG_REGNUM 61 /* aux reg begins */
127#define AUX_END_REGNUM 90 /* aux reg ends, pc not real aux reg */
128
129/* Fake registers used to mark immediate data. */
130#define SHIMM_FLAG_REGNUM 61
131#define LIMM_REGNUM 62
132#define SHIMM_REGNUM 63
133
134#define AUX_REG_MAP \
135{ \
136 { 0, 1, 2, 3, 4, 5, \
137 16, -1, -1, -1, -1, \
138 -1, -1, -1, -1, -1, \
139 -1, -1, -1, -1, 30, \
140 -1, 32, 33, -1, \
141 48, 49, 50, 51, 64, \
142 0 \
143 }, \
144 { 0, 1, 2, 3, 4, 5, \
145 16, -1, -1, -1, -1, \
146 -1, -1, -1, -1, -1, \
147 -1, -1, -1, -1, 30, \
148 31, 32, 33, -1, \
149 -1, -1, -1, -1, -1, \
150 0 \
151 }, \
152 { 0, 1, 2, 3, 4, 5, \
153 16, 17, 18, 19, 20, \
154 21, 22, 23, 24, 25, \
155 26, 27, 28, 29, 30, \
156 31, 32, 33, 34, \
157 -1, -1, -1, -1, -1, \
158 0 \
159 } \
160}
161
162#define PFP_REGNUM R0_REGNUM /* Previous frame pointer */
163
164/* Total amount of space needed to store our copies of the machine's
165 register state, the array `registers'. */
166#define REGISTER_BYTES (NUM_REGS * 4)
167
168/* Index within `registers' of the first byte of the space for register N. */
169#define REGISTER_BYTE(N) (4*(N))
170
171/* Number of bytes of storage in the actual machine representation
172 for register N. */
173#define REGISTER_RAW_SIZE(N) 4
174
175/* Number of bytes of storage in the program's representation for register N. */
176#define REGISTER_VIRTUAL_SIZE(N) 4
177
178/* Largest value REGISTER_RAW_SIZE can have. */
179#define MAX_REGISTER_RAW_SIZE 4
180
181/* Largest value REGISTER_VIRTUAL_SIZE can have. */
182#define MAX_REGISTER_VIRTUAL_SIZE 4
183
184/* Return the GDB type object for the "standard" data type
185 of data in register N. */
186#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
187
188\f
189/* Macros for understanding function return values... */
190
191/* Does the specified function use the "struct returning" convention
192 or the "value returning" convention? The "value returning" convention
193 almost invariably returns the entire value in registers. The
194 "struct returning" convention often returns the entire value in
195 memory, and passes a pointer (out of or into the function) saying
196 where the value (is or should go).
197
198 Since this sometimes depends on whether it was compiled with GCC,
199 this is also an argument. This is used in call_function to build a
200 stack, and in value_being_returned to print return values.
201
202 On arc, a structure is always retunred with pointer in r0. */
203
204#define USE_STRUCT_CONVENTION(gcc_p, type) 1
205
206/* Extract from an array REGBUF containing the (raw) register state
207 a function return value of type TYPE, and copy that, in virtual format,
208 into VALBUF. This is only called if USE_STRUCT_CONVENTION for this
209 type is 0.
210*/
211#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
212 memcpy(VALBUF, REGBUF+REGISTER_BYTE(R0_REGNUM), TYPE_LENGTH (TYPE))
213
214/* If USE_STRUCT_CONVENTION produces a 1,
215 extract from an array REGBUF containing the (raw) register state
216 the address in which a function should return its structure value,
217 as a CORE_ADDR (or an expression that can be used as one). */
218#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
219 (error("Don't know where large structure is returned on arc"), 0)
220
221/* Write into appropriate registers a function return value
222 of type TYPE, given in virtual format, for "value returning" functions.
223 For 'return' command: not (yet) implemented for arc. */
224#define STORE_RETURN_VALUE(TYPE,VALBUF) \
225 error ("Returning values from functions is not implemented in arc gdb")
226
227/* Store the address of the place in which to copy the structure the
228 subroutine will return. This is called from call_function. */
229#define STORE_STRUCT_RETURN(ADDR, SP) \
230 error ("Returning values from functions is not implemented in arc gdb")
231
232\f
233/* Describe the pointer in each stack frame to the previous stack frame
234 (its caller). */
235
236/* We cache information about saved registers in the frame structure,
237 to save us from having to re-scan function prologues every time
238 a register in a non-current frame is accessed. */
239
240#define EXTRA_FRAME_INFO \
241 struct frame_saved_regs *fsr; \
242 CORE_ADDR arg_pointer;
243
244/* Zero the frame_saved_regs pointer when the frame is initialized,
245 so that FRAME_FIND_SAVED_REGS () will know to allocate and
246 initialize a frame_saved_regs struct the first time it is called.
247 Set the arg_pointer to -1, which is not valid; 0 and other values
248 indicate real, cached values. */
249
250#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
251 ((fi)->fsr = 0, (fi)->arg_pointer = -1)
252
253/* FRAME_CHAIN takes a frame's nominal address
254 and produces the frame's chain-pointer.
255 However, if FRAME_CHAIN_VALID returns zero,
256 it means the given frame is the outermost one and has no caller. */
257/* On the arc, we get the chain pointer by reading the PFP saved
258 on the stack. */
259/* The PFP and RPC is in fp and fp+4. */
260
261#define FRAME_CHAIN(thisframe) \
262 (read_memory_integer (FRAME_FP (thisframe), 4))
263
264/* FRAME_CHAIN_VALID returns zero if the given frame is the outermost one
265 and has no caller. */
266#define FRAME_CHAIN_VALID(chain, thisframe) nonnull_frame_chain_valid (chain, thisframe)
267
392a587b
JM
268/* An expression that tells us whether the function invocation represented
269 by FI does not have a frame on the stack associated with it. */
270
271#define FRAMELESS_FUNCTION_INVOCATION(FI) \
272 (((FI)->signal_handler_caller) ? 0 : frameless_look_for_prologue (FI))
c906108c
SS
273
274/* Where is the PC for a specific frame.
275 A leaf function may never save blink, so we have to check for that here. */
276
277#define FRAME_SAVED_PC(frame) (arc_frame_saved_pc (frame))
278struct frame_info; /* in case frame.h not included yet */
279CORE_ADDR arc_frame_saved_pc PARAMS ((struct frame_info *));
280
281/* If the argument is on the stack, it will be here.
282 We cache this value in the frame info if we've already looked it up. */
283/* ??? Is the arg_pointer check necessary? */
284
285#define FRAME_ARGS_ADDRESS(fi) \
286 (((fi)->arg_pointer != -1) ? (fi)->arg_pointer : (fi)->frame)
287
288/* This is the same except it should return 0 when
289 it does not really know where the args are, rather than guessing.
290 This value is not cached since it is only used infrequently. */
291
292#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
293
294/* Set NUMARGS to the number of args passed to a frame.
295 Can return -1, meaning no way to tell. */
296
392a587b 297#define FRAME_NUM_ARGS(fi) (-1)
c906108c
SS
298
299/* Return number of bytes at start of arglist that are not really args. */
300
301#define FRAME_ARGS_SKIP 0
302
303/* Produce the positions of the saved registers in a stack frame. */
304
305#define FRAME_FIND_SAVED_REGS(frame_info_addr, sr) \
306 frame_find_saved_regs (frame_info_addr, &sr)
307extern void frame_find_saved_regs(); /* See arc-tdep.c */
308
309\f
310/* Things needed for making calls to functions in the inferior process */
311#define PUSH_DUMMY_FRAME \
312 push_dummy_frame ()
313
314/* Discard from the stack the innermost frame, restoring all registers. */
315#define POP_FRAME \
316 pop_frame ()
317
318/* This sequence of words is the instructions bl xxxx, flag 1 */
319#define CALL_DUMMY { 0x28000000, 0x1fbe8001 }
320#define CALL_DUMMY_LENGTH 8
321
322/* Start execution at beginning of dummy */
323#define CALL_DUMMY_START_OFFSET 0
324
325/* Insert the specified number of args and function address
326 into a call sequence of the above form stored at 'dummyname'.*/
327#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
328{ \
329 int from, to, delta, loc; \
330 loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
331 from = loc + 4; \
332 to = (int)(fun); \
333 delta = (to - from) >> 2; \
334 *((char *)(dummyname) + 1) = (delta & 0x1); \
335 *((char *)(dummyname) + 2) = ((delta >> 1) & 0xff); \
336 *((char *)(dummyname) + 3) = ((delta >> 9) & 0xff); \
337 *((char *)(dummyname) + 4) = ((delta >> 17) & 0x7); \
338}
339