+2007-11-15 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
+
+ * config/spu/spu-protos.h (legitimate_const): Remove prototype.
+ * config/spu/spu.c (legitimate_const): Remove.
+ (classify_immediate): Inline call to legitimate_const.
+ (spu_legitimate_address): Likewise. Allow SMBOL_REF + CONST_INT
+ for any constant, not just -512 .. 511.
+
2007-11-15 Sa Liu <saliu@de.ibm.com>
* config/spu/spu.c (spu_emit_branch_or_set): Remove PROCESSOR_CELL
extern int iohl_immediate_p (rtx op, enum machine_mode mode);
extern int arith_immediate_p (rtx op, enum machine_mode mode,
HOST_WIDE_INT low, HOST_WIDE_INT high);
-extern int legitimate_const (rtx x, int aligned);
extern int spu_constant_address_p (rtx x);
extern int spu_legitimate_constant_p (rtx x);
extern int spu_legitimate_address (enum machine_mode mode, rtx x,
return CONST_DOUBLE_FROM_REAL_VALUE (value, mode);
}
-/* Given a (CONST (PLUS (SYMBOL_REF) (CONST_INT))) return TRUE when the
- CONST_INT fits constraint 'K', i.e., is small. */
-int
-legitimate_const (rtx x, int aligned)
-{
- /* We can never know if the resulting address fits in 18 bits and can be
- loaded with ila. Instead we should use the HI and LO relocations to
- load a 32-bit address. */
- rtx sym, cst;
-
- gcc_assert (GET_CODE (x) == CONST);
-
- if (GET_CODE (XEXP (x, 0)) != PLUS)
- return 0;
- sym = XEXP (XEXP (x, 0), 0);
- cst = XEXP (XEXP (x, 0), 1);
- if (GET_CODE (sym) != SYMBOL_REF || GET_CODE (cst) != CONST_INT)
- return 0;
- if (aligned && ((INTVAL (cst) & 15) != 0 || !ALIGNED_SYMBOL_REF_P (sym)))
- return 0;
- return satisfies_constraint_K (cst);
-}
-
int
spu_constant_address_p (rtx x)
{
return TARGET_LARGE_MEM ? IC_IL2s : IC_IL1s;
case CONST:
- return TARGET_LARGE_MEM
- || !legitimate_const (op, 0) ? IC_IL2s : IC_IL1s;
+ /* We can never know if the resulting address fits in 18 bits and can be
+ loaded with ila. For now, assume the address will not overflow if
+ the displacement is "small" (fits 'K' constraint). */
+ if (!TARGET_LARGE_MEM && GET_CODE (XEXP (op, 0)) == PLUS)
+ {
+ rtx sym = XEXP (XEXP (op, 0), 0);
+ rtx cst = XEXP (XEXP (op, 0), 1);
+
+ if (GET_CODE (sym) == SYMBOL_REF
+ && GET_CODE (cst) == CONST_INT
+ && satisfies_constraint_K (cst))
+ return IC_IL1s;
+ }
+ return IC_IL2s;
case HIGH:
return IC_IL1s;
return !TARGET_LARGE_MEM;
case CONST:
- return !TARGET_LARGE_MEM && legitimate_const (x, 0);
+ if (!TARGET_LARGE_MEM && GET_CODE (XEXP (x, 0)) == PLUS)
+ {
+ rtx sym = XEXP (XEXP (x, 0), 0);
+ rtx cst = XEXP (XEXP (x, 0), 1);
+
+ /* Accept any symbol_ref + constant, assuming it does not
+ wrap around the local store addressability limit. */
+ if (GET_CODE (sym) == SYMBOL_REF && GET_CODE (cst) == CONST_INT)
+ return 1;
+ }
+ return 0;
case CONST_INT:
return INTVAL (x) >= 0 && INTVAL (x) <= 0x3ffff;