From c28883e6412287f04b901e6035ac7c2ff81cc4f6 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Tue, 14 Sep 2010 03:26:54 -0400 Subject: [PATCH] re PR target/44749 (mep-elf fails to build) 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. From-SVN: r164268 --- gcc/ChangeLog | 19 +++++ gcc/config/mep/mep-pragma.c | 37 +++++++-- gcc/config/mep/mep-protos.h | 8 ++ gcc/config/mep/mep.c | 188 ++++++++++++++++++++++++-------------------- 4 files changed, 159 insertions(+), 93 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a33cba7..8a42db2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,22 @@ +2010-09-14 DJ Delorie + + 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. + 2010-09-13 Joseph Myers PR target/44749 diff --git a/gcc/config/mep/mep-pragma.c b/gcc/config/mep/mep-pragma.c index ac70449..1c9651a 100644 --- a/gcc/config/mep/mep-pragma.c +++ b/gcc/config/mep/mep-pragma.c @@ -24,7 +24,6 @@ along with GCC; see the file COPYING3. If not see #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" @@ -39,6 +38,14 @@ along with GCC; see the file COPYING3. If not see 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) { @@ -201,8 +208,8 @@ mep_pragma_coprocessor_which (enum cw_which cw_which) } /* Fix up register class hierarchy. */ - save_register_info (); - reinit_regs (); + mep_save_register_info (); + mep_reinit_regs (); if (cfun == 0) { @@ -263,20 +270,34 @@ mep_pragma_coprocessor_subclass (void) 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); @@ -291,8 +312,8 @@ mep_pragma_coprocessor_subclass (void) 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: diff --git a/gcc/config/mep/mep-protos.h b/gcc/config/mep/mep-protos.h index 44699f7..ed8facd 100644 --- a/gcc/config/mep/mep-protos.h +++ b/gcc/config/mep/mep-protos.h @@ -108,6 +108,14 @@ 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); diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c index 50edeff..7fdb538 100644 --- a/gcc/config/mep/mep.c +++ b/gcc/config/mep/mep.c @@ -122,8 +122,6 @@ struct GTY(()) machine_function #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; @@ -231,83 +229,6 @@ 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 @@ -4302,6 +4223,30 @@ 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 @@ -5629,7 +5574,7 @@ mep_invert_branch (rtx insn, rtx after) 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)) @@ -5644,7 +5589,6 @@ mep_reorg_erepeat (rtx insns) 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 @@ -5733,8 +5677,6 @@ mep_reorg_erepeat (rtx insns) if (INSN_P (prev)) { count ++; - if (count == 2) - label_before = prev; } } } @@ -6332,7 +6274,6 @@ mep_expand_builtin (tree exp, rtx target ATTRIBUTE_UNUSED, 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); @@ -6354,7 +6295,7 @@ mep_expand_builtin (tree exp, rtx target ATTRIBUTE_UNUSED, 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 --; } @@ -7415,5 +7356,82 @@ mep_asm_init_sections (void) "\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" -- 2.7.4