Patchwork MeP build fixes

login
register
mail settings
Submitter DJ Delorie
Date Sept. 14, 2010, 7:26 a.m.
Message ID <201009140726.o8E7QxPr013653@greed.delorie.com>
Download mbox | patch
Permalink /patch/64675/
State New
Headers show

Comments

DJ Delorie - Sept. 14, 2010, 7:26 a.m.
> * mep-pragma.c gets a series of errors starting with
> 
>   rtl.h:22:9: error: attempt to use poisoned "GCC_RTL_H"
> 
>   because it is being treated as a front-end file but uses rtl.h and
>   uses various RTL-related functionality.  I don't know the right fix
>   for this issue - for my testing I worked around it with "#undef
>   IN_GCC_FRONTEND" but the right fix is more likely to be moving the
>   RTL functionality into mep.c while keeping the code using front-end
>   pragma interfaces in mep-pragma.c.  Thus, this patch does not fix
>   this issue.

Here's the fix for this part.  Committed.

	PR target/44749
	* config/mep/mep-protos.h (mep_save_register_info,
	mep_reinit_regs, mep_init_regs): Declare.

	* config/mep/mep.c: Move all target definitions to the end of the
	file to avoid the need for duplicate declarations.
	(mep_save_register_info, mep_reinit_regs, mep_init_regs): New.
	(mep_reorg_erepeat): Remove unused variables.
	(mep_expand_builtin): Likewise.

	* config/mep/mep-pragma.c: Don't include rtl.h.
	(INVALID_REGNUM): New.
	(mep_pragma_coprocessor_which): Call mep-specific rtl-layer bridge
	functions.
	(mep_pragma_coprocessor_subclass): Rename "class" to "rclass".
	Avoid enum/integer math.

Patch

Index: config/mep/mep-protos.h
===================================================================
--- config/mep/mep-protos.h	(revision 164267)
+++ config/mep/mep-protos.h	(working copy)
@@ -105,12 +105,20 @@  extern bool mep_lookup_pragma_call (cons
 extern bool mep_have_core_copro_moves_p;
 extern bool mep_have_copro_copro_moves_p;
 
 extern bool mep_cannot_change_mode_class (enum machine_mode, enum machine_mode,
 					  enum reg_class);
 
+/* These are called from mep-pragmas (front end) and then call into
+   the RTL layer to re-initialize the register tables once we're done
+   changing them via pragmas.  */
+extern void mep_save_register_info (void);
+extern void mep_reinit_regs (void);
+extern void mep_init_regs (void);
+
+
 extern int cgen_h_uint_6a1_immediate (rtx, enum machine_mode);
 extern int cgen_h_uint_7a1_immediate (rtx, enum machine_mode);
 extern int cgen_h_uint_8a1_immediate (rtx, enum machine_mode);
 extern int cgen_h_uint_6a2_immediate (rtx, enum machine_mode);
 extern int cgen_h_uint_22a4_immediate (rtx, enum machine_mode);
 extern int cgen_h_sint_2a1_immediate (rtx, enum machine_mode);
Index: config/mep/mep.c
===================================================================
--- config/mep/mep.c	(revision 164267)
+++ config/mep/mep.c	(working copy)
@@ -119,14 +119,12 @@  struct GTY(()) machine_function
   int asms_without_operands;
 };
 
 #define MEP_CONTROL_REG(x) \
   (GET_CODE (x) == REG && ANY_CONTROL_REGNO_P (REGNO (x)))
 
-static const struct attribute_spec mep_attribute_table[11];
-
 static GTY(()) section * based_section;
 static GTY(()) section * tinybss_section;
 static GTY(()) section * far_section;
 static GTY(()) section * farbss_section;
 static GTY(()) section * frodata_section;
 static GTY(()) section * srodata_section;
@@ -228,89 +226,12 @@  static rtx mep_expand_builtin_saveregs (
 static tree mep_build_builtin_va_list (void);
 static void mep_expand_va_start (tree, rtx);
 static tree mep_gimplify_va_arg_expr (tree, tree, gimple_seq *, gimple_seq *);
 static bool mep_can_eliminate (const int, const int);
 static void mep_trampoline_init (rtx, tree, rtx);
 
-/* Initialize the GCC target structure.  */
-
-#undef  TARGET_ASM_FUNCTION_PROLOGUE
-#define TARGET_ASM_FUNCTION_PROLOGUE	mep_start_function
-#undef  TARGET_ATTRIBUTE_TABLE
-#define TARGET_ATTRIBUTE_TABLE		mep_attribute_table
-#undef  TARGET_COMP_TYPE_ATTRIBUTES
-#define TARGET_COMP_TYPE_ATTRIBUTES	mep_comp_type_attributes
-#undef  TARGET_INSERT_ATTRIBUTES
-#define TARGET_INSERT_ATTRIBUTES	mep_insert_attributes
-#undef  TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P
-#define TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P	mep_function_attribute_inlinable_p
-#undef  TARGET_CAN_INLINE_P
-#define TARGET_CAN_INLINE_P		mep_can_inline_p
-#undef  TARGET_SECTION_TYPE_FLAGS
-#define TARGET_SECTION_TYPE_FLAGS	mep_section_type_flags
-#undef  TARGET_ASM_NAMED_SECTION
-#define TARGET_ASM_NAMED_SECTION	mep_asm_named_section
-#undef  TARGET_INIT_BUILTINS
-#define TARGET_INIT_BUILTINS		mep_init_builtins
-#undef  TARGET_EXPAND_BUILTIN
-#define TARGET_EXPAND_BUILTIN		mep_expand_builtin
-#undef  TARGET_SCHED_ADJUST_COST
-#define TARGET_SCHED_ADJUST_COST	mep_adjust_cost
-#undef  TARGET_SCHED_ISSUE_RATE
-#define TARGET_SCHED_ISSUE_RATE		mep_issue_rate
-#undef  TARGET_SCHED_REORDER
-#define TARGET_SCHED_REORDER		mep_sched_reorder
-#undef  TARGET_STRIP_NAME_ENCODING
-#define TARGET_STRIP_NAME_ENCODING	mep_strip_name_encoding
-#undef  TARGET_ASM_SELECT_SECTION
-#define TARGET_ASM_SELECT_SECTION	mep_select_section
-#undef  TARGET_ASM_UNIQUE_SECTION
-#define TARGET_ASM_UNIQUE_SECTION	mep_unique_section
-#undef  TARGET_ENCODE_SECTION_INFO
-#define TARGET_ENCODE_SECTION_INFO	mep_encode_section_info
-#undef  TARGET_FUNCTION_OK_FOR_SIBCALL
-#define TARGET_FUNCTION_OK_FOR_SIBCALL	mep_function_ok_for_sibcall
-#undef  TARGET_RTX_COSTS
-#define TARGET_RTX_COSTS		mep_rtx_cost
-#undef  TARGET_ADDRESS_COST
-#define TARGET_ADDRESS_COST 		mep_address_cost
-#undef  TARGET_MACHINE_DEPENDENT_REORG
-#define TARGET_MACHINE_DEPENDENT_REORG  mep_reorg
-#undef  TARGET_SETUP_INCOMING_VARARGS
-#define TARGET_SETUP_INCOMING_VARARGS	mep_setup_incoming_varargs
-#undef  TARGET_PASS_BY_REFERENCE
-#define TARGET_PASS_BY_REFERENCE        mep_pass_by_reference
-#undef  TARGET_VECTOR_MODE_SUPPORTED_P
-#define TARGET_VECTOR_MODE_SUPPORTED_P	mep_vector_mode_supported_p
-#undef  TARGET_HANDLE_OPTION
-#define TARGET_HANDLE_OPTION            mep_handle_option
-#undef  TARGET_DEFAULT_TARGET_FLAGS
-#define TARGET_DEFAULT_TARGET_FLAGS	TARGET_DEFAULT
-#undef  TARGET_ALLOCATE_INITIAL_VALUE
-#define TARGET_ALLOCATE_INITIAL_VALUE   mep_allocate_initial_value
-#undef  TARGET_ASM_INIT_SECTIONS
-#define TARGET_ASM_INIT_SECTIONS 	mep_asm_init_sections
-#undef  TARGET_RETURN_IN_MEMORY
-#define TARGET_RETURN_IN_MEMORY		mep_return_in_memory
-#undef  TARGET_NARROW_VOLATILE_BITFIELD
-#define TARGET_NARROW_VOLATILE_BITFIELD mep_narrow_volatile_bitfield
-#undef	TARGET_EXPAND_BUILTIN_SAVEREGS
-#define	TARGET_EXPAND_BUILTIN_SAVEREGS	mep_expand_builtin_saveregs
-#undef  TARGET_BUILD_BUILTIN_VA_LIST
-#define TARGET_BUILD_BUILTIN_VA_LIST	mep_build_builtin_va_list
-#undef  TARGET_EXPAND_BUILTIN_VA_START
-#define TARGET_EXPAND_BUILTIN_VA_START	mep_expand_va_start
-#undef	TARGET_GIMPLIFY_VA_ARG_EXPR
-#define	TARGET_GIMPLIFY_VA_ARG_EXPR	mep_gimplify_va_arg_expr
-#undef  TARGET_CAN_ELIMINATE
-#define TARGET_CAN_ELIMINATE            mep_can_eliminate
-#undef  TARGET_TRAMPOLINE_INIT
-#define TARGET_TRAMPOLINE_INIT		mep_trampoline_init
-
-struct gcc_target targetm = TARGET_INITIALIZER;
-
 #define WANT_GCC_DEFINITIONS
 #include "mep-intrin.h"
 #undef WANT_GCC_DEFINITIONS
 
 
 /* Command Line Option Support.  */
@@ -4299,12 +4220,36 @@  note_unused_pragma_disinterrupt (void **
 void
 mep_file_cleanups (void)
 {
   if (pragma_htab)
     htab_traverse (pragma_htab, note_unused_pragma_disinterrupt, NULL);
 }
+
+/* These three functions provide a bridge between the pramgas that
+   affect register classes, and the functions that maintain them.  We
+   can't call those functions directly as pragma handling is part of
+   the front end and doesn't have direct access to them.  */
+
+void
+mep_save_register_info (void)
+{
+  save_register_info ();
+}
+
+void
+mep_reinit_regs (void)
+{
+  reinit_regs ();
+}
+
+void
+mep_init_regs (void)
+{
+  init_regs ();
+}
+
      
 
 static int
 mep_attrlist_to_encoding (tree list, tree decl)
 {
   if (mep_multiple_address_regions (list, false) > 1)
@@ -5626,13 +5571,13 @@  mep_invert_branch (rtx insn, rtx after)
   gcc_assert (i >= 0);
 }
 
 static void
 mep_reorg_erepeat (rtx insns)
 {
-  rtx insn, prev, label_before, l, x;
+  rtx insn, prev, l, x;
   int count;
 
   for (insn = insns; insn; insn = NEXT_INSN (insn))
     if (JUMP_P (insn)
 	&& ! JUMP_TABLE_DATA_P (insn)
 	&& mep_invertable_branch_p (insn))
@@ -5641,13 +5586,12 @@  mep_reorg_erepeat (rtx insns)
 	  {
 	    fprintf (dump_file, "\n------------------------------\n");
 	    fprintf (dump_file, "erepeat: considering this jump:\n");
 	    print_rtl_single (dump_file, insn);
 	  }
 	count = simplejump_p (insn) ? 0 : 1;
-	label_before = 0;
 	for (prev = PREV_INSN (insn); prev; prev = PREV_INSN (prev))
 	  {
 	    if (GET_CODE (prev) == CALL_INSN
 		|| BARRIER_P (prev))
 	      break;
 
@@ -5730,14 +5674,12 @@  mep_reorg_erepeat (rtx insns)
 			   safe, INSN_UID (prev));
 	      }
 
 	    if (INSN_P (prev))
 	      {
 		count ++;
-		if (count == 2)
-		  label_before = prev;
 	      }
 	  }
       }
   if (dump_file)
     fprintf (dump_file, "\n==============================\n");
 }
@@ -6329,13 +6271,12 @@  mep_expand_builtin (tree exp, rtx target
   tree fndecl, args;
   unsigned int n_args;
   tree fnname;
   const struct cgen_insn *cgen_insn;
   const struct insn_data_d *idata;
   unsigned int first_arg = 0;
-  tree return_type = void_type_node;
   unsigned int builtin_n_args;
 
   fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
   fnname = DECL_NAME (fndecl);
 
   /* Find out which instruction we should emit.  Note that some coprocessor
@@ -6351,13 +6292,13 @@  mep_expand_builtin (tree exp, rtx target
 
   if (cgen_insn->cret_p)
     {
       if (cgen_insn->cret_p > 1)
 	builtin_n_args ++;
       first_arg = 1;
-      return_type = mep_cgen_regnum_to_type (cgen_insn->regnums[0].type);
+      mep_cgen_regnum_to_type (cgen_insn->regnums[0].type);
       builtin_n_args --;
     }
 
   /* Evaluate each argument.  */
   n_args = call_expr_nargs (exp);
 
@@ -7412,8 +7353,85 @@  mep_asm_init_sections (void)
 
   ftext_section
     = get_unnamed_section (SECTION_CODE, output_section_asm_op,
 			   "\t.section .ftext,\"ax\"\n\t.core");
 
 }
+
+/* Initialize the GCC target structure.  */
+
+#undef  TARGET_ASM_FUNCTION_PROLOGUE
+#define TARGET_ASM_FUNCTION_PROLOGUE	mep_start_function
+#undef  TARGET_ATTRIBUTE_TABLE
+#define TARGET_ATTRIBUTE_TABLE		mep_attribute_table
+#undef  TARGET_COMP_TYPE_ATTRIBUTES
+#define TARGET_COMP_TYPE_ATTRIBUTES	mep_comp_type_attributes
+#undef  TARGET_INSERT_ATTRIBUTES
+#define TARGET_INSERT_ATTRIBUTES	mep_insert_attributes
+#undef  TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P
+#define TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P	mep_function_attribute_inlinable_p
+#undef  TARGET_CAN_INLINE_P
+#define TARGET_CAN_INLINE_P		mep_can_inline_p
+#undef  TARGET_SECTION_TYPE_FLAGS
+#define TARGET_SECTION_TYPE_FLAGS	mep_section_type_flags
+#undef  TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION	mep_asm_named_section
+#undef  TARGET_INIT_BUILTINS
+#define TARGET_INIT_BUILTINS		mep_init_builtins
+#undef  TARGET_EXPAND_BUILTIN
+#define TARGET_EXPAND_BUILTIN		mep_expand_builtin
+#undef  TARGET_SCHED_ADJUST_COST
+#define TARGET_SCHED_ADJUST_COST	mep_adjust_cost
+#undef  TARGET_SCHED_ISSUE_RATE
+#define TARGET_SCHED_ISSUE_RATE		mep_issue_rate
+#undef  TARGET_SCHED_REORDER
+#define TARGET_SCHED_REORDER		mep_sched_reorder
+#undef  TARGET_STRIP_NAME_ENCODING
+#define TARGET_STRIP_NAME_ENCODING	mep_strip_name_encoding
+#undef  TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION	mep_select_section
+#undef  TARGET_ASM_UNIQUE_SECTION
+#define TARGET_ASM_UNIQUE_SECTION	mep_unique_section
+#undef  TARGET_ENCODE_SECTION_INFO
+#define TARGET_ENCODE_SECTION_INFO	mep_encode_section_info
+#undef  TARGET_FUNCTION_OK_FOR_SIBCALL
+#define TARGET_FUNCTION_OK_FOR_SIBCALL	mep_function_ok_for_sibcall
+#undef  TARGET_RTX_COSTS
+#define TARGET_RTX_COSTS		mep_rtx_cost
+#undef  TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST 		mep_address_cost
+#undef  TARGET_MACHINE_DEPENDENT_REORG
+#define TARGET_MACHINE_DEPENDENT_REORG  mep_reorg
+#undef  TARGET_SETUP_INCOMING_VARARGS
+#define TARGET_SETUP_INCOMING_VARARGS	mep_setup_incoming_varargs
+#undef  TARGET_PASS_BY_REFERENCE
+#define TARGET_PASS_BY_REFERENCE        mep_pass_by_reference
+#undef  TARGET_VECTOR_MODE_SUPPORTED_P
+#define TARGET_VECTOR_MODE_SUPPORTED_P	mep_vector_mode_supported_p
+#undef  TARGET_HANDLE_OPTION
+#define TARGET_HANDLE_OPTION            mep_handle_option
+#undef  TARGET_DEFAULT_TARGET_FLAGS
+#define TARGET_DEFAULT_TARGET_FLAGS	TARGET_DEFAULT
+#undef  TARGET_ALLOCATE_INITIAL_VALUE
+#define TARGET_ALLOCATE_INITIAL_VALUE   mep_allocate_initial_value
+#undef  TARGET_ASM_INIT_SECTIONS
+#define TARGET_ASM_INIT_SECTIONS 	mep_asm_init_sections
+#undef  TARGET_RETURN_IN_MEMORY
+#define TARGET_RETURN_IN_MEMORY		mep_return_in_memory
+#undef  TARGET_NARROW_VOLATILE_BITFIELD
+#define TARGET_NARROW_VOLATILE_BITFIELD mep_narrow_volatile_bitfield
+#undef	TARGET_EXPAND_BUILTIN_SAVEREGS
+#define	TARGET_EXPAND_BUILTIN_SAVEREGS	mep_expand_builtin_saveregs
+#undef  TARGET_BUILD_BUILTIN_VA_LIST
+#define TARGET_BUILD_BUILTIN_VA_LIST	mep_build_builtin_va_list
+#undef  TARGET_EXPAND_BUILTIN_VA_START
+#define TARGET_EXPAND_BUILTIN_VA_START	mep_expand_va_start
+#undef	TARGET_GIMPLIFY_VA_ARG_EXPR
+#define	TARGET_GIMPLIFY_VA_ARG_EXPR	mep_gimplify_va_arg_expr
+#undef  TARGET_CAN_ELIMINATE
+#define TARGET_CAN_ELIMINATE            mep_can_eliminate
+#undef  TARGET_TRAMPOLINE_INIT
+#define TARGET_TRAMPOLINE_INIT		mep_trampoline_init
+
+struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-mep.h"
Index: config/mep/mep-pragma.c
===================================================================
--- config/mep/mep-pragma.c	(revision 164267)
+++ config/mep/mep-pragma.c	(working copy)
@@ -21,13 +21,12 @@  along with GCC; see the file COPYING3.  
 #include <stdio.h>
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
-#include "rtl.h"
 #include "diagnostic-core.h"
 #include "toplev.h"
 #include "c-family/c-pragma.h"
 #include "cpplib.h"
 #include "hard-reg-set.h"
 #include "output.h"
@@ -36,12 +35,20 @@  along with GCC; see the file COPYING3.  
 #define MAX_RECOG_OPERANDS 10
 #include "reload.h"
 #include "target.h"
 
 enum cw_which { CW_AVAILABLE, CW_CALL_SAVED };
 
+/* This is normally provided by rtl.h but we can't include that file
+   here.  It's safe to copy the definition here because we're only
+   using it internally; the value isn't passed to functions outside
+   this file.  */
+#ifndef INVALID_REGNUM
+#define INVALID_REGNUM                    (~(unsigned int) 0)
+#endif
+
 static enum cpp_ttype
 mep_pragma_lex (tree *valp)
 {
   enum cpp_ttype t = pragma_lex (valp);
   if (t == CPP_EOF)
     t = CPP_PRAGMA_EOL;
@@ -198,14 +205,14 @@  mep_pragma_coprocessor_which (enum cw_wh
 
     default:
       gcc_unreachable ();
     }
 
   /* Fix up register class hierarchy.  */
-  save_register_info ();
-  reinit_regs ();
+  mep_save_register_info ();
+  mep_reinit_regs ();
 
   if (cfun == 0)
     {
       init_dummy_function_start ();
       init_caller_save ();
       expand_dummy_function_end ();
@@ -260,26 +267,40 @@  static void
 mep_pragma_coprocessor_subclass (void)
 {
   tree val;
   enum cpp_ttype type;
   HARD_REG_SET set;
   int class_letter;
-  enum reg_class class;
+  enum reg_class rclass;
 
   type = mep_pragma_lex (&val);
   if (type != CPP_CHAR)
     goto syntax_error;
   class_letter = tree_low_cst (val, 1);
   if (class_letter >= 'A' && class_letter <= 'D')
-    class = class_letter - 'A' + USER0_REGS;
+    switch (class_letter)
+      {
+      case 'A':
+	rclass = USER0_REGS;
+	break;
+      case 'B':
+	rclass = USER1_REGS;
+	break;
+      case 'C':
+	rclass = USER2_REGS;
+	break;
+      case 'D':
+	rclass = USER3_REGS;
+	break;
+      }
   else
     {
       error ("#pragma GCC coprocessor subclass letter must be in [ABCD]");
       return;
     }
-  if (reg_class_size[class] > 0)
+  if (reg_class_size[rclass] > 0)
     {
       error ("#pragma GCC coprocessor subclass '%c' already defined",
 	     class_letter);
       return;
     }
 
@@ -288,14 +309,14 @@  mep_pragma_coprocessor_subclass (void)
     goto syntax_error;
 
   if (! parse_cr_set (&set))
     return;
 
   /* Fix up register class hierarchy.  */
-  COPY_HARD_REG_SET (reg_class_contents[class], set);
-  init_regs ();
+  COPY_HARD_REG_SET (reg_class_contents[rclass], set);
+  mep_init_regs ();
   return;
 
  syntax_error:
   error ("malformed #pragma GCC coprocessor subclass");
 }