public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Prettify assembly output on SPARC (part #2)
@ 2004-07-09 11:39 Eric Botcazou
  2004-07-09 17:02 ` Richard Sandiford
  2004-09-05 15:25 ` Hans-Peter Nilsson
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Botcazou @ 2004-07-09 11:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: dave.anglin, joern.rennecke

[-- Attachment #1: Type: text/plain, Size: 3125 bytes --]

The patch tweaks final.c to let it output insns in a delay slot with a 
1-space indentation over the normal ones.  This makes it easier for humans 
to parse the assembly output:

sdbm__splpage:
        save    %sp, -1168, %sp
        add     %fp, -1056, %l4
        mov     %i0, %o1
        mov     1024, %o2
        call    memcpy, 0
         mov    %l4, %o0
        mov     %i0, %o0
        mov     0, %o1
        mov     1024, %o2
        call    memset, 0
         add    %fp, -1054, %l3
        mov     %i1, %o0
        mov     0, %o1
        call    memset, 0
         mov    1024, %o2
        ldsh    [%fp-1056], %l2
        cmp     %l2, 0
        ble,pn  %icc, .LL10
         nop
        mov     1024, %o1
        add     %fp, -1064, %l6
        add     %fp, -1072, %l5
.LL4:
        ldsh    [%l3], %g1
        add     %l2, -2, %l2
        ldsh    [%l3+2], %o5
        add     %l4, %g1, %l0
        sub     %o1, %g1, %o1
        st      %o1, [%fp-20]
        sub     %g1, %o5, %g1
        mov     %l0, %o0
        st      %g1, [%fp-28]
        add     %l4, %o5, %o5
        call    sdbm_hash, 0
         st     %o5, [%fp-32]
        st      %l0, [%fp-24]
        ldd     [%fp-24], %o4
        mov     %l6, %o1
        andcc   %o0, %i2, %g0
        mov     %i0, %o0
        ldd     [%fp-32], %l0
        mov     %l5, %o2
        movne   %icc, %i1, %o0
        std     %o4, [%fp-1064]
        call    sdbm__putpair, 0
         std    %l0, [%fp-1072]
        ldsh    [%l3+2], %o1
        cmp     %l2, 0
        bg,pt   %icc, .LL4
         add    %l3, 4, %l3
.LL10:
        return  %i7+8
         nop


final_scan_insn already had an argument to track the "delayslot-ness" so I 
simply made that more explicit by renaming it.  I checked all the back-ends 
and final_scan_insn is only called by targets using delay slots, and only 
invoked from within delay slots (with the argument set to 1 except on PA, 
which should probably be corrected).  The only exception is in sh.c:

/* Print an instruction which would have gone into a delay slot after
   another instruction, but couldn't because the other instruction expanded
   into a sequence where putting the slot insn at the end wouldn't work.  */

static void
print_slot (rtx insn)
{
  final_scan_insn (XVECEXP (insn, 0, 1), asm_out_file, optimize, 0, 1, NULL);

  INSN_DELETED_P (XVECEXP (insn, 0, 1)) = 1;
}

I'm not sure, but I think the "1" could be turned into "0" safely.

I added a static global because output_asm_insn is used all over the place in 
the back-ends and only a minority of targets uses delay slots.

Bootstrapped/regtested on sparc64-sun-solaris2.9 and sparc-sun-solaris2.8.  
OK for mainline?


2004-07-09  Eric Botcazou  <ebotcazou@libertysurf.fr>

	* final.c (output_in_slot): New global variable.
	(final_scan_insn): Rename 'nopeepholes' parameter into 'inslot'.
	Pass zero as 'inslot' for the first insn of a SEQUENCE.  Adjust
	for above renaming.  Set 'output_in_slot' to the value of 'inslot'
	before invoking output_asm_insn and unset it after.
	(output_asm_insn): Add a space after the tab if 'output_in_slot'
	is set.


-- 
Eric Botcazou

[-- Attachment #2: sparc_prettify-2.diff --]
[-- Type: text/x-diff, Size: 3139 bytes --]

Index: final.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/final.c,v
retrieving revision 1.318
diff -u -p -r1.318 final.c
--- final.c	1 Jul 2004 17:09:31 -0000	1.318
+++ final.c	9 Jul 2004 10:07:03 -0000
@@ -200,6 +200,10 @@ static int app_on;
 
 rtx final_sequence;
 
+/* True if we are outputting insns in a delay slot.  This is used to prettify
+   the assembly output.  */
+static bool output_in_slot;
+
 #ifdef ASSEMBLER_DIALECT
 
 /* Number of the assembler dialect to use, starting at 0.  */
@@ -1663,8 +1667,8 @@ scan_ahead_for_unlikely_executed_note (r
    is the insn being scanned.
    Value returned is the next insn to be scanned.
 
-   NOPEEPHOLES is the flag to disallow peephole processing (currently
-   used for within delayed branch sequence output).
+   INSLOT is used to specify that we are in the
+   slot of a delayed branch.
 
    SEEN is used to track the end of the prologue, for emitting
    debug information.  We force the emission of a line note after
@@ -1674,8 +1678,7 @@ scan_ahead_for_unlikely_executed_note (r
 
 rtx
 final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
-		 int prescan, int nopeepholes ATTRIBUTE_UNUSED,
-		 int *seen)
+		 int prescan, int inslot, int *seen)
 {
 #ifdef HAVE_cc0
   rtx set;
@@ -2187,7 +2190,7 @@ final_scan_insn (rtx insn, FILE *file, i
 	       thought unnecessary.  If that happens, cancel this sequence
 	       and cause that insn to be restored.  */
 
-	    next = final_scan_insn (XVECEXP (body, 0, 0), file, 0, prescan, 1, seen);
+	    next = final_scan_insn (XVECEXP (body, 0, 0), file, 0, prescan, 0, seen);
 	    if (next != XVECEXP (body, 0, 1))
 	      {
 		final_sequence = 0;
@@ -2394,7 +2397,7 @@ final_scan_insn (rtx insn, FILE *file, i
 #ifdef HAVE_peephole
 	/* Do machine-specific peephole optimizations if desired.  */
 
-	if (optimize && !flag_no_peephole && !nopeepholes)
+	if (optimize && !flag_no_peephole && !inslot)
 	  {
 	    rtx next = peephole (insn);
 	    /* When peepholing, if there were notes within the peephole,
@@ -2405,7 +2408,7 @@ final_scan_insn (rtx insn, FILE *file, i
 
 		for (note = NEXT_INSN (insn); note != next;
 		     note = NEXT_INSN (note))
-		  final_scan_insn (note, file, optimize, prescan, nopeepholes, seen);
+		  final_scan_insn (note, file, optimize, prescan, inslot, seen);
 
 		/* In case this is prescan, put the notes
 		   in proper position for later rescan.  */
@@ -2529,8 +2532,9 @@ final_scan_insn (rtx insn, FILE *file, i
 	IA64_UNWIND_EMIT (asm_out_file, insn);
 #endif
 	/* Output assembler code from the template.  */
-
+	output_in_slot = inslot;
 	output_asm_insn (template, recog_data.operand);
+	output_in_slot = false;
 
 	/* If necessary, report the effect that the instruction has on
 	   the unwind info.   We've already done this for delay slots
@@ -3001,6 +3005,8 @@ output_asm_insn (const char *template, r
   memset (opoutput, 0, sizeof opoutput);
   p = template;
   putc ('\t', asm_out_file);
+  if (output_in_slot)
+    putc (' ', asm_out_file);
 
 #ifdef ASM_OUTPUT_OPCODE
   ASM_OUTPUT_OPCODE (asm_out_file, p);

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-09-08 19:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-09 11:39 [PATCH] Prettify assembly output on SPARC (part #2) Eric Botcazou
2004-07-09 17:02 ` Richard Sandiford
2004-09-05 15:25 ` Hans-Peter Nilsson
2004-09-06  7:14   ` Eric Botcazou
2004-09-06 12:28     ` Hans-Peter Nilsson
2004-09-06 15:50       ` Eric Botcazou
2004-09-06 17:39         ` Hans-Peter Nilsson
2004-09-08 19:34           ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).