* ppc-linux-nat.c (store_altivec_registers): Don't cast fourth
[deliverable/binutils-gdb.git] / gdb / m32r-tdep.c
CommitLineData
05d57f6f
AC
1// OBSOLETE /* Target-dependent code for the Mitsubishi m32r for GDB, the GNU debugger.
2// OBSOLETE
3// OBSOLETE Copyright 1996, 1998, 1999, 2000, 2001, 2003 Free Software
4// OBSOLETE Foundation, Inc.
5// OBSOLETE
6// OBSOLETE This file is part of GDB.
7// OBSOLETE
8// OBSOLETE This program is free software; you can redistribute it and/or modify
9// OBSOLETE it under the terms of the GNU General Public License as published by
10// OBSOLETE the Free Software Foundation; either version 2 of the License, or
11// OBSOLETE (at your option) any later version.
12// OBSOLETE
13// OBSOLETE This program is distributed in the hope that it will be useful,
14// OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of
15// OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// OBSOLETE GNU General Public License for more details.
17// OBSOLETE
18// OBSOLETE You should have received a copy of the GNU General Public License
19// OBSOLETE along with this program; if not, write to the Free Software
20// OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330,
21// OBSOLETE Boston, MA 02111-1307, USA. */
22// OBSOLETE
23// OBSOLETE #include "defs.h"
24// OBSOLETE #include "frame.h"
25// OBSOLETE #include "inferior.h"
26// OBSOLETE #include "target.h"
27// OBSOLETE #include "value.h"
28// OBSOLETE #include "bfd.h"
29// OBSOLETE #include "gdb_string.h"
30// OBSOLETE #include "gdbcore.h"
31// OBSOLETE #include "symfile.h"
32// OBSOLETE #include "regcache.h"
33// OBSOLETE
34// OBSOLETE /* Function: m32r_use_struct_convention
35// OBSOLETE Return nonzero if call_function should allocate stack space for a
36// OBSOLETE struct return? */
37// OBSOLETE int
38// OBSOLETE m32r_use_struct_convention (int gcc_p, struct type *type)
39// OBSOLETE {
40// OBSOLETE return (TYPE_LENGTH (type) > 8);
41// OBSOLETE }
42// OBSOLETE
43// OBSOLETE /* Function: frame_find_saved_regs
44// OBSOLETE Return the frame_saved_regs structure for the frame.
45// OBSOLETE Doesn't really work for dummy frames, but it does pass back
46// OBSOLETE an empty frame_saved_regs, so I guess that's better than total failure */
47// OBSOLETE
48// OBSOLETE void
49// OBSOLETE m32r_frame_find_saved_regs (struct frame_info *fi,
50// OBSOLETE struct frame_saved_regs *regaddr)
51// OBSOLETE {
52// OBSOLETE memcpy (regaddr, &fi->fsr, sizeof (struct frame_saved_regs));
53// OBSOLETE }
54// OBSOLETE
55// OBSOLETE /* Turn this on if you want to see just how much instruction decoding
56// OBSOLETE if being done, its quite a lot
57// OBSOLETE */
58// OBSOLETE #if 0
59// OBSOLETE static void
60// OBSOLETE dump_insn (char *commnt, CORE_ADDR pc, int insn)
61// OBSOLETE {
62// OBSOLETE printf_filtered (" %s %08x %08x ",
63// OBSOLETE commnt, (unsigned int) pc, (unsigned int) insn);
64// OBSOLETE TARGET_PRINT_INSN (pc, &tm_print_insn_info);
65// OBSOLETE printf_filtered ("\n");
66// OBSOLETE }
67// OBSOLETE #define insn_debug(args) { printf_filtered args; }
68// OBSOLETE #else
69// OBSOLETE #define dump_insn(a,b,c) {}
70// OBSOLETE #define insn_debug(args) {}
71// OBSOLETE #endif
72// OBSOLETE
73// OBSOLETE #define DEFAULT_SEARCH_LIMIT 44
74// OBSOLETE
75// OBSOLETE /* Function: scan_prologue
76// OBSOLETE This function decodes the target function prologue to determine
77// OBSOLETE 1) the size of the stack frame, and 2) which registers are saved on it.
78// OBSOLETE It saves the offsets of saved regs in the frame_saved_regs argument,
79// OBSOLETE and returns the frame size. */
80// OBSOLETE
81// OBSOLETE /*
82// OBSOLETE The sequence it currently generates is:
83// OBSOLETE
84// OBSOLETE if (varargs function) { ddi sp,#n }
85// OBSOLETE push registers
86// OBSOLETE if (additional stack <= 256) { addi sp,#-stack }
87// OBSOLETE else if (additional stack < 65k) { add3 sp,sp,#-stack
88// OBSOLETE
89// OBSOLETE } else if (additional stack) {
90// OBSOLETE seth sp,#(stack & 0xffff0000)
91// OBSOLETE or3 sp,sp,#(stack & 0x0000ffff)
92// OBSOLETE sub sp,r4
93// OBSOLETE }
94// OBSOLETE if (frame pointer) {
95// OBSOLETE mv sp,fp
96// OBSOLETE }
97// OBSOLETE
98// OBSOLETE These instructions are scheduled like everything else, so you should stop at
99// OBSOLETE the first branch instruction.
100// OBSOLETE
101// OBSOLETE */
102// OBSOLETE
103// OBSOLETE /* This is required by skip prologue and by m32r_init_extra_frame_info.
104// OBSOLETE The results of decoding a prologue should be cached because this
105// OBSOLETE thrashing is getting nuts.
106// OBSOLETE I am thinking of making a container class with two indexes, name and
107// OBSOLETE address. It may be better to extend the symbol table.
108// OBSOLETE */
109// OBSOLETE
110// OBSOLETE static void
111// OBSOLETE decode_prologue (CORE_ADDR start_pc, CORE_ADDR scan_limit, CORE_ADDR *pl_endptr, /* var parameter */
112// OBSOLETE unsigned long *framelength, struct frame_info *fi,
113// OBSOLETE struct frame_saved_regs *fsr)
114// OBSOLETE {
115// OBSOLETE unsigned long framesize;
116// OBSOLETE int insn;
117// OBSOLETE int op1;
118// OBSOLETE int maybe_one_more = 0;
119// OBSOLETE CORE_ADDR after_prologue = 0;
120// OBSOLETE CORE_ADDR after_stack_adjust = 0;
121// OBSOLETE CORE_ADDR current_pc;
122// OBSOLETE
123// OBSOLETE
124// OBSOLETE framesize = 0;
125// OBSOLETE after_prologue = 0;
126// OBSOLETE insn_debug (("rd prolog l(%d)\n", scan_limit - current_pc));
127// OBSOLETE
128// OBSOLETE for (current_pc = start_pc; current_pc < scan_limit; current_pc += 2)
129// OBSOLETE {
130// OBSOLETE
131// OBSOLETE insn = read_memory_unsigned_integer (current_pc, 2);
132// OBSOLETE dump_insn ("insn-1", current_pc, insn); /* MTZ */
133// OBSOLETE
134// OBSOLETE /* If this is a 32 bit instruction, we dont want to examine its
135// OBSOLETE immediate data as though it were an instruction */
136// OBSOLETE if (current_pc & 0x02)
137// OBSOLETE { /* Clear the parallel execution bit from 16 bit instruction */
138// OBSOLETE if (maybe_one_more)
139// OBSOLETE { /* The last instruction was a branch, usually terminates
140// OBSOLETE the series, but if this is a parallel instruction,
141// OBSOLETE it may be a stack framing instruction */
142// OBSOLETE if (!(insn & 0x8000))
143// OBSOLETE {
144// OBSOLETE insn_debug (("Really done"));
145// OBSOLETE break; /* nope, we are really done */
146// OBSOLETE }
147// OBSOLETE }
148// OBSOLETE insn &= 0x7fff; /* decode this instruction further */
149// OBSOLETE }
150// OBSOLETE else
151// OBSOLETE {
152// OBSOLETE if (maybe_one_more)
153// OBSOLETE break; /* This isnt the one more */
154// OBSOLETE if (insn & 0x8000)
155// OBSOLETE {
156// OBSOLETE insn_debug (("32 bit insn\n"));
157// OBSOLETE if (current_pc == scan_limit)
158// OBSOLETE scan_limit += 2; /* extend the search */
159// OBSOLETE current_pc += 2; /* skip the immediate data */
160// OBSOLETE if (insn == 0x8faf) /* add3 sp, sp, xxxx */
161// OBSOLETE /* add 16 bit sign-extended offset */
162// OBSOLETE {
163// OBSOLETE insn_debug (("stack increment\n"));
164// OBSOLETE framesize += -((short) read_memory_unsigned_integer (current_pc, 2));
165// OBSOLETE }
166// OBSOLETE else
167// OBSOLETE {
168// OBSOLETE if (((insn >> 8) == 0xe4) && /* ld24 r4, xxxxxx; sub sp, r4 */
169// OBSOLETE read_memory_unsigned_integer (current_pc + 2, 2) == 0x0f24)
170// OBSOLETE { /* subtract 24 bit sign-extended negative-offset */
171// OBSOLETE dump_insn ("insn-2", current_pc + 2, insn);
172// OBSOLETE insn = read_memory_unsigned_integer (current_pc - 2, 4);
173// OBSOLETE dump_insn ("insn-3(l4)", current_pc - 2, insn);
174// OBSOLETE if (insn & 0x00800000) /* sign extend */
175// OBSOLETE insn |= 0xff000000; /* negative */
176// OBSOLETE else
177// OBSOLETE insn &= 0x00ffffff; /* positive */
178// OBSOLETE framesize += insn;
179// OBSOLETE }
180// OBSOLETE }
181// OBSOLETE after_prologue = current_pc;
182// OBSOLETE continue;
183// OBSOLETE }
184// OBSOLETE }
185// OBSOLETE op1 = insn & 0xf000; /* isolate just the first nibble */
186// OBSOLETE
187// OBSOLETE if ((insn & 0xf0ff) == 0x207f)
188// OBSOLETE { /* st reg, @-sp */
189// OBSOLETE int regno;
190// OBSOLETE insn_debug (("push\n"));
191// OBSOLETE #if 0 /* No, PUSH FP is not an indication that we will use a frame pointer. */
192// OBSOLETE if (((insn & 0xffff) == 0x2d7f) && fi)
193// OBSOLETE fi->using_frame_pointer = 1;
194// OBSOLETE #endif
195// OBSOLETE framesize += 4;
196// OBSOLETE #if 0
197// OBSOLETE /* Why should we increase the scan limit, just because we did a push?
198// OBSOLETE And if there is a reason, surely we would only want to do it if we
199// OBSOLETE had already reached the scan limit... */
200// OBSOLETE if (current_pc == scan_limit)
201// OBSOLETE scan_limit += 2;
202// OBSOLETE #endif
203// OBSOLETE regno = ((insn >> 8) & 0xf);
204// OBSOLETE if (fsr) /* save_regs offset */
205// OBSOLETE fsr->regs[regno] = framesize;
206// OBSOLETE after_prologue = 0;
207// OBSOLETE continue;
208// OBSOLETE }
209// OBSOLETE if ((insn >> 8) == 0x4f) /* addi sp, xx */
210// OBSOLETE /* add 8 bit sign-extended offset */
211// OBSOLETE {
212// OBSOLETE int stack_adjust = (char) (insn & 0xff);
213// OBSOLETE
214// OBSOLETE /* there are probably two of these stack adjustments:
215// OBSOLETE 1) A negative one in the prologue, and
216// OBSOLETE 2) A positive one in the epilogue.
217// OBSOLETE We are only interested in the first one. */
218// OBSOLETE
219// OBSOLETE if (stack_adjust < 0)
220// OBSOLETE {
221// OBSOLETE framesize -= stack_adjust;
222// OBSOLETE after_prologue = 0;
223// OBSOLETE /* A frameless function may have no "mv fp, sp".
224// OBSOLETE In that case, this is the end of the prologue. */
225// OBSOLETE after_stack_adjust = current_pc + 2;
226// OBSOLETE }
227// OBSOLETE continue;
228// OBSOLETE }
229// OBSOLETE if (insn == 0x1d8f)
230// OBSOLETE { /* mv fp, sp */
231// OBSOLETE if (fi)
232// OBSOLETE fi->using_frame_pointer = 1; /* fp is now valid */
233// OBSOLETE insn_debug (("done fp found\n"));
234// OBSOLETE after_prologue = current_pc + 2;
235// OBSOLETE break; /* end of stack adjustments */
236// OBSOLETE }
237// OBSOLETE if (insn == 0x7000) /* Nop looks like a branch, continue explicitly */
238// OBSOLETE {
239// OBSOLETE insn_debug (("nop\n"));
240// OBSOLETE after_prologue = current_pc + 2;
241// OBSOLETE continue; /* nop occurs between pushes */
242// OBSOLETE }
243// OBSOLETE /* End of prolog if any of these are branch instructions */
244// OBSOLETE if ((op1 == 0x7000)
245// OBSOLETE || (op1 == 0xb000)
246// OBSOLETE || (op1 == 0xf000))
247// OBSOLETE {
248// OBSOLETE after_prologue = current_pc;
249// OBSOLETE insn_debug (("Done: branch\n"));
250// OBSOLETE maybe_one_more = 1;
251// OBSOLETE continue;
252// OBSOLETE }
253// OBSOLETE /* Some of the branch instructions are mixed with other types */
254// OBSOLETE if (op1 == 0x1000)
255// OBSOLETE {
256// OBSOLETE int subop = insn & 0x0ff0;
257// OBSOLETE if ((subop == 0x0ec0) || (subop == 0x0fc0))
258// OBSOLETE {
259// OBSOLETE insn_debug (("done: jmp\n"));
260// OBSOLETE after_prologue = current_pc;
261// OBSOLETE maybe_one_more = 1;
262// OBSOLETE continue; /* jmp , jl */
263// OBSOLETE }
264// OBSOLETE }
265// OBSOLETE }
266// OBSOLETE
267// OBSOLETE if (current_pc >= scan_limit)
268// OBSOLETE {
269// OBSOLETE if (pl_endptr)
270// OBSOLETE {
271// OBSOLETE #if 1
272// OBSOLETE if (after_stack_adjust != 0)
273// OBSOLETE /* We did not find a "mv fp,sp", but we DID find
274// OBSOLETE a stack_adjust. Is it safe to use that as the
275// OBSOLETE end of the prologue? I just don't know. */
276// OBSOLETE {
277// OBSOLETE *pl_endptr = after_stack_adjust;
278// OBSOLETE if (framelength)
279// OBSOLETE *framelength = framesize;
280// OBSOLETE }
281// OBSOLETE else
282// OBSOLETE #endif
283// OBSOLETE /* We reached the end of the loop without finding the end
284// OBSOLETE of the prologue. No way to win -- we should report failure.
285// OBSOLETE The way we do that is to return the original start_pc.
286// OBSOLETE GDB will set a breakpoint at the start of the function (etc.) */
287// OBSOLETE *pl_endptr = start_pc;
288// OBSOLETE }
289// OBSOLETE return;
290// OBSOLETE }
291// OBSOLETE if (after_prologue == 0)
292// OBSOLETE after_prologue = current_pc;
293// OBSOLETE
294// OBSOLETE insn_debug ((" framesize %d, firstline %08x\n", framesize, after_prologue));
295// OBSOLETE if (framelength)
296// OBSOLETE *framelength = framesize;
297// OBSOLETE if (pl_endptr)
298// OBSOLETE *pl_endptr = after_prologue;
299// OBSOLETE } /* decode_prologue */
300// OBSOLETE
301// OBSOLETE /* Function: skip_prologue
302// OBSOLETE Find end of function prologue */
303// OBSOLETE
304// OBSOLETE CORE_ADDR
305// OBSOLETE m32r_skip_prologue (CORE_ADDR pc)
306// OBSOLETE {
307// OBSOLETE CORE_ADDR func_addr, func_end;
308// OBSOLETE struct symtab_and_line sal;
309// OBSOLETE
310// OBSOLETE /* See what the symbol table says */
311// OBSOLETE
312// OBSOLETE if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
313// OBSOLETE {
314// OBSOLETE sal = find_pc_line (func_addr, 0);
315// OBSOLETE
316// OBSOLETE if (sal.line != 0 && sal.end <= func_end)
317// OBSOLETE {
318// OBSOLETE
319// OBSOLETE insn_debug (("BP after prologue %08x\n", sal.end));
320// OBSOLETE func_end = sal.end;
321// OBSOLETE }
322// OBSOLETE else
323// OBSOLETE /* Either there's no line info, or the line after the prologue is after
324// OBSOLETE the end of the function. In this case, there probably isn't a
325// OBSOLETE prologue. */
326// OBSOLETE {
327// OBSOLETE insn_debug (("No line info, line(%x) sal_end(%x) funcend(%x)\n",
328// OBSOLETE sal.line, sal.end, func_end));
329// OBSOLETE func_end = min (func_end, func_addr + DEFAULT_SEARCH_LIMIT);
330// OBSOLETE }
331// OBSOLETE }
332// OBSOLETE else
333// OBSOLETE func_end = pc + DEFAULT_SEARCH_LIMIT;
334// OBSOLETE decode_prologue (pc, func_end, &sal.end, 0, 0, 0);
335// OBSOLETE return sal.end;
336// OBSOLETE }
337// OBSOLETE
338// OBSOLETE static unsigned long
339// OBSOLETE m32r_scan_prologue (struct frame_info *fi, struct frame_saved_regs *fsr)
340// OBSOLETE {
341// OBSOLETE struct symtab_and_line sal;
342// OBSOLETE CORE_ADDR prologue_start, prologue_end, current_pc;
343// OBSOLETE unsigned long framesize = 0;
344// OBSOLETE
345// OBSOLETE /* this code essentially duplicates skip_prologue,
346// OBSOLETE but we need the start address below. */
347// OBSOLETE
348// OBSOLETE if (find_pc_partial_function (fi->pc, NULL, &prologue_start, &prologue_end))
349// OBSOLETE {
350// OBSOLETE sal = find_pc_line (prologue_start, 0);
351// OBSOLETE
352// OBSOLETE if (sal.line == 0) /* no line info, use current PC */
353// OBSOLETE if (prologue_start == entry_point_address ())
354// OBSOLETE return 0;
355// OBSOLETE }
356// OBSOLETE else
357// OBSOLETE {
358// OBSOLETE prologue_start = fi->pc;
359// OBSOLETE prologue_end = prologue_start + 48; /* We're in the boondocks:
360// OBSOLETE allow for 16 pushes, an add,
361// OBSOLETE and "mv fp,sp" */
362// OBSOLETE }
363// OBSOLETE #if 0
364// OBSOLETE prologue_end = min (prologue_end, fi->pc);
365// OBSOLETE #endif
366// OBSOLETE insn_debug (("fipc(%08x) start(%08x) end(%08x)\n",
367// OBSOLETE fi->pc, prologue_start, prologue_end));
368// OBSOLETE prologue_end = min (prologue_end, prologue_start + DEFAULT_SEARCH_LIMIT);
369// OBSOLETE decode_prologue (prologue_start, prologue_end, &prologue_end, &framesize,
370// OBSOLETE fi, fsr);
371// OBSOLETE return framesize;
372// OBSOLETE }
373// OBSOLETE
374// OBSOLETE /* Function: init_extra_frame_info
375// OBSOLETE This function actually figures out the frame address for a given pc and
376// OBSOLETE sp. This is tricky on the m32r because we sometimes don't use an explicit
377// OBSOLETE frame pointer, and the previous stack pointer isn't necessarily recorded
378// OBSOLETE on the stack. The only reliable way to get this info is to
379// OBSOLETE examine the prologue. */
380// OBSOLETE
381// OBSOLETE void
382// OBSOLETE m32r_init_extra_frame_info (struct frame_info *fi)
383// OBSOLETE {
384// OBSOLETE int reg;
385// OBSOLETE
386// OBSOLETE if (fi->next)
387// OBSOLETE fi->pc = FRAME_SAVED_PC (fi->next);
388// OBSOLETE
389// OBSOLETE memset (fi->fsr.regs, '\000', sizeof fi->fsr.regs);
390// OBSOLETE
391// OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
392// OBSOLETE {
393// OBSOLETE /* We need to setup fi->frame here because run_stack_dummy gets it wrong
394// OBSOLETE by assuming it's always FP. */
395// OBSOLETE fi->frame = deprecated_read_register_dummy (fi->pc, fi->frame,
396// OBSOLETE SP_REGNUM);
397// OBSOLETE fi->framesize = 0;
398// OBSOLETE return;
399// OBSOLETE }
400// OBSOLETE else
401// OBSOLETE {
402// OBSOLETE fi->using_frame_pointer = 0;
403// OBSOLETE fi->framesize = m32r_scan_prologue (fi, &fi->fsr);
404// OBSOLETE
405// OBSOLETE if (!fi->next)
406// OBSOLETE if (fi->using_frame_pointer)
407// OBSOLETE {
408// OBSOLETE fi->frame = read_register (FP_REGNUM);
409// OBSOLETE }
410// OBSOLETE else
411// OBSOLETE fi->frame = read_register (SP_REGNUM);
412// OBSOLETE else
413// OBSOLETE /* fi->next means this is not the innermost frame */ if (fi->using_frame_pointer)
414// OBSOLETE /* we have an FP */
415// OBSOLETE if (fi->next->fsr.regs[FP_REGNUM] != 0) /* caller saved our FP */
416// OBSOLETE fi->frame = read_memory_integer (fi->next->fsr.regs[FP_REGNUM], 4);
417// OBSOLETE for (reg = 0; reg < NUM_REGS; reg++)
418// OBSOLETE if (fi->fsr.regs[reg] != 0)
419// OBSOLETE fi->fsr.regs[reg] = fi->frame + fi->framesize - fi->fsr.regs[reg];
420// OBSOLETE }
421// OBSOLETE }
422// OBSOLETE
423// OBSOLETE /* Function: m32r_virtual_frame_pointer
424// OBSOLETE Return the register that the function uses for a frame pointer,
425// OBSOLETE plus any necessary offset to be applied to the register before
426// OBSOLETE any frame pointer offsets. */
427// OBSOLETE
428// OBSOLETE void
429// OBSOLETE m32r_virtual_frame_pointer (CORE_ADDR pc, long *reg, long *offset)
430// OBSOLETE {
431// OBSOLETE struct frame_info *fi = deprecated_frame_xmalloc ();
432// OBSOLETE struct cleanup *old_chain = make_cleanup (xfree, fi);
433// OBSOLETE
434// OBSOLETE /* Set up a dummy frame_info. */
435// OBSOLETE fi->next = NULL;
436// OBSOLETE fi->prev = NULL;
437// OBSOLETE fi->frame = 0;
438// OBSOLETE fi->pc = pc;
439// OBSOLETE
440// OBSOLETE /* Analyze the prolog and fill in the extra info. */
441// OBSOLETE m32r_init_extra_frame_info (fi);
442// OBSOLETE
443// OBSOLETE /* Results will tell us which type of frame it uses. */
444// OBSOLETE if (fi->using_frame_pointer)
445// OBSOLETE {
446// OBSOLETE *reg = FP_REGNUM;
447// OBSOLETE *offset = 0;
448// OBSOLETE }
449// OBSOLETE else
450// OBSOLETE {
451// OBSOLETE *reg = SP_REGNUM;
452// OBSOLETE *offset = 0;
453// OBSOLETE }
454// OBSOLETE do_cleanups (old_chain);
455// OBSOLETE }
456// OBSOLETE
457// OBSOLETE /* Function: find_callers_reg
458// OBSOLETE Find REGNUM on the stack. Otherwise, it's in an active register. One thing
459// OBSOLETE we might want to do here is to check REGNUM against the clobber mask, and
460// OBSOLETE somehow flag it as invalid if it isn't saved on the stack somewhere. This
461// OBSOLETE would provide a graceful failure mode when trying to get the value of
462// OBSOLETE caller-saves registers for an inner frame. */
463// OBSOLETE
464// OBSOLETE CORE_ADDR
465// OBSOLETE m32r_find_callers_reg (struct frame_info *fi, int regnum)
466// OBSOLETE {
467// OBSOLETE for (; fi; fi = fi->next)
468// OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
469// OBSOLETE return deprecated_read_register_dummy (fi->pc, fi->frame, regnum);
470// OBSOLETE else if (fi->fsr.regs[regnum] != 0)
471// OBSOLETE return read_memory_integer (fi->fsr.regs[regnum],
472// OBSOLETE REGISTER_RAW_SIZE (regnum));
473// OBSOLETE return read_register (regnum);
474// OBSOLETE }
475// OBSOLETE
476// OBSOLETE /* Function: frame_chain Given a GDB frame, determine the address of
477// OBSOLETE the calling function's frame. This will be used to create a new
478// OBSOLETE GDB frame struct, and then INIT_EXTRA_FRAME_INFO and
479// OBSOLETE DEPRECATED_INIT_FRAME_PC will be called for the new frame. For
480// OBSOLETE m32r, we save the frame size when we initialize the frame_info. */
481// OBSOLETE
482// OBSOLETE CORE_ADDR
483// OBSOLETE m32r_frame_chain (struct frame_info *fi)
484// OBSOLETE {
485// OBSOLETE CORE_ADDR fn_start, callers_pc, fp;
486// OBSOLETE
487// OBSOLETE /* is this a dummy frame? */
488// OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
489// OBSOLETE return fi->frame; /* dummy frame same as caller's frame */
490// OBSOLETE
491// OBSOLETE /* is caller-of-this a dummy frame? */
492// OBSOLETE callers_pc = FRAME_SAVED_PC (fi); /* find out who called us: */
493// OBSOLETE fp = m32r_find_callers_reg (fi, FP_REGNUM);
494// OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (callers_pc, fp, fp))
495// OBSOLETE return fp; /* dummy frame's frame may bear no relation to ours */
496// OBSOLETE
497// OBSOLETE if (find_pc_partial_function (fi->pc, 0, &fn_start, 0))
498// OBSOLETE if (fn_start == entry_point_address ())
499// OBSOLETE return 0; /* in _start fn, don't chain further */
500// OBSOLETE if (fi->framesize == 0)
501// OBSOLETE {
502// OBSOLETE printf_filtered ("cannot determine frame size @ %s , pc(%s)\n",
503// OBSOLETE paddr (fi->frame),
504// OBSOLETE paddr (fi->pc));
505// OBSOLETE return 0;
506// OBSOLETE }
507// OBSOLETE insn_debug (("m32rx frame %08x\n", fi->frame + fi->framesize));
508// OBSOLETE return fi->frame + fi->framesize;
509// OBSOLETE }
510// OBSOLETE
511// OBSOLETE /* Function: push_return_address (pc)
512// OBSOLETE Set up the return address for the inferior function call.
513// OBSOLETE Necessary for targets that don't actually execute a JSR/BSR instruction
514// OBSOLETE (ie. when using an empty CALL_DUMMY) */
515// OBSOLETE
516// OBSOLETE CORE_ADDR
517// OBSOLETE m32r_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
518// OBSOLETE {
519// OBSOLETE write_register (RP_REGNUM, CALL_DUMMY_ADDRESS ());
520// OBSOLETE return sp;
521// OBSOLETE }
522// OBSOLETE
523// OBSOLETE
524// OBSOLETE /* Function: pop_frame
525// OBSOLETE Discard from the stack the innermost frame,
526// OBSOLETE restoring all saved registers. */
527// OBSOLETE
528// OBSOLETE struct frame_info *
529// OBSOLETE m32r_pop_frame (struct frame_info *frame)
530// OBSOLETE {
531// OBSOLETE int regnum;
532// OBSOLETE
533// OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
534// OBSOLETE generic_pop_dummy_frame ();
535// OBSOLETE else
536// OBSOLETE {
537// OBSOLETE for (regnum = 0; regnum < NUM_REGS; regnum++)
538// OBSOLETE if (frame->fsr.regs[regnum] != 0)
539// OBSOLETE write_register (regnum,
540// OBSOLETE read_memory_integer (frame->fsr.regs[regnum], 4));
541// OBSOLETE
542// OBSOLETE write_register (PC_REGNUM, FRAME_SAVED_PC (frame));
543// OBSOLETE write_register (SP_REGNUM, read_register (FP_REGNUM));
544// OBSOLETE if (read_register (PSW_REGNUM) & 0x80)
545// OBSOLETE write_register (SPU_REGNUM, read_register (SP_REGNUM));
546// OBSOLETE else
547// OBSOLETE write_register (SPI_REGNUM, read_register (SP_REGNUM));
548// OBSOLETE }
549// OBSOLETE flush_cached_frames ();
550// OBSOLETE return NULL;
551// OBSOLETE }
552// OBSOLETE
553// OBSOLETE /* Function: frame_saved_pc
554// OBSOLETE Find the caller of this frame. We do this by seeing if RP_REGNUM is saved
555// OBSOLETE in the stack anywhere, otherwise we get it from the registers. */
556// OBSOLETE
557// OBSOLETE CORE_ADDR
558// OBSOLETE m32r_frame_saved_pc (struct frame_info *fi)
559// OBSOLETE {
560// OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
561// OBSOLETE return deprecated_read_register_dummy (fi->pc, fi->frame, PC_REGNUM);
562// OBSOLETE else
563// OBSOLETE return m32r_find_callers_reg (fi, RP_REGNUM);
564// OBSOLETE }
565// OBSOLETE
566// OBSOLETE /* Function: push_arguments
567// OBSOLETE Setup the function arguments for calling a function in the inferior.
568// OBSOLETE
569// OBSOLETE On the Mitsubishi M32R architecture, there are four registers (R0 to R3)
570// OBSOLETE which are dedicated for passing function arguments. Up to the first
571// OBSOLETE four arguments (depending on size) may go into these registers.
572// OBSOLETE The rest go on the stack.
573// OBSOLETE
574// OBSOLETE Arguments that are smaller than 4 bytes will still take up a whole
575// OBSOLETE register or a whole 32-bit word on the stack, and will be
576// OBSOLETE right-justified in the register or the stack word. This includes
577// OBSOLETE chars, shorts, and small aggregate types.
578// OBSOLETE
579// OBSOLETE Arguments of 8 bytes size are split between two registers, if
580// OBSOLETE available. If only one register is available, the argument will
581// OBSOLETE be split between the register and the stack. Otherwise it is
582// OBSOLETE passed entirely on the stack. Aggregate types with sizes between
583// OBSOLETE 4 and 8 bytes are passed entirely on the stack, and are left-justified
584// OBSOLETE within the double-word (as opposed to aggregates smaller than 4 bytes
585// OBSOLETE which are right-justified).
586// OBSOLETE
587// OBSOLETE Aggregates of greater than 8 bytes are first copied onto the stack,
588// OBSOLETE and then a pointer to the copy is passed in the place of the normal
589// OBSOLETE argument (either in a register if available, or on the stack).
590// OBSOLETE
591// OBSOLETE Functions that must return an aggregate type can return it in the
592// OBSOLETE normal return value registers (R0 and R1) if its size is 8 bytes or
593// OBSOLETE less. For larger return values, the caller must allocate space for
594// OBSOLETE the callee to copy the return value to. A pointer to this space is
595// OBSOLETE passed as an implicit first argument, always in R0. */
596// OBSOLETE
597// OBSOLETE CORE_ADDR
598// OBSOLETE m32r_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
599// OBSOLETE unsigned char struct_return, CORE_ADDR struct_addr)
600// OBSOLETE {
601// OBSOLETE int stack_offset, stack_alloc;
602// OBSOLETE int argreg;
603// OBSOLETE int argnum;
604// OBSOLETE struct type *type;
605// OBSOLETE CORE_ADDR regval;
606// OBSOLETE char *val;
607// OBSOLETE char valbuf[4];
608// OBSOLETE int len;
609// OBSOLETE int odd_sized_struct;
610// OBSOLETE
611// OBSOLETE /* first force sp to a 4-byte alignment */
612// OBSOLETE sp = sp & ~3;
613// OBSOLETE
614// OBSOLETE argreg = ARG0_REGNUM;
615// OBSOLETE /* The "struct return pointer" pseudo-argument goes in R0 */
616// OBSOLETE if (struct_return)
617// OBSOLETE write_register (argreg++, struct_addr);
618// OBSOLETE
619// OBSOLETE /* Now make sure there's space on the stack */
620// OBSOLETE for (argnum = 0, stack_alloc = 0;
621// OBSOLETE argnum < nargs; argnum++)
622// OBSOLETE stack_alloc += ((TYPE_LENGTH (VALUE_TYPE (args[argnum])) + 3) & ~3);
623// OBSOLETE sp -= stack_alloc; /* make room on stack for args */
624// OBSOLETE
625// OBSOLETE
626// OBSOLETE /* Now load as many as possible of the first arguments into
627// OBSOLETE registers, and push the rest onto the stack. There are 16 bytes
628// OBSOLETE in four registers available. Loop thru args from first to last. */
629// OBSOLETE
630// OBSOLETE argreg = ARG0_REGNUM;
631// OBSOLETE for (argnum = 0, stack_offset = 0; argnum < nargs; argnum++)
632// OBSOLETE {
633// OBSOLETE type = VALUE_TYPE (args[argnum]);
634// OBSOLETE len = TYPE_LENGTH (type);
635// OBSOLETE memset (valbuf, 0, sizeof (valbuf));
636// OBSOLETE if (len < 4)
637// OBSOLETE { /* value gets right-justified in the register or stack word */
638// OBSOLETE memcpy (valbuf + (4 - len),
639// OBSOLETE (char *) VALUE_CONTENTS (args[argnum]), len);
640// OBSOLETE val = valbuf;
641// OBSOLETE }
642// OBSOLETE else
643// OBSOLETE val = (char *) VALUE_CONTENTS (args[argnum]);
644// OBSOLETE
645// OBSOLETE if (len > 4 && (len & 3) != 0)
646// OBSOLETE odd_sized_struct = 1; /* such structs go entirely on stack */
647// OBSOLETE else
648// OBSOLETE odd_sized_struct = 0;
649// OBSOLETE while (len > 0)
650// OBSOLETE {
651// OBSOLETE if (argreg > ARGLAST_REGNUM || odd_sized_struct)
652// OBSOLETE { /* must go on the stack */
653// OBSOLETE write_memory (sp + stack_offset, val, 4);
654// OBSOLETE stack_offset += 4;
655// OBSOLETE }
656// OBSOLETE /* NOTE WELL!!!!! This is not an "else if" clause!!!
657// OBSOLETE That's because some *&^%$ things get passed on the stack
658// OBSOLETE AND in the registers! */
659// OBSOLETE if (argreg <= ARGLAST_REGNUM)
660// OBSOLETE { /* there's room in a register */
661// OBSOLETE regval = extract_address (val, REGISTER_RAW_SIZE (argreg));
662// OBSOLETE write_register (argreg++, regval);
663// OBSOLETE }
664// OBSOLETE /* Store the value 4 bytes at a time. This means that things
665// OBSOLETE larger than 4 bytes may go partly in registers and partly
666// OBSOLETE on the stack. */
667// OBSOLETE len -= REGISTER_RAW_SIZE (argreg);
668// OBSOLETE val += REGISTER_RAW_SIZE (argreg);
669// OBSOLETE }
670// OBSOLETE }
671// OBSOLETE return sp;
672// OBSOLETE }
673// OBSOLETE
674// OBSOLETE /* Function: fix_call_dummy
675// OBSOLETE If there is real CALL_DUMMY code (eg. on the stack), this function
676// OBSOLETE has the responsability to insert the address of the actual code that
677// OBSOLETE is the target of the target function call. */
678// OBSOLETE
679// OBSOLETE void
680// OBSOLETE m32r_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
681// OBSOLETE struct value **args, struct type *type, int gcc_p)
682// OBSOLETE {
683// OBSOLETE /* ld24 r8, <(imm24) fun> */
684// OBSOLETE *(unsigned long *) (dummy) = (fun & 0x00ffffff) | 0xe8000000;
685// OBSOLETE }
686// OBSOLETE
687// OBSOLETE
688// OBSOLETE /* Function: m32r_write_sp
689// OBSOLETE Because SP is really a read-only register that mirrors either SPU or SPI,
690// OBSOLETE we must actually write one of those two as well, depending on PSW. */
691// OBSOLETE
692// OBSOLETE void
693// OBSOLETE m32r_write_sp (CORE_ADDR val)
694// OBSOLETE {
695// OBSOLETE unsigned long psw = read_register (PSW_REGNUM);
696// OBSOLETE
697// OBSOLETE if (psw & 0x80) /* stack mode: user or interrupt */
698// OBSOLETE write_register (SPU_REGNUM, val);
699// OBSOLETE else
700// OBSOLETE write_register (SPI_REGNUM, val);
701// OBSOLETE write_register (SP_REGNUM, val);
702// OBSOLETE }
703// OBSOLETE
704// OBSOLETE void
705// OBSOLETE _initialize_m32r_tdep (void)
706// OBSOLETE {
707// OBSOLETE tm_print_insn = print_insn_m32r;
708// OBSOLETE }
This page took 0.07952 seconds and 4 git commands to generate.