+2003-09-18 Mark Mitchell <mark@codesourcery.com>
+
+ PR target/11184
+ * builtins.c (expand_builtin_apply): Use convert_memory_address
+ before returning the value.
+
+ * alias.c (find_base_value): Simplify use of
+ convert_memory_address.
+ (find_base_term): Likewise.
+ * builtins.c (expand_builtin_stejmp_setup): Likewise.
+ (expand_builtin_longjmp): Likewise.
+ (expand_builtin_prefetch): Likewise.
+ (get_memory_rtx): Likewise.
+ (expand_builtin_return): Likewise.
+ (expand_builtin_memcpy): Likewise.
+ (expand_builtin_strncpy): Likewise.
+ (expand_builtin_memset): Likewise.
+ (expand_builtin_va_arg): Likewise.
+ (expand_builtin_va_copy): Likewise.
+ (expand_builtin_alloca): Likewise.
+ * calls.c (expand_call): Likewise.
+ * except.c (expand_builtin_extract_return_addr): Likewise.
+ (expand_builtin_eh_return): Likewise.
+ * explow.c (convert_memory_address): Define even when
+ POINTER_EXTEND_UNSIGNED is not defined. Do nothing if the address
+ is already in the right mode.
+ * explow.c (memory_address): Simplify use of convert_memory_address.
+ (probe_stack_range): Likewise.
+ * expmed.c (make_tree): Likewise.
+ * expr.c (emit_block_move_in_libcall): Likewise.
+ (expand_assignment): Likewise.
+ (expand_expr): Likewise.
+ * function.c (assign_parms): Likewise.
+ (expand_function_end): Likewise.
+ * integrate.c (copy_rtx_and_substitute): Likewise.
+ * stmt.c (expand_computed_goto): Likewise.
+
2003-09-18 Roger Sayle <roger@eyesopen.com>
* simplify-rtx.c (simplify_unary_operation): Only transform
{
rtx temp = find_base_value (XEXP (src, 0));
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (temp != 0 && CONSTANT_P (temp) && GET_MODE (temp) != Pmode)
+ if (temp != 0 && CONSTANT_P (temp))
temp = convert_memory_address (Pmode, temp);
-#endif
return temp;
}
{
rtx temp = find_base_term (XEXP (x, 0));
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (temp != 0 && CONSTANT_P (temp) && GET_MODE (temp) != Pmode)
+ if (temp != 0 && CONSTANT_P (temp))
temp = convert_memory_address (Pmode, temp);
-#endif
return temp;
}
if (setjmp_alias_set == -1)
setjmp_alias_set = new_alias_set ();
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (buf_addr) != Pmode)
- buf_addr = convert_memory_address (Pmode, buf_addr);
-#endif
+ buf_addr = convert_memory_address (Pmode, buf_addr);
buf_addr = force_reg (Pmode, force_operand (buf_addr, NULL_RTX));
if (setjmp_alias_set == -1)
setjmp_alias_set = new_alias_set ();
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (buf_addr) != Pmode)
- buf_addr = convert_memory_address (Pmode, buf_addr);
-#endif
+ buf_addr = convert_memory_address (Pmode, buf_addr);
buf_addr = force_reg (Pmode, buf_addr);
insn_data[(int) CODE_FOR_prefetch].operand[0].mode))
|| (GET_MODE (op0) != Pmode))
{
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (op0) != Pmode)
- op0 = convert_memory_address (Pmode, op0);
-#endif
+ op0 = convert_memory_address (Pmode, op0);
op0 = force_reg (Pmode, op0);
}
emit_insn (gen_prefetch (op0, op1, op2));
rtx addr = expand_expr (exp, NULL_RTX, ptr_mode, EXPAND_SUM);
rtx mem;
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (addr) != Pmode)
- addr = convert_memory_address (Pmode, addr);
-#endif
+ addr = convert_memory_address (Pmode, addr);
mem = gen_rtx_MEM (BLKmode, memory_address (BLKmode, addr));
rtx call_fusage = 0;
rtx struct_value = targetm.calls.struct_value_rtx (cfun ? TREE_TYPE (cfun->decl) : 0, 0);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (arguments) != Pmode)
- arguments = convert_memory_address (Pmode, arguments);
-#endif
+ arguments = convert_memory_address (Pmode, arguments);
/* Create a block where the return registers can be saved. */
result = assign_stack_local (BLKmode, apply_result_size (), -1);
OK_DEFER_POP;
/* Return the address of the result block. */
- return copy_addr_to_reg (XEXP (result, 0));
+ result = copy_addr_to_reg (XEXP (result, 0));
+ return convert_memory_address (ptr_mode, result);
}
/* Perform an untyped return. */
rtx reg;
rtx call_fusage = 0;
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (result) != Pmode)
- result = convert_memory_address (Pmode, result);
-#endif
+ result = convert_memory_address (Pmode, result);
apply_result_size ();
result = gen_rtx_MEM (BLKmode, result);
builtin_memcpy_read_str,
(void *) src_str, dest_align, 0);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (dest_mem) != ptr_mode)
- dest_mem = convert_memory_address (ptr_mode, dest_mem);
-#endif
+ dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
if (dest_addr == 0)
{
dest_addr = force_operand (XEXP (dest_mem, 0), NULL_RTX);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (dest_addr) != ptr_mode)
- dest_addr = convert_memory_address (ptr_mode, dest_addr);
-#endif
+ dest_addr = convert_memory_address (ptr_mode, dest_addr);
}
return dest_addr;
}
builtin_memcpy_read_str,
(void *) src_str, dest_align, endp);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (dest_mem) != ptr_mode)
- dest_mem = convert_memory_address (ptr_mode, dest_mem);
-#endif
+ dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
dest_mem = move_by_pieces (dest_mem, src_mem, INTVAL (len_rtx),
MIN (dest_align, src_align), endp);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (dest_mem) != ptr_mode)
- dest_mem = convert_memory_address (ptr_mode, dest_mem);
-#endif
+ dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
builtin_strncpy_read_str,
(void *) p, dest_align, 0);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (dest_mem) != ptr_mode)
- dest_mem = convert_memory_address (ptr_mode, dest_mem);
-#endif
+ dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
builtin_memset_gen_str,
val_rtx, dest_align, 0);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (dest_mem) != ptr_mode)
- dest_mem = convert_memory_address (ptr_mode, dest_mem);
-#endif
+ dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
builtin_memset_read_str,
&c, dest_align, 0);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (dest_mem) != ptr_mode)
- dest_mem = convert_memory_address (ptr_mode, dest_mem);
-#endif
+ dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
if (dest_addr == 0)
{
dest_addr = force_operand (XEXP (dest_mem, 0), NULL_RTX);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (dest_addr) != ptr_mode)
- dest_addr = convert_memory_address (ptr_mode, dest_addr);
-#endif
+ dest_addr = convert_memory_address (ptr_mode, dest_addr);
}
return dest_addr;
#endif
}
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (addr) != Pmode)
- addr = convert_memory_address (Pmode, addr);
-#endif
+ addr = convert_memory_address (Pmode, addr);
result = gen_rtx_MEM (TYPE_MODE (type), addr);
set_mem_alias_set (result, get_varargs_alias_set ());
size = expand_expr (TYPE_SIZE_UNIT (va_list_type_node), NULL_RTX,
VOIDmode, EXPAND_NORMAL);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (dstb) != Pmode)
- dstb = convert_memory_address (Pmode, dstb);
-
- if (GET_MODE (srcb) != Pmode)
- srcb = convert_memory_address (Pmode, srcb);
-#endif
+ dstb = convert_memory_address (Pmode, dstb);
+ srcb = convert_memory_address (Pmode, srcb);
/* "Dereference" to BLKmode memories. */
dstb = gen_rtx_MEM (BLKmode, dstb);
/* Allocate the desired space. */
result = allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
-
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (result) != ptr_mode)
- result = convert_memory_address (ptr_mode, result);
-#endif
+ result = convert_memory_address (ptr_mode, result);
return result;
}
structure value. */
if (pass != 0 && structure_value_addr && ! structure_value_addr_parm)
{
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (structure_value_addr) != Pmode)
- structure_value_addr = convert_memory_address
- (Pmode, structure_value_addr);
-#endif
+ structure_value_addr
+ = convert_memory_address (Pmode, structure_value_addr);
emit_move_insn (struct_value,
force_reg (Pmode,
force_operand (structure_value_addr,
{
rtx addr = expand_expr (addr_tree, NULL_RTX, ptr_mode, 0);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (addr) != Pmode)
- addr = convert_memory_address (Pmode, addr);
-#endif
+ addr = convert_memory_address (Pmode, addr);
#ifdef RETURN_ADDR_OFFSET
addr = force_reg (Pmode, addr);
#ifdef EH_RETURN_STACKADJ_RTX
tmp = expand_expr (stackadj_tree, cfun->eh->ehr_stackadj, VOIDmode, 0);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (tmp) != Pmode)
- tmp = convert_memory_address (Pmode, tmp);
-#endif
+ tmp = convert_memory_address (Pmode, tmp);
if (!cfun->eh->ehr_stackadj)
cfun->eh->ehr_stackadj = copy_to_reg (tmp);
else if (tmp != cfun->eh->ehr_stackadj)
#endif
tmp = expand_expr (handler_tree, cfun->eh->ehr_handler, VOIDmode, 0);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (tmp) != Pmode)
- tmp = convert_memory_address (Pmode, tmp);
-#endif
+ tmp = convert_memory_address (Pmode, tmp);
if (!cfun->eh->ehr_handler)
cfun->eh->ehr_handler = copy_to_reg (tmp);
else if (tmp != cfun->eh->ehr_handler)
return x;
}
-#ifdef POINTERS_EXTEND_UNSIGNED
-
/* Given X, a memory address in ptr_mode, convert it to an address
in Pmode, or vice versa (TO_MODE says which way). We take advantage of
the fact that pointers are not allowed to overflow by commuting arithmetic
used. */
rtx
-convert_memory_address (enum machine_mode to_mode, rtx x)
+convert_memory_address (enum machine_mode to_mode ATTRIBUTE_UNUSED,
+ rtx x)
{
- enum machine_mode from_mode = to_mode == ptr_mode ? Pmode : ptr_mode;
+#ifndef POINTERS_EXTEND_UNSIGNED
+ return x;
+#else /* defined(POINTERS_EXTEND_UNSIGNED) */
+ enum machine_mode from_mode;
rtx temp;
enum rtx_code code;
+ /* If X already has the right mode, just return it. */
+ if (GET_MODE (x) == to_mode)
+ return x;
+
+ from_mode = to_mode == ptr_mode ? Pmode : ptr_mode;
+
/* Here we handle some special cases. If none of them apply, fall through
to the default case. */
switch (GET_CODE (x))
return convert_modes (to_mode, from_mode,
x, POINTERS_EXTEND_UNSIGNED);
+#endif /* defined(POINTERS_EXTEND_UNSIGNED) */
}
-#endif
/* Given a memory address or facsimile X, construct a new address,
currently equivalent, that is stable: future stores won't change it.
if (GET_CODE (x) == ADDRESSOF)
return x;
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (x) != Pmode)
- x = convert_memory_address (Pmode, x);
-#endif
+ x = convert_memory_address (Pmode, x);
/* By passing constant addresses thru registers
we get a chance to cse them. */
stack_pointer_rtx,
plus_constant (size, first)));
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (addr) != ptr_mode)
- addr = convert_memory_address (ptr_mode, addr);
-#endif
-
+ addr = convert_memory_address (ptr_mode, addr);
emit_library_call (stack_check_libfunc, LCT_NORMAL, VOIDmode, 1, addr,
ptr_mode);
}
t = make_node (RTL_EXPR);
TREE_TYPE (t) = type;
-#ifdef POINTERS_EXTEND_UNSIGNED
/* If TYPE is a POINTER_TYPE, X might be Pmode with TYPE_MODE being
ptr_mode. So convert. */
- if (POINTER_TYPE_P (type) && GET_MODE (x) != TYPE_MODE (type))
+ if (POINTER_TYPE_P (type))
x = convert_memory_address (TYPE_MODE (type), x);
-#endif
RTL_EXPR_RTL (t) = x;
/* There are no insns to be output
dst_addr = copy_to_mode_reg (Pmode, XEXP (dst, 0));
src_addr = copy_to_mode_reg (Pmode, XEXP (src, 0));
-#ifdef POINTERS_EXTEND_UNSIGNED
dst_addr = convert_memory_address (ptr_mode, dst_addr);
src_addr = convert_memory_address (ptr_mode, src_addr);
-#endif
dst_tree = make_tree (ptr_type_node, dst_addr);
src_tree = make_tree (ptr_type_node, src_addr);
emit_block_move (to_rtx, value, expr_size (from), BLOCK_OP_NORMAL);
else
{
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (POINTER_TYPE_P (TREE_TYPE (to))
- && GET_MODE (to_rtx) != GET_MODE (value))
+ if (POINTER_TYPE_P (TREE_TYPE (to)))
value = convert_memory_address (GET_MODE (to_rtx), value);
-#endif
emit_move_insn (to_rtx, value);
}
preserve_temp_slots (to_rtx);
if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
{
op0 = XEXP (op0, 0);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (op0) == Pmode && GET_MODE (op0) != mode
- && mode == ptr_mode)
+ if (GET_MODE (op0) == Pmode && mode == ptr_mode)
op0 = convert_memory_address (ptr_mode, op0);
-#endif
return op0;
}
&& ! REG_USERVAR_P (op0))
mark_reg_pointer (op0, TYPE_ALIGN (TREE_TYPE (type)));
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (op0) == Pmode && GET_MODE (op0) != mode
- && mode == ptr_mode)
+ if (GET_MODE (op0) == Pmode && mode == ptr_mode)
op0 = convert_memory_address (ptr_mode, op0);
-#endif
return op0;
rtx addr = DECL_RTL (function_result_decl);
rtx x;
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (addr) != Pmode)
- addr = convert_memory_address (Pmode, addr);
-#endif
-
+ addr = convert_memory_address (Pmode, addr);
x = gen_rtx_MEM (DECL_MODE (result), addr);
set_mem_attributes (x, result, 1);
SET_DECL_RTL (result, x);
assignment and USE below when inlining this function. */
REG_FUNCTION_VALUE_P (outgoing) = 1;
-#ifdef POINTERS_EXTEND_UNSIGNED
/* The address may be ptr_mode and OUTGOING may be Pmode. */
- if (GET_MODE (outgoing) != GET_MODE (value_address))
- value_address = convert_memory_address (GET_MODE (outgoing),
- value_address);
-#endif
+ value_address = convert_memory_address (GET_MODE (outgoing),
+ value_address);
emit_move_insn (outgoing, value_address);
#endif
temp = XEXP (temp, 0);
-
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (temp) != GET_MODE (orig))
- temp = convert_memory_address (GET_MODE (orig), temp);
-#endif
+ temp = convert_memory_address (GET_MODE (orig), temp);
return temp;
}
else if (GET_CODE (constant) == LABEL_REF)
{
rtx x = expand_expr (exp, NULL_RTX, VOIDmode, 0);
-#ifdef POINTERS_EXTEND_UNSIGNED
- if (GET_MODE (x) != Pmode)
- x = convert_memory_address (Pmode, x);
-#endif
+ x = convert_memory_address (Pmode, x);
emit_queue ();
+2003-09-18 Mark Mitchell <mark@codesourcery.com>
+
+ PR target/11184
+ * gcc.dg/builtin-apply1.c: New test.
+
2003-09-18 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9848
--- /dev/null
+/* PR 11184 */
+/* Origin: Dara Hazeghi <dhazeghi@yahoo.com> */
+
+void *
+objc_msg_sendv (char * arg_frame, void (*foo)())
+{
+ return __builtin_apply ( foo, arg_frame, 4);
+}
+