Add flags for the global and TLS type to help debugging
[libfirm] / ir / tr / typegmod.c
1 /*
2  * Project:     libFIRM
3  * File name:   ir/tr/typegmod.c
4  * Purpose:     Functionality to modify the type graph.
5  * Author:      Goetz Lindenmaier
6  * Modified by: Michael Beck
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2001-2006 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15
16 #include "typegmod.h"
17 #include "type_t.h"
18 #include "tpop_t.h"
19 #include "irmode.h"
20
21 void exchange_types(ir_type *old_type, ir_type *new_type) {
22   unsigned flags = old_type->flags & (tf_frame_type | tf_value_param_type | tf_global_type | tf_tls_type);
23   /* Deallocate datastructures not directly contained in the
24      old type.  We must do this now as it is the latest point
25      where we know the original kind of type.
26      */
27   free_type_attrs(old_type);
28
29   /* @@@@
30      Things to deal with:
31      * After exchange_types the type has two entries in the list of
32        all types in irp.  So far this is fine for the walker.
33        Maybe it's better to remove the id entry and shrink the list.
34        Does this conflict with the walker?  Might a type be left out
35        during the walk?
36      * Deallocation:  if the Id is removed from the list it will eventually
37        disappear in a memory leak.  When is impossible to determine so we
38        need to hold it in a separate list for deallocation.
39   */
40
41   /* Exchange the types */
42   old_type->type_op = type_id;
43   old_type->mode = (ir_mode *) new_type;
44   /* ensure that the frame, value param, global and tls flags
45      are set right if these types are exchanged */
46   new_type->flags |= flags;
47 }
48
49 ir_type *skip_tid(ir_type *tp) {
50   /* @@@ implement the self cycle killing trick of skip_id(ir_node *) */
51   while (tp->type_op == type_id)
52     tp = (ir_type *) tp->mode;
53   return tp;
54 }