This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFT/RFA] Fix AIX fallout from PR/19653 patch



On 10/04/2006, at 9:33 AM, Paolo Bonzini wrote:



As I said, I don't believe the chunk of code that calls create_TOC_reference should be using constant_pool_expr_1 at all. It should be checking explicitly for the patterns for which relocs can be created, either a SYMBOL_REF or a SYMBOL_REF plus a constant.
Compared to what constant_pool_expr_p lets through, this only rules out toc-relative expressions.

I think someone should make a list of what kinds of expressions can be made that involve TOC symbols and constant_pool_expr_p should allow only those.


Do you think the attached (untested) patch makes sense?

I don't know.


Paolo
2006-04-04  Paolo Bonzini  <bonzini@gnu.org>

* rs6000.c (constant_pool_expr_1): Add MODE parameter defaulting
to the pool constant's mode.
(constant_pool_expr_p): Add a MODE parameter, pass it. Add
ALLOW_TOC_REL parameter.
(toc_relative_expr_p): Adjust call.
(legitimate_constant_pool_address_p, rs6000_legitimize_reload_address,
rs6000_emit_move): Merge invocations of ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
with preceding calls to constant_pool_expr_p.


Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c (revision 112658)
+++ config/rs6000/rs6000.c (working copy)
@@ -588,8 +588,8 @@ static void rs6000_emit_allocate_stack (
static unsigned rs6000_hash_constant (rtx);
static unsigned toc_hash_function (const void *);
static int toc_hash_eq (const void *, const void *);
-static int constant_pool_expr_1 (rtx, int *, int *);
-static bool constant_pool_expr_p (rtx);
+static int constant_pool_expr_1 (rtx, enum machine_mode, int *, int *);
+static bool constant_pool_expr_p (rtx, enum machine_mode);
static bool legitimate_small_data_p (enum machine_mode, rtx);
static bool legitimate_indexed_address_p (rtx, int);
static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
@@ -2642,7 +2642,8 @@ gpr_or_gpr_p (rtx op0, rtx op1)
/* Subroutines of rs6000_legitimize_address and rs6000_legitimate_address. */


static int
-constant_pool_expr_1 (rtx op, int *have_sym, int *have_toc)
+constant_pool_expr_1 (rtx op, enum machine_mode mode,
+ int *have_sym, int *have_toc)
{
switch (GET_CODE (op))
{
@@ -2651,7 +2652,9 @@ constant_pool_expr_1 (rtx op, int *have_
return 0;
else if (CONSTANT_POOL_ADDRESS_P (op))
{
- if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (op), Pmode))
+ if (mode == VOIDmode)
+ mode = get_pool_mode (op);
+ if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (op), mode))
{
*have_sym = 1;
return 1;
@@ -2668,10 +2671,10 @@ constant_pool_expr_1 (rtx op, int *have_
return 0;
case PLUS:
case MINUS:
- return (constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc)
- && constant_pool_expr_1 (XEXP (op, 1), have_sym, have_toc));
+ return (constant_pool_expr_1 (XEXP (op, 0), mode, have_sym, have_toc)
+ && constant_pool_expr_1 (XEXP (op, 1), mode, have_sym, have_toc));
case CONST:
- return constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc);
+ return constant_pool_expr_1 (XEXP (op, 0), mode, have_sym, have_toc);
case CONST_INT:
return 1;
default:
@@ -2680,11 +2683,12 @@ constant_pool_expr_1 (rtx op, int *have_
}


static bool
-constant_pool_expr_p (rtx op)
+constant_pool_expr_p (rtx op, enum machine_mode mode, bool allow_toc_rel)
{
int have_sym = 0;
int have_toc = 0;
- return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_sym;
+ return constant_pool_expr_1 (op, mode, &have_sym, &have_toc)
+ && have_sym && (allow_toc_rel || !have_toc);
}


bool
@@ -2692,7 +2696,7 @@ toc_relative_expr_p (rtx op)
{
int have_sym = 0;
int have_toc = 0;
- return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_toc;
+ return constant_pool_expr_1 (op, Pmode, &have_sym, &have_toc) && have_toc;
}


 bool
@@ -2702,7 +2706,7 @@ legitimate_constant_pool_address_p (rtx
 	  && GET_CODE (x) == PLUS
 	  && GET_CODE (XEXP (x, 0)) == REG
 	  && (TARGET_MINIMAL_TOC || REGNO (XEXP (x, 0)) == TOC_REGISTER)
-	  && constant_pool_expr_p (XEXP (x, 1)));
+	  && constant_pool_expr_p (XEXP (x, 1), Pmode, true));
 }

static bool
@@ -3004,9 +3008,7 @@ rs6000_legitimize_address (rtx x, rtx ol
emit_insn (gen_macho_high (reg, x));
return gen_rtx_LO_SUM (Pmode, reg, x);
}
- else if (TARGET_TOC
- && constant_pool_expr_p (x)
- && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode))
+ else if (TARGET_TOC && constant_pool_expr_p (x, Pmode, false))
{
return create_TOC_reference (x);
}
@@ -3440,8 +3442,7 @@ rs6000_legitimize_reload_address (rtx x,
}


if (TARGET_TOC
- && constant_pool_expr_p (x)
- && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), mode))
+ && constant_pool_expr_p (x, mode, false))
{
(x) = create_TOC_reference (x);
*win = 1;
@@ -4112,9 +4113,7 @@ rs6000_emit_move (rtx dest, rtx source,
reference to it. */
if (TARGET_TOC
&& GET_CODE (operands[1]) == SYMBOL_REF
- && constant_pool_expr_p (operands[1])
- && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (operands [1]),
- get_pool_mode (operands[1])))
+ && constant_pool_expr_p (operands[1], VOIDmode, false))
{
operands[1] = create_TOC_reference (operands[1]);
}
@@ -4179,10 +4178,7 @@ rs6000_emit_move (rtx dest, rtx source,
operands[1] = force_const_mem (mode, operands[1]);


if (TARGET_TOC
- && constant_pool_expr_p (XEXP (operands[1], 0))
- && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (
- get_pool_constant (XEXP (operands[1], 0)),
- get_pool_mode (XEXP (operands[1], 0))))
+ && constant_pool_expr_p (XEXP (operands[1], 0), VOIDmode, true))
{
operands[1]
= gen_const_mem (mode,

Attachment: smime.p7s
Description: S/MIME cryptographic signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]