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]

Avoid using of quad on i386



Hi,
this patch implements the target vector entries for ASM_OUTPUT_* familly for
outputting integer.  I still do use the default functions that use the old
ASM_OUTPUT_* hooks, as my attempts to remove them from whole compiler at once
run out of control.  This way we can convert the backends one by one.

I've also added the function for i386 backend to avoid using of quad
opcode.

Honza

Thu Nov  8 16:53:02 CET 2001  Jan Hubicka  <jh@suse.cz>
	* output.h (default_asm_out_*): Declare.
	* target-def.h (TARGET_ASM_CHAR, TARGET_ASM_SHORT,
	TARGET_ASM_INT, TARGET_ASM_DOUBLE_INT,
	TARGET_ASM_QUADRUPLE_INT, TARGET_ASM_OUT_INTEGER): New macros.
	* target.h (asm_out_int): New structure.
	(asm_out): Add integer field.
	* varasm.c (default_asm_out_*): New functions.
	(assemble_integer): Use the new functions.
	* i386.c (x86_64_asm_double_int): New function.
	(TARGET_ASM_DOUBLE_INT): New constant.

Index: output.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/output.h,v
retrieving revision 1.87
diff -c -3 -p -r1.87 output.h
*** output.h	2001/11/04 02:47:36	1.87
--- output.h	2001/11/08 15:51:55
*************** extern void default_exception_section	PA
*** 470,475 ****
--- 470,482 ----
  /* Tell assembler to switch to the section for the EH frames.  */
  extern void default_eh_frame_section	PARAMS ((void));
  
+ /* Tell assembler to output various integer types.  */
+ extern bool default_asm_out_char	PARAMS ((FILE *, rtx));
+ extern bool default_asm_out_short	PARAMS ((FILE *, rtx));
+ extern bool default_asm_out_int		PARAMS ((FILE *, rtx));
+ extern bool default_asm_out_double_int	PARAMS ((FILE *, rtx));
+ extern bool default_asm_out_quadruple_int PARAMS ((FILE *, rtx));
+ 
  /* Default target hook that outputs nothing to a stream.  */
  extern void no_asm_to_stream PARAMS ((FILE *));
  
Index: target-def.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/target-def.h,v
retrieving revision 1.15
diff -c -3 -p -r1.15 target-def.h
*** target-def.h	2001/10/22 14:43:27	1.15
--- target-def.h	2001/11/08 15:51:55
*************** Foundation, 59 Temple Place - Suite 330,
*** 84,89 ****
--- 84,115 ----
  #define TARGET_ASM_EH_FRAME_SECTION default_eh_frame_section
  #endif
  
+ #ifndef TARGET_ASM_CHAR
+ #define TARGET_ASM_CHAR default_asm_out_char
+ #endif
+ 
+ #ifndef TARGET_ASM_SHORT
+ #define TARGET_ASM_SHORT default_asm_out_short
+ #endif
+ 
+ #ifndef TARGET_ASM_INT
+ #define TARGET_ASM_INT default_asm_out_int
+ #endif
+ 
+ #ifndef TARGET_ASM_DOUBLE_INT
+ #define TARGET_ASM_DOUBLE_INT default_asm_out_double_int
+ #endif
+ 
+ #ifndef TARGET_ASM_QUADRUPLE_INT
+ #define TARGET_ASM_QUADRUPLE_INT default_asm_out_quadruple_int
+ #endif
+ 
+ #define TARGET_ASM_OUT_INTEGER {TARGET_ASM_CHAR,		\
+ 				TARGET_ASM_SHORT,		\
+ 				TARGET_ASM_INT,			\
+ 				TARGET_ASM_DOUBLE_INT,		\
+ 				TARGET_ASM_QUADRUPLE_INT}
+ 
  #define TARGET_ASM_OUT {TARGET_ASM_OPEN_PAREN,			\
  			TARGET_ASM_CLOSE_PAREN,			\
  			TARGET_ASM_FUNCTION_PROLOGUE,		\
*************** Foundation, 59 Temple Place - Suite 330,
*** 94,100 ****
  			TARGET_ASM_EXCEPTION_SECTION,		\
  			TARGET_ASM_EH_FRAME_SECTION,		\
  			TARGET_ASM_CONSTRUCTOR,			\
! 			TARGET_ASM_DESTRUCTOR}
  
  /* Scheduler hooks.  All of these default to null pointers, which
     haifa-sched.c looks for and handles.  */
--- 120,127 ----
  			TARGET_ASM_EXCEPTION_SECTION,		\
  			TARGET_ASM_EH_FRAME_SECTION,		\
  			TARGET_ASM_CONSTRUCTOR,			\
! 			TARGET_ASM_DESTRUCTOR,			\
! 			TARGET_ASM_OUT_INTEGER}
  
  /* Scheduler hooks.  All of these default to null pointers, which
     haifa-sched.c looks for and handles.  */
Index: target.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/target.h,v
retrieving revision 1.17
diff -c -3 -p -r1.17 target.h
*** target.h	2001/10/22 14:43:27	1.17
--- target.h	2001/11/08 15:51:55
*************** struct gcc_target
*** 79,84 ****
--- 79,92 ----
  
      /* Output a destructor for a symbol with a given priority.  */
      void (* destructor) PARAMS ((rtx, int));
+     struct asm_out_int
+       {
+ 	bool (* out_char) PARAMS ((FILE *, rtx));
+ 	bool (* out_short) PARAMS ((FILE *, rtx));
+ 	bool (* out_int) PARAMS ((FILE *, rtx));
+ 	bool (* out_double_int) PARAMS ((FILE *, rtx));
+ 	bool (* out_quadruple_int) PARAMS ((FILE *, rtx));
+       } integer;
    } asm_out;
  
    /* Functions relating to instruction scheduling.  */
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.225
diff -c -3 -p -r1.225 varasm.c
*** varasm.c	2001/11/06 14:47:37	1.225
--- varasm.c	2001/11/08 15:51:56
*************** min_align (a, b)
*** 1939,1944 ****
--- 1939,2012 ----
    return (a | b) & -(a | b);
  }
  
+ /* Output an char; return false if failed.  */
+ bool
+ default_asm_out_char (file, x)
+      rtx x ATTRIBUTE_UNUSED;
+      FILE *file ATTRIBUTE_UNUSED;
+ {
+ #ifdef ASM_OUTPUT_CHAR
+   ASM_OUTPUT_CHAR (file, x);
+   return true;
+ #endif
+   return false;
+ }
+ 
+ /* Output an short; return false if failed.  */
+ bool
+ default_asm_out_short (file, x)
+      rtx x ATTRIBUTE_UNUSED;
+      FILE *file ATTRIBUTE_UNUSED;
+ {
+ #ifdef ASM_OUTPUT_SHORT
+   ASM_OUTPUT_SHORT (file, x);
+   return true;
+ #endif
+   return false;
+ }
+ 
+ /* Output an int; return false if failed.  */
+ 
+ bool
+ default_asm_out_int (file, x)
+      rtx x ATTRIBUTE_UNUSED;
+      FILE *file ATTRIBUTE_UNUSED;
+ {
+ #ifdef ASM_OUTPUT_INT
+   ASM_OUTPUT_INT (file, x);
+   return true;
+ #endif
+   return false;
+ }
+ 
+ /* Output an double int; return false if failed.  */
+ 
+ bool
+ default_asm_out_double_int (file, x)
+      rtx x ATTRIBUTE_UNUSED;
+      FILE *file ATTRIBUTE_UNUSED;
+ {
+ #ifdef ASM_OUTPUT_DOUBLE_INT
+   ASM_OUTPUT_DOUBLE_INT (file, x);
+   return true;
+ #endif
+   return false;
+ }
+ 
+ /* Output an quadruple int; return false if failed.  */
+ 
+ bool
+ default_asm_out_quadruple_int (file, x)
+      rtx x ATTRIBUTE_UNUSED;
+      FILE *file ATTRIBUTE_UNUSED;
+ {
+ #ifdef ASM_OUTPUT_QUADRUPLE_INT
+   ASM_OUTPUT_QUADRUPLE_INT (file, x);
+   return true;
+ #endif
+   return false;
+ }
+ 
  /* Assemble the integer constant X into an object of SIZE bytes.  ALIGN is
     the alignment of the integer in bits.  Return 1 if we were able to output
     the constant, otherwise 0.  If FORCE is non-zero, abort if we can't output
*************** assemble_integer (x, size, align, force)
*** 1957,1987 ****
    if (align >= MIN (size * BITS_PER_UNIT, BIGGEST_ALIGNMENT))
      switch (size)
        {
- #ifdef ASM_OUTPUT_CHAR
        case 1:
! 	ASM_OUTPUT_CHAR (asm_out_file, x);
! 	return 1;
! #endif
! #ifdef ASM_OUTPUT_SHORT
        case 2:
! 	ASM_OUTPUT_SHORT (asm_out_file, x);
! 	return 1;
! #endif
! #ifdef ASM_OUTPUT_INT
        case 4:
! 	ASM_OUTPUT_INT (asm_out_file, x);
! 	return 1;
! #endif
! #ifdef ASM_OUTPUT_DOUBLE_INT
        case 8:
! 	ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
! 	return 1;
! #endif
! #ifdef ASM_OUTPUT_QUADRUPLE_INT
        case 16:
! 	ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x);
! 	return 1;
! #endif
        }
    else
      {
--- 2025,2050 ----
    if (align >= MIN (size * BITS_PER_UNIT, BIGGEST_ALIGNMENT))
      switch (size)
        {
        case 1:
! 	if ((*targetm.asm_out.integer.out_char) (asm_out_file, x))
! 	  return 1;
! 	break;
        case 2:
! 	if ((*targetm.asm_out.integer.out_short) (asm_out_file, x))
! 	  return 2;
! 	break;
        case 4:
! 	if ((*targetm.asm_out.integer.out_int) (asm_out_file, x))
! 	  return 4;
! 	break;
        case 8:
! 	if ((*targetm.asm_out.integer.out_double_int) (asm_out_file, x))
! 	  return 8;
! 	break;
        case 16:
! 	if ((*targetm.asm_out.integer.out_quadruple_int) (asm_out_file, x))
! 	  return 16;
! 	break;
        }
    else
      {
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.333
diff -c -3 -p -r1.333 i386.c
*** i386.c	2001/11/07 12:35:14	1.333
--- i386.c	2001/11/08 15:52:01
*************** static int ix86_adjust_cost PARAMS ((rtx
*** 656,661 ****
--- 656,662 ----
  static void ix86_sched_init PARAMS ((FILE *, int, int));
  static int ix86_sched_reorder PARAMS ((FILE *, int, rtx *, int *, int));
  static int ix86_variable_issue PARAMS ((FILE *, int, rtx, int));
+ static bool x86_64_asm_double_int PARAMS ((FILE *, rtx));
  
  struct ix86_address
  {
*************** static enum x86_64_reg_class merge_class
*** 771,776 ****
--- 772,779 ----
  #define TARGET_SCHED_INIT ix86_sched_init
  #undef TARGET_SCHED_REORDER
  #define TARGET_SCHED_REORDER ix86_sched_reorder
+ #undef TARGET_ASM_DOUBLE_INT
+ #define TARGET_ASM_DOUBLE_INT x86_64_asm_double_int
  
  struct gcc_target targetm = TARGET_INITIALIZER;
  
*************** ix86_svr3_asm_out_constructor (symbol, p
*** 12481,12483 ****
--- 12484,12499 ----
    fputc ('\n', asm_out_file);
  }
  #endif
+ 
+ static bool
+ x86_64_asm_double_int (file, x)
+      FILE *file;
+      rtx x;
+ {
+   if (!TARGET_64BIT)
+     return false;
+   fprintf (file, "%s\t", ASM_QUAD);
+   output_addr_const (file, x);
+   putc ('\n', file);
+   return true;
+ }


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