ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/kpx_cpu/include/basic-blockinfo.hpp
Revision: 1.1
Committed: 2003-09-07T14:25:03Z (21 years, 2 months ago) by gbeauche
Branch: MAIN
Log Message:
Merge in old kpx_cpu snapshot for debugging

File Contents

# User Rev Content
1 gbeauche 1.1 /*
2     * basic-blockinfo.hpp - PowerPC basic block information
3     *
4     * Kheperix (C) 2003 Gwenole Beauchesne
5     *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #ifndef BASIC_BLOCKINFO_H
22     #define BASIC_BLOCKINFO_H
23    
24     struct basic_block_info
25     {
26     typedef basic_block_info block_info;
27     static const int MAX_TARGETS = 2;
28    
29     struct dependency
30     {
31     block_info * source;
32     block_info * target;
33     dependency * next;
34     dependency ** prev_p;
35     };
36    
37     uintptr pc;
38     int32 count;
39     uint32 size;
40     uint32 c1;
41     uint32 c2;
42    
43     // List of blocks we depend on
44     dependency dep[MAX_TARGETS];
45    
46     // List of blocks that depends on this block
47     dependency * deplist;
48    
49     void init(uintptr start_pc);
50     void remove_dep(dependency *d);
51     void remove_deps();
52     void create_jmpdep(block_info *tbi, int i);
53     void maybe_create_jmpdep(block_info *tbi);
54     };
55    
56     inline void
57     basic_block_info::init(uintptr start_pc)
58     {
59     pc = start_pc;
60     deplist = NULL;
61     for (int i = 0; i < MAX_TARGETS; i++) {
62     dep[i].source = NULL;
63     dep[i].target = NULL;
64     dep[i].next = NULL;
65     dep[i].prev_p = NULL;
66     }
67     }
68    
69     inline void
70     basic_block_info::remove_dep(dependency *d)
71     {
72     if (d->prev_p)
73     *(d->prev_p) = d->next;
74     if (d->next)
75     d->next->prev_p = d->prev_p;
76     d->prev_p = NULL;
77     d->next = NULL;
78     }
79    
80     inline void
81     basic_block_info::remove_deps()
82     {
83     for (int i = 0; i < MAX_TARGETS; i++)
84     remove_dep(&dep[i]);
85     }
86    
87     inline void
88     basic_block_info::create_jmpdep(block_info *tbi, int i)
89     {
90     dep[i].source = this;
91     dep[i].target = tbi;
92     dep[i].next = tbi->deplist;
93     if (dep[i].next)
94     dep[i].next->prev_p = &(dep[i].next);
95     dep[i].prev_p = &(tbi->deplist);
96     tbi->deplist = &(dep[i]);
97     }
98    
99     inline void
100     basic_block_info::maybe_create_jmpdep(block_info *tbi)
101     {
102     for (int i = 0; i < MAX_TARGETS && dep[i].target != tbi; i++) {
103     if (dep[i].source == NULL) {
104     create_jmpdep(tbi, i);
105     break;
106     }
107     }
108     }
109    
110     #endif /* BASIC_BLOCKINFO_H */