diff options
author | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-25 12:04:17 +0000 |
---|---|---|
committer | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-25 12:04:17 +0000 |
commit | d263732c915b08ccfb5ef155ed27a8671760dc91 (patch) | |
tree | 0fecbc9fb7d6fe74247aea9809ba392638ca87c6 /gcc/rtlhooks.c | |
parent | 25715f21635867d814cee580670af40bb5185be9 (diff) | |
download | gcc-d263732c915b08ccfb5ef155ed27a8671760dc91.tar.gz |
2004-05-25 Paolo Bonzini <bonzini@gnu.org>
* Makefile.in (OBJS): Add rtlhooks.o.
(rtlanal.o): Depend on function.h.
(cse.o): Depend on rtlhooks-def.h.
(combine.o): Depend on rtlhooks-def.h.
(rtlhooks.o): New rule.
* combine.c: Include rtlhooks-def.h.
(nonzero_bits, cached_nonzero_bits, nonzero_bits1,
num_sign_bit_copies, cached_num_sign_bit_copies,
num_sign_bit_copies1): Move most of the code to rtlanal.c.
(reg_nonzero_bits_for_combine,
reg_num_sign_bit_copies_for_combine): New functions holding
the remnants of the above.
(combine_rtl_hooks): New.
(combine_instructions): Set rtl_hooks instead of gen_lowpart.
* cse.c: Include rtlhooks-def.h.
(cse_rtl_hooks): New.
(cse_main): Set rtl_hooks instead of gen_lowpart.
* emit-rtl.c (gen_lowpart): Remove.
(gen_lowpart_general): Move to rtlhooks.c.
* rtl.h (nonzero_bits, num_sign_bit_copies,
struct rtl_hooks, rtl_hooks, general_rtl_hooks): New.
(gen_lowpart_general): Remove.
(gen_lowpart): Temporarily redefine as a macro.
* rtlanal.c: Include function.h.
(nonzero_bits, cached_nonzero_bits, nonzero_bits1,
num_sign_bit_copies, cached_num_sign_bit_copies,
num_sign_bit_copies1): New, from combine.c.
* rtlhooks.c: New file.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82234 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/rtlhooks.c')
-rw-r--r-- | gcc/rtlhooks.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/gcc/rtlhooks.c b/gcc/rtlhooks.c new file mode 100644 index 00000000000..b27cecea2ca --- /dev/null +++ b/gcc/rtlhooks.c @@ -0,0 +1,105 @@ +/* Generic hooks for the RTL middle-end. + Copyright (C) 2004 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "rtl.h" +#include "rtlhooks-def.h" +#include "expr.h" + + +/* For speed, we will copy the RTX hooks struct member-by-member + instead of doing indirect calls. For these reason, we initialize + *two* struct rtl_hooks globals: rtl_hooks is the one that is used + to actually call the hooks, while general_rtl_hooks is used + to restore the hooks by passes that modify them. */ + +const struct rtl_hooks general_rtl_hooks = RTL_HOOKS_INITIALIZER; +struct rtl_hooks rtl_hooks = RTL_HOOKS_INITIALIZER; + +rtx +gen_lowpart_general (enum machine_mode mode, rtx x) +{ + rtx result = gen_lowpart_common (mode, x); + + if (result) + return result; + else if (GET_CODE (x) == REG) + { + /* Must be a hard reg that's not valid in MODE. */ + result = gen_lowpart_common (mode, copy_to_reg (x)); + if (result == 0) + abort (); + return result; + } + else if (GET_CODE (x) == MEM) + { + /* The only additional case we can do is MEM. */ + int offset = 0; + + /* The following exposes the use of "x" to CSE. */ + if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD + && SCALAR_INT_MODE_P (GET_MODE (x)) + && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode), + GET_MODE_BITSIZE (GET_MODE (x))) + && ! no_new_pseudos) + return gen_lowpart_general (mode, force_reg (GET_MODE (x), x)); + + if (WORDS_BIG_ENDIAN) + offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD) + - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD)); + + if (BYTES_BIG_ENDIAN) + /* Adjust the address so that the address-after-the-data + is unchanged. */ + offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode)) + - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x)))); + + return adjust_address (x, mode, offset); + } + else if (GET_CODE (x) == ADDRESSOF) + return gen_lowpart_general (mode, force_reg (GET_MODE (x), x)); + else + abort (); +} + +rtx +reg_num_sign_bit_copies_general (rtx x ATTRIBUTE_UNUSED, + enum machine_mode mode ATTRIBUTE_UNUSED, + rtx known_x ATTRIBUTE_UNUSED, + enum machine_mode known_mode ATTRIBUTE_UNUSED, + unsigned int known_ret ATTRIBUTE_UNUSED, + unsigned int *result ATTRIBUTE_UNUSED) +{ + return NULL; +} + +rtx +reg_nonzero_bits_general (rtx x ATTRIBUTE_UNUSED, + enum machine_mode mode ATTRIBUTE_UNUSED, + rtx known_x ATTRIBUTE_UNUSED, + enum machine_mode known_mode ATTRIBUTE_UNUSED, + unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED, + unsigned HOST_WIDE_INT *nonzero ATTRIBUTE_UNUSED) +{ + return NULL; +} |