2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Functionality to modify the type graph.
23 * @author Goetz Lindenmaier, Michael Beck
34 void exchange_types(ir_type *old_type, ir_type *new_type) {
35 unsigned flags = old_type->flags & (tf_frame_type | tf_value_param_type | tf_global_type | tf_tls_type);
36 /* Deallocate datastructures not directly contained in the
37 old type. We must do this now as it is the latest point
38 where we know the original kind of type.
40 free_type_attrs(old_type);
44 * After exchange_types the type has two entries in the list of
45 all types in irp. So far this is fine for the walker.
46 Maybe it's better to remove the id entry and shrink the list.
47 Does this conflict with the walker? Might a type be left out
49 * Deallocation: if the Id is removed from the list it will eventually
50 disappear in a memory leak. When is impossible to determine so we
51 need to hold it in a separate list for deallocation.
54 /* Exchange the types */
55 old_type->type_op = type_id;
56 old_type->mode = (ir_mode *) new_type;
57 /* ensure that the frame, value param, global and tls flags
58 are set right if these types are exchanged */
59 new_type->flags |= flags;
62 ir_type *skip_tid(ir_type *tp) {
63 /* @@@ implement the self cycle killing trick of skip_id(ir_node *) */
64 while (tp->type_op == type_id)
65 tp = (ir_type *) tp->mode;