1 /* This file contains the definitions and documentation for the common
2 tree codes used in the GNU C and C++ compilers (see c-common.def
3 for the standard codes).
4 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
5 Free Software Foundation, Inc.
6 Written by Benjamin Chelf (chelf@codesourcery.com).
8 This file is part of GCC.
10 GCC is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 2, or (at your option) any later
15 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING. If not, write to the Free
22 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
27 #include "coretypes.h"
31 #include "splay-tree.h"
35 /* In order for the format checking to accept the C frontend
36 diagnostic framework extensions, you must define this token before
37 including toplev.h. */
38 #define GCC_DIAG_STYLE __gcc_cdiag__
46 #include "tree-inline.h"
47 #include "tree-gimple.h"
48 #include "langhooks.h"
50 /* Create an empty statement tree rooted at T. */
56 t
= alloc_stmt_list ();
57 TREE_CHAIN (t
) = cur_stmt_list
;
62 /* Finish the statement tree rooted at T. */
65 pop_stmt_list (tree t
)
67 tree u
= cur_stmt_list
, chain
;
69 /* Pop statement lists until we reach the target level. The extra
70 nestings will be due to outstanding cleanups. */
73 chain
= TREE_CHAIN (u
);
74 TREE_CHAIN (u
) = NULL_TREE
;
79 cur_stmt_list
= chain
;
81 /* If the statement list is completely empty, just return it. This is
82 just as good small as build_empty_stmt, with the advantage that
83 statement lists are merged when they appended to one another. So
84 using the STATEMENT_LIST avoids pathological buildup of EMPTY_STMT_P
86 if (TREE_SIDE_EFFECTS (t
))
88 tree_stmt_iterator i
= tsi_start (t
);
90 /* If the statement list contained exactly one statement, then
91 extract it immediately. */
92 if (tsi_one_before_end_p (i
))
104 /* Build a generic statement based on the given type of node and
105 arguments. Similar to `build_nt', except that we set
106 EXPR_LOCATION to be the current source location. */
107 /* ??? This should be obsolete with the lineno_stmt productions
111 build_stmt (enum tree_code code
, ...)
120 ret
= make_node (code
);
121 TREE_TYPE (ret
) = void_type_node
;
122 length
= TREE_CODE_LENGTH (code
);
123 SET_EXPR_LOCATION (ret
, input_location
);
125 /* TREE_SIDE_EFFECTS will already be set for statements with
126 implicit side effects. Here we make sure it is set for other
127 expressions by checking whether the parameters have side
130 side_effects
= false;
131 for (i
= 0; i
< length
; i
++)
133 tree t
= va_arg (p
, tree
);
134 if (t
&& !TYPE_P (t
))
135 side_effects
|= TREE_SIDE_EFFECTS (t
);
136 TREE_OPERAND (ret
, i
) = t
;
139 TREE_SIDE_EFFECTS (ret
) |= side_effects
;
145 /* Let the back-end know about DECL. */
148 emit_local_var (tree decl
)
150 /* Create RTL for this variable. */
151 if (!DECL_RTL_SET_P (decl
))
153 if (DECL_HARD_REGISTER (decl
))
154 /* The user specified an assembler name for this variable.
156 rest_of_decl_compilation (decl
, 0, 0);
162 /* Create a CASE_LABEL_EXPR tree node and return it. */
165 build_case_label (tree low_value
, tree high_value
, tree label_decl
)
167 return build_stmt (CASE_LABEL_EXPR
, low_value
, high_value
, label_decl
);