aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>2001-02-01 12:29:18 +0000
committerRichard Kenner <kenner@gcc.gnu.org>2001-02-01 07:29:18 -0500
commitd54571406e15250c1f73fac6b0ce85438f84b4fb (patch)
treee5b324c5c826bd74ab4f7fe2ac03b199ea6b5f34 /gcc
parentfcbfaa65a5e27ee6f772056bf52cf27202518def (diff)
downloadgcc-d54571406e15250c1f73fac6b0ce85438f84b4fb.zip
gcc-d54571406e15250c1f73fac6b0ce85438f84b4fb.tar.gz
gcc-d54571406e15250c1f73fac6b0ce85438f84b4fb.tar.bz2
builtins.c (expand_builtin_alloca): allocate_dynamic_stack_space returns Pmode pseudo, but we need ptr_mode.
* builtins.c (expand_builtin_alloca): allocate_dynamic_stack_space returns Pmode pseudo, but we need ptr_mode. * explow.c (allocate_dynamic_stack_space): Use plus_constant. Remove bogus conversions; use HOST_WIDE_INT for size. Don't use TARGET if wrong mode. From-SVN: r39390
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/builtins.c12
-rw-r--r--gcc/explow.c25
3 files changed, 27 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index edd63af..b18311d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
Thu Feb 1 07:22:41 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
+ * builtins.c (expand_builtin_alloca): allocate_dynamic_stack_space
+ returns Pmode pseudo, but we need ptr_mode.
+ * explow.c (allocate_dynamic_stack_space): Use plus_constant.
+ Remove bogus conversions; use HOST_WIDE_INT for size.
+ Don't use TARGET if wrong mode.
+
* config/i386/i386.c (ix86_compute_frame_size): Allow
stack_alignment_needed to be non-default even if size is zero.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index a49fc17..1a6d87f 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -3095,12 +3095,14 @@ expand_builtin_frame_address (exp)
/* Expand a call to the alloca builtin, with arguments ARGLIST. Return 0 if
we failed and the caller should emit a normal call, otherwise try to get
the result in TARGET, if convenient. */
+
static rtx
expand_builtin_alloca (arglist, target)
tree arglist;
rtx target;
{
rtx op0;
+ rtx result;
if (!validate_arglist (arglist, INTEGER_TYPE, VOID_TYPE))
return 0;
@@ -3109,13 +3111,20 @@ expand_builtin_alloca (arglist, target)
op0 = expand_expr (TREE_VALUE (arglist), NULL_RTX, VOIDmode, 0);
/* Allocate the desired space. */
- return allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
+ result = allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
+
+#ifdef POINTERS_EXTEND_UNSIGNED
+ result = convert_memory_address (ptr_mode, result);
+#endif
+
+ return result;
}
/* Expand a call to the ffs builtin. The arguments are in ARGLIST.
Return 0 if a normal call should be emitted rather than expanding the
function in-line. If convenient, the result should be placed in TARGET.
SUBTARGET may be used as the target for computing one of EXP's operands. */
+
static rtx
expand_builtin_ffs (arglist, target, subtarget)
tree arglist;
@@ -3138,6 +3147,7 @@ expand_builtin_ffs (arglist, target, subtarget)
/* If the string passed to fputs is a constant and is one character
long, we attempt to transform this call into __builtin_fputc(). */
+
static rtx
expand_builtin_fputs (arglist, ignore)
tree arglist;
diff --git a/gcc/explow.c b/gcc/explow.c
index aa1e8a6..d36ceff 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -1294,15 +1294,10 @@ allocate_dynamic_stack_space (size, target, known_align)
#endif
if (MUST_ALIGN)
- {
- if (GET_CODE (size) == CONST_INT)
- size = GEN_INT (INTVAL (size)
- + (BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1));
- else
- size = expand_binop (Pmode, add_optab, size,
- GEN_INT (BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1),
- NULL_RTX, 1, OPTAB_LIB_WIDEN);
- }
+ size
+ = force_operand (plus_constant (size,
+ BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1),
+ NULL_RTX);
#ifdef SETJMP_VIA_SAVE_AREA
/* If setjmp restores regs from a save area in the stack frame,
@@ -1325,12 +1320,12 @@ allocate_dynamic_stack_space (size, target, known_align)
#if !defined(PREFERRED_STACK_BOUNDARY) || !defined(MUST_ALIGN) || (PREFERRED_STACK_BOUNDARY != BIGGEST_ALIGNMENT)
/* If anyone creates a target with these characteristics, let them
know that our optimization cannot work correctly in such a case. */
- abort();
+ abort ();
#endif
if (GET_CODE (size) == CONST_INT)
{
- int new = INTVAL (size) / align * align;
+ HOST_WIDE_INT new = INTVAL (size) / align * align;
if (INTVAL (size) != new)
setjmpless_size = GEN_INT (new);
@@ -1395,9 +1390,10 @@ allocate_dynamic_stack_space (size, target, known_align)
if (flag_stack_check && ! STACK_CHECK_BUILTIN)
probe_stack_range (STACK_CHECK_MAX_FRAME_SIZE + STACK_CHECK_PROTECT, size);
- /* Don't use a TARGET that isn't a pseudo. */
+ /* Don't use a TARGET that isn't a pseudo or is the wrong mode. */
if (target == 0 || GET_CODE (target) != REG
- || REGNO (target) < FIRST_PSEUDO_REGISTER)
+ || REGNO (target) < FIRST_PSEUDO_REGISTER
+ || GET_MODE (target) != Pmode)
target = gen_reg_rtx (Pmode);
mark_reg_pointer (target, known_align);
@@ -1422,7 +1418,6 @@ allocate_dynamic_stack_space (size, target, known_align)
if (mode == VOIDmode)
mode = Pmode;
- size = convert_modes (mode, ptr_mode, size, 1);
pred = insn_data[(int) CODE_FOR_allocate_stack].operand[1].predicate;
if (pred && ! ((*pred) (size, mode)))
size = copy_to_mode_reg (mode, size);
@@ -1435,7 +1430,6 @@ allocate_dynamic_stack_space (size, target, known_align)
#ifndef STACK_GROWS_DOWNWARD
emit_move_insn (target, virtual_stack_dynamic_rtx);
#endif
- size = convert_modes (Pmode, ptr_mode, size, 1);
/* Check stack bounds if necessary. */
if (current_function_limit_stack)
@@ -1474,6 +1468,7 @@ allocate_dynamic_stack_space (size, target, known_align)
REG_NOTES (note_target));
}
#endif /* SETJMP_VIA_SAVE_AREA */
+
#ifdef STACK_GROWS_DOWNWARD
emit_move_insn (target, virtual_stack_dynamic_rtx);
#endif