ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/kpx_cpu/include/basic-blockinfo.hpp
Revision: 1.2
Committed: 2003-11-03T21:28:30Z (21 years ago) by gbeauche
Branch: MAIN
Changes since 1.1: +1 -0 lines
Log Message:
Implement partial block cache invalidation. Rewrite core cached blocks
execution loop with a Duff's device. Gather some predecode time statistics.
This shows that only around 2% of total emulation time is spent for
predecoding the instructions.

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 gbeauche 1.2 uintptr end_pc;
39 gbeauche 1.1 int32 count;
40     uint32 size;
41     uint32 c1;
42     uint32 c2;
43    
44     // List of blocks we depend on
45     dependency dep[MAX_TARGETS];
46    
47     // List of blocks that depends on this block
48     dependency * deplist;
49    
50     void init(uintptr start_pc);
51     void remove_dep(dependency *d);
52     void remove_deps();
53     void create_jmpdep(block_info *tbi, int i);
54     void maybe_create_jmpdep(block_info *tbi);
55     };
56    
57     inline void
58     basic_block_info::init(uintptr start_pc)
59     {
60     pc = start_pc;
61     deplist = NULL;
62     for (int i = 0; i < MAX_TARGETS; i++) {
63     dep[i].source = NULL;
64     dep[i].target = NULL;
65     dep[i].next = NULL;
66     dep[i].prev_p = NULL;
67     }
68     }
69    
70     inline void
71     basic_block_info::remove_dep(dependency *d)
72     {
73     if (d->prev_p)
74     *(d->prev_p) = d->next;
75     if (d->next)
76     d->next->prev_p = d->prev_p;
77     d->prev_p = NULL;
78     d->next = NULL;
79     }
80    
81     inline void
82     basic_block_info::remove_deps()
83     {
84     for (int i = 0; i < MAX_TARGETS; i++)
85     remove_dep(&dep[i]);
86     }
87    
88     inline void
89     basic_block_info::create_jmpdep(block_info *tbi, int i)
90     {
91     dep[i].source = this;
92     dep[i].target = tbi;
93     dep[i].next = tbi->deplist;
94     if (dep[i].next)
95     dep[i].next->prev_p = &(dep[i].next);
96     dep[i].prev_p = &(tbi->deplist);
97     tbi->deplist = &(dep[i]);
98     }
99    
100     inline void
101     basic_block_info::maybe_create_jmpdep(block_info *tbi)
102     {
103     for (int i = 0; i < MAX_TARGETS && dep[i].target != tbi; i++) {
104     if (dep[i].source == NULL) {
105     create_jmpdep(tbi, i);
106     break;
107     }
108     }
109     }
110    
111     #endif /* BASIC_BLOCKINFO_H */