]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/config/tic80/tm-tic80.h
import gdb-1999-07-07 post reformat
[thirdparty/binutils-gdb.git] / gdb / config / tic80 / tm-tic80.h
1 /* Parameters for execution on a TI TMS320C80 (MVP) processor.
2 Copyright 1997
3 Free Software Foundation, Inc.
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., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #ifndef TM_TIC80_H
23 #define TM_TIC80_H
24
25 #ifdef __STDC__ /* Forward declare structs used in prototypes */
26 struct frame_info;
27 struct type;
28 struct value;
29 struct symbol;
30 struct frame_saved_regs;
31 #endif
32
33 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
34
35 #define NUM_REGS 38
36
37 #define REGISTER_NAMES \
38 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
39 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
40 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
41 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
42 "pc", "npc", \
43 "a0", "a1", "a2", "a3", \
44 }
45
46 /* Various dedicated register numbers
47 FIXME: Shadow updates in sim/tic80/sim-calls.c */
48
49 #define SP_REGNUM 1 /* Contains address of top of stack */
50 #define ARG0_REGNUM 2 /* Contains argument 1 (r3 has high word) */
51 #define RET_REGNUM 2 /* Contains function return value */
52 #define ARGLAST_REGNUM 12 /* Contains argument 6 (r13 has high word) */
53 #define FP_REGNUM 30 /* Contains address of executing stack frame */
54 #define LR_REGNUM 31 /* Contains address of caller (link register) */
55 #define PC_REGNUM 32 /* Contains program counter (FIXME?) */
56 #define NPC_REGNUM 33 /* Contains the next program counter (FIXME?) */
57 #define A0_REGNUM 34 /* Accumulator register 0 */
58 #define A3_REGNUM 37 /* Accumulator register 1 */
59
60 #define R0_REGNUM 0 /* General Purpose Register 0 - for sim */
61 #define Rn_REGNUM 31 /* Last General Purpose Register - for sim */
62 #define An_REGNUM A3_REGNUM /* Last Accumulator register - for sim */
63
64 /* Total amount of space needed to store our copies of the machine's
65 register state, the array `registers'. */
66
67 #define REGISTER_BYTES (((NUM_REGS - 4) * 4) + (4 * 8))
68
69 /* Index within `registers' of the first byte of the space for
70 register N. */
71
72 #define REGISTER_BYTE(N) \
73 (((N) >= A0_REGNUM) ? (((N) - A0_REGNUM) * 8 + A0_REGNUM * 4) : ((N) * 4))
74
75 /* Most registers are 4 bytes */
76
77 #define REGISTER_SIZE 4
78
79 /* Some registers are 8 bytes. */
80
81 #define REGISTER_RAW_SIZE(N) \
82 (((N) >= A0_REGNUM) ? 8 : 4)
83
84 /* Largest value REGISTER_RAW_SIZE can have. */
85
86 #define MAX_REGISTER_RAW_SIZE (8)
87
88 /* All regs are 4 bytes. */
89
90 #define REGISTER_VIRTUAL_SIZE(N) (REGISTER_RAW_SIZE(N))
91
92 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
93
94 #define MAX_REGISTER_VIRTUAL_SIZE (MAX_REGISTER_RAW_SIZE)
95
96 /* Return the GDB type object for the "standard" data type
97 of data in register N. */
98
99 #define REGISTER_VIRTUAL_TYPE(N) /* FIXME? */ \
100 (((N) >= A0_REGNUM) ? builtin_type_float : builtin_type_int)
101
102 /* Offset from address of function to start of its code.
103 Zero on most machines. */
104
105 #define FUNCTION_START_OFFSET 0
106
107 /* Stack grows downward. */
108
109 #define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
110
111 /* Sequence of bytes for breakpoint instruction.
112 This is padded out to the size of a machine word. */
113
114 #define BREAKPOINT {0x49, 0x80, 0x00, 0x00} /* FIXME! */
115
116 /* Amount PC must be decremented by after a breakpoint.
117 This is often the number of bytes in BREAKPOINT
118 but not always. */
119
120 #define DECR_PC_AFTER_BREAK 0 /* FIXME! */
121
122 /* Discard from the stack the innermost frame, restoring all registers. */
123
124 #define POP_FRAME tic80_pop_frame(get_current_frame ())
125 extern struct frame_info *tic80_pop_frame PARAMS ((struct frame_info * frame));
126
127 /* Return number of bytes at start of arglist that are not really args. */
128
129 #define FRAME_ARGS_SKIP 0
130
131 /* Set VAL to the number of args passed to frame described by FI.
132 Can set VAL to -1, meaning no way to tell. */
133 /* We can't tell how many args there are */
134
135 #define FRAME_NUM_ARGS(fi) (-1)
136
137 #define FRAME_ARGS_SKIP 0
138 #define FRAME_ARGS_ADDRESS(fi) (fi)->frame
139 #define FRAME_LOCALS_ADDRESS(fi) (fi)->frame
140
141 /* Define other aspects of the stack frame.
142 We keep the offsets of all saved registers, 'cause we need 'em a lot!
143 We also keep the current size of the stack frame, and the offset of
144 the frame pointer from the stack pointer (for frameless functions, and
145 when we're still in the prologue of a function with a frame) */
146
147 #define EXTRA_FRAME_INFO \
148 struct frame_saved_regs fsr; \
149 int framesize; \
150 int frameoffset; \
151 int framereg;
152
153 extern void tic80_init_extra_frame_info PARAMS ((struct frame_info * fi));
154 #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) tic80_init_extra_frame_info (fi)
155 #define INIT_FRAME_PC /* Not necessary */
156
157 /* Put here the code to store, into a struct frame_saved_regs,
158 the addresses of the saved registers of frame described by FRAME_INFO.
159 This includes special registers such as pc and fp saved in special
160 ways in the stack frame. sp is even more special:
161 the address we return for it IS the sp for the next frame. */
162
163 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
164 tic80_frame_find_saved_regs(frame_info, &(frame_saved_regs))
165 extern void tic80_frame_find_saved_regs PARAMS ((struct frame_info *, struct frame_saved_regs *));
166
167 /* Advance PC across any function entry prologue instructions
168 to reach some "real" code. */
169
170 #define SKIP_PROLOGUE(pc) (tic80_skip_prologue (pc))
171 extern CORE_ADDR tic80_skip_prologue PARAMS ((CORE_ADDR pc));
172
173 /* Immediately after a function call, return the saved pc.
174 Can't always go through the frames for this because on some machines
175 the new frame is not set up until the new function executes
176 some instructions. */
177
178 #define SAVED_PC_AFTER_CALL(frame) read_register (LR_REGNUM)
179
180 /* Describe the pointer in each stack frame to the previous stack frame
181 (its caller). */
182
183 /* FRAME_CHAIN takes a frame's nominal address
184 and produces the frame's chain-pointer. */
185
186 #define FRAME_CHAIN(thisframe) (CORE_ADDR) tic80_frame_chain (thisframe)
187 extern CORE_ADDR tic80_frame_chain PARAMS ((struct frame_info *));
188
189 #define FRAME_SAVED_PC(FRAME) tic80_frame_saved_pc (FRAME)
190 extern CORE_ADDR tic80_frame_saved_pc PARAMS ((struct frame_info *));
191
192 /* Store the address of the place in which to copy the structure the
193 subroutine will return. This is called from call_function.
194
195 We store structs through a pointer passed in R2 */
196
197 #define STORE_STRUCT_RETURN(STRUCT_ADDR, SP) \
198 write_register (ARG0_REGNUM, STRUCT_ADDR)
199
200 /* Extract from an array REGBUF containing the (raw) register state
201 a function return value of type TYPE, and copy that, in virtual format,
202 into VALBUF. */
203
204 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
205 memcpy ((VALBUF), \
206 (char *)(REGBUF) + REGISTER_BYTE (RET_REGNUM) + \
207 ((TYPE_LENGTH (TYPE) > 4 ? 8 : 4) - TYPE_LENGTH (TYPE)), \
208 TYPE_LENGTH (TYPE))
209
210 /* Write into appropriate registers a function return value
211 of type TYPE, given in virtual format. */
212
213 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
214 write_register_bytes(REGISTER_BYTE (RET_REGNUM) + \
215 ((TYPE_LENGTH (TYPE) > 4 ? 8:4) - TYPE_LENGTH (TYPE)),\
216 (VALBUF), TYPE_LENGTH (TYPE));
217
218
219
220 /* PUSH_ARGUMENTS */
221 extern CORE_ADDR tic80_push_arguments PARAMS ((int nargs,
222 struct value ** args,
223 CORE_ADDR sp,
224 unsigned char struct_return,
225 CORE_ADDR struct_addr));
226
227 #define PUSH_ARGUMENTS(NARGS, ARGS, SP, STRUCT_RETURN, STRUCT_ADDR) \
228 (tic80_push_arguments (NARGS, ARGS, SP, STRUCT_RETURN, STRUCT_ADDR))
229
230 /* PUSH_RETURN_ADDRESS */
231 extern CORE_ADDR tic80_push_return_address PARAMS ((CORE_ADDR, CORE_ADDR));
232 #define PUSH_RETURN_ADDRESS(PC, SP) tic80_push_return_address (PC, SP)
233
234 /* override the standard get_saved_register function with
235 one that takes account of generic CALL_DUMMY frames */
236 #define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) \
237 generic_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval)
238
239 #define USE_GENERIC_DUMMY_FRAMES 1
240 #define CALL_DUMMY {0}
241 #define CALL_DUMMY_LENGTH (0)
242 #define CALL_DUMMY_START_OFFSET (0)
243 #define CALL_DUMMY_BREAKPOINT_OFFSET (0)
244 #define FIX_CALL_DUMMY(DUMMY1, STARTADDR, FUNADDR, NARGS, ARGS, TYPE, GCCP)
245 #define CALL_DUMMY_LOCATION AT_ENTRY_POINT
246 #define CALL_DUMMY_ADDRESS() entry_point_address ()
247
248 /* generic dummy frame stuff */
249
250 #define PUSH_DUMMY_FRAME generic_push_dummy_frame ()
251 #define PC_IN_CALL_DUMMY(PC, SP, FP) generic_pc_in_call_dummy (PC, SP, FP)
252
253 #endif /* TM_TIC80_H */