* ieee-float.c: Moved to ../libiberty.
[deliverable/binutils-gdb.git] / gdb / tm-i860.h
CommitLineData
67278683 1/* Parameters for execution on the Intel I860 for GDB, the GNU debugger.
c653bc6d 2 Copyright 1986, 1987, 1993 Free Software Foundation, Inc.
67278683
FF
3
4GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5WARRANTY. No author or distributor accepts responsibility to anyone
6for the consequences of using it or for whether it serves any
7particular purpose or works at all, unless he says so in writing.
8Refer to the GDB General Public License for full details.
9
10Everyone is granted permission to copy, modify and redistribute GDB,
11but only under the conditions described in the GDB General Public
12License. A copy of this license is supposed to have been given to you
13along with GDB so you can know your rights and responsibilities. It
14should be in a file named COPYING. Among other things, the copyright
15notice and this notice must be preserved on all copies.
16
17In other words, go ahead and share GDB, but don't try to stop
18anyone else from sharing it farther. Help stamp out software hoarding!
19*/
20
21#ifndef i860
22#define i860 1
23#endif
24
25#define HAVE_TERMIO
26#define vfork fork
27
67278683
FF
28/* Offset from address of function to start of its code.
29 Zero on most machines. */
30
31#define FUNCTION_START_OFFSET 0
32
33/* The call instruction puts its return address in register r1 and does
34 not change the stack pointer */
35
36#define RETURN_ADDR_IN_REGISTER
37
38/* Advance PC across any function entry prologue instructions
39 to reach some "real" code. */
40
41#define SKIP_PROLOGUE(pc) \
42 { pc = skip_prologue (pc); }
43
44/* Immediately after a function call, return the saved pc.
45 Can't go through the frames for this because on some machines
46 the new frame is not set up until the new function executes
47 some instructions. */
48
49#define SAVED_PC_AFTER_CALL(frame) \
50 (read_register(RP_REGNUM))
51
52/* Address of end of stack space. */
53
54#define STACK_END_ADDR 0xfc000000
55
56/* Stack grows downward. */
57
58#define INNER_THAN <
59
60/* Stack has strict alignment. */
61
62#define ALIGN_STACK(ADDR) (((ADDR)+15)&-16)
63
64
65/* Sequence of bytes for breakpoint instruction. */
66#if defined(i860) && defined(BIG_ENDIAN)
67#define BREAKPOINT {0x44, 0x00, 0x00, 0x00}
68#define BREAKFLOAT {0x22, 0x06, 0x00, 0x48}
69#else
70#define BREAKPOINT {0x00, 0x00, 0x00, 0x44}
71#define BREAKFLOAT {0x48, 0x00, 0x06, 0x22}
72#endif
73/* Amount PC must be decremented by after a breakpoint.
74 This is often the number of bytes in BREAKPOINT
75 but not always. */
76
77#define DECR_PC_AFTER_BREAK 0
78
79/* Nonzero if instruction at PC is a return instruction. */
80/* should be "bri r1" */
81#define ABOUT_TO_RETURN(pc) \
82 (adj_read_memory_integer (pc) == 0x40000800)
83
84
85/* Return 1 if P points to an invalid floating point value. */
86
87#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
88
89/* Largest integer type */
90#define LONGEST long
91
92/* Name of the builtin type for the LONGEST type above. */
93#define BUILTIN_TYPE_LONGEST builtin_type_long
94
95/* Say how long (ordinary) registers are. */
96
97#define REGISTER_TYPE long
98
99/* Number of machine registers */
100
101#define NUM_REGS i860REGCOUNT
102
103/* Initializer for an array of names of registers.
104 There should be NUM_REGS strings in this initializer. */
105#define REGISTER_NAMES \
106{ \
107"psr", "fir", "trap", "dbrk", \
108"r0", "r1", "sp", "fp", "r4", "r5", "r6", "r7", \
109"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
110"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
111"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
112 \
113"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
114"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
115"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
116"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
117 \
118"fsr", \
119"fsr1", "fsr2", "fsr3", \
120"mul1", "", "mul2", "", "mul3", "", \
121"add1", "", "add2", "", "add3", "", \
122"KI", "", "KR", "", "T", "", \
123"MERGE", "", \
124"pfld1", "", "", "", "pfld2", "", "", "", "pfld3", "", "", "", \
125"graph1", "", \
126"fpe_fp1","", "fpe_fp2", "", "fpe_fp3", "", \
127"fpe_fp4", "", \
128"ieee_stat", "fpe_trapped_op", \
129"fpe_fp5","", "fpe_fp6", "", \
130"fpe_rfsr", "","","", \
131"epsr", \
132"ccr", "bear", "err" \
133}
134/* Register numbers of various important registers.
135 Note that some of these values are "real" register numbers,
136 and correspond to the general registers of the machine,
137 and some are "phony" register numbers which are too large
138 to be actual register numbers as far as the user is concerned
139 but do serve to get the desired values when passed to read_register. */
140
141#define RP_REGNUM R1 /* Contains return address value */
142#define SP_REGNUM SP /* Contains address of top of stack, */
143#define FP_REGNUM FP /* Contains address of executing stack frame */
144 /* which is also the bottom of the frame. */
145#define RTRN RP_REGNUM
146#define R_FP FP /* used by dwarfread.c */
147#define Y_REGNUM R31 /* Temp register for address calc., etc. */
148#define PC_REGNUM PC /* Contains program counter */
149#define PS_REGNUM PSR /* Contains processor status */
150#define FP0_REGNUM FREGS /* Floating point register 0 */
151#define FPS_REGNUM FSR /* Floating point status register */
152#define DB_REGNUM DB /* Debug register */
153
154/* Total amount of space needed to store our copies of the machine's
155 register state, the array `registers'. */
156#define REGISTER_BYTES (NUM_REGS * 4)
157
158/* Index within `registers' of the first byte of the space for
159 register N. */
160
161#define REGISTER_BYTE(N) ((N)*4)
162
163/* Number of bytes of storage in the actual machine representation
164 for register N. */
165
166/* On the i860, all regs are 4 bytes. */
167
168#define REGISTER_RAW_SIZE(N) (4)
169
170/* Number of bytes of storage in the program's representation
171 for register N. */
172
173/* On the i860, all regs are 4 bytes. */
174
175#define REGISTER_VIRTUAL_SIZE(N) (4)
176
177/* Largest value REGISTER_RAW_SIZE can have. */
178
179#define MAX_REGISTER_RAW_SIZE 8
180
181/* Largest value REGISTER_VIRTUAL_SIZE can have. */
182
183#define MAX_REGISTER_VIRTUAL_SIZE 8
184
185/* Nonzero if register N requires conversion
186 from raw format to virtual format. */
187
188#define REGISTER_CONVERTIBLE(N) (0)
189
190/* Convert data from raw format for register REGNUM
191 to virtual format for register REGNUM. */
192
193#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
194{ bcopy ((FROM), (TO), 4); }
195
196/* Convert data from virtual format for register REGNUM
197 to raw format for register REGNUM. */
198
199#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
200{ bcopy ((FROM), (TO), 4); }
201
202/* Return the GDB type object for the "standard" data type
203 of data in register N. */
204
205#define REGISTER_VIRTUAL_TYPE(N) \
206 ((N) < F0 ? builtin_type_int : (N) <= F31 ? builtin_type_float : builtin_type_int)
207
208/* Store the address of the place in which to copy the structure the
209 subroutine will return. This is called from call_function. */
210
211#define STORE_STRUCT_RETURN(ADDR, SP) { write_register (R16, (ADDR)); }
212
213/* Extract from an array REGBUF containing the (raw) register state
214 a function return value of type TYPE, and copy that, in virtual format,
215 into VALBUF. */
216
217#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
218 i860_extract_return_value(TYPE, REGBUF, VALBUF)
219
220/* Write into appropriate registers a function return value
221 of type TYPE, given in virtual format. */
222/* On i860, values are returned in register r16. */
223#define STORE_RETURN_VALUE(TYPE,VALBUF) \
224 i860_store_return_value(TYPE, VALBUF)
225
226/* Extract from an array REGBUF containing the (raw) register state
227 the address in which a function should return its structure value,
228 as a CORE_ADDR (or an expression that can be used as one). */
229
230#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
231 (*(int *) ((REGBUF) + REGISTER_BYTE(R16)))
232
233\f
234/* Describe the pointer in each stack frame to the previous stack frame
235 (its caller). */
236#include <sys/types.h>
237#include <sys/regset.h>
238#include "i860_reg.h"
239
240/* FRAME_CHAIN takes a frame's nominal address
241 and produces the frame's chain-pointer.
242
243 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
244 and produces the nominal address of the caller frame.
245
246 However, if FRAME_CHAIN_VALID returns zero,
247 it means the given frame is the outermost one and has no caller.
248 In that case, FRAME_CHAIN_COMBINE is not used. */
249
250/* In the case of the i860, the frame-chain's nominal address
251 is held in the frame pointer register.
252
253 On the i860 the frame (in %fp) points to %fp for the previous frame.
254 */
255
256/* our FRAME_CHAIN requires a pointer to all the frame info (e.g. pc)
257
258 */
259
260#define FRAME_CHAIN(thisframe) frame_chain(thisframe)
261
262#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
263
264/* Define other aspects of the stack frame. */
265
266#define FRAME_SAVED_PC(frame_struct) frame_saved_pc(frame_struct)
267
268#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
269
270#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
271
272/* Set VAL to the number of args passed to frame described by FI.
273 Can set VAL to -1, meaning no way to tell. */
274
275/* We can't tell how many args there are */
276
277#define FRAME_NUM_ARGS(val,fi) (val = -1)
278
279#define FRAME_STRUCT_ARGS_ADDRESS(fi) ((fi)->frame)
280
281/* extra stuff in frame structure to support
282 * backtraceing thru non fp frame based frames
283 * (trace stuff thats not -g compiled)
284 */
285
286#define EXTRA_FRAME_INFO int is_minus_g; CORE_ADDR sp; CORE_ADDR rp;
287
288#define INIT_EXTRA_FRAME_INFO(fromleaf,fci) (fci)->is_minus_g = 0; (fci)->sp = 0; (fci)->rp = 0;
289
290/* Return number of bytes at start of arglist that are not really args. */
291
292#define FRAME_ARGS_SKIP 8
293
294/* Put here the code to store, into a struct frame_saved_regs,
295 the addresses of the saved registers of frame described by FRAME_INFO.
296 This includes special registers such as pc and fp saved in special
297 ways in the stack frame. sp is even more special:
298 the address we return for it IS the sp for the next frame. */
299
300/* Grind through the various st.l rx,Y(fp) and fst.z fx,Y(fp) */
301
302#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
303 frame_find_saved_regs(frame_info, &(frame_saved_regs))
304\f
305/* Things needed for making the inferior call functions. */
306
307/* Push an empty stack frame, to record the current PC, etc. */
308/* We have this frame with fp pointing to a block where all GDB-visible
309 registers are stored in the order GDB knows them, and sp at the next
310 alignment point below fp. Note: fp + NUM_REGS*4 was the old sp
311 */
312
313#define PUSH_DUMMY_FRAME i860_push_frame()
314
315/* Discard from the stack the innermost frame,
316 restoring all saved registers. */
317
318#define POP_FRAME i860_pop_frame()
319
320/* This sequence of words is the instructions:
321 *../
322--
323 nop
324 calli r31
325 nop
326 trap r0,r0,r0
327--
328Note this is 16 bytes.
329Saving of the registers is done by PUSH_DUMMY_FRAME. The address of the
330function to call will be placed in register r31 prior to starting.
331The arguments have to be put into the parameter registers by GDB after
332the PUSH_DUMMY_FRAME is done. NOTE: GDB expects to push arguments, but
333i860 takes them in registers */
334#ifdef BIG_ENDIAN
335/* account for reversal of instructions in memory */
336
337#define CALL_DUMMY { \
338 0x4c00f802, 0xa0000000, 0x44000000, 0xa0000000 }
339#else
340#define CALL_DUMMY { \
341 0xa0000000, 0x4c00F802, 0xa0000000, 0x44000000 }
342#endif
343
344/* This setup is somewhat unusual. PUSH_DUMMY_FRAME and
345 FRAME_FIND_SAVED_REGS conspire to handle dummy frames differently.
346 Therefore, CALL_DUMMY can be minimal. We put the address of the called
347 function in r31 and let'er rip */
348
349#define CALL_DUMMY_LENGTH 16
350
351/* Actually start at the calli */
352
353#define CALL_DUMMY_START_OFFSET 4
354
355/* Normally, GDB will patch the dummy code here to put in the function
356 address, etc., but we only need to put the call adddress in r31 */
357#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
358 write_register(R31, fun)
359
360\f
361/* i860 has no reliable single step ptrace call */
362
363#define NO_SINGLE_STEP 1
364
365#define KERNEL_U_ADDR 0xfc7fe530
366#define REGISTER_U_ADDR(addr,ar0,regno) \
367 addr = (REGISTER_BYTE(regno) + ar0 );
368
369/* How many bytes are pushed on the stack for the argument list
370 */
371#define STACK_ARG_BYTES(RESULT,ARGS,NARGS,STRUCT_RETURN) {(RESULT) = 0;}
372
373/* Pass arguments to a function
374 */
375
376#define PUSH_ARGUMENTS(NARGS,ARGS,STACKP,STRUCT_RETURN,STRUCT_ADDR) \
377 { \
378 STACKP = (STACKP) & (-16); \
379 STACKP = i860_arg_coerce(NARGS, ARGS, STRUCT_RETURN,STACKP); \
380 STACKP =pass_function_arguments(ARGS,NARGS,STRUCT_RETURN, STRUCT_ADDR, STACKP); }
381
382#define CALL_DUMMY_LOCATION AFTER_TEXT_END
383
384#define NEED_TEXT_START_END
385
386#define NONSTANDARD_MEMORY_LAYOUT
387
388/* We support pseudo-frame structure so actual frame pointer value must be
389 * read from the register.
390 */
391#define FP_FROM_REGISTER
392
393/* Support a quit from info register command because we have so many regs
394 */
395#define INFO_REGISTER_QUIT
396
397/* Identify text or absolute symbols to put in misc function table. In the
398 * i860 case, only text symbols not starting with _L00
399 */
400#define MISC_FUNCTION(cs) ((cs)->c_secnum == 1 && (cs)->c_value && \
401 strncmp((cs)->c_name, "_L00", 4) != 0)
402
403/* Define our a.out magic number and undefine the 386 one if it's defined
404 */
405#ifdef I860MAGIC
406#define AOUT_MAGIC I860MAGIC
407#else
408#define AOUT_MAGIC 0515
409#endif
410
411#ifdef I386MAGIC
412#undef I386MAGIC
413#endif
414
415/* The aouthdr may be larger than defined in a.out.h
416 */
417#define AOUTHDR_VARIABLE
418
419/* We have a bug where lineno information is not in symbol table correctly
420 */
421#define LINENO_BUG
422
423/* Similarly, the Endndx of a structure definition is bogus in ld860
424 */
425 /* #define STRUCT_SYMBOL_BUG */
426
427/* Also, we see T_ARG types when we shouldn't
428 */
429#define T_ARG_BUG
430
431/* Macro to sign extend to 32 bits */
432#define SIGN_EXT(n,x) (((int) (x) << (32-n)) >> (32-n))
433
434#define SIGN_EXT16(x) (((int) (x) << (16)) >> (16))
435
436#define FRAMELESS_FUNCTION_INVOCATION(FI,FRAMELESS) frameless_look_for_prologue(FI)
437#if defined(i860) && defined(BIG_ENDIAN)
438#define ADJ_PC(pc) ((unsigned)pc ^ 4)
439#define ADJ_FREG(freg) (F0 + (((freg) - F0) ^ 1))
440#define ADJ_FREG_BYTE(freg) (REGISTER_BYTE(F0) + (((freg) - REGISTER_BYTE(F0)) ^ REGISTER_BYTE(1)))
441#else
442#define ADJ_PC(pc) (pc)
443#define ADJ_FREG(freg) (freg)
444#define ADJ_FREG_BYTE(freg) (freg)
445#endif
446/* define DO_REGISTERS_INFO to do i860-specific formatting */
447#define DO_REGISTERS_INFO(regnum,fpregs) i860_do_registers_info(regnum,fpregs)
448/* the two low order bits of the return pointer are ignored when returning; some systems store information
449 in them. To avoid confusing the stack trace, provide this macro to "clean" the two low order bits */
450#define CLEAN_PC(pc) ((unsigned) pc & 0xfffffffc)
451#define adj_target_read_memory(memaddr,myaddr,len) target_read_memory(ADJ_PC(memaddr),myaddr,len)
452#define adj_target_write_memory(memaddr,myaddr,len) target_write_memory(ADJ_PC(memaddr),myaddr,len)
453#define adj_read_memory_integer(memaddr) read_memory_integer(ADJ_PC(memaddr),4)
454#define adj_read_memory(memaddr,myaddr,len) read_memory(ADJ_PC(memaddr),myaddr,len)
455#define adj_write_memory(memaddr,myaddr,len) write_memory(ADJ_PC(memaddr),myaddr,len)
456#define INIT_FRAME_PC(fromleaf, prev) \
457 { struct frame_info *nextframe = prev->next; \
458 if (nextframe->rp) \
459 { prev->pc = CLEAN_PC( nextframe ->rp); \
460 prev->rp = 0; } \
461 else prev->pc = CLEAN_PC((fromleaf ? SAVED_PC_AFTER_CALL (prev->next) : \
462 prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ())); }
463
464#define INTERNAL_REGISTER_VAL(regno) regno+R0
465/* used to indicate that the misc function vector has size information about
466 misc functions -- currently true for elf format only -- mlf */
467#define MISC_FUNCTIONS_HAS_SIZE
ca8820f9
FF
468#define FRAME_GET_BASEREG_VALUE(frame,basereg) get_saved_basereg(frame, basereg);
469
This page took 0.064566 seconds and 4 git commands to generate.