This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Instruction packing with --gstabs for d10v assembler


The d10v assembler, when possible, packs adjacent short instructions into
a single packed instruction.  When the assembler is invoked with --gstabs,
however, this behavior is suppressed.  The following patch, in concert
with the patch that adds the outputting_line_debug_p variable to the
generic assembler, enables packing even when --gstabs is specified, unless
--gstabs-no-packing is specified as well.

gdb handles this in a mostly graceful manner.  The only problem is that
the patched assembler will generate pairs of stabs asm lineno directives
at a single PC.  When looking up a line number based on the program's PC
(i.e., after a step or upon hitting a breakpoint), gdb will conclude that
execution has stopped at the second of the two line numbers.  This is
undesirable, but it looks as though solutions to this particular problem
will be quite involved.

2000-11-06  Matthew Hiller  <hiller@redhat.com>

	* config/tc-d10v.c (flag_no_gstabs_packing): New variable.
	(md_longopts): New option --gstabs-no-packing.
	(md_show_usage): New option --gstabs-no-packing.
	(md_parse_option): New option --gstabs-no-packing.
	(d10v_cleanup): Writes pending instruction only if
	!outputting_line_debug_p || flag_no_gstabs_packing.

Index: gas/config/tc-d10v.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-d10v.c,v
retrieving revision 1.13
diff -c -3 -p -r1.13 tc-d10v.c
*** tc-d10v.c	2000/08/04 01:01:32	1.13
--- tc-d10v.c	2000/11/06 23:33:52
*************** static packing_type etype = PACK_UNSPEC;
*** 72,77 ****
--- 72,78 ----
  
  /* True if instruction swapping warnings should be inhibited.  */
  static unsigned char flag_warn_suppress_instructionswap; /* --nowarnswap  */
+ static unsigned char flag_no_gstabs_packing;   /* --no-gstabs-packing  */
  
  /* Local functions.  */
  static int reg_name_search PARAMS ((char *name));
*************** struct option md_longopts[] =
*** 98,103 ****
--- 99,107 ----
  {
  #define OPTION_NOWARNSWAP (OPTION_MD_BASE)
    {"nowarnswap", no_argument, NULL, OPTION_NOWARNSWAP},
+ #define OPTION_NOGSTABSPACKING (OPTION_MD_BASE + 1)
+   {"nogstabspacking", no_argument, NULL, OPTION_NOGSTABSPACKING},
+   {"no-gstabs-packing", no_argument, NULL, OPTION_NOGSTABSPACKING},
    {NULL, no_argument, NULL, 0}
  };
  
*************** md_show_usage (stream)
*** 232,238 ****
       FILE *stream;
  {
    fprintf (stream, _("D10V options:\n\
! -O                      optimize.  Will do some operations in parallel.\n"));
  }
  
  int
--- 236,245 ----
       FILE *stream;
  {
    fprintf (stream, _("D10V options:\n\
! -O                      optimize.  Will do some operations in parallel.\n\
! --no-gstabs-packing     if --gstabs is specified, do not pack adjacent\n\
!                         instructions together\n"));
! 
  }
  
  int
*************** md_parse_option (c, arg)
*** 249,254 ****
--- 256,264 ----
      case OPTION_NOWARNSWAP:
        flag_warn_suppress_instructionswap = 1;
        break;
+     case OPTION_NOGSTABSPACKING:
+       flag_no_gstabs_packing = 1;
+       break;
      default:
        return 0;
      }
*************** md_apply_fix3 (fixp, valuep, seg)
*** 1612,1622 ****
    return 0;
  }
  
! /* Called after the assembler has finished parsing the input file or
!    after a label is defined.  Because the D10V assembler sometimes
     saves short instructions to see if it can package them with the
     next instruction, there may be a short instruction that still needs
     to be written.
  
     NOTE: accesses a global, etype.
     NOTE: invoked by various macros such as md_cleanup: see.  */
--- 1622,1633 ----
    return 0;
  }
  
! /* d10v_cleanup() is called after the assembler has finished parsing
!    the input file, when a label is read from the input file, or when a
!    stab directive is output.  Because the D10V assembler sometimes
     saves short instructions to see if it can package them with the
     next instruction, there may be a short instruction that still needs
     to be written.
  
     NOTE: accesses a global, etype.
     NOTE: invoked by various macros such as md_cleanup: see.  */
*************** d10v_cleanup ()
*** 1626,1641 ****
  {
    segT seg;
    subsegT subseg;

    if (prev_opcode && etype == PACK_UNSPEC)
      {
        seg = now_seg;
        subseg = now_subseg;
!       if (prev_seg)
! 	subseg_set (prev_seg, prev_subseg);
!       write_1_short (prev_opcode, prev_insn, fixups->next);
        subseg_set (seg, subseg);
-       prev_opcode = NULL;
      }
    return 1;
  }
--- 1637,1660 ----
  {
    segT seg;
    subsegT subseg;

    if (prev_opcode && etype == PACK_UNSPEC)
      {
        seg = now_seg;
        subseg = now_subseg;
!       /* If cleanup was invoked because the assembler encountered,
!  	 i.e., a user label, we write out the pending instruction. If
!  	 it was invoked because the assembler is outputting a line
!  	 debugging information, though, we write out the pending
!  	 instruction only if --no-gstabs-packing was specified on the
!  	 command line */
!       if (!outputting_line_debug_p || flag_no_gstabs_packing)
!  	{
!  	  if (prev_seg)
!  	    subseg_set (prev_seg, prev_subseg);
!  	  write_1_short (prev_opcode, prev_insn, fixups->next);
!  	  prev_opcode = NULL;
!  	}
        subseg_set (seg, subseg);
      }
    return 1;
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]