[committed] Fix mips16 jump tables

Richard Sandiford rsandifo@redhat.com
Wed Apr 13 20:49:00 GMT 2005


This patch is a repost of:

    http://gcc.gnu.org/ml/gcc/2005-04/msg00632.html

Tested on mips64-elf with -mips16 runs and on mips-elf
(test pattern {,-msoft-float}{-EL,-EB}).  Applied to mainline.

WRT the comment change: as Ian says, it might make sense to
make get_insn_length() return the length of jump tables if
JUMP_TABLES_IN_TEXT_SECTION.  That's a separate issue though.
I'll put it on the list...

Richard


	* config/mips/mips.h (ASM_OUTPUT_CASE_LABEL): Delete.
	(JUMP_TABLES_IN_TEXT_SECTION): Define.
	* config/mips/mips.c (mips16_insn_length): Remove reference to
	JUMP_TABLES_IN_TEXT_SECTION.

Index: config/mips/mips.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.h,v
retrieving revision 1.388
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.388 mips.h
*** config/mips/mips.h	7 Apr 2005 18:04:42 -0000	1.388
--- config/mips/mips.h	13 Apr 2005 20:39:58 -0000
*************** do {									\
*** 2576,2593 ****
  	     LOCAL_LABEL_PREFIX, VALUE);				\
  } while (0)
  
! /* When generating mips16 code we want to put the jump table in the .text
!    section.  In all other cases, we want to put the jump table in the .rdata
!    section.  Unfortunately, we can't use JUMP_TABLES_IN_TEXT_SECTION, because
!    it is not conditional.  Instead, we use ASM_OUTPUT_CASE_LABEL to switch back
!    to the .text section if appropriate.  */
! #undef ASM_OUTPUT_CASE_LABEL
! #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, INSN)			\
! do {									\
!   if (TARGET_MIPS16)							\
!     function_section (current_function_decl);				\
!   (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM);		\
! } while (0)
  
  /* This is how to output an assembler line
     that says to advance the location counter
--- 2576,2584 ----
  	     LOCAL_LABEL_PREFIX, VALUE);				\
  } while (0)
  
! /* When generating MIPS16 code, we want the jump table to be in the text
!    section so that we can load its address using a PC-relative addition.  */
! #define JUMP_TABLES_IN_TEXT_SECTION TARGET_MIPS16
  
  /* This is how to output an assembler line
     that says to advance the location counter
Index: config/mips/mips.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.495
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.495 mips.c
*** config/mips/mips.c	5 Apr 2005 09:36:06 -0000	1.495
--- config/mips/mips.c	13 Apr 2005 20:40:00 -0000
*************** dump_constants (struct mips16_constant *
*** 7988,7998 ****
    emit_barrier_after (insn);
  }
  
! /* Return the length of instruction INSN.
! 
!    ??? MIPS16 switch tables go in .text, but we don't define
!    JUMP_TABLES_IN_TEXT_SECTION, so get_attr_length will not
!    compute their lengths correctly.  */
  
  static int
  mips16_insn_length (rtx insn)
--- 7988,7994 ----
    emit_barrier_after (insn);
  }
  
! /* Return the length of instruction INSN.  */
  
  static int
  mips16_insn_length (rtx insn)



More information about the Gcc-patches mailing list