Mercurial > hg > CbC > CbC_gcc
diff gcc/config/moxie/moxie.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
line wrap: on
line diff
--- a/gcc/config/moxie/moxie.c Sun Aug 21 07:07:55 2011 +0900 +++ b/gcc/config/moxie/moxie.c Fri Oct 27 22:46:09 2017 +0900 @@ -1,5 +1,5 @@ /* Target Code for moxie - Copyright (C) 2008, 2009, 2010 Free Software Foundation + Copyright (C) 2008-2017 Free Software Foundation, Inc. Contributed by Anthony Green. This file is part of GCC. @@ -21,31 +21,26 @@ #include "config.h" #include "system.h" #include "coretypes.h" -#include "tm.h" +#include "backend.h" +#include "target.h" #include "rtl.h" +#include "tree.h" +#include "stringpool.h" +#include "attribs.h" +#include "df.h" #include "regs.h" -#include "hard-reg-set.h" -#include "insn-config.h" -#include "conditions.h" -#include "insn-flags.h" -#include "output.h" -#include "insn-attr.h" -#include "flags.h" -#include "recog.h" -#include "reload.h" +#include "memmodel.h" +#include "emit-rtl.h" #include "diagnostic-core.h" -#include "obstack.h" -#include "tree.h" +#include "output.h" +#include "stor-layout.h" +#include "varasm.h" +#include "calls.h" #include "expr.h" -#include "optabs.h" -#include "except.h" -#include "function.h" -#include "ggc.h" -#include "target.h" +#include "builtins.h" + +/* This file should be included last. */ #include "target-def.h" -#include "tm_p.h" -#include "langhooks.h" -#include "df.h" #define LOSE_AND_RETURN(msgid, x) \ do \ @@ -83,7 +78,7 @@ We always return values in register $r0 for moxie. */ static rtx -moxie_libcall_value (enum machine_mode mode, +moxie_libcall_value (machine_mode mode, const_rtx fun ATTRIBUTE_UNUSED) { return gen_rtx_REG (mode, MOXIE_R0); @@ -113,8 +108,8 @@ /* The PRINT_OPERAND_ADDRESS worker. */ -void -moxie_print_operand_address (FILE *file, rtx x) +static void +moxie_print_operand_address (FILE *file, machine_mode, rtx x) { switch (GET_CODE (x)) { @@ -160,7 +155,7 @@ /* The PRINT_OPERAND worker. */ -void +static void moxie_print_operand (FILE *file, rtx x, int code) { rtx operand = x; @@ -191,7 +186,7 @@ return; case MEM: - output_address (XEXP (operand, 0)); + output_address (GET_MODE (XEXP (operand, 0)), XEXP (operand, 0)); return; default: @@ -226,17 +221,20 @@ static struct machine_function * moxie_init_machine_status (void) { - return ggc_alloc_cleared_machine_function (); + return ggc_cleared_alloc<machine_function> (); } -/* The TARGET_OPTION_OVERRIDE worker. - All this curently does is set init_machine_status. */ +/* The TARGET_OPTION_OVERRIDE worker. */ static void moxie_option_override (void) { /* Set the per-function-data initializer. */ init_machine_status = moxie_init_machine_status; + +#ifdef TARGET_MOXIEBOX + target_flags |= MASK_HAS_MULX; +#endif } /* Compute the size of the local area and the size to be adjusted by the @@ -281,6 +279,9 @@ moxie_compute_frame (); + if (flag_stack_usage_info) + current_function_static_stack_size = cfun->machine->size_for_adjusting_sp; + /* Save callee-saved registers. */ for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) { @@ -293,8 +294,8 @@ if (cfun->machine->size_for_adjusting_sp > 0) { - int i = cfun->machine->size_for_adjusting_sp; - while (i > 255) + int i = cfun->machine->size_for_adjusting_sp; + while ((i >= 255) && (i <= 510)) { insn = emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx, @@ -302,13 +303,23 @@ RTX_FRAME_RELATED_P (insn) = 1; i -= 255; } - if (i > 0) + if (i <= 255) { insn = emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx, GEN_INT (i))); RTX_FRAME_RELATED_P (insn) = 1; } + else + { + rtx reg = gen_rtx_REG (SImode, MOXIE_R12); + insn = emit_move_insn (reg, GEN_INT (i)); + RTX_FRAME_RELATED_P (insn) = 1; + insn = emit_insn (gen_subsi3 (stack_pointer_rtx, + stack_pointer_rtx, + reg)); + RTX_FRAME_RELATED_P (insn) = 1; + } } } @@ -320,7 +331,7 @@ if (cfun->machine->callee_saved_reg_size != 0) { - reg = gen_rtx_REG (Pmode, MOXIE_R5); + reg = gen_rtx_REG (Pmode, MOXIE_R12); if (cfun->machine->callee_saved_reg_size <= 255) { emit_move_insn (reg, hard_frame_pointer_rtx); @@ -370,11 +381,12 @@ /* Worker function for TARGET_SETUP_INCOMING_VARARGS. */ static void -moxie_setup_incoming_varargs (CUMULATIVE_ARGS *cum, - enum machine_mode mode ATTRIBUTE_UNUSED, +moxie_setup_incoming_varargs (cumulative_args_t cum_v, + machine_mode mode ATTRIBUTE_UNUSED, tree type ATTRIBUTE_UNUSED, int *pretend_size, int no_rtl) { + CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); int regno; int regs = 8 - *cum; @@ -409,10 +421,12 @@ NULL_RTX if there's no more space. */ static rtx -moxie_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, +moxie_function_arg (cumulative_args_t cum_v, machine_mode mode, const_tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED) { + CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); + if (*cum < 8) return gen_rtx_REG (mode, *cum); else @@ -424,9 +438,11 @@ : (unsigned) int_size_in_bytes (TYPE)) static void -moxie_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode, +moxie_function_arg_advance (cumulative_args_t cum_v, machine_mode mode, const_tree type, bool named ATTRIBUTE_UNUSED) { + CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); + *cum = (*cum < MOXIE_R6 ? *cum + ((3 + MOXIE_FUNCTION_ARG_SIZE (mode, type)) / 4) : *cum); @@ -436,8 +452,8 @@ passed by reference. */ static bool -moxie_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED, - enum machine_mode mode, const_tree type, +moxie_pass_by_reference (cumulative_args_t cum ATTRIBUTE_UNUSED, + machine_mode mode, const_tree type, bool named ATTRIBUTE_UNUSED) { unsigned HOST_WIDE_INT size; @@ -459,16 +475,17 @@ that fit in argument passing registers. */ static int -moxie_arg_partial_bytes (CUMULATIVE_ARGS *cum, - enum machine_mode mode, +moxie_arg_partial_bytes (cumulative_args_t cum_v, + machine_mode mode, tree type, bool named) { + CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); int bytes_left, size; if (*cum >= 8) return 0; - if (moxie_pass_by_reference (cum, mode, type, named)) + if (moxie_pass_by_reference (cum_v, mode, type, named)) size = 4; else if (type) { @@ -490,17 +507,14 @@ /* Worker function for TARGET_STATIC_CHAIN. */ static rtx -moxie_static_chain (const_tree fndecl, bool incoming_p) +moxie_static_chain (const_tree ARG_UNUSED (fndecl_or_type), bool incoming_p) { rtx addr, mem; - if (!DECL_STATIC_CHAIN (fndecl)) - return NULL; - if (incoming_p) - addr = plus_constant (arg_pointer_rtx, 2 * UNITS_PER_WORD); + addr = plus_constant (Pmode, arg_pointer_rtx, 2 * UNITS_PER_WORD); else - addr = plus_constant (stack_pointer_rtx, -UNITS_PER_WORD); + addr = plus_constant (Pmode, stack_pointer_rtx, -UNITS_PER_WORD); mem = gen_rtx_MEM (Pmode, addr); MEM_NOTRAP_P (mem) = 1; @@ -517,7 +531,6 @@ fprintf (f, "\tldi.l $r0, 0x0\n"); fprintf (f, "\tsto.l 0x8($fp), $r0\n"); fprintf (f, "\tpop $sp, $r0\n"); - fprintf (f, "\tnop\n"); fprintf (f, "\tjmpa 0x0\n"); } @@ -533,10 +546,67 @@ mem = adjust_address (m_tramp, SImode, 4); emit_move_insn (mem, chain_value); - mem = adjust_address (m_tramp, SImode, 20); + mem = adjust_address (m_tramp, SImode, 16); emit_move_insn (mem, fnaddr); } +/* Return true for memory offset addresses between -32768 and 32767. */ +bool +moxie_offset_address_p (rtx x) +{ + x = XEXP (x, 0); + + if (GET_CODE (x) == PLUS) + { + x = XEXP (x, 1); + if (GET_CODE (x) == CONST_INT) + { + unsigned int v = INTVAL (x) & 0xFFFF8000; + return (v == 0xFFFF8000 || v == 0x00000000); + } + } + return 0; +} + +/* Helper function for `moxie_legitimate_address_p'. */ + +static bool +moxie_reg_ok_for_base_p (const_rtx reg, bool strict_p) +{ + int regno = REGNO (reg); + + if (strict_p) + return HARD_REGNO_OK_FOR_BASE_P (regno) + || HARD_REGNO_OK_FOR_BASE_P (reg_renumber[regno]); + else + return !HARD_REGISTER_NUM_P (regno) + || HARD_REGNO_OK_FOR_BASE_P (regno); +} + +/* Worker function for TARGET_LEGITIMATE_ADDRESS_P. */ + +static bool +moxie_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED, + rtx x, bool strict_p, + addr_space_t as) +{ + gcc_assert (ADDR_SPACE_GENERIC_P (as)); + + if (GET_CODE(x) == PLUS + && REG_P (XEXP (x, 0)) + && moxie_reg_ok_for_base_p (XEXP (x, 0), strict_p) + && CONST_INT_P (XEXP (x, 1)) + && IN_RANGE (INTVAL (XEXP (x, 1)), -32768, 32767)) + return true; + if (REG_P (x) && moxie_reg_ok_for_base_p (x, strict_p)) + return true; + if (GET_CODE (x) == SYMBOL_REF + || GET_CODE (x) == LABEL_REF + || GET_CODE (x) == CONST) + return true; + return false; +} + /* The Global `targetm' Variable. */ /* Initialize the GCC target structure. */ @@ -557,6 +627,11 @@ #undef TARGET_FUNCTION_ARG_ADVANCE #define TARGET_FUNCTION_ARG_ADVANCE moxie_function_arg_advance +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + +#undef TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P +#define TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P moxie_legitimate_address_p #undef TARGET_SETUP_INCOMING_VARARGS #define TARGET_SETUP_INCOMING_VARARGS moxie_setup_incoming_varargs @@ -566,7 +641,7 @@ /* Define this to return an RTX representing the place where a function returns or receives a value of data type RET_TYPE, a tree - node node representing a data type. */ + node representing a data type. */ #undef TARGET_FUNCTION_VALUE #define TARGET_FUNCTION_VALUE moxie_function_value #undef TARGET_LIBCALL_VALUE @@ -587,6 +662,14 @@ #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE moxie_option_override +#undef TARGET_PRINT_OPERAND +#define TARGET_PRINT_OPERAND moxie_print_operand +#undef TARGET_PRINT_OPERAND_ADDRESS +#define TARGET_PRINT_OPERAND_ADDRESS moxie_print_operand_address + +#undef TARGET_CONSTANT_ALIGNMENT +#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-moxie.h"