1 /* Target-dependent code for Renesas Super-H, for GDB.
3 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
4 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 Contributed by Steve Chamberlain
30 #include "frame-base.h"
31 #include "frame-unwind.h"
32 #include "dwarf2-frame.h"
40 #include "gdb_string.h"
41 #include "gdb_assert.h"
42 #include "arch-utils.h"
43 #include "floatformat.h"
51 #include "solib-svr4.h"
55 /* registers numbers shared with the simulator */
56 #include "gdb/sim-sh.h"
58 static void (*sh_show_regs) (void);
60 #define SH_NUM_REGS 67
69 /* Flag showing that a frame has been created in the prologue code. */
72 /* Saved registers. */
73 CORE_ADDR saved_regs[SH_NUM_REGS];
78 sh_sh_register_name (int reg_nr)
80 static char *register_names[] = {
81 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
82 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
83 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
85 "", "", "", "", "", "", "", "",
86 "", "", "", "", "", "", "", "",
88 "", "", "", "", "", "", "", "",
89 "", "", "", "", "", "", "", "",
90 "", "", "", "", "", "", "", "",
94 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
96 return register_names[reg_nr];
100 sh_sh3_register_name (int reg_nr)
102 static char *register_names[] = {
103 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
104 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
105 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
107 "", "", "", "", "", "", "", "",
108 "", "", "", "", "", "", "", "",
110 "r0b0", "r1b0", "r2b0", "r3b0", "r4b0", "r5b0", "r6b0", "r7b0",
111 "r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1"
112 "", "", "", "", "", "", "", "",
116 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
118 return register_names[reg_nr];
122 sh_sh3e_register_name (int reg_nr)
124 static char *register_names[] = {
125 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
126 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
127 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
129 "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7",
130 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
132 "r0b0", "r1b0", "r2b0", "r3b0", "r4b0", "r5b0", "r6b0", "r7b0",
133 "r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1",
134 "", "", "", "", "", "", "", "",
138 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
140 return register_names[reg_nr];
144 sh_sh2e_register_name (int reg_nr)
146 static char *register_names[] = {
147 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
148 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
149 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
151 "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7",
152 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
154 "", "", "", "", "", "", "", "",
155 "", "", "", "", "", "", "", "",
156 "", "", "", "", "", "", "", "",
160 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
162 return register_names[reg_nr];
166 sh_sh2a_register_name (int reg_nr)
168 static char *register_names[] = {
169 /* general registers 0-15 */
170 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
171 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
173 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
176 /* floating point registers 25 - 40 */
177 "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7",
178 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
181 /* 43 - 62. Banked registers. The bank number used is determined by
182 the bank register (63). */
183 "r0b", "r1b", "r2b", "r3b", "r4b", "r5b", "r6b", "r7b",
184 "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b",
185 "machb", "ivnb", "prb", "gbrb", "maclb",
186 /* 63: register bank number, not a real register but used to
187 communicate the register bank currently get/set. This register
188 is hidden to the user, who manipulates it using the pseudo
189 register called "bank" (67). See below. */
192 "ibcr", "ibnr", "tbr",
193 /* 67: register bank number, the user visible pseudo register. */
195 /* double precision (pseudo) 68 - 75 */
196 "dr0", "dr2", "dr4", "dr6", "dr8", "dr10", "dr12", "dr14",
200 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
202 return register_names[reg_nr];
206 sh_sh2a_nofpu_register_name (int reg_nr)
208 static char *register_names[] = {
209 /* general registers 0-15 */
210 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
211 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
213 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
216 /* floating point registers 25 - 40 */
217 "", "", "", "", "", "", "", "",
218 "", "", "", "", "", "", "", "",
221 /* 43 - 62. Banked registers. The bank number used is determined by
222 the bank register (63). */
223 "r0b", "r1b", "r2b", "r3b", "r4b", "r5b", "r6b", "r7b",
224 "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b",
225 "machb", "ivnb", "prb", "gbrb", "maclb",
226 /* 63: register bank number, not a real register but used to
227 communicate the register bank currently get/set. This register
228 is hidden to the user, who manipulates it using the pseudo
229 register called "bank" (67). See below. */
232 "ibcr", "ibnr", "tbr",
233 /* 67: register bank number, the user visible pseudo register. */
235 /* double precision (pseudo) 68 - 75 */
236 "", "", "", "", "", "", "", "",
240 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
242 return register_names[reg_nr];
246 sh_sh_dsp_register_name (int reg_nr)
248 static char *register_names[] = {
249 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
250 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
251 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
253 "a0g", "a0", "a1g", "a1", "m0", "m1", "x0", "x1",
254 "y0", "y1", "", "", "", "", "", "mod",
256 "rs", "re", "", "", "", "", "", "",
257 "", "", "", "", "", "", "", "",
258 "", "", "", "", "", "", "", "",
262 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
264 return register_names[reg_nr];
268 sh_sh3_dsp_register_name (int reg_nr)
270 static char *register_names[] = {
271 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
272 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
273 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
275 "a0g", "a0", "a1g", "a1", "m0", "m1", "x0", "x1",
276 "y0", "y1", "", "", "", "", "", "mod",
278 "rs", "re", "", "", "", "", "", "",
279 "r0b", "r1b", "r2b", "r3b", "r4b", "r5b", "r6b", "r7b",
280 "", "", "", "", "", "", "", "",
281 "", "", "", "", "", "", "", "",
285 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
287 return register_names[reg_nr];
291 sh_sh4_register_name (int reg_nr)
293 static char *register_names[] = {
294 /* general registers 0-15 */
295 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
296 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
298 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
301 /* floating point registers 25 - 40 */
302 "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7",
303 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
307 "r0b0", "r1b0", "r2b0", "r3b0", "r4b0", "r5b0", "r6b0", "r7b0",
309 "r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1",
310 "", "", "", "", "", "", "", "",
311 /* pseudo bank register. */
313 /* double precision (pseudo) 59 - 66 */
314 "dr0", "dr2", "dr4", "dr6", "dr8", "dr10", "dr12", "dr14",
315 /* vectors (pseudo) 67 - 70 */
316 "fv0", "fv4", "fv8", "fv12",
317 /* FIXME: missing XF 71 - 86 */
318 /* FIXME: missing XD 87 - 94 */
322 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
324 return register_names[reg_nr];
328 sh_sh4_nofpu_register_name (int reg_nr)
330 static char *register_names[] = {
331 /* general registers 0-15 */
332 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
333 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
335 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
338 /* floating point registers 25 - 40 -- not for nofpu target */
339 "", "", "", "", "", "", "", "",
340 "", "", "", "", "", "", "", "",
344 "r0b0", "r1b0", "r2b0", "r3b0", "r4b0", "r5b0", "r6b0", "r7b0",
346 "r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1",
347 "", "", "", "", "", "", "", "",
348 /* pseudo bank register. */
350 /* double precision (pseudo) 59 - 66 -- not for nofpu target */
351 "", "", "", "", "", "", "", "",
352 /* vectors (pseudo) 67 - 70 -- not for nofpu target */
357 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
359 return register_names[reg_nr];
363 sh_sh4al_dsp_register_name (int reg_nr)
365 static char *register_names[] = {
366 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
367 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
368 "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
370 "a0g", "a0", "a1g", "a1", "m0", "m1", "x0", "x1",
371 "y0", "y1", "", "", "", "", "", "mod",
373 "rs", "re", "", "", "", "", "", "",
374 "r0b", "r1b", "r2b", "r3b", "r4b", "r5b", "r6b", "r7b",
375 "", "", "", "", "", "", "", "",
376 "", "", "", "", "", "", "", "",
380 if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
382 return register_names[reg_nr];
385 static const unsigned char *
386 sh_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
388 /* 0xc3c3 is trapa #c3, and it works in big and little endian modes */
389 static unsigned char breakpoint[] = { 0xc3, 0xc3 };
391 *lenptr = sizeof (breakpoint);
395 /* Prologue looks like
399 sub <room_for_loca_vars>,r15
402 Actually it can be more complicated than this but that's it, basically.
405 #define GET_SOURCE_REG(x) (((x) >> 4) & 0xf)
406 #define GET_TARGET_REG(x) (((x) >> 8) & 0xf)
408 /* JSR @Rm 0100mmmm00001011 */
409 #define IS_JSR(x) (((x) & 0xf0ff) == 0x400b)
411 /* STS.L PR,@-r15 0100111100100010
412 r15-4-->r15, PR-->(r15) */
413 #define IS_STS(x) ((x) == 0x4f22)
415 /* STS.L MACL,@-r15 0100111100010010
416 r15-4-->r15, MACL-->(r15) */
417 #define IS_MACL_STS(x) ((x) == 0x4f12)
419 /* MOV.L Rm,@-r15 00101111mmmm0110
420 r15-4-->r15, Rm-->(R15) */
421 #define IS_PUSH(x) (((x) & 0xff0f) == 0x2f06)
423 /* MOV r15,r14 0110111011110011
425 #define IS_MOV_SP_FP(x) ((x) == 0x6ef3)
427 /* ADD #imm,r15 01111111iiiiiiii
429 #define IS_ADD_IMM_SP(x) (((x) & 0xff00) == 0x7f00)
431 #define IS_MOV_R3(x) (((x) & 0xff00) == 0x1a00)
432 #define IS_SHLL_R3(x) ((x) == 0x4300)
434 /* ADD r3,r15 0011111100111100
436 #define IS_ADD_R3SP(x) ((x) == 0x3f3c)
438 /* FMOV.S FRm,@-Rn Rn-4-->Rn, FRm-->(Rn) 1111nnnnmmmm1011
439 FMOV DRm,@-Rn Rn-8-->Rn, DRm-->(Rn) 1111nnnnmmm01011
440 FMOV XDm,@-Rn Rn-8-->Rn, XDm-->(Rn) 1111nnnnmmm11011 */
441 /* CV, 2003-08-28: Only suitable with Rn == SP, therefore name changed to
442 make this entirely clear. */
443 /* #define IS_FMOV(x) (((x) & 0xf00f) == 0xf00b) */
444 #define IS_FPUSH(x) (((x) & 0xff0f) == 0xff0b)
446 /* MOV Rm,Rn Rm-->Rn 0110nnnnmmmm0011 4 <= m <= 7 */
447 #define IS_MOV_ARG_TO_REG(x) \
448 (((x) & 0xf00f) == 0x6003 && \
449 ((x) & 0x00f0) >= 0x0040 && \
450 ((x) & 0x00f0) <= 0x0070)
451 /* MOV.L Rm,@Rn 0010nnnnmmmm0010 n = 14, 4 <= m <= 7 */
452 #define IS_MOV_ARG_TO_IND_R14(x) \
453 (((x) & 0xff0f) == 0x2e02 && \
454 ((x) & 0x00f0) >= 0x0040 && \
455 ((x) & 0x00f0) <= 0x0070)
456 /* MOV.L Rm,@(disp*4,Rn) 00011110mmmmdddd n = 14, 4 <= m <= 7 */
457 #define IS_MOV_ARG_TO_IND_R14_WITH_DISP(x) \
458 (((x) & 0xff00) == 0x1e00 && \
459 ((x) & 0x00f0) >= 0x0040 && \
460 ((x) & 0x00f0) <= 0x0070)
462 /* MOV.W @(disp*2,PC),Rn 1001nnnndddddddd */
463 #define IS_MOVW_PCREL_TO_REG(x) (((x) & 0xf000) == 0x9000)
464 /* MOV.L @(disp*4,PC),Rn 1101nnnndddddddd */
465 #define IS_MOVL_PCREL_TO_REG(x) (((x) & 0xf000) == 0xd000)
466 /* MOVI20 #imm20,Rn 0000nnnniiii0000 */
467 #define IS_MOVI20(x) (((x) & 0xf00f) == 0x0000)
468 /* SUB Rn,R15 00111111nnnn1000 */
469 #define IS_SUB_REG_FROM_SP(x) (((x) & 0xff0f) == 0x3f08)
471 #define FPSCR_SZ (1 << 20)
473 /* The following instructions are used for epilogue testing. */
474 #define IS_RESTORE_FP(x) ((x) == 0x6ef6)
475 #define IS_RTS(x) ((x) == 0x000b)
476 #define IS_LDS(x) ((x) == 0x4f26)
477 #define IS_MACL_LDS(x) ((x) == 0x4f16)
478 #define IS_MOV_FP_SP(x) ((x) == 0x6fe3)
479 #define IS_ADD_REG_TO_FP(x) (((x) & 0xff0f) == 0x3e0c)
480 #define IS_ADD_IMM_FP(x) (((x) & 0xff00) == 0x7e00)
482 /* Disassemble an instruction. */
484 gdb_print_insn_sh (bfd_vma memaddr, disassemble_info * info)
486 info->endian = TARGET_BYTE_ORDER;
487 return print_insn_sh (memaddr, info);
491 sh_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
492 struct sh_frame_cache *cache)
499 int reg, sav_reg = -1;
501 if (pc >= current_pc)
505 for (opc = pc + (2 * 28); pc < opc; pc += 2)
507 inst = read_memory_unsigned_integer (pc, 2);
508 /* See where the registers will be saved to */
511 cache->saved_regs[GET_SOURCE_REG (inst)] = cache->sp_offset;
512 cache->sp_offset += 4;
514 else if (IS_STS (inst))
516 cache->saved_regs[PR_REGNUM] = cache->sp_offset;
517 cache->sp_offset += 4;
519 else if (IS_MACL_STS (inst))
521 cache->saved_regs[MACL_REGNUM] = cache->sp_offset;
522 cache->sp_offset += 4;
524 else if (IS_MOV_R3 (inst))
526 r3_val = ((inst & 0xff) ^ 0x80) - 0x80;
528 else if (IS_SHLL_R3 (inst))
532 else if (IS_ADD_R3SP (inst))
534 cache->sp_offset += -r3_val;
536 else if (IS_ADD_IMM_SP (inst))
538 offset = ((inst & 0xff) ^ 0x80) - 0x80;
539 cache->sp_offset -= offset;
541 else if (IS_MOVW_PCREL_TO_REG (inst))
545 reg = GET_TARGET_REG (inst);
549 offset = (inst & 0xff) << 1;
551 read_memory_integer ((pc + 4) + offset, 2);
555 else if (IS_MOVL_PCREL_TO_REG (inst))
559 reg = GET_TARGET_REG (inst);
563 offset = (inst & 0xff) << 2;
565 read_memory_integer (((pc & 0xfffffffc) + 4) + offset, 4);
569 else if (IS_MOVI20 (inst))
573 reg = GET_TARGET_REG (inst);
577 sav_offset = GET_SOURCE_REG (inst) << 16;
578 /* MOVI20 is a 32 bit instruction! */
580 sav_offset |= read_memory_unsigned_integer (pc, 2);
581 /* Now sav_offset contains an unsigned 20 bit value.
582 It must still get sign extended. */
583 if (sav_offset & 0x00080000)
584 sav_offset |= 0xfff00000;
588 else if (IS_SUB_REG_FROM_SP (inst))
590 reg = GET_SOURCE_REG (inst);
591 if (sav_reg > 0 && reg == sav_reg)
595 cache->sp_offset += sav_offset;
597 else if (IS_FPUSH (inst))
599 if (read_register (FPSCR_REGNUM) & FPSCR_SZ)
601 cache->sp_offset += 8;
605 cache->sp_offset += 4;
608 else if (IS_MOV_SP_FP (inst))
611 /* At this point, only allow argument register moves to other
612 registers or argument register moves to @(X,fp) which are
613 moving the register arguments onto the stack area allocated
614 by a former add somenumber to SP call. Don't allow moving
615 to an fp indirect address above fp + cache->sp_offset. */
617 for (opc = pc + 12; pc < opc; pc += 2)
619 inst = read_memory_integer (pc, 2);
620 if (IS_MOV_ARG_TO_IND_R14 (inst))
622 reg = GET_SOURCE_REG (inst);
623 if (cache->sp_offset > 0)
624 cache->saved_regs[reg] = cache->sp_offset;
626 else if (IS_MOV_ARG_TO_IND_R14_WITH_DISP (inst))
628 reg = GET_SOURCE_REG (inst);
629 offset = (inst & 0xf) * 4;
630 if (cache->sp_offset > offset)
631 cache->saved_regs[reg] = cache->sp_offset - offset;
633 else if (IS_MOV_ARG_TO_REG (inst))
640 else if (IS_JSR (inst))
642 /* We have found a jsr that has been scheduled into the prologue.
643 If we continue the scan and return a pc someplace after this,
644 then setting a breakpoint on this function will cause it to
645 appear to be called after the function it is calling via the
646 jsr, which will be very confusing. Most likely the next
647 instruction is going to be IS_MOV_SP_FP in the delay slot. If
648 so, note that before returning the current pc. */
649 inst = read_memory_integer (pc + 2, 2);
650 if (IS_MOV_SP_FP (inst))
654 #if 0 /* This used to just stop when it found an instruction that
655 was not considered part of the prologue. Now, we just
656 keep going looking for likely instructions. */
665 /* Skip any prologue before the guts of a function */
667 /* Skip the prologue using the debug information. If this fails we'll
668 fall back on the 'guess' method below. */
670 after_prologue (CORE_ADDR pc)
672 struct symtab_and_line sal;
673 CORE_ADDR func_addr, func_end;
675 /* If we can not find the symbol in the partial symbol table, then
676 there is no hope we can determine the function's start address
678 if (!find_pc_partial_function (pc, NULL, &func_addr, &func_end))
681 /* Get the line associated with FUNC_ADDR. */
682 sal = find_pc_line (func_addr, 0);
684 /* There are only two cases to consider. First, the end of the source line
685 is within the function bounds. In that case we return the end of the
686 source line. Second is the end of the source line extends beyond the
687 bounds of the current function. We need to use the slow code to
688 examine instructions in that case. */
689 if (sal.end < func_end)
696 sh_skip_prologue (CORE_ADDR start_pc)
699 struct sh_frame_cache cache;
701 /* See if we can determine the end of the prologue via the symbol table.
702 If so, then return either PC, or the PC after the prologue, whichever
704 pc = after_prologue (start_pc);
706 /* If after_prologue returned a useful address, then use it. Else
707 fall back on the instruction skipping code. */
709 return max (pc, start_pc);
711 cache.sp_offset = -4;
712 pc = sh_analyze_prologue (start_pc, (CORE_ADDR) -1, &cache);
721 Aggregate types not bigger than 8 bytes that have the same size and
722 alignment as one of the integer scalar types are returned in the
723 same registers as the integer type they match.
725 For example, a 2-byte aligned structure with size 2 bytes has the
726 same size and alignment as a short int, and will be returned in R0.
727 A 4-byte aligned structure with size 8 bytes has the same size and
728 alignment as a long long int, and will be returned in R0 and R1.
730 When an aggregate type is returned in R0 and R1, R0 contains the
731 first four bytes of the aggregate, and R1 contains the
732 remainder. If the size of the aggregate type is not a multiple of 4
733 bytes, the aggregate is tail-padded up to a multiple of 4
734 bytes. The value of the padding is undefined. For little-endian
735 targets the padding will appear at the most significant end of the
736 last element, for big-endian targets the padding appears at the
737 least significant end of the last element.
739 All other aggregate types are returned by address. The caller
740 function passes the address of an area large enough to hold the
741 aggregate value in R2. The called function stores the result in
744 To reiterate, structs smaller than 8 bytes could also be returned
745 in memory, if they don't pass the "same size and alignment as an
750 struct s { char c[3]; } wibble;
751 struct s foo(void) { return wibble; }
753 the return value from foo() will be in memory, not
754 in R0, because there is no 3-byte integer type.
758 struct s { char c[2]; } wibble;
759 struct s foo(void) { return wibble; }
761 because a struct containing two chars has alignment 1, that matches
762 type char, but size 2, that matches type short. There's no integer
763 type that has alignment 1 and size 2, so the struct is returned in
769 sh_use_struct_convention (int gcc_p, struct type *type)
771 int len = TYPE_LENGTH (type);
772 int nelem = TYPE_NFIELDS (type);
774 /* Non-power of 2 length types and types bigger than 8 bytes (which don't
775 fit in two registers anyway) use struct convention. */
776 if (len != 1 && len != 2 && len != 4 && len != 8)
779 /* Scalar types and aggregate types with exactly one field are aligned
780 by definition. They are returned in registers. */
784 /* If the first field in the aggregate has the same length as the entire
785 aggregate type, the type is returned in registers. */
786 if (TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) == len)
789 /* If the size of the aggregate is 8 bytes and the first field is
790 of size 4 bytes its alignment is equal to long long's alignment,
791 so it's returned in registers. */
792 if (len == 8 && TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) == 4)
795 /* Otherwise use struct convention. */
799 /* Extract from an array REGBUF containing the (raw) register state
800 the address in which a function should return its structure value,
801 as a CORE_ADDR (or an expression that can be used as one). */
803 sh_extract_struct_value_address (struct regcache *regcache)
807 regcache_cooked_read_unsigned (regcache, STRUCT_RETURN_REGNUM, &addr);
812 sh_frame_align (struct gdbarch *ignore, CORE_ADDR sp)
817 /* Function: push_dummy_call (formerly push_arguments)
818 Setup the function arguments for calling a function in the inferior.
820 On the Renesas SH architecture, there are four registers (R4 to R7)
821 which are dedicated for passing function arguments. Up to the first
822 four arguments (depending on size) may go into these registers.
823 The rest go on the stack.
825 MVS: Except on SH variants that have floating point registers.
826 In that case, float and double arguments are passed in the same
827 manner, but using FP registers instead of GP registers.
829 Arguments that are smaller than 4 bytes will still take up a whole
830 register or a whole 32-bit word on the stack, and will be
831 right-justified in the register or the stack word. This includes
832 chars, shorts, and small aggregate types.
834 Arguments that are larger than 4 bytes may be split between two or
835 more registers. If there are not enough registers free, an argument
836 may be passed partly in a register (or registers), and partly on the
837 stack. This includes doubles, long longs, and larger aggregates.
838 As far as I know, there is no upper limit to the size of aggregates
839 that will be passed in this way; in other words, the convention of
840 passing a pointer to a large aggregate instead of a copy is not used.
842 MVS: The above appears to be true for the SH variants that do not
843 have an FPU, however those that have an FPU appear to copy the
844 aggregate argument onto the stack (and not place it in registers)
845 if it is larger than 16 bytes (four GP registers).
847 An exceptional case exists for struct arguments (and possibly other
848 aggregates such as arrays) if the size is larger than 4 bytes but
849 not a multiple of 4 bytes. In this case the argument is never split
850 between the registers and the stack, but instead is copied in its
851 entirety onto the stack, AND also copied into as many registers as
852 there is room for. In other words, space in registers permitting,
853 two copies of the same argument are passed in. As far as I can tell,
854 only the one on the stack is used, although that may be a function
855 of the level of compiler optimization. I suspect this is a compiler
856 bug. Arguments of these odd sizes are left-justified within the
857 word (as opposed to arguments smaller than 4 bytes, which are
860 If the function is to return an aggregate type such as a struct, it
861 is either returned in the normal return value register R0 (if its
862 size is no greater than one byte), or else the caller must allocate
863 space into which the callee will copy the return value (if the size
864 is greater than one byte). In this case, a pointer to the return
865 value location is passed into the callee in register R2, which does
866 not displace any of the other arguments passed in via registers R4
869 /* Helper function to justify value in register according to endianess. */
871 sh_justify_value_in_reg (struct value *val, int len)
873 static char valbuf[4];
875 memset (valbuf, 0, sizeof (valbuf));
878 /* value gets right-justified in the register or stack word */
879 if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
880 memcpy (valbuf + (4 - len), (char *) value_contents (val), len);
882 memcpy (valbuf, (char *) value_contents (val), len);
885 return (char *) value_contents (val);
888 /* Helper function to eval number of bytes to allocate on stack. */
890 sh_stack_allocsize (int nargs, struct value **args)
894 stack_alloc += ((TYPE_LENGTH (value_type (args[nargs])) + 3) & ~3);
898 /* Helper functions for getting the float arguments right. Registers usage
899 depends on the ABI and the endianess. The comments should enlighten how
900 it's intended to work. */
902 /* This array stores which of the float arg registers are already in use. */
903 static int flt_argreg_array[FLOAT_ARGLAST_REGNUM - FLOAT_ARG0_REGNUM + 1];
905 /* This function just resets the above array to "no reg used so far". */
907 sh_init_flt_argreg (void)
909 memset (flt_argreg_array, 0, sizeof flt_argreg_array);
912 /* This function returns the next register to use for float arg passing.
913 It returns either a valid value between FLOAT_ARG0_REGNUM and
914 FLOAT_ARGLAST_REGNUM if a register is available, otherwise it returns
915 FLOAT_ARGLAST_REGNUM + 1 to indicate that no register is available.
917 Note that register number 0 in flt_argreg_array corresponds with the
918 real float register fr4. In contrast to FLOAT_ARG0_REGNUM (value is
919 29) the parity of the register number is preserved, which is important
920 for the double register passing test (see the "argreg & 1" test below). */
922 sh_next_flt_argreg (int len)
926 /* First search for the next free register. */
927 for (argreg = 0; argreg <= FLOAT_ARGLAST_REGNUM - FLOAT_ARG0_REGNUM;
929 if (!flt_argreg_array[argreg])
932 /* No register left? */
933 if (argreg > FLOAT_ARGLAST_REGNUM - FLOAT_ARG0_REGNUM)
934 return FLOAT_ARGLAST_REGNUM + 1;
938 /* Doubles are always starting in a even register number. */
941 flt_argreg_array[argreg] = 1;
945 /* No register left? */
946 if (argreg > FLOAT_ARGLAST_REGNUM - FLOAT_ARG0_REGNUM)
947 return FLOAT_ARGLAST_REGNUM + 1;
949 /* Also mark the next register as used. */
950 flt_argreg_array[argreg + 1] = 1;
952 else if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
954 /* In little endian, gcc passes floats like this: f5, f4, f7, f6, ... */
955 if (!flt_argreg_array[argreg + 1])
958 flt_argreg_array[argreg] = 1;
959 return FLOAT_ARG0_REGNUM + argreg;
962 /* Helper function which figures out, if a type is treated like a float type.
964 The FPU ABIs have a special way how to treat types as float types.
965 Structures with exactly one member, which is of type float or double, are
966 treated exactly as the base types float or double:
976 are handled the same way as just
982 As a result, arguments of these struct types are pushed into floating point
983 registers exactly as floats or doubles, using the same decision algorithm.
985 The same is valid if these types are used as function return types. The
986 above structs are returned in fr0 resp. fr0,fr1 instead of in r0, r0,r1
987 or even using struct convention as it is for other structs. */
990 sh_treat_as_flt_p (struct type *type)
992 int len = TYPE_LENGTH (type);
994 /* Ordinary float types are obviously treated as float. */
995 if (TYPE_CODE (type) == TYPE_CODE_FLT)
997 /* Otherwise non-struct types are not treated as float. */
998 if (TYPE_CODE (type) != TYPE_CODE_STRUCT)
1000 /* Otherwise structs with more than one memeber are not treated as float. */
1001 if (TYPE_NFIELDS (type) != 1)
1003 /* Otherwise if the type of that member is float, the whole type is
1004 treated as float. */
1005 if (TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_FLT)
1007 /* Otherwise it's not treated as float. */
1012 sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
1013 struct value *function,
1014 struct regcache *regcache,
1015 CORE_ADDR bp_addr, int nargs,
1016 struct value **args,
1017 CORE_ADDR sp, int struct_return,
1018 CORE_ADDR struct_addr)
1020 int stack_offset = 0;
1021 int argreg = ARG0_REGNUM;
1027 int len, reg_size = 0;
1028 int pass_on_stack = 0;
1031 /* first force sp to a 4-byte alignment */
1032 sp = sh_frame_align (gdbarch, sp);
1035 regcache_cooked_write_unsigned (regcache,
1036 STRUCT_RETURN_REGNUM, struct_addr);
1038 /* make room on stack for args */
1039 sp -= sh_stack_allocsize (nargs, args);
1041 /* Initialize float argument mechanism. */
1042 sh_init_flt_argreg ();
1044 /* Now load as many as possible of the first arguments into
1045 registers, and push the rest onto the stack. There are 16 bytes
1046 in four registers available. Loop thru args from first to last. */
1047 for (argnum = 0; argnum < nargs; argnum++)
1049 type = value_type (args[argnum]);
1050 len = TYPE_LENGTH (type);
1051 val = sh_justify_value_in_reg (args[argnum], len);
1053 /* Some decisions have to be made how various types are handled.
1054 This also differs in different ABIs. */
1057 /* Find out the next register to use for a floating point value. */
1058 treat_as_flt = sh_treat_as_flt_p (type);
1060 flt_argreg = sh_next_flt_argreg (len);
1061 /* In contrast to non-FPU CPUs, arguments are never split between
1062 registers and stack. If an argument doesn't fit in the remaining
1063 registers it's always pushed entirely on the stack. */
1064 else if (len > ((ARGLAST_REGNUM - argreg + 1) * 4))
1069 if ((treat_as_flt && flt_argreg > FLOAT_ARGLAST_REGNUM)
1070 || (!treat_as_flt && (argreg > ARGLAST_REGNUM
1073 /* The data goes entirely on the stack, 4-byte aligned. */
1074 reg_size = (len + 3) & ~3;
1075 write_memory (sp + stack_offset, val, reg_size);
1076 stack_offset += reg_size;
1078 else if (treat_as_flt && flt_argreg <= FLOAT_ARGLAST_REGNUM)
1080 /* Argument goes in a float argument register. */
1081 reg_size = register_size (gdbarch, flt_argreg);
1082 regval = extract_unsigned_integer (val, reg_size);
1083 /* In little endian mode, float types taking two registers
1084 (doubles on sh4, long doubles on sh2e, sh3e and sh4) must
1085 be stored swapped in the argument registers. The below
1086 code first writes the first 32 bits in the next but one
1087 register, increments the val and len values accordingly
1088 and then proceeds as normal by writing the second 32 bits
1089 into the next register. */
1090 if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE
1091 && TYPE_LENGTH (type) == 2 * reg_size)
1093 regcache_cooked_write_unsigned (regcache, flt_argreg + 1,
1097 regval = extract_unsigned_integer (val, reg_size);
1099 regcache_cooked_write_unsigned (regcache, flt_argreg++, regval);
1101 else if (!treat_as_flt && argreg <= ARGLAST_REGNUM)
1103 /* there's room in a register */
1104 reg_size = register_size (gdbarch, argreg);
1105 regval = extract_unsigned_integer (val, reg_size);
1106 regcache_cooked_write_unsigned (regcache, argreg++, regval);
1108 /* Store the value one register at a time or in one step on stack. */
1114 /* Store return address. */
1115 regcache_cooked_write_unsigned (regcache, PR_REGNUM, bp_addr);
1117 /* Update stack pointer. */
1118 regcache_cooked_write_unsigned (regcache, SP_REGNUM, sp);
1124 sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
1125 struct value *function,
1126 struct regcache *regcache,
1128 int nargs, struct value **args,
1129 CORE_ADDR sp, int struct_return,
1130 CORE_ADDR struct_addr)
1132 int stack_offset = 0;
1133 int argreg = ARG0_REGNUM;
1140 /* first force sp to a 4-byte alignment */
1141 sp = sh_frame_align (gdbarch, sp);
1144 regcache_cooked_write_unsigned (regcache,
1145 STRUCT_RETURN_REGNUM, struct_addr);
1147 /* make room on stack for args */
1148 sp -= sh_stack_allocsize (nargs, args);
1150 /* Now load as many as possible of the first arguments into
1151 registers, and push the rest onto the stack. There are 16 bytes
1152 in four registers available. Loop thru args from first to last. */
1153 for (argnum = 0; argnum < nargs; argnum++)
1155 type = value_type (args[argnum]);
1156 len = TYPE_LENGTH (type);
1157 val = sh_justify_value_in_reg (args[argnum], len);
1161 if (argreg > ARGLAST_REGNUM)
1163 /* The remainder of the data goes entirely on the stack,
1165 reg_size = (len + 3) & ~3;
1166 write_memory (sp + stack_offset, val, reg_size);
1167 stack_offset += reg_size;
1169 else if (argreg <= ARGLAST_REGNUM)
1171 /* there's room in a register */
1172 reg_size = register_size (gdbarch, argreg);
1173 regval = extract_unsigned_integer (val, reg_size);
1174 regcache_cooked_write_unsigned (regcache, argreg++, regval);
1176 /* Store the value reg_size bytes at a time. This means that things
1177 larger than reg_size bytes may go partly in registers and partly
1184 /* Store return address. */
1185 regcache_cooked_write_unsigned (regcache, PR_REGNUM, bp_addr);
1187 /* Update stack pointer. */
1188 regcache_cooked_write_unsigned (regcache, SP_REGNUM, sp);
1193 /* Find a function's return value in the appropriate registers (in
1194 regbuf), and copy it into valbuf. Extract from an array REGBUF
1195 containing the (raw) register state a function return value of type
1196 TYPE, and copy that, in virtual format, into VALBUF. */
1198 sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache,
1201 int len = TYPE_LENGTH (type);
1202 int return_register = R0_REGNUM;
1209 regcache_cooked_read_unsigned (regcache, R0_REGNUM, &c);
1210 store_unsigned_integer (valbuf, len, c);
1214 int i, regnum = R0_REGNUM;
1215 for (i = 0; i < len; i += 4)
1216 regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
1219 error (_("bad size for return value"));
1223 sh_extract_return_value_fpu (struct type *type, struct regcache *regcache,
1226 if (sh_treat_as_flt_p (type))
1228 int len = TYPE_LENGTH (type);
1229 int i, regnum = FP0_REGNUM;
1230 for (i = 0; i < len; i += 4)
1231 if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
1232 regcache_raw_read (regcache, regnum++, (char *) valbuf + len - 4 - i);
1234 regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
1237 sh_extract_return_value_nofpu (type, regcache, valbuf);
1240 /* Write into appropriate registers a function return value
1241 of type TYPE, given in virtual format.
1242 If the architecture is sh4 or sh3e, store a function's return value
1243 in the R0 general register or in the FP0 floating point register,
1244 depending on the type of the return value. In all the other cases
1245 the result is stored in r0, left-justified. */
1247 sh_store_return_value_nofpu (struct type *type, struct regcache *regcache,
1251 int len = TYPE_LENGTH (type);
1255 val = extract_unsigned_integer (valbuf, len);
1256 regcache_cooked_write_unsigned (regcache, R0_REGNUM, val);
1260 int i, regnum = R0_REGNUM;
1261 for (i = 0; i < len; i += 4)
1262 regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
1267 sh_store_return_value_fpu (struct type *type, struct regcache *regcache,
1270 if (sh_treat_as_flt_p (type))
1272 int len = TYPE_LENGTH (type);
1273 int i, regnum = FP0_REGNUM;
1274 for (i = 0; i < len; i += 4)
1275 if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
1276 regcache_raw_write (regcache, regnum++,
1277 (char *) valbuf + len - 4 - i);
1279 regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
1282 sh_store_return_value_nofpu (type, regcache, valbuf);
1285 static enum return_value_convention
1286 sh_return_value_nofpu (struct gdbarch *gdbarch, struct type *type,
1287 struct regcache *regcache,
1288 void *readbuf, const void *writebuf)
1290 if (sh_use_struct_convention (0, type))
1291 return RETURN_VALUE_STRUCT_CONVENTION;
1293 sh_store_return_value_nofpu (type, regcache, writebuf);
1295 sh_extract_return_value_nofpu (type, regcache, readbuf);
1296 return RETURN_VALUE_REGISTER_CONVENTION;
1299 static enum return_value_convention
1300 sh_return_value_fpu (struct gdbarch *gdbarch, struct type *type,
1301 struct regcache *regcache,
1302 void *readbuf, const void *writebuf)
1304 if (sh_use_struct_convention (0, type))
1305 return RETURN_VALUE_STRUCT_CONVENTION;
1307 sh_store_return_value_fpu (type, regcache, writebuf);
1309 sh_extract_return_value_fpu (type, regcache, readbuf);
1310 return RETURN_VALUE_REGISTER_CONVENTION;
1313 /* Print the registers in a form similar to the E7000 */
1316 sh_generic_show_regs (void)
1318 printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n",
1319 paddr (read_register (PC_REGNUM)),
1320 (long) read_register (SR_REGNUM),
1321 (long) read_register (PR_REGNUM),
1322 (long) read_register (MACH_REGNUM),
1323 (long) read_register (MACL_REGNUM));
1325 printf_filtered ("GBR=%08lx VBR=%08lx",
1326 (long) read_register (GBR_REGNUM),
1327 (long) read_register (VBR_REGNUM));
1330 ("\nR0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1331 (long) read_register (0), (long) read_register (1),
1332 (long) read_register (2), (long) read_register (3),
1333 (long) read_register (4), (long) read_register (5),
1334 (long) read_register (6), (long) read_register (7));
1335 printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1336 (long) read_register (8), (long) read_register (9),
1337 (long) read_register (10), (long) read_register (11),
1338 (long) read_register (12), (long) read_register (13),
1339 (long) read_register (14), (long) read_register (15));
1343 sh3_show_regs (void)
1345 printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n",
1346 paddr (read_register (PC_REGNUM)),
1347 (long) read_register (SR_REGNUM),
1348 (long) read_register (PR_REGNUM),
1349 (long) read_register (MACH_REGNUM),
1350 (long) read_register (MACL_REGNUM));
1352 printf_filtered ("GBR=%08lx VBR=%08lx",
1353 (long) read_register (GBR_REGNUM),
1354 (long) read_register (VBR_REGNUM));
1355 printf_filtered (" SSR=%08lx SPC=%08lx",
1356 (long) read_register (SSR_REGNUM),
1357 (long) read_register (SPC_REGNUM));
1360 ("\nR0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1361 (long) read_register (0), (long) read_register (1),
1362 (long) read_register (2), (long) read_register (3),
1363 (long) read_register (4), (long) read_register (5),
1364 (long) read_register (6), (long) read_register (7));
1365 printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1366 (long) read_register (8), (long) read_register (9),
1367 (long) read_register (10), (long) read_register (11),
1368 (long) read_register (12), (long) read_register (13),
1369 (long) read_register (14), (long) read_register (15));
1374 sh2e_show_regs (void)
1376 printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n",
1377 paddr (read_register (PC_REGNUM)),
1378 (long) read_register (SR_REGNUM),
1379 (long) read_register (PR_REGNUM),
1380 (long) read_register (MACH_REGNUM),
1381 (long) read_register (MACL_REGNUM));
1383 printf_filtered ("GBR=%08lx VBR=%08lx",
1384 (long) read_register (GBR_REGNUM),
1385 (long) read_register (VBR_REGNUM));
1386 printf_filtered (" FPUL=%08lx FPSCR=%08lx",
1387 (long) read_register (FPUL_REGNUM),
1388 (long) read_register (FPSCR_REGNUM));
1391 ("\nR0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1392 (long) read_register (0), (long) read_register (1),
1393 (long) read_register (2), (long) read_register (3),
1394 (long) read_register (4), (long) read_register (5),
1395 (long) read_register (6), (long) read_register (7));
1396 printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1397 (long) read_register (8), (long) read_register (9),
1398 (long) read_register (10), (long) read_register (11),
1399 (long) read_register (12), (long) read_register (13),
1400 (long) read_register (14), (long) read_register (15));
1402 printf_filtered (("FP0-FP7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n"), (long) read_register (FP0_REGNUM + 0), (long) read_register (FP0_REGNUM + 1), (long) read_register (FP0_REGNUM + 2), (long) read_register (FP0_REGNUM + 3), (long) read_register (FP0_REGNUM + 4), (long) read_register (FP0_REGNUM + 5), (long) read_register (FP0_REGNUM + 6), (long) read_register (FP0_REGNUM + 7));
1403 printf_filtered (("FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n"), (long) read_register (FP0_REGNUM + 8), (long) read_register (FP0_REGNUM + 9), (long) read_register (FP0_REGNUM + 10), (long) read_register (FP0_REGNUM + 11), (long) read_register (FP0_REGNUM + 12), (long) read_register (FP0_REGNUM + 13), (long) read_register (FP0_REGNUM + 14), (long) read_register (FP0_REGNUM + 15));
1407 sh2a_show_regs (void)
1409 int pr = read_register (FPSCR_REGNUM) & 0x80000;
1410 printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n",
1411 paddr (read_register (PC_REGNUM)),
1412 (long) read_register (SR_REGNUM),
1413 (long) read_register (PR_REGNUM),
1414 (long) read_register (MACH_REGNUM),
1415 (long) read_register (MACL_REGNUM));
1417 printf_filtered ("GBR=%08lx VBR=%08lx TBR=%08lx",
1418 (long) read_register (GBR_REGNUM),
1419 (long) read_register (VBR_REGNUM),
1420 (long) read_register (TBR_REGNUM));
1421 printf_filtered (" FPUL=%08lx FPSCR=%08lx\n",
1422 (long) read_register (FPUL_REGNUM),
1423 (long) read_register (FPSCR_REGNUM));
1425 printf_filtered ("R0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1426 (long) read_register (0), (long) read_register (1),
1427 (long) read_register (2), (long) read_register (3),
1428 (long) read_register (4), (long) read_register (5),
1429 (long) read_register (6), (long) read_register (7));
1430 printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1431 (long) read_register (8), (long) read_register (9),
1432 (long) read_register (10), (long) read_register (11),
1433 (long) read_register (12), (long) read_register (13),
1434 (long) read_register (14), (long) read_register (15));
1436 printf_filtered ((pr
1437 ? "DR0-DR6 %08lx%08lx %08lx%08lx %08lx%08lx %08lx%08lx\n"
1439 "FP0-FP7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n"),
1440 (long) read_register (FP0_REGNUM + 0),
1441 (long) read_register (FP0_REGNUM + 1),
1442 (long) read_register (FP0_REGNUM + 2),
1443 (long) read_register (FP0_REGNUM + 3),
1444 (long) read_register (FP0_REGNUM + 4),
1445 (long) read_register (FP0_REGNUM + 5),
1446 (long) read_register (FP0_REGNUM + 6),
1447 (long) read_register (FP0_REGNUM + 7));
1448 printf_filtered ((pr ?
1449 "DR8-DR14 %08lx%08lx %08lx%08lx %08lx%08lx %08lx%08lx\n" :
1450 "FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n"),
1451 (long) read_register (FP0_REGNUM + 8),
1452 (long) read_register (FP0_REGNUM + 9),
1453 (long) read_register (FP0_REGNUM + 10),
1454 (long) read_register (FP0_REGNUM + 11),
1455 (long) read_register (FP0_REGNUM + 12),
1456 (long) read_register (FP0_REGNUM + 13),
1457 (long) read_register (FP0_REGNUM + 14),
1458 (long) read_register (FP0_REGNUM + 15));
1459 printf_filtered ("BANK=%-3d\n", (int) read_register (BANK_REGNUM));
1460 printf_filtered ("R0b - R7b %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1461 (long) read_register (R0_BANK0_REGNUM + 0),
1462 (long) read_register (R0_BANK0_REGNUM + 1),
1463 (long) read_register (R0_BANK0_REGNUM + 2),
1464 (long) read_register (R0_BANK0_REGNUM + 3),
1465 (long) read_register (R0_BANK0_REGNUM + 4),
1466 (long) read_register (R0_BANK0_REGNUM + 5),
1467 (long) read_register (R0_BANK0_REGNUM + 6),
1468 (long) read_register (R0_BANK0_REGNUM + 7));
1469 printf_filtered ("R8b - R14b %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1470 (long) read_register (R0_BANK0_REGNUM + 8),
1471 (long) read_register (R0_BANK0_REGNUM + 9),
1472 (long) read_register (R0_BANK0_REGNUM + 10),
1473 (long) read_register (R0_BANK0_REGNUM + 11),
1474 (long) read_register (R0_BANK0_REGNUM + 12),
1475 (long) read_register (R0_BANK0_REGNUM + 13),
1476 (long) read_register (R0_BANK0_REGNUM + 14));
1477 printf_filtered ("MACHb=%08lx IVNb=%08lx PRb=%08lx GBRb=%08lx MACLb=%08lx\n",
1478 (long) read_register (R0_BANK0_REGNUM + 15),
1479 (long) read_register (R0_BANK0_REGNUM + 16),
1480 (long) read_register (R0_BANK0_REGNUM + 17),
1481 (long) read_register (R0_BANK0_REGNUM + 18),
1482 (long) read_register (R0_BANK0_REGNUM + 19));
1486 sh2a_nofpu_show_regs (void)
1488 int pr = read_register (FPSCR_REGNUM) & 0x80000;
1489 printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n",
1490 paddr (read_register (PC_REGNUM)),
1491 (long) read_register (SR_REGNUM),
1492 (long) read_register (PR_REGNUM),
1493 (long) read_register (MACH_REGNUM),
1494 (long) read_register (MACL_REGNUM));
1496 printf_filtered ("GBR=%08lx VBR=%08lx TBR=%08lx",
1497 (long) read_register (GBR_REGNUM),
1498 (long) read_register (VBR_REGNUM),
1499 (long) read_register (TBR_REGNUM));
1500 printf_filtered (" FPUL=%08lx FPSCR=%08lx\n",
1501 (long) read_register (FPUL_REGNUM),
1502 (long) read_register (FPSCR_REGNUM));
1504 printf_filtered ("R0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1505 (long) read_register (0), (long) read_register (1),
1506 (long) read_register (2), (long) read_register (3),
1507 (long) read_register (4), (long) read_register (5),
1508 (long) read_register (6), (long) read_register (7));
1509 printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1510 (long) read_register (8), (long) read_register (9),
1511 (long) read_register (10), (long) read_register (11),
1512 (long) read_register (12), (long) read_register (13),
1513 (long) read_register (14), (long) read_register (15));
1515 printf_filtered ("BANK=%-3d\n", (int) read_register (BANK_REGNUM));
1516 printf_filtered ("R0b - R7b %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1517 (long) read_register (R0_BANK0_REGNUM + 0),
1518 (long) read_register (R0_BANK0_REGNUM + 1),
1519 (long) read_register (R0_BANK0_REGNUM + 2),
1520 (long) read_register (R0_BANK0_REGNUM + 3),
1521 (long) read_register (R0_BANK0_REGNUM + 4),
1522 (long) read_register (R0_BANK0_REGNUM + 5),
1523 (long) read_register (R0_BANK0_REGNUM + 6),
1524 (long) read_register (R0_BANK0_REGNUM + 7));
1525 printf_filtered ("R8b - R14b %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1526 (long) read_register (R0_BANK0_REGNUM + 8),
1527 (long) read_register (R0_BANK0_REGNUM + 9),
1528 (long) read_register (R0_BANK0_REGNUM + 10),
1529 (long) read_register (R0_BANK0_REGNUM + 11),
1530 (long) read_register (R0_BANK0_REGNUM + 12),
1531 (long) read_register (R0_BANK0_REGNUM + 13),
1532 (long) read_register (R0_BANK0_REGNUM + 14));
1533 printf_filtered ("MACHb=%08lx IVNb=%08lx PRb=%08lx GBRb=%08lx MACLb=%08lx\n",
1534 (long) read_register (R0_BANK0_REGNUM + 15),
1535 (long) read_register (R0_BANK0_REGNUM + 16),
1536 (long) read_register (R0_BANK0_REGNUM + 17),
1537 (long) read_register (R0_BANK0_REGNUM + 18),
1538 (long) read_register (R0_BANK0_REGNUM + 19));
1542 sh3e_show_regs (void)
1544 printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n",
1545 paddr (read_register (PC_REGNUM)),
1546 (long) read_register (SR_REGNUM),
1547 (long) read_register (PR_REGNUM),
1548 (long) read_register (MACH_REGNUM),
1549 (long) read_register (MACL_REGNUM));
1551 printf_filtered ("GBR=%08lx VBR=%08lx",
1552 (long) read_register (GBR_REGNUM),
1553 (long) read_register (VBR_REGNUM));
1554 printf_filtered (" SSR=%08lx SPC=%08lx",
1555 (long) read_register (SSR_REGNUM),
1556 (long) read_register (SPC_REGNUM));
1557 printf_filtered (" FPUL=%08lx FPSCR=%08lx",
1558 (long) read_register (FPUL_REGNUM),
1559 (long) read_register (FPSCR_REGNUM));
1562 ("\nR0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1563 (long) read_register (0), (long) read_register (1),
1564 (long) read_register (2), (long) read_register (3),
1565 (long) read_register (4), (long) read_register (5),
1566 (long) read_register (6), (long) read_register (7));
1567 printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1568 (long) read_register (8), (long) read_register (9),
1569 (long) read_register (10), (long) read_register (11),
1570 (long) read_register (12), (long) read_register (13),
1571 (long) read_register (14), (long) read_register (15));
1573 printf_filtered (("FP0-FP7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n"), (long) read_register (FP0_REGNUM + 0), (long) read_register (FP0_REGNUM + 1), (long) read_register (FP0_REGNUM + 2), (long) read_register (FP0_REGNUM + 3), (long) read_register (FP0_REGNUM + 4), (long) read_register (FP0_REGNUM + 5), (long) read_register (FP0_REGNUM + 6), (long) read_register (FP0_REGNUM + 7));
1574 printf_filtered (("FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n"), (long) read_register (FP0_REGNUM + 8), (long) read_register (FP0_REGNUM + 9), (long) read_register (FP0_REGNUM + 10), (long) read_register (FP0_REGNUM + 11), (long) read_register (FP0_REGNUM + 12), (long) read_register (FP0_REGNUM + 13), (long) read_register (FP0_REGNUM + 14), (long) read_register (FP0_REGNUM + 15));
1578 sh3_dsp_show_regs (void)
1580 printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n",
1581 paddr (read_register (PC_REGNUM)),
1582 (long) read_register (SR_REGNUM),
1583 (long) read_register (PR_REGNUM),
1584 (long) read_register (MACH_REGNUM),
1585 (long) read_register (MACL_REGNUM));
1587 printf_filtered ("GBR=%08lx VBR=%08lx",
1588 (long) read_register (GBR_REGNUM),
1589 (long) read_register (VBR_REGNUM));
1591 printf_filtered (" SSR=%08lx SPC=%08lx",
1592 (long) read_register (SSR_REGNUM),
1593 (long) read_register (SPC_REGNUM));
1595 printf_filtered (" DSR=%08lx", (long) read_register (DSR_REGNUM));
1598 ("\nR0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1599 (long) read_register (0), (long) read_register (1),
1600 (long) read_register (2), (long) read_register (3),
1601 (long) read_register (4), (long) read_register (5),
1602 (long) read_register (6), (long) read_register (7));
1603 printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1604 (long) read_register (8), (long) read_register (9),
1605 (long) read_register (10), (long) read_register (11),
1606 (long) read_register (12), (long) read_register (13),
1607 (long) read_register (14), (long) read_register (15));
1610 ("A0G=%02lx A0=%08lx M0=%08lx X0=%08lx Y0=%08lx RS=%08lx MOD=%08lx\n",
1611 (long) read_register (A0G_REGNUM) & 0xff,
1612 (long) read_register (A0_REGNUM), (long) read_register (M0_REGNUM),
1613 (long) read_register (X0_REGNUM), (long) read_register (Y0_REGNUM),
1614 (long) read_register (RS_REGNUM), (long) read_register (MOD_REGNUM));
1615 printf_filtered ("A1G=%02lx A1=%08lx M1=%08lx X1=%08lx Y1=%08lx RE=%08lx\n",
1616 (long) read_register (A1G_REGNUM) & 0xff,
1617 (long) read_register (A1_REGNUM),
1618 (long) read_register (M1_REGNUM),
1619 (long) read_register (X1_REGNUM),
1620 (long) read_register (Y1_REGNUM),
1621 (long) read_register (RE_REGNUM));
1625 sh4_show_regs (void)
1627 int pr = read_register (FPSCR_REGNUM) & 0x80000;
1628 printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n",
1629 paddr (read_register (PC_REGNUM)),
1630 (long) read_register (SR_REGNUM),
1631 (long) read_register (PR_REGNUM),
1632 (long) read_register (MACH_REGNUM),
1633 (long) read_register (MACL_REGNUM));
1635 printf_filtered ("GBR=%08lx VBR=%08lx",
1636 (long) read_register (GBR_REGNUM),
1637 (long) read_register (VBR_REGNUM));
1638 printf_filtered (" SSR=%08lx SPC=%08lx",
1639 (long) read_register (SSR_REGNUM),
1640 (long) read_register (SPC_REGNUM));
1641 printf_filtered (" FPUL=%08lx FPSCR=%08lx",
1642 (long) read_register (FPUL_REGNUM),
1643 (long) read_register (FPSCR_REGNUM));
1646 ("\nR0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1647 (long) read_register (0), (long) read_register (1),
1648 (long) read_register (2), (long) read_register (3),
1649 (long) read_register (4), (long) read_register (5),
1650 (long) read_register (6), (long) read_register (7));
1651 printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1652 (long) read_register (8), (long) read_register (9),
1653 (long) read_register (10), (long) read_register (11),
1654 (long) read_register (12), (long) read_register (13),
1655 (long) read_register (14), (long) read_register (15));
1657 printf_filtered ((pr
1658 ? "DR0-DR6 %08lx%08lx %08lx%08lx %08lx%08lx %08lx%08lx\n"
1660 "FP0-FP7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n"),
1661 (long) read_register (FP0_REGNUM + 0),
1662 (long) read_register (FP0_REGNUM + 1),
1663 (long) read_register (FP0_REGNUM + 2),
1664 (long) read_register (FP0_REGNUM + 3),
1665 (long) read_register (FP0_REGNUM + 4),
1666 (long) read_register (FP0_REGNUM + 5),
1667 (long) read_register (FP0_REGNUM + 6),
1668 (long) read_register (FP0_REGNUM + 7));
1669 printf_filtered ((pr ?
1670 "DR8-DR14 %08lx%08lx %08lx%08lx %08lx%08lx %08lx%08lx\n" :
1671 "FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n"),
1672 (long) read_register (FP0_REGNUM + 8),
1673 (long) read_register (FP0_REGNUM + 9),
1674 (long) read_register (FP0_REGNUM + 10),
1675 (long) read_register (FP0_REGNUM + 11),
1676 (long) read_register (FP0_REGNUM + 12),
1677 (long) read_register (FP0_REGNUM + 13),
1678 (long) read_register (FP0_REGNUM + 14),
1679 (long) read_register (FP0_REGNUM + 15));
1683 sh4_nofpu_show_regs (void)
1685 printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n",
1686 paddr (read_register (PC_REGNUM)),
1687 (long) read_register (SR_REGNUM),
1688 (long) read_register (PR_REGNUM),
1689 (long) read_register (MACH_REGNUM),
1690 (long) read_register (MACL_REGNUM));
1692 printf_filtered ("GBR=%08lx VBR=%08lx",
1693 (long) read_register (GBR_REGNUM),
1694 (long) read_register (VBR_REGNUM));
1695 printf_filtered (" SSR=%08lx SPC=%08lx",
1696 (long) read_register (SSR_REGNUM),
1697 (long) read_register (SPC_REGNUM));
1700 ("\nR0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1701 (long) read_register (0), (long) read_register (1),
1702 (long) read_register (2), (long) read_register (3),
1703 (long) read_register (4), (long) read_register (5),
1704 (long) read_register (6), (long) read_register (7));
1705 printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1706 (long) read_register (8), (long) read_register (9),
1707 (long) read_register (10), (long) read_register (11),
1708 (long) read_register (12), (long) read_register (13),
1709 (long) read_register (14), (long) read_register (15));
1713 sh_dsp_show_regs (void)
1715 printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n",
1716 paddr (read_register (PC_REGNUM)),
1717 (long) read_register (SR_REGNUM),
1718 (long) read_register (PR_REGNUM),
1719 (long) read_register (MACH_REGNUM),
1720 (long) read_register (MACL_REGNUM));
1722 printf_filtered ("GBR=%08lx VBR=%08lx",
1723 (long) read_register (GBR_REGNUM),
1724 (long) read_register (VBR_REGNUM));
1726 printf_filtered (" DSR=%08lx", (long) read_register (DSR_REGNUM));
1729 ("\nR0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1730 (long) read_register (0), (long) read_register (1),
1731 (long) read_register (2), (long) read_register (3),
1732 (long) read_register (4), (long) read_register (5),
1733 (long) read_register (6), (long) read_register (7));
1734 printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
1735 (long) read_register (8), (long) read_register (9),
1736 (long) read_register (10), (long) read_register (11),
1737 (long) read_register (12), (long) read_register (13),
1738 (long) read_register (14), (long) read_register (15));
1741 ("A0G=%02lx A0=%08lx M0=%08lx X0=%08lx Y0=%08lx RS=%08lx MOD=%08lx\n",
1742 (long) read_register (A0G_REGNUM) & 0xff,
1743 (long) read_register (A0_REGNUM), (long) read_register (M0_REGNUM),
1744 (long) read_register (X0_REGNUM), (long) read_register (Y0_REGNUM),
1745 (long) read_register (RS_REGNUM), (long) read_register (MOD_REGNUM));
1746 printf_filtered ("A1G=%02lx A1=%08lx M1=%08lx X1=%08lx Y1=%08lx RE=%08lx\n",
1747 (long) read_register (A1G_REGNUM) & 0xff,
1748 (long) read_register (A1_REGNUM),
1749 (long) read_register (M1_REGNUM),
1750 (long) read_register (X1_REGNUM),
1751 (long) read_register (Y1_REGNUM),
1752 (long) read_register (RE_REGNUM));
1756 sh_show_regs_command (char *args, int from_tty)
1762 static struct type *
1763 sh_sh2a_register_type (struct gdbarch *gdbarch, int reg_nr)
1765 if ((reg_nr >= FP0_REGNUM
1766 && (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM))
1767 return builtin_type_float;
1768 else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
1769 return builtin_type_double;
1771 return builtin_type_int;
1774 /* Return the GDB type object for the "standard" data type
1775 of data in register N. */
1776 static struct type *
1777 sh_sh3e_register_type (struct gdbarch *gdbarch, int reg_nr)
1779 if ((reg_nr >= FP0_REGNUM
1780 && (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM))
1781 return builtin_type_float;
1783 return builtin_type_int;
1786 static struct type *
1787 sh_sh4_build_float_register_type (int high)
1791 temp = create_range_type (NULL, builtin_type_int, 0, high);
1792 return create_array_type (NULL, builtin_type_float, temp);
1795 static struct type *
1796 sh_sh4_register_type (struct gdbarch *gdbarch, int reg_nr)
1798 if ((reg_nr >= FP0_REGNUM
1799 && (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM))
1800 return builtin_type_float;
1801 else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
1802 return builtin_type_double;
1803 else if (reg_nr >= FV0_REGNUM && reg_nr <= FV_LAST_REGNUM)
1804 return sh_sh4_build_float_register_type (3);
1806 return builtin_type_int;
1809 static struct type *
1810 sh_default_register_type (struct gdbarch *gdbarch, int reg_nr)
1812 return builtin_type_int;
1815 /* On the sh4, the DRi pseudo registers are problematic if the target
1816 is little endian. When the user writes one of those registers, for
1817 instance with 'ser var $dr0=1', we want the double to be stored
1819 fr0 = 0x00 0x00 0x00 0x00 0x00 0xf0 0x3f
1820 fr1 = 0x00 0x00 0x00 0x00 0x00 0x00 0x00
1822 This corresponds to little endian byte order & big endian word
1823 order. However if we let gdb write the register w/o conversion, it
1824 will write fr0 and fr1 this way:
1825 fr0 = 0x00 0x00 0x00 0x00 0x00 0x00 0x00
1826 fr1 = 0x00 0x00 0x00 0x00 0x00 0xf0 0x3f
1827 because it will consider fr0 and fr1 as a single LE stretch of memory.
1829 To achieve what we want we must force gdb to store things in
1830 floatformat_ieee_double_littlebyte_bigword (which is defined in
1831 include/floatformat.h and libiberty/floatformat.c.
1833 In case the target is big endian, there is no problem, the
1834 raw bytes will look like:
1835 fr0 = 0x3f 0xf0 0x00 0x00 0x00 0x00 0x00
1836 fr1 = 0x00 0x00 0x00 0x00 0x00 0x00 0x00
1838 The other pseudo registers (the FVs) also don't pose a problem
1839 because they are stored as 4 individual FP elements. */
1842 sh_register_convert_to_virtual (int regnum, struct type *type,
1843 char *from, char *to)
1845 if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
1848 floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword,
1850 store_typed_floating (to, type, val);
1854 ("sh_register_convert_to_virtual called with non DR register number");
1858 sh_register_convert_to_raw (struct type *type, int regnum,
1859 const void *from, void *to)
1861 if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
1863 DOUBLEST val = extract_typed_floating (from, type);
1864 floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword,
1868 error (_("sh_register_convert_to_raw called with non DR register number"));
1871 /* For vectors of 4 floating point registers. */
1873 fv_reg_base_num (int fv_regnum)
1877 fp_regnum = FP0_REGNUM + (fv_regnum - FV0_REGNUM) * 4;
1881 /* For double precision floating point registers, i.e 2 fp regs.*/
1883 dr_reg_base_num (int dr_regnum)
1887 fp_regnum = FP0_REGNUM + (dr_regnum - DR0_REGNUM) * 2;
1892 sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
1893 int reg_nr, void *buffer)
1895 int base_regnum, portion;
1896 char temp_buffer[MAX_REGISTER_SIZE];
1898 if (reg_nr == PSEUDO_BANK_REGNUM)
1899 regcache_raw_read (regcache, BANK_REGNUM, buffer);
1901 if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
1903 base_regnum = dr_reg_base_num (reg_nr);
1905 /* Build the value in the provided buffer. */
1906 /* Read the real regs for which this one is an alias. */
1907 for (portion = 0; portion < 2; portion++)
1908 regcache_raw_read (regcache, base_regnum + portion,
1910 + register_size (gdbarch,
1911 base_regnum) * portion));
1912 /* We must pay attention to the endiannes. */
1913 sh_register_convert_to_virtual (reg_nr,
1914 gdbarch_register_type (gdbarch, reg_nr),
1915 temp_buffer, buffer);
1917 else if (reg_nr >= FV0_REGNUM && reg_nr <= FV_LAST_REGNUM)
1919 base_regnum = fv_reg_base_num (reg_nr);
1921 /* Read the real regs for which this one is an alias. */
1922 for (portion = 0; portion < 4; portion++)
1923 regcache_raw_read (regcache, base_regnum + portion,
1925 + register_size (gdbarch,
1926 base_regnum) * portion));
1931 sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
1932 int reg_nr, const void *buffer)
1934 int base_regnum, portion;
1935 char temp_buffer[MAX_REGISTER_SIZE];
1937 if (reg_nr == PSEUDO_BANK_REGNUM)
1939 /* When the bank register is written to, the whole register bank
1940 is switched and all values in the bank registers must be read
1941 from the target/sim again. We're just invalidating the regcache
1942 so that a re-read happens next time it's necessary. */
1945 regcache_raw_write (regcache, BANK_REGNUM, buffer);
1946 for (bregnum = R0_BANK0_REGNUM; bregnum < MACLB_REGNUM; ++bregnum)
1947 set_register_cached (bregnum, 0);
1949 else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
1951 base_regnum = dr_reg_base_num (reg_nr);
1953 /* We must pay attention to the endiannes. */
1954 sh_register_convert_to_raw (gdbarch_register_type (gdbarch, reg_nr),
1955 reg_nr, buffer, temp_buffer);
1957 /* Write the real regs for which this one is an alias. */
1958 for (portion = 0; portion < 2; portion++)
1959 regcache_raw_write (regcache, base_regnum + portion,
1961 + register_size (gdbarch,
1962 base_regnum) * portion));
1964 else if (reg_nr >= FV0_REGNUM && reg_nr <= FV_LAST_REGNUM)
1966 base_regnum = fv_reg_base_num (reg_nr);
1968 /* Write the real regs for which this one is an alias. */
1969 for (portion = 0; portion < 4; portion++)
1970 regcache_raw_write (regcache, base_regnum + portion,
1972 + register_size (gdbarch,
1973 base_regnum) * portion));
1977 /* Floating point vector of 4 float registers. */
1979 do_fv_register_info (struct gdbarch *gdbarch, struct ui_file *file,
1982 int first_fp_reg_num = fv_reg_base_num (fv_regnum);
1983 fprintf_filtered (file, "fv%d\t0x%08x\t0x%08x\t0x%08x\t0x%08x\n",
1984 fv_regnum - FV0_REGNUM,
1985 (int) read_register (first_fp_reg_num),
1986 (int) read_register (first_fp_reg_num + 1),
1987 (int) read_register (first_fp_reg_num + 2),
1988 (int) read_register (first_fp_reg_num + 3));
1991 /* Double precision registers. */
1993 do_dr_register_info (struct gdbarch *gdbarch, struct ui_file *file,
1996 int first_fp_reg_num = dr_reg_base_num (dr_regnum);
1998 fprintf_filtered (file, "dr%d\t0x%08x%08x\n",
1999 dr_regnum - DR0_REGNUM,
2000 (int) read_register (first_fp_reg_num),
2001 (int) read_register (first_fp_reg_num + 1));
2004 do_bank_register_info (struct gdbarch *gdbarch, struct ui_file *file)
2006 fprintf_filtered (file, "bank %d\n",
2007 (int) read_register (BANK_REGNUM));
2011 sh_print_pseudo_register (struct gdbarch *gdbarch, struct ui_file *file,
2014 if (regnum < NUM_REGS || regnum >= NUM_REGS + NUM_PSEUDO_REGS)
2015 internal_error (__FILE__, __LINE__,
2016 _("Invalid pseudo register number %d\n"), regnum);
2017 else if (regnum == PSEUDO_BANK_REGNUM)
2018 do_bank_register_info (gdbarch, file);
2019 else if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
2020 do_dr_register_info (gdbarch, file, regnum);
2021 else if (regnum >= FV0_REGNUM && regnum <= FV_LAST_REGNUM)
2022 do_fv_register_info (gdbarch, file, regnum);
2026 sh_do_fp_register (struct gdbarch *gdbarch, struct ui_file *file, int regnum)
2027 { /* do values for FP (float) regs */
2029 double flt; /* double extracted from raw hex data */
2033 /* Allocate space for the float. */
2034 raw_buffer = (char *) alloca (register_size (gdbarch, FP0_REGNUM));
2036 /* Get the data in raw format. */
2037 if (!frame_register_read (get_selected_frame (NULL), regnum, raw_buffer))
2038 error (_("can't read register %d (%s)"), regnum, REGISTER_NAME (regnum));
2040 /* Get the register as a number */
2041 flt = unpack_double (builtin_type_float, raw_buffer, &inv);
2043 /* Print the name and some spaces. */
2044 fputs_filtered (REGISTER_NAME (regnum), file);
2045 print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file);
2047 /* Print the value. */
2049 fprintf_filtered (file, "<invalid float>");
2051 fprintf_filtered (file, "%-10.9g", flt);
2053 /* Print the fp register as hex. */
2054 fprintf_filtered (file, "\t(raw 0x");
2055 for (j = 0; j < register_size (gdbarch, regnum); j++)
2057 int idx = (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
2059 : register_size (gdbarch, regnum) - 1 - j);
2060 fprintf_filtered (file, "%02x", (unsigned char) raw_buffer[idx]);
2062 fprintf_filtered (file, ")");
2063 fprintf_filtered (file, "\n");
2067 sh_do_register (struct gdbarch *gdbarch, struct ui_file *file, int regnum)
2069 char raw_buffer[MAX_REGISTER_SIZE];
2071 fputs_filtered (REGISTER_NAME (regnum), file);
2072 print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file);
2074 /* Get the data in raw format. */
2075 if (!frame_register_read (get_selected_frame (NULL), regnum, raw_buffer))
2076 fprintf_filtered (file, "*value not available*\n");
2078 val_print (gdbarch_register_type (gdbarch, regnum), raw_buffer, 0, 0,
2079 file, 'x', 1, 0, Val_pretty_default);
2080 fprintf_filtered (file, "\t");
2081 val_print (gdbarch_register_type (gdbarch, regnum), raw_buffer, 0, 0,
2082 file, 0, 1, 0, Val_pretty_default);
2083 fprintf_filtered (file, "\n");
2087 sh_print_register (struct gdbarch *gdbarch, struct ui_file *file, int regnum)
2089 if (regnum < 0 || regnum >= NUM_REGS + NUM_PSEUDO_REGS)
2090 internal_error (__FILE__, __LINE__,
2091 _("Invalid register number %d\n"), regnum);
2093 else if (regnum >= 0 && regnum < NUM_REGS)
2095 if (TYPE_CODE (gdbarch_register_type (gdbarch, regnum)) ==
2097 sh_do_fp_register (gdbarch, file, regnum); /* FP regs */
2099 sh_do_register (gdbarch, file, regnum); /* All other regs */
2102 else if (regnum < NUM_REGS + NUM_PSEUDO_REGS)
2104 sh_print_pseudo_register (gdbarch, file, regnum);
2109 sh_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
2110 struct frame_info *frame, int regnum, int fpregs)
2112 if (regnum != -1) /* do one specified register */
2114 if (*(REGISTER_NAME (regnum)) == '\0')
2115 error (_("Not a valid register for the current processor type"));
2117 sh_print_register (gdbarch, file, regnum);
2120 /* do all (or most) registers */
2122 for (regnum = 0; regnum < NUM_REGS; ++regnum)
2124 /* If the register name is empty, it is undefined for this
2125 processor, so don't display anything. */
2126 if (REGISTER_NAME (regnum) == NULL
2127 || *(REGISTER_NAME (regnum)) == '\0')
2130 if (TYPE_CODE (gdbarch_register_type (gdbarch, regnum)) ==
2133 /* true for "INFO ALL-REGISTERS" command */
2135 sh_do_fp_register (gdbarch, file, regnum); /* FP regs */
2138 sh_do_register (gdbarch, file, regnum); /* All other regs */
2141 if (regnum == PSEUDO_BANK_REGNUM
2142 && REGISTER_NAME (regnum)
2143 && *REGISTER_NAME (regnum))
2144 sh_print_pseudo_register (gdbarch, file, regnum++);
2147 while (regnum < NUM_REGS + NUM_PSEUDO_REGS)
2149 sh_print_pseudo_register (gdbarch, file, regnum);
2156 sh_dsp_register_sim_regno (int nr)
2158 if (legacy_register_sim_regno (nr) < 0)
2159 return legacy_register_sim_regno (nr);
2160 if (nr >= DSR_REGNUM && nr <= Y1_REGNUM)
2161 return nr - DSR_REGNUM + SIM_SH_DSR_REGNUM;
2162 if (nr == MOD_REGNUM)
2163 return SIM_SH_MOD_REGNUM;
2164 if (nr == RS_REGNUM)
2165 return SIM_SH_RS_REGNUM;
2166 if (nr == RE_REGNUM)
2167 return SIM_SH_RE_REGNUM;
2168 if (nr >= DSP_R0_BANK_REGNUM && nr <= DSP_R7_BANK_REGNUM)
2169 return nr - DSP_R0_BANK_REGNUM + SIM_SH_R0_BANK_REGNUM;
2174 sh_sh2a_register_sim_regno (int nr)
2179 return SIM_SH_TBR_REGNUM;
2181 return SIM_SH_IBNR_REGNUM;
2183 return SIM_SH_IBCR_REGNUM;
2185 return SIM_SH_BANK_REGNUM;
2187 return SIM_SH_BANK_MACL_REGNUM;
2189 return SIM_SH_BANK_GBR_REGNUM;
2191 return SIM_SH_BANK_PR_REGNUM;
2193 return SIM_SH_BANK_IVN_REGNUM;
2195 return SIM_SH_BANK_MACH_REGNUM;
2199 return legacy_register_sim_regno (nr);
2202 static struct sh_frame_cache *
2203 sh_alloc_frame_cache (void)
2205 struct sh_frame_cache *cache;
2208 cache = FRAME_OBSTACK_ZALLOC (struct sh_frame_cache);
2212 cache->saved_sp = 0;
2213 cache->sp_offset = 0;
2216 /* Frameless until proven otherwise. */
2219 /* Saved registers. We initialize these to -1 since zero is a valid
2220 offset (that's where fp is supposed to be stored). */
2221 for (i = 0; i < SH_NUM_REGS; i++)
2223 cache->saved_regs[i] = -1;
2229 static struct sh_frame_cache *
2230 sh_frame_cache (struct frame_info *next_frame, void **this_cache)
2232 struct sh_frame_cache *cache;
2233 CORE_ADDR current_pc;
2239 cache = sh_alloc_frame_cache ();
2240 *this_cache = cache;
2242 /* In principle, for normal frames, fp holds the frame pointer,
2243 which holds the base address for the current stack frame.
2244 However, for functions that don't need it, the frame pointer is
2245 optional. For these "frameless" functions the frame pointer is
2246 actually the frame pointer of the calling frame. */
2247 cache->base = frame_unwind_register_unsigned (next_frame, FP_REGNUM);
2248 if (cache->base == 0)
2251 cache->pc = frame_func_unwind (next_frame);
2252 current_pc = frame_pc_unwind (next_frame);
2254 sh_analyze_prologue (cache->pc, current_pc, cache);
2256 if (!cache->uses_fp)
2258 /* We didn't find a valid frame, which means that CACHE->base
2259 currently holds the frame pointer for our calling frame. If
2260 we're at the start of a function, or somewhere half-way its
2261 prologue, the function's frame probably hasn't been fully
2262 setup yet. Try to reconstruct the base address for the stack
2263 frame by looking at the stack pointer. For truly "frameless"
2264 functions this might work too. */
2265 cache->base = frame_unwind_register_unsigned (next_frame, SP_REGNUM);
2268 /* Now that we have the base address for the stack frame we can
2269 calculate the value of sp in the calling frame. */
2270 cache->saved_sp = cache->base + cache->sp_offset;
2272 /* Adjust all the saved registers such that they contain addresses
2273 instead of offsets. */
2274 for (i = 0; i < SH_NUM_REGS; i++)
2275 if (cache->saved_regs[i] != -1)
2276 cache->saved_regs[i] = cache->saved_sp - cache->saved_regs[i] - 4;
2282 sh_frame_prev_register (struct frame_info *next_frame, void **this_cache,
2283 int regnum, int *optimizedp,
2284 enum lval_type *lvalp, CORE_ADDR *addrp,
2285 int *realnump, void *valuep)
2287 struct sh_frame_cache *cache = sh_frame_cache (next_frame, this_cache);
2289 gdb_assert (regnum >= 0);
2291 if (regnum == SP_REGNUM && cache->saved_sp)
2299 /* Store the value. */
2300 store_unsigned_integer (valuep, 4, cache->saved_sp);
2305 /* The PC of the previous frame is stored in the PR register of
2306 the current frame. Frob regnum so that we pull the value from
2307 the correct place. */
2308 if (regnum == PC_REGNUM)
2311 if (regnum < SH_NUM_REGS && cache->saved_regs[regnum] != -1)
2314 *lvalp = lval_memory;
2315 *addrp = cache->saved_regs[regnum];
2319 /* Read the value in from memory. */
2320 read_memory (*addrp, valuep,
2321 register_size (current_gdbarch, regnum));
2327 *lvalp = lval_register;
2331 frame_unwind_register (next_frame, (*realnump), valuep);
2335 sh_frame_this_id (struct frame_info *next_frame, void **this_cache,
2336 struct frame_id *this_id)
2338 struct sh_frame_cache *cache = sh_frame_cache (next_frame, this_cache);
2340 /* This marks the outermost frame. */
2341 if (cache->base == 0)
2344 *this_id = frame_id_build (cache->saved_sp, cache->pc);
2347 static const struct frame_unwind sh_frame_unwind = {
2350 sh_frame_prev_register
2353 static const struct frame_unwind *
2354 sh_frame_sniffer (struct frame_info *next_frame)
2356 return &sh_frame_unwind;
2360 sh_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
2362 return frame_unwind_register_unsigned (next_frame, SP_REGNUM);
2366 sh_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
2368 return frame_unwind_register_unsigned (next_frame, PC_REGNUM);
2371 static struct frame_id
2372 sh_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
2374 return frame_id_build (sh_unwind_sp (gdbarch, next_frame),
2375 frame_pc_unwind (next_frame));
2379 sh_frame_base_address (struct frame_info *next_frame, void **this_cache)
2381 struct sh_frame_cache *cache = sh_frame_cache (next_frame, this_cache);
2386 static const struct frame_base sh_frame_base = {
2388 sh_frame_base_address,
2389 sh_frame_base_address,
2390 sh_frame_base_address
2393 /* The epilogue is defined here as the area at the end of a function,
2394 either on the `ret' instruction itself or after an instruction which
2395 destroys the function's stack frame. */
2397 sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
2399 CORE_ADDR func_addr = 0, func_end = 0;
2401 if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
2404 /* The sh epilogue is max. 14 bytes long. Give another 14 bytes
2405 for a nop and some fixed data (e.g. big offsets) which are
2406 unfortunately also treated as part of the function (which
2407 means, they are below func_end. */
2408 CORE_ADDR addr = func_end - 28;
2409 if (addr < func_addr + 4)
2410 addr = func_addr + 4;
2414 /* First search forward until hitting an rts. */
2415 while (addr < func_end
2416 && !IS_RTS (read_memory_unsigned_integer (addr, 2)))
2418 if (addr >= func_end)
2421 /* At this point we should find a mov.l @r15+,r14 instruction,
2422 either before or after the rts. If not, then the function has
2423 probably no "normal" epilogue and we bail out here. */
2424 inst = read_memory_unsigned_integer (addr - 2, 2);
2425 if (IS_RESTORE_FP (read_memory_unsigned_integer (addr - 2, 2)))
2427 else if (!IS_RESTORE_FP (read_memory_unsigned_integer (addr + 2, 2)))
2430 inst = read_memory_unsigned_integer (addr - 2, 2);
2432 /* Step over possible lds.l @r15+,macl. */
2433 if (IS_MACL_LDS (inst))
2436 inst = read_memory_unsigned_integer (addr - 2, 2);
2439 /* Step over possible lds.l @r15+,pr. */
2443 inst = read_memory_unsigned_integer (addr - 2, 2);
2446 /* Step over possible mov r14,r15. */
2447 if (IS_MOV_FP_SP (inst))
2450 inst = read_memory_unsigned_integer (addr - 2, 2);
2453 /* Now check for FP adjustments, using add #imm,r14 or add rX, r14
2455 while (addr > func_addr + 4
2456 && (IS_ADD_REG_TO_FP (inst) || IS_ADD_IMM_FP (inst)))
2459 inst = read_memory_unsigned_integer (addr - 2, 2);
2462 /* On SH2a check if the previous instruction was perhaps a MOVI20.
2463 That's allowed for the epilogue. */
2464 if ((gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_sh2a
2465 || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_sh2a_nofpu)
2466 && addr > func_addr + 6
2467 && IS_MOVI20 (read_memory_unsigned_integer (addr - 4, 2)))
2477 static struct gdbarch *
2478 sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
2480 struct gdbarch *gdbarch;
2482 sh_show_regs = sh_generic_show_regs;
2483 switch (info.bfd_arch_info->mach)
2486 sh_show_regs = sh2e_show_regs;
2489 sh_show_regs = sh2a_show_regs;
2491 case bfd_mach_sh2a_nofpu:
2492 sh_show_regs = sh2a_nofpu_show_regs;
2494 case bfd_mach_sh_dsp:
2495 sh_show_regs = sh_dsp_show_regs;
2499 sh_show_regs = sh3_show_regs;
2503 sh_show_regs = sh3e_show_regs;
2506 case bfd_mach_sh3_dsp:
2507 case bfd_mach_sh4al_dsp:
2508 sh_show_regs = sh3_dsp_show_regs;
2513 sh_show_regs = sh4_show_regs;
2516 case bfd_mach_sh4_nofpu:
2517 case bfd_mach_sh4a_nofpu:
2518 sh_show_regs = sh4_nofpu_show_regs;
2522 sh_show_regs = sh64_show_regs;
2523 /* SH5 is handled entirely in sh64-tdep.c */
2524 return sh64_gdbarch_init (info, arches);
2527 /* If there is already a candidate, use it. */
2528 arches = gdbarch_list_lookup_by_info (arches, &info);
2530 return arches->gdbarch;
2532 /* None found, create a new architecture from the information
2534 gdbarch = gdbarch_alloc (&info, NULL);
2536 set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
2537 set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
2538 set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
2539 set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT);
2540 set_gdbarch_float_bit (gdbarch, 4 * TARGET_CHAR_BIT);
2541 set_gdbarch_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
2542 set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
2543 set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
2545 set_gdbarch_num_regs (gdbarch, SH_NUM_REGS);
2546 set_gdbarch_sp_regnum (gdbarch, 15);
2547 set_gdbarch_pc_regnum (gdbarch, 16);
2548 set_gdbarch_fp0_regnum (gdbarch, -1);
2549 set_gdbarch_num_pseudo_regs (gdbarch, 0);
2551 set_gdbarch_register_type (gdbarch, sh_default_register_type);
2553 set_gdbarch_print_registers_info (gdbarch, sh_print_registers_info);
2555 set_gdbarch_breakpoint_from_pc (gdbarch, sh_breakpoint_from_pc);
2557 set_gdbarch_print_insn (gdbarch, gdb_print_insn_sh);
2558 set_gdbarch_register_sim_regno (gdbarch, legacy_register_sim_regno);
2560 set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
2562 set_gdbarch_return_value (gdbarch, sh_return_value_nofpu);
2563 set_gdbarch_deprecated_extract_struct_value_address (gdbarch,
2564 sh_extract_struct_value_address);
2566 set_gdbarch_skip_prologue (gdbarch, sh_skip_prologue);
2567 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
2569 set_gdbarch_push_dummy_call (gdbarch, sh_push_dummy_call_nofpu);
2571 set_gdbarch_believe_pcc_promotion (gdbarch, 1);
2573 set_gdbarch_frame_align (gdbarch, sh_frame_align);
2574 set_gdbarch_unwind_sp (gdbarch, sh_unwind_sp);
2575 set_gdbarch_unwind_pc (gdbarch, sh_unwind_pc);
2576 set_gdbarch_unwind_dummy_id (gdbarch, sh_unwind_dummy_id);
2577 frame_base_set_default (gdbarch, &sh_frame_base);
2579 set_gdbarch_in_function_epilogue_p (gdbarch, sh_in_function_epilogue_p);
2581 switch (info.bfd_arch_info->mach)
2584 set_gdbarch_register_name (gdbarch, sh_sh_register_name);
2588 set_gdbarch_register_name (gdbarch, sh_sh_register_name);
2592 /* doubles on sh2e and sh3e are actually 4 byte. */
2593 set_gdbarch_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
2595 set_gdbarch_register_name (gdbarch, sh_sh2e_register_name);
2596 set_gdbarch_register_type (gdbarch, sh_sh3e_register_type);
2597 set_gdbarch_fp0_regnum (gdbarch, 25);
2598 set_gdbarch_return_value (gdbarch, sh_return_value_fpu);
2599 set_gdbarch_push_dummy_call (gdbarch, sh_push_dummy_call_fpu);
2603 set_gdbarch_register_name (gdbarch, sh_sh2a_register_name);
2604 set_gdbarch_register_type (gdbarch, sh_sh2a_register_type);
2605 set_gdbarch_register_sim_regno (gdbarch, sh_sh2a_register_sim_regno);
2607 set_gdbarch_fp0_regnum (gdbarch, 25);
2608 set_gdbarch_num_pseudo_regs (gdbarch, 9);
2609 set_gdbarch_pseudo_register_read (gdbarch, sh_pseudo_register_read);
2610 set_gdbarch_pseudo_register_write (gdbarch, sh_pseudo_register_write);
2611 set_gdbarch_return_value (gdbarch, sh_return_value_fpu);
2612 set_gdbarch_push_dummy_call (gdbarch, sh_push_dummy_call_fpu);
2615 case bfd_mach_sh2a_nofpu:
2616 set_gdbarch_register_name (gdbarch, sh_sh2a_nofpu_register_name);
2617 set_gdbarch_register_sim_regno (gdbarch, sh_sh2a_register_sim_regno);
2619 set_gdbarch_num_pseudo_regs (gdbarch, 1);
2620 set_gdbarch_pseudo_register_read (gdbarch, sh_pseudo_register_read);
2621 set_gdbarch_pseudo_register_write (gdbarch, sh_pseudo_register_write);
2624 case bfd_mach_sh_dsp:
2625 set_gdbarch_register_name (gdbarch, sh_sh_dsp_register_name);
2626 set_gdbarch_register_sim_regno (gdbarch, sh_dsp_register_sim_regno);
2630 set_gdbarch_register_name (gdbarch, sh_sh3_register_name);
2634 /* doubles on sh2e and sh3e are actually 4 byte. */
2635 set_gdbarch_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
2637 set_gdbarch_register_name (gdbarch, sh_sh3e_register_name);
2638 set_gdbarch_register_type (gdbarch, sh_sh3e_register_type);
2639 set_gdbarch_fp0_regnum (gdbarch, 25);
2640 set_gdbarch_return_value (gdbarch, sh_return_value_fpu);
2641 set_gdbarch_push_dummy_call (gdbarch, sh_push_dummy_call_fpu);
2644 case bfd_mach_sh3_dsp:
2645 set_gdbarch_register_name (gdbarch, sh_sh3_dsp_register_name);
2646 set_gdbarch_register_sim_regno (gdbarch, sh_dsp_register_sim_regno);
2651 set_gdbarch_register_name (gdbarch, sh_sh4_register_name);
2652 set_gdbarch_register_type (gdbarch, sh_sh4_register_type);
2653 set_gdbarch_fp0_regnum (gdbarch, 25);
2654 set_gdbarch_num_pseudo_regs (gdbarch, 13);
2655 set_gdbarch_pseudo_register_read (gdbarch, sh_pseudo_register_read);
2656 set_gdbarch_pseudo_register_write (gdbarch, sh_pseudo_register_write);
2657 set_gdbarch_return_value (gdbarch, sh_return_value_fpu);
2658 set_gdbarch_push_dummy_call (gdbarch, sh_push_dummy_call_fpu);
2661 case bfd_mach_sh4_nofpu:
2662 case bfd_mach_sh4a_nofpu:
2663 set_gdbarch_register_name (gdbarch, sh_sh4_nofpu_register_name);
2666 case bfd_mach_sh4al_dsp:
2667 set_gdbarch_register_name (gdbarch, sh_sh4al_dsp_register_name);
2668 set_gdbarch_register_sim_regno (gdbarch, sh_dsp_register_sim_regno);
2672 set_gdbarch_register_name (gdbarch, sh_sh_register_name);
2676 /* Hook in ABI-specific overrides, if they have been registered. */
2677 gdbarch_init_osabi (info, gdbarch);
2679 frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
2680 frame_unwind_append_sniffer (gdbarch, sh_frame_sniffer);
2685 extern initialize_file_ftype _initialize_sh_tdep; /* -Wmissing-prototypes */
2688 _initialize_sh_tdep (void)
2690 struct cmd_list_element *c;
2692 gdbarch_register (bfd_arch_sh, sh_gdbarch_init, NULL);
2694 add_com ("regs", class_vars, sh_show_regs_command, _("Print all registers"));