aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>2000-05-31 18:37:31 +0000
committerRichard Kenner <kenner@gcc.gnu.org>2000-05-31 14:37:31 -0400
commit3bdf5ad13852aaa871ab41a6e8f509809c8c104d (patch)
treeb0b7fe92ad1922c85f0e4c70693ee5b33b128261 /gcc/builtins.c
parent99923eedd0700c7055810224f548f70bcd009267 (diff)
downloadgcc-3bdf5ad13852aaa871ab41a6e8f509809c8c104d.zip
gcc-3bdf5ad13852aaa871ab41a6e8f509809c8c104d.tar.gz
gcc-3bdf5ad13852aaa871ab41a6e8f509809c8c104d.tar.bz2
Makefile.in (c-decl.o): Depend on rtl.h and expr.h.
* Makefile.in (c-decl.o): Depend on rtl.h and expr.h. * alias.c (struct alias_entry): alias_set is HOST_WIDE_INT. (REG_BASE_VALUE): Remove unneeded cast to unsigned. (get_alias_set_entry): ALIAS_SET arg is HOST_WIDE_INT. (find_base_decl): New function, from c_find_base_decl in c-common.c. (new_alias_set): Moved from tree.c; return is HOST_WIDE_INT. (get_alias_set): Likewise. Major rework to do more things and allow language-specific code to just handle special-cases. (record_alias_subset): Args are HOST_WIDE_INT. (record_component_alias): Local vars are HOST_WIDE_INT. Don't handle COMPLEX_EXPR. (get_varargs_alias_set): Moved from builtins.c. (get_frame_alias_set): New function. * builtins.c (expand_builtin_return_address): Use frame alias set. (expand_builtin_setjmp, expand_builtin_longjmp): Use alias set for setjmp buffer. (get_memory_rtx): Rework to use set_mem_attributes. (get_varargs_alias_set): Deleted from here. * c-common.c (c_apply_type_quals_to_decl): Alias sets now HOST_WIDE_INT. (c_find_base_decl): Deleted from here. (c_get_alias_set): Remove many cases and rework to just handle C-specific cases. * c-common.h (c_get_alias_set): Returns HOST_WIDE_INT. * c-decl.c (rtl.h, expr.h): Now included. (init_decl_processing): Call record_component_aliases on array types. (grokdeclarator): Likewise. Set TREE_ADDRESSABLE for all fields that are not bitfields. * c-typeck.c (common_type): Call record_component_aliases for array. * caller-save.c (setup_save_areas): Rework register loop for unsigned. Set all save areas to the frame alias set. * calls.c (initialie_argument_information): Call set_mem_attributes. (compute_argument_addresses, expand_call): Likewise. * explow.c (set_mem_attributes): New function. (stabilize): Use MEM_COPY_ATTRIBUTES and force_reg. * expr.c (struct move_by_pieces): Remove {to,from}_{struct,readonly}. LEN and OFFSET now HOST_WIDE_INT. (clear_by_pieces): Similar changes. (move_by_pieces): LEN now HOST_WIDE_INT; don't set deleted fields. (move_by_pieces_ninsns): Now returns unsigned HOST_WIDE_INT. (move_by_pieces_1): Don't use deleted fields, use MEM_COPY_ATTRIBUTES. (clear_by_pieces_1): Likewise. (emit_push_insn): Call set_mem_attributes. (expand_expr, case INDIRECT_REF): Likewise. (expand_expr, case VAR_DECL): Call change_address. * expr.h (ADD_PARM_SIZE, SUB_PARM_SIZE): Use host_integerp and tree_low_cst. (get_varargs_alias_set, get_frame_alias_set): New decls. (record_base_value, record_alias_subset, lang_get_alias_set): Likewise. (new_alias_set, set_mem_attributes): Likewse. * function.c (struct temp_slot): ALIAS_SET is HOST_WIDE_INT. (assign_stack_temp_for_type): Likewise. Can split slot even if alias set since can copy. Set MEM_ALIAS_SET and MEM_SET_IN_STRUCT_P. (assign_temp): Use host_integerp and tree_low_cst. (put_var_into_stack): Properly handle SAVE_EXPR. (put_addressof_into_stack): Likewise. (assign_parms): Call set_mem_attributes. Delete #if 0 code. (fix_lexical_address): Put reference to chain into frame alias set. (expand_function_start): Call set_mem_attributes. * integrate.c (expand_inline_function): Likewise. * recog.c (adj_offsettable_operand): Use MEM_COPY_ATTRIBUTES. * regmove.c (try_apply_stack_adjustment): Likewise. * reload.c (push_reload, make_memloc): Likewise. * reload1.c (alter_reg): Make alias sets for spilled pseudos. * rtl.def (MEM): Update comment. * rtl.h (MEM_ALIAS_SET): Now uses XCWINT. (move_by_pieces): Change length to HOST_WIDE_INT. (record_base_value, record_alias_subset): Delete from here. * stmt.c (expand_decl): Call set_mem_attributes. * stor-layout.c (finish_record_layout): Call record_component_aliases.i * toplev.c (compile_file): Call init_alias_once earlier. * tree.c (lang_get_alias_set, get_alias_set, new_alias_set): Deleted from here: now in alias.c. * tree.h (struct tree_type): alias_set is HOST_WIDE_INT. (struct tree_decl): Likewise. (get_alias_set, new_alias_set, lang_get_alias_set): Deleted from here. * varasm.c (make_function_rtl, make_decl_rtl): Call set_mem_attributes. (output_constant_def, force_const_mem): Likewise. * cp/Makefile.in (decl.o): Include ../expr.h. * cp/decl.c (expr.h): Include. (init_decl_processing): Call record_component_aliases for arrays. (grokdeclarator): Likewise. Set TREE_ADDRESSABLE for fields that aren't bitfields. * cp/tree.c (build_cplus_array_type_1): Call record_component_aliases. From-SVN: r34305
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c118
1 files changed, 56 insertions, 62 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 1094e30..0e89481 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -288,6 +288,7 @@ expand_builtin_return_addr (fndecl_code, count, tem)
#endif
tem = memory_address (Pmode, tem);
tem = copy_to_reg (gen_rtx_MEM (Pmode, tem));
+ MEM_ALIAS_SET (tem) = get_frame_alias_set ();
}
/* For __builtin_frame_address, return what we've got. */
@@ -302,10 +303,14 @@ expand_builtin_return_addr (fndecl_code, count, tem)
tem = memory_address (Pmode,
plus_constant (tem, GET_MODE_SIZE (Pmode)));
tem = gen_rtx_MEM (Pmode, tem);
+ MEM_ALIAS_SET (tem) = get_frame_alias_set ();
#endif
return tem;
}
+/* Alias set used for setjmp buffer. */
+static HOST_WIDE_INT setjmp_alias_set = -1;
+
/* __builtin_setjmp is passed a pointer to an array of five words (not
all will be used on all machines). It operates similarly to the C
library function of the same name, but is more efficient. Much of
@@ -326,9 +331,13 @@ expand_builtin_setjmp (buf_addr, target, first_label, next_label)
enum machine_mode sa_mode = STACK_SAVEAREA_MODE (SAVE_NONLOCAL);
enum machine_mode value_mode;
rtx stack_save;
+ rtx mem;
value_mode = TYPE_MODE (integer_type_node);
+ if (setjmp_alias_set == -1)
+ setjmp_alias_set = new_alias_set ();
+
#ifdef POINTERS_EXTEND_UNSIGNED
buf_addr = convert_memory_address (Pmode, buf_addr);
#endif
@@ -349,17 +358,20 @@ expand_builtin_setjmp (buf_addr, target, first_label, next_label)
#define BUILTIN_SETJMP_FRAME_VALUE virtual_stack_vars_rtx
#endif
- emit_move_insn (gen_rtx_MEM (Pmode, buf_addr),
- BUILTIN_SETJMP_FRAME_VALUE);
- emit_move_insn (validize_mem
- (gen_rtx_MEM (Pmode,
- plus_constant (buf_addr,
- GET_MODE_SIZE (Pmode)))),
+ mem = gen_rtx_MEM (Pmode, buf_addr);
+ MEM_ALIAS_SET (mem) = setjmp_alias_set;
+ emit_move_insn (mem, BUILTIN_SETJMP_FRAME_VALUE);
+
+ mem = gen_rtx_MEM (Pmode, plus_constant (buf_addr, GET_MODE_SIZE (Pmode))),
+ MEM_ALIAS_SET (mem) = setjmp_alias_set;
+
+ emit_move_insn (validize_mem (mem),
force_reg (Pmode, gen_rtx_LABEL_REF (Pmode, lab1)));
stack_save = gen_rtx_MEM (sa_mode,
plus_constant (buf_addr,
2 * GET_MODE_SIZE (Pmode)));
+ MEM_ALIAS_SET (stack_save) = setjmp_alias_set;
emit_stack_save (SAVE_NONLOCAL, &stack_save, NULL_RTX);
/* If there is further processing to do, do it. */
@@ -464,6 +476,9 @@ expand_builtin_longjmp (buf_addr, value)
rtx fp, lab, stack;
enum machine_mode sa_mode = STACK_SAVEAREA_MODE (SAVE_NONLOCAL);
+ if (setjmp_alias_set == -1)
+ setjmp_alias_set = new_alias_set ();
+
#ifdef POINTERS_EXTEND_UNSIGNED
buf_addr = convert_memory_address (Pmode, buf_addr);
#endif
@@ -489,6 +504,8 @@ expand_builtin_longjmp (buf_addr, value)
stack = gen_rtx_MEM (sa_mode, plus_constant (buf_addr,
2 * GET_MODE_SIZE (Pmode)));
+ MEM_ALIAS_SET (fp) = MEM_ALIAS_SET (lab) = MEM_ALIAS_SET (stack)
+ = setjmp_alias_set;
/* Pick up FP, label, and SP from the block and jump. This code is
from expand_goto in stmt.c; see there for detailed comments. */
@@ -513,53 +530,34 @@ expand_builtin_longjmp (buf_addr, value)
}
}
-/* Get a MEM rtx for expression EXP which can be used in a string instruction
- (cmpstrsi, movstrsi, ..). */
+/* Get a MEM rtx for expression EXP which is the address of an operand
+ to be used to be used in a string instruction (cmpstrsi, movstrsi, ..). */
+
static rtx
get_memory_rtx (exp)
tree exp;
{
- rtx mem;
- int is_aggregate;
-
- mem = gen_rtx_MEM (BLKmode,
- memory_address (BLKmode,
- expand_expr (exp, NULL_RTX,
- ptr_mode, EXPAND_SUM)));
-
- RTX_UNCHANGING_P (mem) = TREE_READONLY (exp);
-
- /* Figure out the type of the object pointed to. Set MEM_IN_STRUCT_P
- if the value is the address of a structure or if the expression is
- cast to a pointer to structure type. */
- is_aggregate = 0;
-
- while (TREE_CODE (exp) == NOP_EXPR)
- {
- tree cast_type = TREE_TYPE (exp);
- if (TREE_CODE (cast_type) == POINTER_TYPE
- && AGGREGATE_TYPE_P (TREE_TYPE (cast_type)))
- {
- is_aggregate = 1;
- break;
- }
- exp = TREE_OPERAND (exp, 0);
- }
-
- if (is_aggregate == 0)
- {
- tree type;
-
- if (TREE_CODE (exp) == ADDR_EXPR)
- /* If this is the address of an object, check whether the
- object is an array. */
- type = TREE_TYPE (TREE_OPERAND (exp, 0));
- else
- type = TREE_TYPE (TREE_TYPE (exp));
- is_aggregate = AGGREGATE_TYPE_P (type);
- }
+ rtx mem = gen_rtx_MEM (BLKmode,
+ memory_address (BLKmode,
+ expand_expr (exp, NULL_RTX,
+ ptr_mode, EXPAND_SUM)));
+
+ /* Get an expression we can use to find the attributes to assign to MEM.
+ If it is an ADDR_EXPR, use the operand. Otherwise, dereference it if
+ we can. First remove any nops. */
+ while ((TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
+ || TREE_CODE (exp) == NON_LVALUE_EXPR)
+ && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (exp, 0))))
+ exp = TREE_OPERAND (exp, 0);
+
+ if (TREE_CODE (exp) == ADDR_EXPR)
+ exp = TREE_OPERAND (exp, 0);
+ else if (POINTER_TYPE_P (TREE_TYPE (exp)))
+ exp = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (exp)), exp);
+ else
+ return mem;
- MEM_SET_IN_STRUCT_P (mem, is_aggregate);
+ set_mem_attributes (mem, exp, 0);
return mem;
}
@@ -1306,6 +1304,7 @@ expand_builtin_mathfn (exp, target, subtarget)
if we failed the caller should emit a normal call, otherwise
try to get the result in TARGET, if convenient (and in mode MODE if that's
convenient). */
+
static rtx
expand_builtin_strlen (exp, target, mode)
tree exp;
@@ -1377,8 +1376,9 @@ expand_builtin_strlen (exp, target, mode)
TYPE_MODE (integer_type_node));
char_rtx = const0_rtx;
- char_mode = insn_data[(int)icode].operand[2].mode;
- if (! (*insn_data[(int)icode].operand[2].predicate) (char_rtx, char_mode))
+ char_mode = insn_data[(int) icode].operand[2].mode;
+ if (! (*insn_data[(int) icode].operand[2].predicate) (char_rtx,
+ char_mode))
char_rtx = copy_to_mode_reg (char_mode, char_rtx);
pat = GEN_FCN (icode) (result, gen_rtx_MEM (BLKmode, src_reg),
@@ -1390,7 +1390,7 @@ expand_builtin_strlen (exp, target, mode)
/* Now that we are assured of success, expand the source. */
start_sequence ();
pat = memory_address (BLKmode,
- expand_expr (src, src_reg, ptr_mode, EXPAND_SUM));
+ expand_expr (src, src_reg, ptr_mode, EXPAND_SUM));
if (pat != src_reg)
emit_move_insn (src_reg, pat);
pat = gen_sequence ();
@@ -1814,6 +1814,7 @@ expand_builtin_saveregs ()
/* __builtin_args_info (N) returns word N of the arg space info
for the current function. The number and meanings of words
is controlled by the definition of CUMULATIVE_ARGS. */
+
static rtx
expand_builtin_args_info (exp)
tree exp;
@@ -2007,19 +2008,9 @@ expand_builtin_va_start (stdarg_p, arglist)
return const0_rtx;
}
-/* Allocate an alias set for use in storing and reading from the varargs
- spill area. */
-int
-get_varargs_alias_set ()
-{
- static int set = -1;
- if (set == -1)
- set = new_alias_set ();
- return set;
-}
-
/* The "standard" implementation of va_arg: read the value from the
current (padded) address and increment by the (padded) size. */
+
rtx
std_expand_builtin_va_arg (valist, type)
tree valist, type;
@@ -2063,6 +2054,7 @@ std_expand_builtin_va_arg (valist, type)
/* Expand __builtin_va_arg, which is not really a builtin function, but
a very special sort of operator. */
+
rtx
expand_builtin_va_arg (valist, type)
tree valist, type;
@@ -2146,6 +2138,7 @@ expand_builtin_va_arg (valist, type)
}
/* Expand ARGLIST, from a call to __builtin_va_end. */
+
static rtx
expand_builtin_va_end (arglist)
tree arglist;
@@ -2168,6 +2161,7 @@ expand_builtin_va_end (arglist)
/* Expand ARGLIST, from a call to __builtin_va_copy. We do this as a
builtin rather than just as an assignment in stdarg.h because of the
nastiness of array-type va_list types. */
+
static rtx
expand_builtin_va_copy (arglist)
tree arglist;