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