1 /* Target-dependent code for the IQ2000 architecture, for GDB, the GNU
4 Copyright (C) 2000, 2004, 2005, 2007, 2008, 2009
5 Free Software Foundation, Inc.
7 Contributed by Red Hat.
9 This file is part of GDB.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 #include "frame-base.h"
27 #include "frame-unwind.h"
28 #include "dwarf2-frame.h"
32 #include "gdb_string.h"
33 #include "arch-utils.h"
40 E_R0_REGNUM, E_R1_REGNUM, E_R2_REGNUM, E_R3_REGNUM,
41 E_R4_REGNUM, E_R5_REGNUM, E_R6_REGNUM, E_R7_REGNUM,
42 E_R8_REGNUM, E_R9_REGNUM, E_R10_REGNUM, E_R11_REGNUM,
43 E_R12_REGNUM, E_R13_REGNUM, E_R14_REGNUM, E_R15_REGNUM,
44 E_R16_REGNUM, E_R17_REGNUM, E_R18_REGNUM, E_R19_REGNUM,
45 E_R20_REGNUM, E_R21_REGNUM, E_R22_REGNUM, E_R23_REGNUM,
46 E_R24_REGNUM, E_R25_REGNUM, E_R26_REGNUM, E_R27_REGNUM,
47 E_R28_REGNUM, E_R29_REGNUM, E_R30_REGNUM, E_R31_REGNUM,
49 E_LR_REGNUM = E_R31_REGNUM, /* Link register. */
50 E_SP_REGNUM = E_R29_REGNUM, /* Stack pointer. */
51 E_FP_REGNUM = E_R27_REGNUM, /* Frame pointer. */
52 E_FN_RETURN_REGNUM = E_R2_REGNUM, /* Function return value register. */
53 E_1ST_ARGREG = E_R4_REGNUM, /* 1st function arg register. */
54 E_LAST_ARGREG = E_R11_REGNUM, /* Last function arg register. */
55 E_NUM_REGS = E_PC_REGNUM + 1
58 /* Use an invalid address value as 'not available' marker. */
59 enum { REG_UNAVAIL = (CORE_ADDR) -1 };
61 struct iq2000_frame_cache
69 CORE_ADDR saved_regs [E_NUM_REGS];
72 /* Harvard methods: */
75 insn_ptr_from_addr (CORE_ADDR addr) /* CORE_ADDR to target pointer. */
77 return addr & 0x7fffffffL;
81 insn_addr_from_ptr (CORE_ADDR ptr) /* target_pointer to CORE_ADDR. */
83 return (ptr & 0x7fffffffL) | 0x80000000L;
86 /* Function: pointer_to_address
87 Convert a target pointer to an address in host (CORE_ADDR) format. */
90 iq2000_pointer_to_address (struct gdbarch *gdbarch,
91 struct type * type, const gdb_byte * buf)
93 enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
94 CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
96 if (target == TYPE_CODE_FUNC
97 || target == TYPE_CODE_METHOD
98 || TYPE_CODE_SPACE (TYPE_TARGET_TYPE (type)))
99 addr = insn_addr_from_ptr (addr);
104 /* Function: address_to_pointer
105 Convert a host-format address (CORE_ADDR) into a target pointer. */
108 iq2000_address_to_pointer (struct gdbarch *gdbarch,
109 struct type *type, gdb_byte *buf, CORE_ADDR addr)
111 enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
113 if (target == TYPE_CODE_FUNC || target == TYPE_CODE_METHOD)
114 addr = insn_ptr_from_addr (addr);
115 store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
118 /* Real register methods: */
120 /* Function: register_name
121 Returns the name of the iq2000 register number N. */
124 iq2000_register_name (struct gdbarch *gdbarch, int regnum)
126 static const char * names[E_NUM_REGS] =
128 "r0", "r1", "r2", "r3", "r4",
129 "r5", "r6", "r7", "r8", "r9",
130 "r10", "r11", "r12", "r13", "r14",
131 "r15", "r16", "r17", "r18", "r19",
132 "r20", "r21", "r22", "r23", "r24",
133 "r25", "r26", "r27", "r28", "r29",
137 if (regnum < 0 || regnum >= E_NUM_REGS)
139 return names[regnum];
142 /* Prologue analysis methods: */
144 /* ADDIU insn (001001 rs(5) rt(5) imm(16)). */
145 #define INSN_IS_ADDIU(X) (((X) & 0xfc000000) == 0x24000000)
146 #define ADDIU_REG_SRC(X) (((X) & 0x03e00000) >> 21)
147 #define ADDIU_REG_TGT(X) (((X) & 0x001f0000) >> 16)
148 #define ADDIU_IMMEDIATE(X) ((signed short) ((X) & 0x0000ffff))
150 /* "MOVE" (OR) insn (000000 rs(5) rt(5) rd(5) 00000 100101). */
151 #define INSN_IS_MOVE(X) (((X) & 0xffe007ff) == 0x00000025)
152 #define MOVE_REG_SRC(X) (((X) & 0x001f0000) >> 16)
153 #define MOVE_REG_TGT(X) (((X) & 0x0000f800) >> 11)
155 /* STORE WORD insn (101011 rs(5) rt(5) offset(16)). */
156 #define INSN_IS_STORE_WORD(X) (((X) & 0xfc000000) == 0xac000000)
157 #define SW_REG_INDEX(X) (((X) & 0x03e00000) >> 21)
158 #define SW_REG_SRC(X) (((X) & 0x001f0000) >> 16)
159 #define SW_OFFSET(X) ((signed short) ((X) & 0x0000ffff))
161 /* Function: find_last_line_symbol
163 Given an address range, first find a line symbol corresponding to
164 the starting address. Then find the last line symbol within the
165 range that has a line number less than or equal to the first line.
167 For optimized code with code motion, this finds the last address
168 for the lowest-numbered line within the address range. */
170 static struct symtab_and_line
171 find_last_line_symbol (CORE_ADDR start, CORE_ADDR end, int notcurrent)
173 struct symtab_and_line sal = find_pc_line (start, notcurrent);
174 struct symtab_and_line best_sal = sal;
176 if (sal.pc == 0 || sal.line == 0 || sal.end == 0)
181 if (sal.line && sal.line <= best_sal.line)
183 sal = find_pc_line (sal.end, notcurrent);
185 while (sal.pc && sal.pc < end);
190 /* Function: scan_prologue
191 Decode the instructions within the given address range.
192 Decide when we must have reached the end of the function prologue.
193 If a frame_info pointer is provided, fill in its prologue information.
195 Returns the address of the first instruction after the prologue. */
198 iq2000_scan_prologue (CORE_ADDR scan_start,
200 struct frame_info *fi,
201 struct iq2000_frame_cache *cache)
203 struct symtab_and_line sal;
206 int found_store_lr = 0;
207 int found_decr_sp = 0;
212 if (scan_end == (CORE_ADDR) 0)
214 loop_end = scan_start + 100;
215 sal.end = sal.pc = 0;
221 sal = find_last_line_symbol (scan_start, scan_end, 0);
225 We first have to save the saved register's offset, and
226 only later do we compute its actual address. Since the
227 offset can be zero, we must first initialize all the
228 saved regs to minus one (so we can later distinguish
229 between one that's not saved, and one that's saved at zero). */
230 for (srcreg = 0; srcreg < E_NUM_REGS; srcreg ++)
231 cache->saved_regs[srcreg] = -1;
233 cache->framesize = 0;
235 for (pc = scan_start; pc < loop_end; pc += 4)
237 LONGEST insn = read_memory_unsigned_integer (pc, 4);
238 /* Skip any instructions writing to (sp) or decrementing the
240 if ((insn & 0xffe00000) == 0xac200000)
242 /* sw using SP/%1 as base. */
243 /* LEGACY -- from assembly-only port. */
244 tgtreg = ((insn >> 16) & 0x1f);
245 if (tgtreg >= 0 && tgtreg < E_NUM_REGS)
246 cache->saved_regs[tgtreg] = -((signed short) (insn & 0xffff));
248 if (tgtreg == E_LR_REGNUM)
253 if ((insn & 0xffff8000) == 0x20218000)
255 /* addi %1, %1, -N == addi %sp, %sp, -N */
256 /* LEGACY -- from assembly-only port */
258 cache->framesize = -((signed short) (insn & 0xffff));
262 if (INSN_IS_ADDIU (insn))
264 srcreg = ADDIU_REG_SRC (insn);
265 tgtreg = ADDIU_REG_TGT (insn);
266 offset = ADDIU_IMMEDIATE (insn);
267 if (srcreg == E_SP_REGNUM && tgtreg == E_SP_REGNUM)
268 cache->framesize = -offset;
272 if (INSN_IS_STORE_WORD (insn))
274 srcreg = SW_REG_SRC (insn);
275 tgtreg = SW_REG_INDEX (insn);
276 offset = SW_OFFSET (insn);
278 if (tgtreg == E_SP_REGNUM || tgtreg == E_FP_REGNUM)
280 /* "push" to stack (via SP or FP reg) */
281 if (cache->saved_regs[srcreg] == -1) /* Don't save twice. */
282 cache->saved_regs[srcreg] = offset;
287 if (INSN_IS_MOVE (insn))
289 srcreg = MOVE_REG_SRC (insn);
290 tgtreg = MOVE_REG_TGT (insn);
292 if (srcreg == E_SP_REGNUM && tgtreg == E_FP_REGNUM)
300 /* Unknown instruction encountered in frame. Bail out?
301 1) If we have a subsequent line symbol, we can keep going.
302 2) If not, we need to bail out and quit scanning instructions. */
304 if (fi && sal.end && (pc < sal.end)) /* Keep scanning. */
314 iq2000_init_frame_cache (struct iq2000_frame_cache *cache)
319 cache->framesize = 0;
322 for (i = 0; i < E_NUM_REGS; i++)
323 cache->saved_regs[i] = -1;
326 /* Function: iq2000_skip_prologue
327 If the input address is in a function prologue,
328 returns the address of the end of the prologue;
329 else returns the input address.
331 Note: the input address is likely to be the function start,
332 since this function is mainly used for advancing a breakpoint
333 to the first line, or stepping to the first line when we have
334 stepped into a function call. */
337 iq2000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
339 CORE_ADDR func_addr = 0 , func_end = 0;
341 if (find_pc_partial_function (pc, NULL, & func_addr, & func_end))
343 struct symtab_and_line sal;
344 struct iq2000_frame_cache cache;
346 /* Found a function. */
347 sal = find_pc_line (func_addr, 0);
348 if (sal.end && sal.end < func_end)
349 /* Found a line number, use it as end of prologue. */
352 /* No useable line symbol. Use prologue parsing method. */
353 iq2000_init_frame_cache (&cache);
354 return iq2000_scan_prologue (func_addr, func_end, NULL, &cache);
357 /* No function symbol -- just return the PC. */
358 return (CORE_ADDR) pc;
361 static struct iq2000_frame_cache *
362 iq2000_frame_cache (struct frame_info *this_frame, void **this_cache)
364 struct iq2000_frame_cache *cache;
365 CORE_ADDR current_pc;
371 cache = FRAME_OBSTACK_ZALLOC (struct iq2000_frame_cache);
372 iq2000_init_frame_cache (cache);
375 cache->base = get_frame_register_unsigned (this_frame, E_FP_REGNUM);
376 //if (cache->base == 0)
379 current_pc = get_frame_pc (this_frame);
380 find_pc_partial_function (current_pc, NULL, &cache->pc, NULL);
382 iq2000_scan_prologue (cache->pc, current_pc, this_frame, cache);
383 if (!cache->using_fp)
384 cache->base = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
386 cache->saved_sp = cache->base + cache->framesize;
388 for (i = 0; i < E_NUM_REGS; i++)
389 if (cache->saved_regs[i] != -1)
390 cache->saved_regs[i] += cache->base;
395 static struct value *
396 iq2000_frame_prev_register (struct frame_info *this_frame, void **this_cache,
399 struct iq2000_frame_cache *cache = iq2000_frame_cache (this_frame, this_cache);
401 if (regnum == E_SP_REGNUM && cache->saved_sp)
402 return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp);
404 if (regnum == E_PC_REGNUM)
405 regnum = E_LR_REGNUM;
407 if (regnum < E_NUM_REGS && cache->saved_regs[regnum] != -1)
408 return frame_unwind_got_memory (this_frame, regnum,
409 cache->saved_regs[regnum]);
411 return frame_unwind_got_register (this_frame, regnum, regnum);
415 iq2000_frame_this_id (struct frame_info *this_frame, void **this_cache,
416 struct frame_id *this_id)
418 struct iq2000_frame_cache *cache = iq2000_frame_cache (this_frame, this_cache);
420 /* This marks the outermost frame. */
421 if (cache->base == 0)
424 *this_id = frame_id_build (cache->saved_sp, cache->pc);
427 static const struct frame_unwind iq2000_frame_unwind = {
429 iq2000_frame_this_id,
430 iq2000_frame_prev_register,
432 default_frame_sniffer
436 iq2000_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
438 return frame_unwind_register_unsigned (next_frame, E_SP_REGNUM);
442 iq2000_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
444 return frame_unwind_register_unsigned (next_frame, E_PC_REGNUM);
447 static struct frame_id
448 iq2000_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
450 CORE_ADDR sp = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
451 return frame_id_build (sp, get_frame_pc (this_frame));
455 iq2000_frame_base_address (struct frame_info *this_frame, void **this_cache)
457 struct iq2000_frame_cache *cache = iq2000_frame_cache (this_frame, this_cache);
462 static const struct frame_base iq2000_frame_base = {
463 &iq2000_frame_unwind,
464 iq2000_frame_base_address,
465 iq2000_frame_base_address,
466 iq2000_frame_base_address
469 static const unsigned char *
470 iq2000_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
473 static const unsigned char big_breakpoint[] = { 0x00, 0x00, 0x00, 0x0d };
474 static const unsigned char little_breakpoint[] = { 0x0d, 0x00, 0x00, 0x00 };
476 if ((*pcptr & 3) != 0)
477 error ("breakpoint_from_pc: invalid breakpoint address 0x%lx",
481 return (gdbarch_byte_order (gdbarch)
482 == BFD_ENDIAN_BIG) ? big_breakpoint : little_breakpoint;
485 /* Target function return value methods: */
487 /* Function: store_return_value
488 Copy the function return value from VALBUF into the
489 proper location for a function return. */
492 iq2000_store_return_value (struct type *type, struct regcache *regcache,
495 int len = TYPE_LENGTH (type);
496 int regno = E_FN_RETURN_REGNUM;
501 int size = len % 4 ?: 4;
504 memcpy (buf + 4 - size, valbuf, size);
505 regcache_raw_write (regcache, regno++, buf);
507 valbuf = ((char *) valbuf) + size;
511 /* Function: use_struct_convention
512 Returns non-zero if the given struct type will be returned using
513 a special convention, rather than the normal function return method. */
516 iq2000_use_struct_convention (struct type *type)
518 return ((TYPE_CODE (type) == TYPE_CODE_STRUCT)
519 || (TYPE_CODE (type) == TYPE_CODE_UNION))
520 && TYPE_LENGTH (type) > 8;
523 /* Function: extract_return_value
524 Copy the function's return value into VALBUF.
525 This function is called only in the context of "target function calls",
526 ie. when the debugger forces a function to be called in the child, and
527 when the debugger forces a function to return prematurely via the
531 iq2000_extract_return_value (struct type *type, struct regcache *regcache,
534 /* If the function's return value is 8 bytes or less, it is
535 returned in a register, and if larger than 8 bytes, it is
536 returned in a stack location which is pointed to by the same
538 int len = TYPE_LENGTH (type);
542 int regno = E_FN_RETURN_REGNUM;
544 /* Return values of <= 8 bytes are returned in
549 int size = len % 4 ?: 4;
551 /* By using store_unsigned_integer we avoid having to
552 do anything special for small big-endian values. */
553 regcache_cooked_read_unsigned (regcache, regno++, &tmp);
554 store_unsigned_integer (valbuf, size, tmp);
556 valbuf = ((char *) valbuf) + size;
561 /* Return values > 8 bytes are returned in memory,
562 pointed to by FN_RETURN_REGNUM. */
563 ULONGEST return_buffer;
564 regcache_cooked_read_unsigned (regcache, E_FN_RETURN_REGNUM,
566 read_memory (return_buffer, valbuf, TYPE_LENGTH (type));
570 static enum return_value_convention
571 iq2000_return_value (struct gdbarch *gdbarch, struct type *func_type,
572 struct type *type, struct regcache *regcache,
573 gdb_byte *readbuf, const gdb_byte *writebuf)
575 if (iq2000_use_struct_convention (type))
576 return RETURN_VALUE_STRUCT_CONVENTION;
578 iq2000_store_return_value (type, regcache, writebuf);
580 iq2000_extract_return_value (type, regcache, readbuf);
581 return RETURN_VALUE_REGISTER_CONVENTION;
584 /* Function: register_virtual_type
585 Returns the default type for register N. */
588 iq2000_register_type (struct gdbarch *gdbarch, int regnum)
590 return builtin_type_int32;
594 iq2000_frame_align (struct gdbarch *ignore, CORE_ADDR sp)
596 /* This is the same frame alignment used by gcc. */
597 return ((sp + 7) & ~7);
600 /* Convenience function to check 8-byte types for being a scalar type
601 or a struct with only one long long or double member. */
603 iq2000_pass_8bytetype_by_address (struct type *type)
608 while (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
609 type = TYPE_TARGET_TYPE (type);
610 /* Non-struct and non-union types are always passed by value. */
611 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
612 && TYPE_CODE (type) != TYPE_CODE_UNION)
614 /* Structs with more than 1 field are always passed by address. */
615 if (TYPE_NFIELDS (type) != 1)
617 /* Get field type. */
618 ftype = (TYPE_FIELDS (type))[0].type;
619 /* The field type must have size 8, otherwise pass by address. */
620 if (TYPE_LENGTH (ftype) != 8)
622 /* Skip typedefs of field type. */
623 while (TYPE_CODE (ftype) == TYPE_CODE_TYPEDEF)
624 ftype = TYPE_TARGET_TYPE (ftype);
625 /* If field is int or float, pass by value. */
626 if (TYPE_CODE (ftype) == TYPE_CODE_FLT
627 || TYPE_CODE (ftype) == TYPE_CODE_INT)
629 /* Everything else, pass by address. */
634 iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
635 struct regcache *regcache, CORE_ADDR bp_addr,
636 int nargs, struct value **args, CORE_ADDR sp,
637 int struct_return, CORE_ADDR struct_addr)
642 int i, argreg, typelen, slacklen;
644 /* Used to copy struct arguments into the stack. */
645 CORE_ADDR struct_ptr;
647 /* First determine how much stack space we will need. */
648 for (i = 0, argreg = E_1ST_ARGREG + (struct_return != 0); i < nargs; i++)
650 type = value_type (args[i]);
651 typelen = TYPE_LENGTH (type);
654 /* Scalars of up to 4 bytes,
655 structs of up to 4 bytes, and
657 if (argreg <= E_LAST_ARGREG)
662 else if (typelen == 8 && !iq2000_pass_8bytetype_by_address (type))
666 structs with a single field of long long or double. */
667 if (argreg <= E_LAST_ARGREG - 1)
669 /* 8-byte arg goes into a register pair
670 (must start with an even-numbered reg) */
671 if (((argreg - E_1ST_ARGREG) % 2) != 0)
677 argreg = E_LAST_ARGREG + 1; /* no more argregs. */
678 /* 8-byte arg goes on stack, must be 8-byte aligned. */
679 stackspace = ((stackspace + 7) & ~7);
685 /* Structs are passed as pointer to a copy of the struct.
686 So we need room on the stack for a copy of the struct
687 plus for the argument pointer. */
688 if (argreg <= E_LAST_ARGREG)
692 /* Care for 8-byte alignment of structs saved on stack. */
693 stackspace += ((typelen + 7) & ~7);
697 /* Now copy params, in ascending order, into their assigned location
698 (either in a register or on the stack). */
700 sp -= (sp % 8); /* align */
703 sp -= (sp % 8); /* align again */
706 argreg = E_1ST_ARGREG;
709 /* A function that returns a struct will consume one argreg to do so.
711 regcache_cooked_write_unsigned (regcache, argreg++, struct_addr);
714 for (i = 0; i < nargs; i++)
716 type = value_type (args[i]);
717 typelen = TYPE_LENGTH (type);
718 val = value_contents (args[i]);
721 /* Char, short, int, float, pointer, and structs <= four bytes. */
722 slacklen = (4 - (typelen % 4)) % 4;
723 memset (buf, 0, sizeof (buf));
724 memcpy (buf + slacklen, val, typelen);
725 if (argreg <= E_LAST_ARGREG)
727 /* Passed in a register. */
728 regcache_raw_write (regcache, argreg++, buf);
732 /* Passed on the stack. */
733 write_memory (sp + stackspace, buf, 4);
737 else if (typelen == 8 && !iq2000_pass_8bytetype_by_address (type))
739 /* (long long), (double), or struct consisting of
740 a single (long long) or (double). */
741 if (argreg <= E_LAST_ARGREG - 1)
743 /* 8-byte arg goes into a register pair
744 (must start with an even-numbered reg) */
745 if (((argreg - E_1ST_ARGREG) % 2) != 0)
747 regcache_raw_write (regcache, argreg++, val);
748 regcache_raw_write (regcache, argreg++, val + 4);
752 /* 8-byte arg goes on stack, must be 8-byte aligned. */
753 argreg = E_LAST_ARGREG + 1; /* no more argregs. */
754 stackspace = ((stackspace + 7) & ~7);
755 write_memory (sp + stackspace, val, typelen);
761 /* Store struct beginning at the upper end of the previously
762 computed stack space. Then store the address of the struct
763 using the usual rules for a 4 byte value. */
764 struct_ptr -= ((typelen + 7) & ~7);
765 write_memory (struct_ptr, val, typelen);
766 if (argreg <= E_LAST_ARGREG)
767 regcache_cooked_write_unsigned (regcache, argreg++, struct_ptr);
770 store_unsigned_integer (buf, 4, struct_ptr);
771 write_memory (sp + stackspace, buf, 4);
777 /* Store return address. */
778 regcache_cooked_write_unsigned (regcache, E_LR_REGNUM, bp_addr);
780 /* Update stack pointer. */
781 regcache_cooked_write_unsigned (regcache, E_SP_REGNUM, sp);
783 /* And that should do it. Return the new stack pointer. */
787 /* Function: gdbarch_init
788 Initializer function for the iq2000 gdbarch vector.
789 Called by gdbarch. Sets up the gdbarch vector(s) for this target. */
791 static struct gdbarch *
792 iq2000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
794 struct gdbarch *gdbarch;
796 /* Look up list for candidates - only one. */
797 arches = gdbarch_list_lookup_by_info (arches, &info);
799 return arches->gdbarch;
801 gdbarch = gdbarch_alloc (&info, NULL);
803 set_gdbarch_num_regs (gdbarch, E_NUM_REGS);
804 set_gdbarch_num_pseudo_regs (gdbarch, 0);
805 set_gdbarch_sp_regnum (gdbarch, E_SP_REGNUM);
806 set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM);
807 set_gdbarch_register_name (gdbarch, iq2000_register_name);
808 set_gdbarch_address_to_pointer (gdbarch, iq2000_address_to_pointer);
809 set_gdbarch_pointer_to_address (gdbarch, iq2000_pointer_to_address);
810 set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
811 set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
812 set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
813 set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
814 set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT);
815 set_gdbarch_float_bit (gdbarch, 4 * TARGET_CHAR_BIT);
816 set_gdbarch_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
817 set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
818 set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
819 set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
820 set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
821 set_gdbarch_return_value (gdbarch, iq2000_return_value);
822 set_gdbarch_breakpoint_from_pc (gdbarch, iq2000_breakpoint_from_pc);
823 set_gdbarch_frame_args_skip (gdbarch, 0);
824 set_gdbarch_skip_prologue (gdbarch, iq2000_skip_prologue);
825 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
826 set_gdbarch_print_insn (gdbarch, print_insn_iq2000);
827 set_gdbarch_register_type (gdbarch, iq2000_register_type);
828 set_gdbarch_frame_align (gdbarch, iq2000_frame_align);
829 set_gdbarch_unwind_sp (gdbarch, iq2000_unwind_sp);
830 set_gdbarch_unwind_pc (gdbarch, iq2000_unwind_pc);
831 set_gdbarch_dummy_id (gdbarch, iq2000_dummy_id);
832 frame_base_set_default (gdbarch, &iq2000_frame_base);
833 set_gdbarch_push_dummy_call (gdbarch, iq2000_push_dummy_call);
835 gdbarch_init_osabi (info, gdbarch);
837 dwarf2_append_unwinders (gdbarch);
838 frame_unwind_append_unwinder (gdbarch, &iq2000_frame_unwind);
843 /* Function: _initialize_iq2000_tdep
844 Initializer function for the iq2000 module.
845 Called by gdb at start-up. */
847 /* Provide a prototype to silence -Wmissing-prototypes. */
848 extern initialize_file_ftype _initialize_iq2000_tdep;
851 _initialize_iq2000_tdep (void)
853 register_gdbarch_init (bfd_arch_iq2000, iq2000_gdbarch_init);