This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Xtensa] fix for PTR-PLUS merge
- From: Bob Wilson <bwilson at tensilica dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 19 Jun 2007 11:03:45 -0700
- Subject: [Xtensa] fix for PTR-PLUS merge
I've committed this patch to fix up the Xtensa port for the ptr-plus merge.
With this change an xtensa-elf build passes all the tests that passed before
ptr-plus was merged.
2007-06-19 Bob Wilson <bob.wilson@acm.org>
* config/xtensa/xtensa.c: Include "df.h".
(xtensa_builtin_saveregs): Use adjust_address instead of change_address.
(xtensa_va_start): Invoke make_tree with sizetype for
expand_builtin_saveregs and then convert the result to a pointer.
Use POINTER_PLUS_EXPR. Use size_int instead of build_int_cst.
(xtensa_gimplify_va_arg_expr): Use size_int instead of build_int_cst.
Subtract argument size from index value as integers and then use
POINTER_PLUS_EXPR to add the result to the array address.
Index: config/xtensa/xtensa.c
===================================================================
--- config/xtensa/xtensa.c (revision 125852)
+++ config/xtensa/xtensa.c (working copy)
@@ -50,6 +50,7 @@
#include "target-def.h"
#include "langhooks.h"
#include "tree-gimple.h"
+#include "df.h"
/* Enumeration for all of the relational tests, so that we can build
@@ -2178,7 +2179,7 @@
static rtx
xtensa_builtin_saveregs (void)
{
- rtx gp_regs, dest;
+ rtx gp_regs;
int arg_words = current_function_args_info.arg_words;
int gp_left = MAX_ARGS_IN_REGISTERS - arg_words;
@@ -2191,12 +2192,12 @@
set_mem_alias_set (gp_regs, get_varargs_alias_set ());
/* Now store the incoming registers. */
- dest = change_address (gp_regs, SImode,
- plus_constant (XEXP (gp_regs, 0),
- arg_words * UNITS_PER_WORD));
cfun->machine->need_a7_copy = true;
cfun->machine->vararg_a7 = true;
- move_block_from_reg (GP_ARG_FIRST + arg_words, dest, gp_left);
+ move_block_from_reg (GP_ARG_FIRST + arg_words,
+ adjust_address (gp_regs, BLKmode,
+ arg_words * UNITS_PER_WORD),
+ gp_left);
return XEXP (gp_regs, 0);
}
@@ -2225,15 +2226,15 @@
ndx = build3 (COMPONENT_REF, TREE_TYPE (f_ndx), valist, f_ndx, NULL_TREE);
/* Call __builtin_saveregs; save the result in __va_reg */
- u = make_tree (ptr_type_node, expand_builtin_saveregs ());
+ u = make_tree (sizetype, expand_builtin_saveregs ());
+ u = fold_convert (ptr_type_node, u);
t = build2 (GIMPLE_MODIFY_STMT, ptr_type_node, reg, u);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
/* Set the __va_stk member to ($arg_ptr - 32). */
u = make_tree (ptr_type_node, virtual_incoming_args_rtx);
- u = fold_build2 (PLUS_EXPR, ptr_type_node, u,
- build_int_cst (NULL_TREE, -32));
+ u = fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, u, size_int (-32));
t = build2 (GIMPLE_MODIFY_STMT, ptr_type_node, stk, u);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
@@ -2243,8 +2244,8 @@
alignment offset for __va_stk. */
if (arg_words >= MAX_ARGS_IN_REGISTERS)
arg_words += 2;
- u = build_int_cst (NULL_TREE, arg_words * UNITS_PER_WORD);
- t = build2 (GIMPLE_MODIFY_STMT, integer_type_node, ndx, u);
+ t = build2 (GIMPLE_MODIFY_STMT, integer_type_node, ndx,
+ size_int (arg_words * UNITS_PER_WORD));
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
}
@@ -2309,10 +2310,8 @@
{
int align = MIN (TYPE_ALIGN (type), STACK_BOUNDARY) / BITS_PER_UNIT;
- t = build2 (PLUS_EXPR, integer_type_node, orig_ndx,
- build_int_cst (NULL_TREE, align - 1));
- t = build2 (BIT_AND_EXPR, integer_type_node, t,
- build_int_cst (NULL_TREE, -align));
+ t = build2 (PLUS_EXPR, integer_type_node, orig_ndx, size_int (align - 1));
+ t = build2 (BIT_AND_EXPR, integer_type_node, t, size_int (-align));
t = build2 (GIMPLE_MODIFY_STMT, integer_type_node, orig_ndx, t);
gimplify_and_add (t, pre_p);
}
@@ -2342,8 +2341,8 @@
lab_false = create_artificial_label ();
lab_over = create_artificial_label ();
- t = build_int_cst (NULL_TREE, MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD);
- t = build2 (GT_EXPR, boolean_type_node, ndx, t);
+ t = build2 (GT_EXPR, boolean_type_node, ndx,
+ size_int (MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD));
t = build3 (COND_EXPR, void_type_node, t,
build1 (GOTO_EXPR, void_type_node, lab_false),
NULL_TREE);
@@ -2372,8 +2371,8 @@
lab_false2 = create_artificial_label ();
- t = build_int_cst (NULL_TREE, MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD);
- t = build2 (GT_EXPR, boolean_type_node, orig_ndx, t);
+ t = build2 (GT_EXPR, boolean_type_node, orig_ndx,
+ size_int (MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD));
t = build3 (COND_EXPR, void_type_node, t,
build1 (GOTO_EXPR, void_type_node, lab_false2),
NULL_TREE);
@@ -2410,18 +2409,16 @@
if (BYTES_BIG_ENDIAN && TREE_CODE (type_size) == INTEGER_CST)
{
- t = size_int (PARM_BOUNDARY / BITS_PER_UNIT);
- t = fold_build2 (GE_EXPR, boolean_type_node, type_size, t);
+ t = fold_build2 (GE_EXPR, boolean_type_node, type_size,
+ size_int (PARM_BOUNDARY / BITS_PER_UNIT));
t = fold_build3 (COND_EXPR, sizetype, t, va_size, type_size);
size = t;
}
else
size = va_size;
- t = fold_convert (ptr_type_node, ndx);
- addr = build2 (PLUS_EXPR, ptr_type_node, array, t);
- t = fold_convert (ptr_type_node, size);
- addr = build2 (MINUS_EXPR, ptr_type_node, addr, t);
+ t = build2 (MINUS_EXPR, sizetype, ndx, size);
+ addr = build2 (POINTER_PLUS_EXPR, ptr_type_node, array, t);
addr = fold_convert (build_pointer_type (type), addr);
if (indirect)