2004-02-14 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / cris-tdep.c
index 1b19999589962d9239c5f691f2c652143df40aab..2e55c9b88f2312dbe23854a0572c5838f92a6ace 100644 (file)
@@ -1,5 +1,7 @@
 /* Target dependent code for CRIS, for GDB, the GNU debugger.
-   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
+
+   Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
    Contributed by Axis Communications AB.
    Written by Hendrik Ruijter, Stefan Andersson, and Orjan Friberg.
 
@@ -170,15 +172,6 @@ cris_mode (void)
   return (gdbarch_tdep (current_gdbarch)->cris_mode);
 }
 
-static const char *
-cris_abi (void)
-{
-  return (gdbarch_tdep (current_gdbarch)->cris_abi);
-}
-
-/* For saving call-clobbered contents in R9 when returning structs.  */
-static CORE_ADDR struct_return_address;
-
 struct frame_extra_info
 {
   CORE_ADDR return_pc;
@@ -293,18 +286,6 @@ cris_get_operand1 (unsigned short insn)
 
 /* Additional functions in order to handle opcodes.  */
 
-static int
-cris_get_wide_opcode (unsigned short insn)
-{
-  return ((insn & 0x03E0) >> 5);
-}
-
-static int
-cris_get_short_size (unsigned short insn)
-{
-  return ((insn & 0x0010) >> 4);
-}
-
 static int
 cris_get_quick_value (unsigned short insn)
 {
@@ -329,12 +310,6 @@ cris_get_asr_shift_steps (unsigned long value)
   return (value & 0x3F);
 }
 
-static int
-cris_get_asr_quick_shift_steps (unsigned short insn)
-{
-  return (insn & 0x1F);
-}
-
 static int
 cris_get_clear_size (unsigned short insn)
 {
@@ -501,10 +476,10 @@ cris_examine (CORE_ADDR ip, CORE_ADDR limit, struct frame_info *fi,
 
   /* We only want to know the end of the prologue when fi->saved_regs == 0.
      When the saved registers are allocated full information is required.  */
-  if (get_frame_saved_regs (fi))
+  if (deprecated_get_frame_saved_regs (fi))
     {
       for (regno = 0; regno < NUM_REGS; regno++)
-        get_frame_saved_regs (fi)[regno] = 0;
+        deprecated_get_frame_saved_regs (fi)[regno] = 0;
     }
  
   /* Find the prologue instructions.  */
@@ -676,34 +651,34 @@ cris_examine (CORE_ADDR ip, CORE_ADDR limit, struct frame_info *fi,
 
   /* We only want to know the end of the prologue when
      fi->saved_regs == 0.  */ 
-  if (!get_frame_saved_regs (fi))
+  if (!deprecated_get_frame_saved_regs (fi))
     return ip;
 
   if (have_fp)
     {
-      get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM] = get_frame_base (fi);
+      deprecated_get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM] = get_frame_base (fi);
       
       /* Calculate the addresses.  */
       for (regno = regsave; regno >= 0; regno--)
         {
-          get_frame_saved_regs (fi)[regno] = get_frame_base (fi) - val;
+          deprecated_get_frame_saved_regs (fi)[regno] = get_frame_base (fi) - val;
           val -= 4;
         }
       if (get_frame_extra_info (fi)->leaf_function)
         {
           /* Set the register SP to contain the stack pointer of 
              the caller.  */
-          get_frame_saved_regs (fi)[SP_REGNUM] = get_frame_base (fi) + 4;
+          deprecated_get_frame_saved_regs (fi)[SP_REGNUM] = get_frame_base (fi) + 4;
         }
       else
         {
           /* Set the register SP to contain the stack pointer of 
              the caller.  */
-          get_frame_saved_regs (fi)[SP_REGNUM] = get_frame_base (fi) + 8;
+          deprecated_get_frame_saved_regs (fi)[SP_REGNUM] = get_frame_base (fi) + 8;
       
           /* Set the register SRP to contain the return address of 
              the caller.  */
-          get_frame_saved_regs (fi)[SRP_REGNUM] = get_frame_base (fi) + 4;
+          deprecated_get_frame_saved_regs (fi)[SRP_REGNUM] = get_frame_base (fi) + 4;
         }
     }
   return ip;
@@ -718,16 +693,6 @@ cris_skip_prologue (CORE_ADDR pc)
   return cris_skip_prologue_main (pc, 0);
 }
 
-/* As cris_skip_prologue, but stops as soon as it knows that the function 
-   has a frame.  Its result is equal to its input pc if the function is 
-   frameless, unequal otherwise.  */
-
-static CORE_ADDR
-cris_skip_prologue_frameless_p (CORE_ADDR pc)
-{
-  return cris_skip_prologue_main (pc, 1);
-}
-
 /* Given a PC value corresponding to the start of a function, return the PC
    of the first instruction after the function prologue.  */
 
@@ -972,7 +937,7 @@ cris_abi_original_store_return_value (struct type *type, char *valbuf)
   int len = TYPE_LENGTH (type);
   
   if (len <= DEPRECATED_REGISTER_SIZE) 
-    deprecated_write_register_bytes (REGISTER_BYTE (RET_REGNUM), valbuf, len);
+    deprecated_write_register_bytes (DEPRECATED_REGISTER_BYTE (RET_REGNUM), valbuf, len);
   else
     internal_error (__FILE__, __LINE__, "cris_abi_original_store_return_value: type length too large.");
 }
@@ -987,8 +952,8 @@ cris_abi_v2_store_return_value (struct type *type, char *valbuf)
   if (len <= 2 * DEPRECATED_REGISTER_SIZE)
     {
       /* Note that this works since R10 and R11 are consecutive registers.  */
-      deprecated_write_register_bytes (REGISTER_BYTE (RET_REGNUM), valbuf,
-                                      len);
+      deprecated_write_register_bytes (DEPRECATED_REGISTER_BYTE (RET_REGNUM),
+                                      valbuf, len);
     }
   else
     internal_error (__FILE__, __LINE__, "cris_abi_v2_store_return_value: type length too large.");
@@ -1058,7 +1023,7 @@ cris_abi_original_extract_return_value (struct type *type, char *regbuf,
   int len = TYPE_LENGTH (type);
   
   if (len <= DEPRECATED_REGISTER_SIZE)
-    memcpy (valbuf, regbuf + REGISTER_BYTE (RET_REGNUM), len);
+    memcpy (valbuf, regbuf + DEPRECATED_REGISTER_BYTE (RET_REGNUM), len);
   else
     internal_error (__FILE__, __LINE__, "cris_abi_original_extract_return_value: type length too large");
 }
@@ -1072,32 +1037,20 @@ cris_abi_v2_extract_return_value (struct type *type, char *regbuf,
   int len = TYPE_LENGTH (type);
   
   if (len <= 2 * DEPRECATED_REGISTER_SIZE)
-    memcpy (valbuf, regbuf + REGISTER_BYTE (RET_REGNUM), len);
+    memcpy (valbuf, regbuf + DEPRECATED_REGISTER_BYTE (RET_REGNUM), len);
   else
     internal_error (__FILE__, __LINE__, "cris_abi_v2_extract_return_value: type length too large");
 }
 
 /* Store the address of the place in which to copy the structure the
-   subroutine will return.  In the CRIS ABI, R9 is used in order to pass 
-   the address of the allocated area where a structure return value must 
-   be stored.  R9 is call-clobbered, which means we must save it here for
-   later use.  */
+   subroutine will return.  In the CRIS ABI, R9 is used in order to
+   pass the address of the allocated area where a structure return
+   value must be stored.  */
 
 static void
 cris_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
 {
   write_register (STR_REGNUM, addr);
-  struct_return_address = addr;
-}
-
-/* Extract from regbuf the address where a function should return a 
-   structure value.  It's not there in the CRIS ABI, so we must do it another
-   way.  */
-
-static CORE_ADDR
-cris_extract_struct_value_address (char *regbuf)
-{
-  return struct_return_address;
 }
 
 /* Returns 1 if the given type will be passed by pointer rather than 
@@ -1148,10 +1101,10 @@ cris_frame_init_saved_regs (struct frame_info *fi)
                                                          get_frame_base (fi));
   
   /* Examine the entire prologue.  */
-  register int frameless_p = 0; 
+  int frameless_p = 0; 
 
   /* Has this frame's registers already been initialized?  */
-  if (get_frame_saved_regs (fi))
+  if (deprecated_get_frame_saved_regs (fi))
     return;
 
   frame_saved_regs_zalloc (fi);
@@ -1161,7 +1114,7 @@ cris_frame_init_saved_regs (struct frame_info *fi)
       /* I don't see this ever happening, considering the context in which
          cris_frame_init_saved_regs is called (always when we're not in
          a dummy frame).  */
-      memcpy (get_frame_saved_regs (fi), dummy_regs, SIZEOF_FRAME_SAVED_REGS);
+      memcpy (deprecated_get_frame_saved_regs (fi), dummy_regs, SIZEOF_FRAME_SAVED_REGS);
     }
   else
     {    
@@ -1219,12 +1172,12 @@ cris_init_extra_frame_info (int fromleaf, struct frame_info *fi)
 
       /* Check fromleaf/frameless_function_invocation.  (FIXME)  */
 
-      if (get_frame_saved_regs (fi)[SRP_REGNUM] != 0)
+      if (deprecated_get_frame_saved_regs (fi)[SRP_REGNUM] != 0)
         {
           /* SRP was saved on the stack; non-leaf function.  */
           get_frame_extra_info (fi)->return_pc =
-            read_memory_integer (get_frame_saved_regs (fi)[SRP_REGNUM], 
-                                 REGISTER_RAW_SIZE (SRP_REGNUM));
+            read_memory_integer (deprecated_get_frame_saved_regs (fi)[SRP_REGNUM], 
+                                 DEPRECATED_REGISTER_RAW_SIZE (SRP_REGNUM));
         }
       else
         {
@@ -1248,7 +1201,7 @@ cris_frame_chain (struct frame_info *fi)
     {
       return get_frame_base (fi);
     }
-  else if (!inside_entry_file (get_frame_pc (fi)))
+  else if (!deprecated_inside_entry_file (get_frame_pc (fi)))
     {
       return read_memory_unsigned_integer (get_frame_base (fi), 4);
     }
@@ -1500,9 +1453,9 @@ cris_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
 static void 
 cris_pop_frame (void)
 {
-  register struct frame_info *fi = get_current_frame ();
-  register int regno;
-  register int stack_offset = 0;
+  struct frame_info *fi = get_current_frame ();
+  int regno;
+  int stack_offset = 0;
   
   if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi),
                                   get_frame_base (fi),
@@ -1527,30 +1480,30 @@ cris_pop_frame (void)
          after SP was saved.  */
       for (regno = 0; regno < DEPRECATED_FP_REGNUM; regno++)
         {
-          if (get_frame_saved_regs (fi)[regno])
+          if (deprecated_get_frame_saved_regs (fi)[regno])
             {
               write_register (regno, 
-                              read_memory_integer (get_frame_saved_regs (fi)[regno], 4));
+                              read_memory_integer (deprecated_get_frame_saved_regs (fi)[regno], 4));
             }
         }
      
-      if (get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM])
+      if (deprecated_get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM])
         {
           /* Pop the frame pointer (R8).  It was pushed before SP 
              was saved.  */
           write_register (DEPRECATED_FP_REGNUM, 
-                          read_memory_integer (get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM], 4));
+                          read_memory_integer (deprecated_get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM], 4));
           stack_offset += 4;
 
           /* Not a leaf function.  */
-          if (get_frame_saved_regs (fi)[SRP_REGNUM])
+          if (deprecated_get_frame_saved_regs (fi)[SRP_REGNUM])
             {     
               /* SRP was pushed before SP was saved.  */
               stack_offset += 4;
             }
       
           /* Restore the SP and adjust for R8 and (possibly) SRP.  */
-          write_register (SP_REGNUM, get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM] + stack_offset);
+          write_register (SP_REGNUM, deprecated_get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM] + stack_offset);
         } 
       else
         {
@@ -2789,63 +2742,6 @@ move_reg_to_mem_movem_op (unsigned short inst, inst_env_type *inst_env)
   inst_env->disable_interrupt = 0;
 }
 
-/* Handles the pop instruction to a general register. 
-   POP is a assembler macro for MOVE.D [SP+], Rd.  */
-
-static void 
-reg_pop_op (unsigned short inst, inst_env_type *inst_env)
-{
-  /* POP can't have a prefix.  */
-  if (inst_env->prefix_found)
-    {
-      inst_env->invalid = 1;
-      return;
-    }
-  if (cris_get_operand2 (inst) == REG_PC)
-    {
-      /* It's invalid to change the PC in a delay slot.  */
-      if (inst_env->slot_needed)
-        {
-          inst_env->invalid = 1;
-          return;
-        }
-      inst_env->reg[REG_PC] = 
-        read_memory_unsigned_integer (inst_env->reg[REG_SP], 4);
-    }
-  inst_env->slot_needed = 0;
-  inst_env->prefix_found = 0;
-  inst_env->xflag_found = 0;
-  inst_env->disable_interrupt = 0;
-}
-
-/* Handles moves from register to memory.  */
-
-static void 
-move_reg_to_mem_index_inc_op (unsigned short inst, inst_env_type *inst_env)
-{
-  /* Check if we have a prefix.  */
-  if (inst_env->prefix_found)
-    {
-      /* The only thing that can change the PC is an assign.  */
-      check_assign (inst, inst_env);
-    }
-  else if ((cris_get_operand1 (inst) == REG_PC) 
-           && (cris_get_mode (inst) == AUTOINC_MODE))
-    {
-      /* It's invalid to change the PC in a delay slot.  */
-      if (inst_env->slot_needed)
-        {
-          inst_env->invalid = 1;
-          return;
-        }
-      process_autoincrement (cris_get_size (inst), inst, inst_env);
-    }
-  inst_env->slot_needed = 0;
-  inst_env->prefix_found = 0;
-  inst_env->xflag_found = 0;
-  inst_env->disable_interrupt = 0;
-}
-
 /* Handles the intructions that's not yet implemented, by setting 
    inst_env->invalid to true.  */
 
@@ -3916,7 +3812,7 @@ cris_version_update (char *ignore_args, int from_tty,
      the set command passed as a parameter.  The clone operation will
      include (BUG?) any ``set'' command callback, if present.
      Commands like ``info set'' call all the ``show'' command
-     callbacks.  Unfortunatly, for ``show'' commands cloned from
+     callbacks.  Unfortunately, for ``show'' commands cloned from
      ``set'', this includes callbacks belonging to ``set'' commands.
      Making this worse, this only occures if add_show_from_set() is
      called after add_cmd_sfunc() (BUG?).  */
@@ -3943,7 +3839,7 @@ cris_mode_update (char *ignore_args, int from_tty,
      the set command passed as a parameter.  The clone operation will
      include (BUG?) any ``set'' command callback, if present.
      Commands like ``info set'' call all the ``show'' command
-     callbacks.  Unfortunatly, for ``show'' commands cloned from
+     callbacks.  Unfortunately, for ``show'' commands cloned from
      ``set'', this includes callbacks belonging to ``set'' commands.
      Making this worse, this only occures if add_show_from_set() is
      called after add_cmd_sfunc() (BUG?).  */
@@ -3970,7 +3866,7 @@ cris_abi_update (char *ignore_args, int from_tty,
      the set command passed as a parameter.  The clone operation will
      include (BUG?) any ``set'' command callback, if present.
      Commands like ``info set'' call all the ``show'' command
-     callbacks.  Unfortunatly, for ``show'' commands cloned from
+     callbacks.  Unfortunately, for ``show'' commands cloned from
      ``set'', this includes callbacks belonging to ``set'' commands.
      Making this worse, this only occures if add_show_from_set() is
      called after add_cmd_sfunc() (BUG?).  */
@@ -4126,7 +4022,7 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* NOTE: cagney/2002-12-06: This can be deleted when this arch is
      ready to unwind the PC first (see frame.c:get_prev_frame()).  */
-  set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
+  set_gdbarch_deprecated_init_frame_pc (gdbarch, deprecated_init_frame_pc_default);
 
   tdep->cris_version = cris_version;
   tdep->cris_mode = cris_mode;
@@ -4156,7 +4052,7 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
                                       cris_abi_original_store_return_value);
       set_gdbarch_deprecated_extract_return_value 
         (gdbarch, cris_abi_original_extract_return_value);
-      set_gdbarch_reg_struct_has_addr 
+      set_gdbarch_deprecated_reg_struct_has_addr 
         (gdbarch, cris_abi_original_reg_struct_has_addr);
     }
   else if (tdep->cris_abi == CRIS_ABI_V2)
@@ -4166,8 +4062,8 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       set_gdbarch_deprecated_store_return_value (gdbarch, cris_abi_v2_store_return_value);
       set_gdbarch_deprecated_extract_return_value
        (gdbarch, cris_abi_v2_extract_return_value);
-      set_gdbarch_reg_struct_has_addr (gdbarch, 
-                                       cris_abi_v2_reg_struct_has_addr);
+      set_gdbarch_deprecated_reg_struct_has_addr
+       (gdbarch, cris_abi_v2_reg_struct_has_addr);
     }
   else
     internal_error (__FILE__, __LINE__, "cris_gdbarch_init: unknown CRIS ABI");
@@ -4184,8 +4080,9 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_register_name (gdbarch, cris_register_name);
   
-  /* Length of ordinary registers used in push_word and a few other places. 
-     REGISTER_RAW_SIZE is the real way to know how big a register is.  */
+  /* Length of ordinary registers used in push_word and a few other
+     places.  DEPRECATED_REGISTER_RAW_SIZE is the real way to know how
+     big a register is.  */
   set_gdbarch_deprecated_register_size (gdbarch, 4);
   
   /* NEW */
@@ -4239,13 +4136,13 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* The length of the registers in the actual machine representation.  */
   set_gdbarch_deprecated_register_raw_size (gdbarch, cris_register_size);
   
-  /* The largest value REGISTER_RAW_SIZE can have.  */
+  /* The largest value DEPRECATED_REGISTER_RAW_SIZE can have.  */
   set_gdbarch_deprecated_max_register_raw_size (gdbarch, 32);
   
   /* The length of the registers in the program's representation.  */
   set_gdbarch_deprecated_register_virtual_size (gdbarch, cris_register_size);
   
-  /* The largest value REGISTER_VIRTUAL_SIZE can have.  */
+  /* The largest value DEPRECATED_REGISTER_VIRTUAL_SIZE can have.  */
   set_gdbarch_deprecated_max_register_virtual_size (gdbarch, 32);
 
   set_gdbarch_deprecated_register_virtual_type (gdbarch, cris_register_virtual_type);
@@ -4266,30 +4163,17 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_deprecated_pop_frame (gdbarch, cris_pop_frame);
 
   set_gdbarch_deprecated_store_struct_return (gdbarch, cris_store_struct_return);
-  set_gdbarch_deprecated_extract_struct_value_address
-    (gdbarch, cris_extract_struct_value_address);
   set_gdbarch_use_struct_convention (gdbarch, always_use_struct_convention);
 
   set_gdbarch_deprecated_frame_init_saved_regs (gdbarch, cris_frame_init_saved_regs);
   set_gdbarch_deprecated_init_extra_frame_info (gdbarch, cris_init_extra_frame_info);
   set_gdbarch_skip_prologue (gdbarch, cris_skip_prologue);
-  set_gdbarch_prologue_frameless_p (gdbarch, generic_prologue_frameless_p);
   
   /* The stack grows downward.  */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
 
   set_gdbarch_breakpoint_from_pc (gdbarch, cris_breakpoint_from_pc);
   
-  /* The PC must not be decremented after a breakpoint.  (The breakpoint
-     handler takes care of that.)  */
-  set_gdbarch_decr_pc_after_break (gdbarch, 0);
-  
-  /* Offset from address of function to start of its code.  */
-  set_gdbarch_function_start_offset (gdbarch, 0);  
-  
-  /* The number of bytes at the start of arglist that are not really args,
-     0 in the CRIS ABI.  */
-  set_gdbarch_frame_args_skip (gdbarch, 0);
   set_gdbarch_frameless_function_invocation 
     (gdbarch, cris_frameless_function_invocation);
   set_gdbarch_deprecated_frame_chain (gdbarch, cris_frame_chain);
This page took 0.030064 seconds and 4 git commands to generate.