From e4942929dd38ec1a09e147d3de11f3058088451e Mon Sep 17 00:00:00 2001 From: Paul Koning Date: Sun, 21 Nov 2010 11:52:36 -0500 Subject: pdp11.c (pdp11_legitimate_address_p): New function. * config/mips/pdp11.c (pdp11_legitimate_address_p): New function. * config/mips/pdp11.h (GO_IF_LEGITIMATE_ADDRESS): Delete. From-SVN: r167005 --- gcc/ChangeLog | 5 +++ gcc/config/pdp11/pdp11.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++- gcc/config/pdp11/pdp11.h | 112 ---------------------------------------------- 3 files changed, 118 insertions(+), 113 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9ed55ab..09544e1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-11-21 Paul Koning + + * config/mips/pdp11.c (pdp11_legitimate_address_p): New function. + * config/mips/pdp11.h (GO_IF_LEGITIMATE_ADDRESS): Delete. + 2010-11-21 Eric Botcazou * config/mips/mips.c (machine_function): Rename load_label_length to diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index 617a7f5..0188dc0 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -227,6 +227,9 @@ static const struct default_options pdp11_option_optimization_table[] = #undef TARGET_PREFERRED_OUTPUT_RELOAD_CLASS #define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS pdp11_preferred_output_reload_class + +#undef TARGET_LEGITIMATE_ADDRESS_P +#define TARGET_LEGITIMATE_ADDRESS_P pdp11_legitimate_address_p /* Implement TARGET_HANDLE_OPTION. */ @@ -1706,6 +1709,115 @@ pdp11_secondary_memory_needed (reg_class_t c1, reg_class_t c2, return (fromfloat != tofloat); } +/* TARGET_LEGITIMATE_ADDRESS_P recognizes an RTL expression + that is a valid memory address for an instruction. + The MODE argument is the machine mode for the MEM expression + that wants to use this address. + +*/ + +static bool +pdp11_legitimate_address_p (enum machine_mode mode, + rtx operand, bool strict) +{ + rtx xfoob; + + /* accept @#address */ + if (CONSTANT_ADDRESS_P (operand)) + return true; + + switch (GET_CODE (operand)) + { + case REG: + /* accept (R0) */ + return !strict || REGNO_OK_FOR_BASE_P (REGNO (operand)); + + case PLUS: + /* accept X(R0) */ + return GET_CODE (XEXP (operand, 0)) == REG + && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (operand, 0)))) + && CONSTANT_ADDRESS_P (XEXP (operand, 1)); + + case PRE_DEC: + /* accept -(R0) */ + return GET_CODE (XEXP (operand, 0)) == REG + && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (operand, 0)))); + + case POST_INC: + /* accept (R0)+ */ + return GET_CODE (XEXP (operand, 0)) == REG + && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (operand, 0)))); + + case PRE_MODIFY: + /* accept -(SP) -- which uses PRE_MODIFY for byte mode */ + return GET_CODE (XEXP (operand, 0)) == REG + && REGNO (XEXP (operand, 0)) == STACK_POINTER_REGNUM + && GET_CODE ((xfoob = XEXP (operand, 1))) == PLUS + && GET_CODE (XEXP (xfoob, 0)) == REG + && REGNO (XEXP (xfoob, 0)) == STACK_POINTER_REGNUM + && CONSTANT_P (XEXP (xfoob, 1)) + && INTVAL (XEXP (xfoob,1)) == -2; + + case POST_MODIFY: + /* accept (SP)+ -- which uses POST_MODIFY for byte mode */ + return GET_CODE (XEXP (operand, 0)) == REG + && REGNO (XEXP (operand, 0)) == STACK_POINTER_REGNUM + && GET_CODE ((xfoob = XEXP (operand, 1))) == PLUS + && GET_CODE (XEXP (xfoob, 0)) == REG + && REGNO (XEXP (xfoob, 0)) == STACK_POINTER_REGNUM + && CONSTANT_P (XEXP (xfoob, 1)) + && INTVAL (XEXP (xfoob,1)) == 2; + + case MEM: + /* handle another level of indirection ! */ + xfoob = XEXP (operand, 0); + + /* (MEM:xx (MEM:xx ())) is not valid for SI, DI and currently + also forbidden for float, because we have to handle this + in output_move_double and/or output_move_quad() - we could + do it, but currently it's not worth it!!! + now that DFmode cannot go into CPU register file, + maybe I should allow float ... + but then I have to handle memory-to-memory moves in movdf ?? */ + if (GET_MODE_BITSIZE(mode) > 16) + return false; + + /* accept @address */ + if (CONSTANT_ADDRESS_P (xfoob)) + return true; + + switch (GET_CODE (xfoob)) + { + case REG: + /* accept @(R0) - which is @0(R0) */ + return !strict || REGNO_OK_FOR_BASE_P(REGNO (xfoob)); + + case PLUS: + /* accept @X(R0) */ + return GET_CODE (XEXP (xfoob, 0)) == REG + && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (xfoob, 0)))) + && CONSTANT_ADDRESS_P (XEXP (xfoob, 1)); + + case PRE_DEC: + /* accept @-(R0) */ + return GET_CODE (XEXP (xfoob, 0)) == REG + && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (xfoob, 0)))); + + case POST_INC: + /* accept @(R0)+ */ + return GET_CODE (XEXP (xfoob, 0)) == REG + && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (xfoob, 0)))); + + default: + /* anything else is invalid */ + return false; + } + + default: + /* anything else is invalid */ + return false; + } +} /* Return the class number of the smallest class containing reg number REGNO. */ enum reg_class @@ -1919,7 +2031,7 @@ pdp11_libcall_value (enum machine_mode mode, static bool pdp11_function_value_regno_p (const unsigned int regno) { - return (regno == 0) || (TARGET_AC0 && (regno == 8)); + return (regno == RETVAL_REGNUM) || (TARGET_AC0 && (regno == AC0_REGNUM)); } /* Worker function for TARGET_TRAMPOLINE_INIT. diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h index 2d06b7d..b5c6449 100644 --- a/gcc/config/pdp11/pdp11.h +++ b/gcc/config/pdp11/pdp11.h @@ -500,118 +500,6 @@ extern int may_call_alloca; #endif -/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression - that is a valid memory address for an instruction. - The MODE argument is the machine mode for the MEM expression - that wants to use this address. - -*/ - -#define GO_IF_LEGITIMATE_ADDRESS(mode, operand, ADDR) \ -{ \ - rtx xfoob; \ - \ - /* accept (R0) */ \ - if (GET_CODE (operand) == REG \ - && REG_OK_FOR_BASE_P(operand)) \ - goto ADDR; \ - \ - /* accept @#address */ \ - if (CONSTANT_ADDRESS_P (operand)) \ - goto ADDR; \ - \ - /* accept X(R0) */ \ - if (GET_CODE (operand) == PLUS \ - && GET_CODE (XEXP (operand, 0)) == REG \ - && REG_OK_FOR_BASE_P (XEXP (operand, 0)) \ - && CONSTANT_ADDRESS_P (XEXP (operand, 1))) \ - goto ADDR; \ - \ - /* accept -(R0) */ \ - if (GET_CODE (operand) == PRE_DEC \ - && GET_CODE (XEXP (operand, 0)) == REG \ - && REG_OK_FOR_BASE_P (XEXP (operand, 0))) \ - goto ADDR; \ - \ - /* accept (R0)+ */ \ - if (GET_CODE (operand) == POST_INC \ - && GET_CODE (XEXP (operand, 0)) == REG \ - && REG_OK_FOR_BASE_P (XEXP (operand, 0))) \ - goto ADDR; \ - \ - /* accept -(SP) -- which uses PRE_MODIFY for byte mode */ \ - if (GET_CODE (operand) == PRE_MODIFY \ - && GET_CODE (XEXP (operand, 0)) == REG \ - && REGNO (XEXP (operand, 0)) == STACK_POINTER_REGNUM \ - && GET_CODE ((xfoob = XEXP (operand, 1))) == PLUS \ - && GET_CODE (XEXP (xfoob, 0)) == REG \ - && REGNO (XEXP (xfoob, 0)) == STACK_POINTER_REGNUM \ - && CONSTANT_P (XEXP (xfoob, 1)) \ - && INTVAL (XEXP (xfoob,1)) == -2) \ - goto ADDR; \ - \ - /* accept (SP)+ -- which uses POST_MODIFY for byte mode */ \ - if (GET_CODE (operand) == POST_MODIFY \ - && GET_CODE (XEXP (operand, 0)) == REG \ - && REGNO (XEXP (operand, 0)) == STACK_POINTER_REGNUM \ - && GET_CODE ((xfoob = XEXP (operand, 1))) == PLUS \ - && GET_CODE (XEXP (xfoob, 0)) == REG \ - && REGNO (XEXP (xfoob, 0)) == STACK_POINTER_REGNUM \ - && CONSTANT_P (XEXP (xfoob, 1)) \ - && INTVAL (XEXP (xfoob,1)) == 2) \ - goto ADDR; \ - \ - \ - /* handle another level of indirection ! */ \ - if (GET_CODE(operand) != MEM) \ - goto fail; \ - \ - xfoob = XEXP (operand, 0); \ - \ - /* (MEM:xx (MEM:xx ())) is not valid for SI, DI and currently */ \ - /* also forbidden for float, because we have to handle this */ \ - /* in output_move_double and/or output_move_quad() - we could */ \ - /* do it, but currently it's not worth it!!! */ \ - /* now that DFmode cannot go into CPU register file, */ \ - /* maybe I should allow float ... */ \ - /* but then I have to handle memory-to-memory moves in movdf ?? */ \ - \ - if (GET_MODE_BITSIZE(mode) > 16) \ - goto fail; \ - \ - /* accept @(R0) - which is @0(R0) */ \ - if (GET_CODE (xfoob) == REG \ - && REG_OK_FOR_BASE_P(xfoob)) \ - goto ADDR; \ - \ - /* accept @address */ \ - if (CONSTANT_ADDRESS_P (xfoob)) \ - goto ADDR; \ - \ - /* accept @X(R0) */ \ - if (GET_CODE (xfoob) == PLUS \ - && GET_CODE (XEXP (xfoob, 0)) == REG \ - && REG_OK_FOR_BASE_P (XEXP (xfoob, 0)) \ - && CONSTANT_ADDRESS_P (XEXP (xfoob, 1))) \ - goto ADDR; \ - \ - /* accept @-(R0) */ \ - if (GET_CODE (xfoob) == PRE_DEC \ - && GET_CODE (XEXP (xfoob, 0)) == REG \ - && REG_OK_FOR_BASE_P (XEXP (xfoob, 0))) \ - goto ADDR; \ - \ - /* accept @(R0)+ */ \ - if (GET_CODE (xfoob) == POST_INC \ - && GET_CODE (XEXP (xfoob, 0)) == REG \ - && REG_OK_FOR_BASE_P (XEXP (xfoob, 0))) \ - goto ADDR; \ - \ - /* anything else is invalid */ \ - fail: ; \ -} - - /* Specify the machine mode that this machine uses for the index in the tablejump instruction. */ #define CASE_VECTOR_MODE HImode -- cgit v1.1