From 1bee9a0e3d326ce4412af1ecd688f53305f0ca0b Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 11 Apr 2016 14:19:54 -0400 Subject: [PATCH 59/91] FIXME: consolidate singletons; enables pass 'vregs' to work --- gcc/read-rtl.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c index 78e3f70..177092e 100644 --- a/gcc/read-rtl.c +++ b/gcc/read-rtl.c @@ -1809,6 +1809,62 @@ read_rtx_code (const char *code_name) return return_rtx; } +#ifndef GENERATOR_FILE + +/* When running in the RTL frontend, we must consolidate some + rtx so that we use singletons where singletons are expected + (e.g. we don't want multiple "(const_int 0 [0])" rtx, since + these are tested via pointer equality against const0_rtx. */ + +static rtx +consolidate_singletons (rtx x) +{ + if (!x) + return x; + + if (GET_CODE (x) == CONST_INT) + if (INTVAL (x) == 0) + return const0_rtx; + + if (GET_CODE (x) == REG) + { + unsigned int regno = REGNO (x); + /* FIXME: do we need to check for Pmode? */ + switch (regno) + { + case STACK_POINTER_REGNUM: + return stack_pointer_rtx; + case FRAME_POINTER_REGNUM: + return frame_pointer_rtx; + case HARD_FRAME_POINTER_REGNUM: + return hard_frame_pointer_rtx; + case ARG_POINTER_REGNUM: + return arg_pointer_rtx; + case VIRTUAL_INCOMING_ARGS_REGNUM: + return virtual_incoming_args_rtx; + case VIRTUAL_STACK_VARS_REGNUM: + return virtual_stack_vars_rtx; + case VIRTUAL_STACK_DYNAMIC_REGNUM: + return virtual_stack_dynamic_rtx; + case VIRTUAL_OUTGOING_ARGS_REGNUM: + return virtual_outgoing_args_rtx; + case VIRTUAL_CFA_REGNUM: + return virtual_cfa_rtx; + case VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM: + return virtual_preferred_stack_boundary_rtx; +#ifdef RETURN_ADDRESS_POINTER_REGNUM + case RETURN_ADDRESS_POINTER_REGNUM: + return return_address_pointer_rtx; +#endif + } + } + + return x; +} + +#endif /* #ifndef GENERATOR_FILE */ + + /* Read a nested rtx construct from the MD file and return it. */ static rtx @@ -1828,14 +1884,7 @@ read_nested_rtx (void) require_char_ws (')'); #ifndef GENERATOR_FILE - /* When running in the RTL frontend, we must consolidate some - rtx so that we use singletons where singletons are expected - (e.g. we don't want multiple "(const_int 0 [0])" rtx, since - these are tested via pointer equality against const0_rtx. */ - if (return_rtx) - if (GET_CODE (return_rtx) == CONST_INT) - if (INTVAL (return_rtx) == 0) - return const0_rtx; + return_rtx = consolidate_singletons (return_rtx); #endif /* #ifndef GENERATOR_FILE */ return return_rtx; -- 1.8.5.3