1999-01-19 Fernando Nasser <fnasser@totem.to.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / v850-tdep.c
index b79221ab72433ff1351d0fd5eac54f40e69b3a5a..082472405e7713bfccf5146490664f270ab34817 100644 (file)
@@ -48,6 +48,17 @@ struct prologue_info
 
 static CORE_ADDR v850_scan_prologue PARAMS ((CORE_ADDR pc, 
                                             struct prologue_info *fs));
+
+
+/* Should call_function allocate stack space for a struct return?  */
+int
+v850_use_struct_convention (gcc_p, type)
+     int gcc_p;
+     struct type *type;
+{
+  return (TYPE_NFIELDS (type) > 1 || TYPE_LENGTH (type) > 4);
+}
+
 \f
 /* Function: scan_prologue
    Scan the prologue of the function that contains PC, and record what
@@ -71,6 +82,7 @@ v850_scan_prologue (pc, pi)
   CORE_ADDR save_pc, save_end;
   int regsave_func_p;
   int current_sp_size;
+  int r12_tmp;
 
   /* First, figure out the bounds of the prologue so that we can limit the
      search to something reasonable.  */
@@ -115,6 +127,7 @@ v850_scan_prologue (pc, pi)
   regsave_func_p = 0;
   save_pc = 0;
   save_end = 0;
+  r12_tmp = 0;
 
 #ifdef DEBUG
   printf_filtered ("Current_pc = 0x%.8lx, prologue_end = 0x%.8lx\n",
@@ -178,19 +191,25 @@ v850_scan_prologue (pc, pi)
        pi->frameoffset += ((insn & 0x1f) ^ 0x10) - 0x10;
       else if (insn == ((SP_REGNUM << 11) | 0x0600 | SP_REGNUM))       /* addi <imm>,sp,sp */
        pi->frameoffset += read_memory_integer (current_pc + 2, 2);
-      else if (insn == ((FP_REGNUM << 11) | 0x0000 | SP_REGNUM))       /* mov sp,fp */
+      else if (insn == ((FP_RAW_REGNUM << 11) | 0x0000 | SP_REGNUM))   /* mov sp,fp */
        {
          fp_used = 1;
-         pi->framereg = FP_REGNUM;
+         pi->framereg = FP_RAW_REGNUM;
        }
 
+      else if (insn == ((R12_REGNUM << 11) | 0x0640 | R0_REGNUM))      /* movhi hi(const),r0,r12 */
+       r12_tmp = read_memory_integer (current_pc + 2, 2) << 16;
+      else if (insn == ((R12_REGNUM << 11) | 0x0620 | R12_REGNUM))     /* movea lo(const),r12,r12 */
+       r12_tmp += read_memory_integer (current_pc + 2, 2);
+      else if (insn == ((SP_REGNUM << 11) | 0x01c0 | R12_REGNUM) && r12_tmp) /* add r12,sp */
+       pi->frameoffset = r12_tmp;
       else if (insn == ((EP_REGNUM << 11) | 0x0000 | SP_REGNUM))       /* mov sp,ep */
        ep_used = 1;
       else if (insn == ((EP_REGNUM << 11) | 0x0000 | R1_REGNUM))       /* mov r1,ep */
        ep_used = 0;
-      else if (((insn & 0x07ff) == (0x0760 | SP_REGNUM)                 /* st.w <reg>,<offset>[sp] */
+      else if (((insn & 0x07ff) == (0x0760 | SP_REGNUM)                        /* st.w <reg>,<offset>[sp] */
                || (fp_used
-                   && (insn & 0x07ff) == (0x0760 | FP_REGNUM))) /* st.w <reg>,<offset>[fp] */
+                   && (insn & 0x07ff) == (0x0760 | FP_RAW_REGNUM)))    /* st.w <reg>,<offset>[fp] */
               && pifsr
               && (((reg = (insn >> 11) & 0x1f) >= SAVE1_START_REGNUM && reg <= SAVE1_END_REGNUM)
                   || (reg >= SAVE2_START_REGNUM && reg <= SAVE2_END_REGNUM)
@@ -316,7 +335,7 @@ v850_frame_chain (fi)
   /* First, find out who called us */
   callers_pc = FRAME_SAVED_PC (fi);
   /* If caller is a call-dummy, then our FP bears no relation to his FP! */
-  fp = v850_find_callers_reg (fi, FP_REGNUM);
+  fp = v850_find_callers_reg (fi, FP_RAW_REGNUM);
   if (PC_IN_CALL_DUMMY(callers_pc, fp, fp))
     return fp; /* caller is call-dummy: return oldest value of FP */
 
@@ -329,7 +348,7 @@ v850_frame_chain (fi)
   if (pi.start_function)
     return 0;                  /* Don't chain beyond the start function */
 
-  if (pi.framereg == FP_REGNUM)
+  if (pi.framereg == FP_RAW_REGNUM)
     return v850_find_callers_reg (fi, pi.framereg);
 
   return fi->frame - pi.frameoffset;
This page took 0.024095 seconds and 4 git commands to generate.