This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

LABEL_ALIGN patch applied to final.c / config/sh/sh*


I have applied the enclosed patch.
Reviewed by Jim Wilson.

Wed Feb 23 16:42:21 2000  J"orn Rennecke <amylaar@cygnus.co.uk>

	* final.c (shorten_branches): Make value passed to LABEL_ALIGN
	conform to documentation.
	* sh.h (LABEL_ALIGN): If aligning loops, call sh_label_align
	to check for special cases.
	* sh-protos.h (sh_label_align): Declare.
	* sh.c (sh_label_align): Define.

Index: final.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/final.c,v
retrieving revision 1.108
diff -p -r1.108 final.c
*** final.c	2000/01/18 22:45:16	1.108
--- final.c	2000/02/23 16:41:15
*************** shorten_branches (first)
*** 1134,1140 ****
  		break;
  	      else if (GET_CODE (label) == CODE_LABEL)
  		{
! 		  log = LOOP_ALIGN (insn);
  		  if (max_log < log)
  		    {
  		      max_log = log;
--- 1134,1140 ----
  		break;
  	      else if (GET_CODE (label) == CODE_LABEL)
  		{
! 		  log = LOOP_ALIGN (label);
  		  if (max_log < log)
  		    {
  		      max_log = log;
Index: config/sh/sh-protos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh-protos.h,v
retrieving revision 1.2
diff -p -r1.2 sh-protos.h
*** sh-protos.h	2000/02/15 22:34:33	1.2
--- sh-protos.h	2000/02/23 16:41:15
*************** extern const char *output_far_jump PARAM
*** 36,41 ****
--- 36,42 ----
  extern void machine_dependent_reorg PARAMS ((rtx));
  extern struct rtx_def *sfunc_uses_reg PARAMS ((rtx));
  extern int barrier_align PARAMS ((rtx));
+ extern int sh_loop_align PARAMS ((rtx));
  extern int fp_zero_operand PARAMS ((rtx));
  extern int fp_one_operand PARAMS ((rtx));
  extern int fp_int_operand PARAMS ((rtx));
Index: config/sh/sh.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh.c,v
retrieving revision 1.42
diff -p -r1.42 sh.c
*** sh.c	2000/02/16 03:23:40	1.42
--- sh.c	2000/02/23 16:41:16
*************** barrier_align (barrier_or_label)
*** 2786,2791 ****
--- 2786,2815 ----
    return CACHE_LOG;
  }
  
+ /* If we are inside a phony loop, almost any kind of label can turn up as the
+    first one in the loop.  Aligning a braf label causes incorrect switch
+    destination addresses; we can detect braf labels because they are
+    followed by a BARRIER.
+    Applying loop alignment to small constant or switch tables is a waste
+    of space, so we suppress this too.  */
+ int
+ sh_loop_align (label)
+      rtx label;
+ {
+   rtx next = label;
+ 
+   do
+     next = next_nonnote_insn (next);
+   while (next && GET_CODE (next) == CODE_LABEL);
+ 
+   if (! next
+       || GET_RTX_CLASS (GET_CODE (next)) != 'i'
+       || GET_CODE (PATTERN (next)) == ADDR_DIFF_VEC
+       || recog_memoized (next) == CODE_FOR_consttable_2)
+     return 0;
+   return 2;
+ }
+ 
  /* Exported to toplev.c.
  
     Do a final pass over the function, just before delayed branch
Index: config/sh/sh.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh.h,v
retrieving revision 1.50
diff -p -r1.50 sh.h
*** sh.h	2000/02/16 03:23:40	1.50
--- sh.h	2000/02/23 16:41:18
*************** do {									\
*** 351,357 ****
    barrier_align (LABEL_AFTER_BARRIER)
  
  #define LOOP_ALIGN(A_LABEL) \
!   ((! optimize || TARGET_HARVARD || TARGET_SMALLCODE) ? 0 : 2)
  
  #define LABEL_ALIGN(A_LABEL) \
  (									\
--- 351,358 ----
    barrier_align (LABEL_AFTER_BARRIER)
  
  #define LOOP_ALIGN(A_LABEL) \
!   ((! optimize || TARGET_HARVARD || TARGET_SMALLCODE) \
!    ? 0 : sh_loop_align (A_LABEL))
  
  #define LABEL_ALIGN(A_LABEL) \
  (									\

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