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