From 0253134551ad49baaba9fb7ab4b6cfe3374316ba Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 18 Dec 1997 14:52:24 +0000 Subject: [PATCH] except.c: Remove register_exception_table{,_p}. * except.c: Remove register_exception_table{,_p}. * decl2.c (finish_file): Remove call to register_exception_table. * cp-tree.def: Add AGGR_INIT_EXPR. * error.c, tree.c, typeck.c: Replace uses of NEW_EXPR with AGGR_INIT_EXPR where appropriate. * expr.c (cplus_expand_expr): Likewise. Simplify. From-SVN: r17132 --- gcc/ChangeLog | 4 ++ gcc/cp/ChangeLog | 9 ++++ gcc/cp/cp-tree.def | 11 +++-- gcc/cp/decl2.c | 5 +-- gcc/cp/error.c | 2 +- gcc/cp/expr.c | 110 +++++++++++---------------------------------- gcc/cp/tree.c | 8 ++-- gcc/cp/typeck.c | 6 +-- gcc/except.c | 24 ---------- 9 files changed, 55 insertions(+), 124 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ba56ccc0375f..25a230144f07 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +Thu Dec 18 14:51:12 1997 Jason Merrill + + * except.c: Remove register_exception_table{,_p}. + Thu Dec 18 14:57:29 1997 Gavin Koch * dwarf2out.c (dwarf2out_frame_debug): Handle adjustments of the diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c6bd7b6c1876..c320ff1aa32e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +Thu Dec 18 14:43:19 1997 Jason Merrill + + * cp-tree.def: Add AGGR_INIT_EXPR. + * error.c, tree.c, typeck.c: Replace uses of NEW_EXPR with + AGGR_INIT_EXPR where appropriate. + * expr.c (cplus_expand_expr): Likewise. Simplify. + + * decl2.c (finish_file): Remove call to register_exception_table. + Wed Dec 17 17:08:52 1997 Benjamin Kosnik * pt.c (instantiate_class_template): Don't do injection when diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 9665a4d916dc..fc66b2cb58df 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -29,6 +29,12 @@ Boston, MA 02111-1307, USA. */ just won't work for us. */ DEFTREECODE (OFFSET_REF, "offset_ref", 'r', 2) +/* For NEW_EXPR, operand 0 is the placement list. + Operand 1 is the new-declarator. + Operand 2 is the initializer. */ +DEFTREECODE (NEW_EXPR, "nw_expr", 'e', 3) +DEFTREECODE (VEC_NEW_EXPR, "vec_nw_expr", 'e', 3) + /* For DELETE_EXPR, operand 0 is the store to be destroyed. Operand 1 is the value to pass to the destroying function saying whether the store should be deallocated as well. */ @@ -50,11 +56,10 @@ DEFTREECODE (MEMBER_REF, "member_ref", 'r', 2) operator converts to. Operand is expression to be converted. */ DEFTREECODE (TYPE_EXPR, "type_expr", 'e', 1) -/* For NEW_EXPR, operand 0 is function which performs initialization, +/* For AGGR_INIT_EXPR, operand 0 is function which performs initialization, operand 1 is argument list to initialization function, and operand 2 is the slot which was allocated for this expression. */ -DEFTREECODE (NEW_EXPR, "nw_expr", 'e', 3) -DEFTREECODE (VEC_NEW_EXPR, "vec_nw_expr", 'e', 3) +DEFTREECODE (AGGR_INIT_EXPR, "nw_expr", 'e', 3) /* A throw expression. operand 0 is the expression, if there was one, else it is NULL_TREE. */ diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 347feed55b94..8b5134a59433 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2971,7 +2971,7 @@ finish_file () rest_of_decl_compilation (TREE_VALUE (vars), 0, 1, 1); vars = static_aggregates; - if (static_ctors || vars || register_exception_table_p ()) + if (static_ctors || vars) needs_messing_up = 1; if (static_dtors) needs_cleaning = 1; @@ -3070,9 +3070,6 @@ finish_file () push_momentary (); expand_start_bindings (0); - if (register_exception_table_p ()) - register_exception_table (); - while (vars) { tree decl = TREE_VALUE (vars); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 6366a50b462f..b318126211eb 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1205,7 +1205,7 @@ dump_expr (t, nop) } break; - case NEW_EXPR: + case AGGR_INIT_EXPR: OB_PUTID (TYPE_IDENTIFIER (TREE_TYPE (t))); OB_PUTC ('('); if (TREE_OPERAND (t, 1)) diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c index 2162b0d7cf09..a2c166999f43 100644 --- a/gcc/cp/expr.c +++ b/gcc/cp/expr.c @@ -59,7 +59,7 @@ cplus_expand_expr (exp, target, tmode, modifier) switch (code) { - case NEW_EXPR: + case AGGR_INIT_EXPR: { /* Something needs to be initialized, but we didn't know where that thing was when building the tree. For example, @@ -76,8 +76,6 @@ cplus_expand_expr (exp, target, tmode, modifier) tree func = TREE_OPERAND (exp, 0); tree args = TREE_OPERAND (exp, 1); tree type = TREE_TYPE (exp), slot; - tree fn_type = TREE_TYPE (TREE_TYPE (func)); - tree return_type = TREE_TYPE (fn_type); tree call_exp; rtx call_target, return_target; int pcc_struct_return = 0; @@ -86,14 +84,8 @@ cplus_expand_expr (exp, target, tmode, modifier) `target' represents. SLOT holds the slot for TARGET. */ slot = TREE_OPERAND (exp, 2); - if (target == 0) - { - /* Should always be called with a target in BLKmode case. */ - my_friendly_assert (mode != BLKmode, 205); - my_friendly_assert (DECL_RTL (slot) != 0, 206); - - target = gen_reg_rtx (mode); - } + /* Should always be called with a target. */ + my_friendly_assert (target != NULL_RTX, 205); /* The target the initializer will initialize (CALL_TARGET) must now be directed to initialize the target we are @@ -118,11 +110,6 @@ cplus_expand_expr (exp, target, tmode, modifier) TREE_VALUE (args) = build1 (ADDR_EXPR, type, slot); call_target = 0; } - else if (TREE_CODE (return_type) == REFERENCE_TYPE) - { - type = return_type; - call_target = 0; - } else { #ifdef PCC_STATIC_STRUCT_RETURN @@ -132,89 +119,42 @@ cplus_expand_expr (exp, target, tmode, modifier) call_target = target; #endif } - if (call_target) - { - /* Make this a valid memory address now. The code below assumes - that it can compare rtx and make assumptions based on the - result. The assumptions are true only if the address was - valid to begin with. */ - call_target = validize_mem (call_target); - - /* If this is a reference to a symbol, expand_inline_function - will do this transformation and return a different target - than the one we gave it, though functionally equivalent. Do - the transformation here to avoid confusion. */ - if (! cse_not_expected && GET_CODE (call_target) == MEM - && GET_CODE (XEXP (call_target, 0)) == SYMBOL_REF) - { - call_target = gen_rtx - (MEM, mode, memory_address (mode, XEXP (call_target, 0))); - MEM_IN_STRUCT_P (call_target) = 1; - } - } call_exp = build (CALL_EXPR, type, func, args, NULL_TREE); TREE_SIDE_EFFECTS (call_exp) = 1; return_target = expand_call (call_exp, call_target, ignore); - if (call_target == 0) - { - if (pcc_struct_return) - { - extern int flag_access_control; - int old_ac = flag_access_control; - - tree init = build_decl (VAR_DECL, 0, type); - TREE_ADDRESSABLE (init) = 1; - DECL_RTL (init) = return_target; - - flag_access_control = 0; - expand_aggr_init (slot, init, 0, LOOKUP_ONLYCONVERTING); - flag_access_control = old_ac; - - if (TYPE_NEEDS_DESTRUCTOR (type)) - { - init = build_decl (VAR_DECL, 0, - build_reference_type (type)); - DECL_RTL (init) = XEXP (return_target, 0); - - init = maybe_build_cleanup (convert_from_reference (init)); - if (init != NULL_TREE) - expand_expr (init, const0_rtx, VOIDmode, 0); - } - call_target = return_target = DECL_RTL (slot); - } - else - call_target = return_target; - } - if (call_target != return_target) + if (call_target) { - my_friendly_assert (TYPE_HAS_TRIVIAL_INIT_REF (type), 317); - if (GET_MODE (return_target) == BLKmode) - emit_block_move (call_target, return_target, expr_size (exp), - TYPE_ALIGN (type) / BITS_PER_UNIT); - else - emit_move_insn (call_target, return_target); + my_friendly_assert (rtx_equal_p (call_target, return_target) + || TYPE_HAS_TRIVIAL_INIT_REF (type), 317); + return return_target; } - if (TREE_CODE (return_type) == REFERENCE_TYPE) + /* If we're suffering under the ancient PCC_STATIC_STRUCT_RETURN + calling convention, we need to copy the return value out of + the static return buffer into slot. */ + if (pcc_struct_return) { - tree init; - - if (GET_CODE (call_target) == REG - && REGNO (call_target) < FIRST_PSEUDO_REGISTER) - my_friendly_abort (39); + extern int flag_access_control; + int old_ac = flag_access_control; - type = TREE_TYPE (exp); + tree init = build_decl (VAR_DECL, NULL_TREE, + build_reference_type (type)); + DECL_RTL (init) = XEXP (return_target, 0); - init = build (RTL_EXPR, return_type, 0, call_target); - /* We got back a reference to the type we want. Now initialize - target with that. */ + flag_access_control = 0; expand_aggr_init (slot, init, 0, LOOKUP_ONLYCONVERTING); + flag_access_control = old_ac; + + if (TYPE_NEEDS_DESTRUCTOR (type)) + { + init = maybe_build_cleanup (convert_from_reference (init)); + if (init != NULL_TREE) + expand_expr (init, const0_rtx, VOIDmode, 0); + } } - if (DECL_RTL (slot) != target) - emit_move_insn (DECL_RTL (slot), target); return DECL_RTL (slot); } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 0c03de9c93c7..735e1a7abde1 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -244,13 +244,13 @@ build_cplus_new (type, init) tree slot; tree rval; - if (TREE_CODE (init) != CALL_EXPR && TREE_CODE (init) != NEW_EXPR) + if (TREE_CODE (init) != CALL_EXPR && TREE_CODE (init) != AGGR_INIT_EXPR) return init; slot = build (VAR_DECL, type); DECL_ARTIFICIAL (slot) = 1; layout_decl (slot, 0); - rval = build (NEW_EXPR, type, + rval = build (AGGR_INIT_EXPR, type, TREE_OPERAND (init, 0), TREE_OPERAND (init, 1), slot); TREE_SIDE_EFFECTS (rval) = 1; rval = build (TARGET_EXPR, type, slot, rval, NULL_TREE, NULL_TREE); @@ -1498,7 +1498,7 @@ mapcar (t, func) case COND_EXPR: case TARGET_EXPR: - case NEW_EXPR: + case AGGR_INIT_EXPR: t = copy_node (t); TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func); TREE_OPERAND (t, 1) = mapcar (TREE_OPERAND (t, 1), func); @@ -1761,7 +1761,7 @@ bot_manip (t) return t; else if (TREE_CODE (t) == TARGET_EXPR) { - if (TREE_CODE (TREE_OPERAND (t, 1)) == NEW_EXPR) + if (TREE_CODE (TREE_OPERAND (t, 1)) == AGGR_INIT_EXPR) { mark_used (TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (t, 1), 0), 0)); return build_cplus_new diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 82db8653999d..365618743245 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -7310,10 +7310,10 @@ c_expand_return (retval) return; } - /* We can't initialize a register from a NEW_EXPR. */ + /* We can't initialize a register from a AGGR_INIT_EXPR. */ else if (! current_function_returns_struct && TREE_CODE (retval) == TARGET_EXPR - && TREE_CODE (TREE_OPERAND (retval, 1)) == NEW_EXPR) + && TREE_CODE (TREE_OPERAND (retval, 1)) == AGGR_INIT_EXPR) retval = build (COMPOUND_EXPR, TREE_TYPE (retval), retval, TREE_OPERAND (retval, 0)); @@ -7337,7 +7337,7 @@ c_expand_return (retval) if (TREE_CODE (whats_returned) == ADDR_EXPR) { whats_returned = TREE_OPERAND (whats_returned, 0); - while (TREE_CODE (whats_returned) == NEW_EXPR + while (TREE_CODE (whats_returned) == AGGR_INIT_EXPR || TREE_CODE (whats_returned) == TARGET_EXPR) { /* Get the target. */ diff --git a/gcc/except.c b/gcc/except.c index e2a591447c0b..c12185f04dd0 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -1559,18 +1559,6 @@ exception_table_p () return 0; } -/* 1 if we need a static constructor to register EH table info. */ - -int -register_exception_table_p () -{ -#if defined (DWARF2_UNWIND_INFO) - return 0; -#endif - - return exception_table_p (); -} - /* Output the entry of the exception table corresponding to to the exception region numbered N to file FILE. @@ -1628,18 +1616,6 @@ output_exception_table () assemble_integer (constm1_rtx, POINTER_SIZE / BITS_PER_UNIT, 1); putc ('\n', asm_out_file); /* blank line */ } - -/* Generate code to initialize the exception table at program startup - time. */ - -void -register_exception_table () -{ - emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__register_exceptions"), 0, - VOIDmode, 1, - gen_rtx (SYMBOL_REF, Pmode, "__EXCEPTION_TABLE__"), - Pmode); -} /* Emit code to get EH context. -- 2.43.5