00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "config.h"
00022 #include "system.h"
00023 #include "coretypes.h"
00024 #include "tm.h"
00025 #include "rtl.h"
00026 #include "rtlhooks-def.h"
00027 #include "expr.h"
00028 #include "recog.h"
00029
00030
00031
00032
00033
00034
00035
00036
00037 const struct rtl_hooks general_rtl_hooks = RTL_HOOKS_INITIALIZER;
00038 struct rtl_hooks rtl_hooks = RTL_HOOKS_INITIALIZER;
00039
00040 rtx
00041 gen_lowpart_general (enum machine_mode mode, rtx x)
00042 {
00043 rtx result = gen_lowpart_common (mode, x);
00044
00045 if (result)
00046 return result;
00047
00048 else if (REG_P (x)
00049
00050 || (GET_CODE (x) == SUBREG
00051 && FLOAT_MODE_P (GET_MODE (SUBREG_REG (x)))))
00052 {
00053 result = gen_lowpart_common (mode, copy_to_reg (x));
00054 gcc_assert (result != 0);
00055 return result;
00056 }
00057 else
00058 {
00059 int offset = 0;
00060
00061
00062 gcc_assert (MEM_P (x));
00063
00064
00065 if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD
00066 && SCALAR_INT_MODE_P (GET_MODE (x))
00067 && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
00068 GET_MODE_BITSIZE (GET_MODE (x)))
00069 && ! no_new_pseudos)
00070 return gen_lowpart_general (mode, force_reg (GET_MODE (x), x));
00071
00072 if (WORDS_BIG_ENDIAN)
00073 offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
00074 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
00075
00076 if (BYTES_BIG_ENDIAN)
00077
00078
00079 offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
00080 - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
00081
00082 return adjust_address (x, mode, offset);
00083 }
00084 }
00085
00086
00087
00088 rtx
00089 gen_lowpart_no_emit_general (enum machine_mode mode, rtx x)
00090 {
00091 rtx result = gen_lowpart_if_possible (mode, x);
00092 if (result)
00093 return result;
00094 else
00095 return x;
00096 }
00097
00098 rtx
00099 reg_num_sign_bit_copies_general (rtx x ATTRIBUTE_UNUSED,
00100 enum machine_mode mode ATTRIBUTE_UNUSED,
00101 rtx known_x ATTRIBUTE_UNUSED,
00102 enum machine_mode known_mode ATTRIBUTE_UNUSED,
00103 unsigned int known_ret ATTRIBUTE_UNUSED,
00104 unsigned int *result ATTRIBUTE_UNUSED)
00105 {
00106 return NULL;
00107 }
00108
00109 rtx
00110 reg_nonzero_bits_general (rtx x ATTRIBUTE_UNUSED,
00111 enum machine_mode mode ATTRIBUTE_UNUSED,
00112 rtx known_x ATTRIBUTE_UNUSED,
00113 enum machine_mode known_mode ATTRIBUTE_UNUSED,
00114 unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED,
00115 unsigned HOST_WIDE_INT *nonzero ATTRIBUTE_UNUSED)
00116 {
00117 return NULL;
00118 }
00119
00120 bool
00121 reg_truncated_to_mode_general (enum machine_mode mode ATTRIBUTE_UNUSED,
00122 rtx x ATTRIBUTE_UNUSED)
00123 {
00124 return false;
00125 }
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 rtx
00137 gen_lowpart_if_possible (enum machine_mode mode, rtx x)
00138 {
00139 rtx result = gen_lowpart_common (mode, x);
00140
00141 if (result)
00142 return result;
00143 else if (MEM_P (x))
00144 {
00145
00146 int offset = 0;
00147 rtx new;
00148
00149 if (WORDS_BIG_ENDIAN)
00150 offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
00151 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
00152 if (BYTES_BIG_ENDIAN)
00153
00154
00155 offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
00156 - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
00157
00158 new = adjust_address_nv (x, mode, offset);
00159 if (! memory_address_p (mode, XEXP (new, 0)))
00160 return 0;
00161
00162 return new;
00163 }
00164 else if (mode != GET_MODE (x) && GET_MODE (x) != VOIDmode)
00165 return gen_lowpart_SUBREG (mode, x);
00166 else
00167 return 0;
00168 }
00169