A few minor non-debug compilation issues.
[gem5.git] / src / mem / cache / tags / repl / repl.hh
1 /*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Erik Hallnor
29 * Steve Reinhardt
30 * Nathan Binkert
31 */
32
33 /**
34 * @file
35 * Declaration of a base replacement policy class.
36 */
37
38 #ifndef __REPL_HH__
39 #define __REPL_HH__
40
41 #include <string>
42 #include <list>
43
44 #include "cpu/smt.hh"
45 #include "sim/host.hh"
46 #include "sim/sim_object.hh"
47
48
49 class IIC;
50
51 /**
52 * A pure virtual base class that defines the interface of a replacement
53 * policy.
54 */
55 class Repl : public SimObject
56 {
57 public:
58 /** Pointer to the IIC using this policy. */
59 IIC *iic;
60
61 /**
62 * Construct and initialize this polixy.
63 * @param name The instance name of this policy.
64 */
65 Repl (const std::string &name)
66 : SimObject(name)
67 {
68 iic = NULL;
69 }
70
71 /**
72 * Set the back pointer to the IIC.
73 * @param iic_ptr Pointer to the IIC.
74 */
75 void setIIC(IIC *iic_ptr)
76 {
77 iic = iic_ptr;
78 }
79
80 /**
81 * Returns the tag pointer of the cache block to replace.
82 * @return The tag to replace.
83 */
84 virtual unsigned long getRepl() = 0;
85
86 /**
87 * Return an array of N tag pointers to replace.
88 * @param n The number of tag pointer to return.
89 * @return An array of tag pointers to replace.
90 */
91 virtual unsigned long *getNRepl(int n) = 0;
92
93 /**
94 * Update replacement data
95 */
96 virtual void doAdvance(std::list<unsigned long> &demoted) = 0;
97
98 /**
99 * Add a tag to the replacement policy and return a pointer to the
100 * replacement entry.
101 * @param tag_index The tag to add.
102 * @return The replacement entry.
103 */
104 virtual void* add(unsigned long tag_index) = 0;
105
106 /**
107 * Register statistics.
108 * @param name The name to prepend to statistic descriptions.
109 */
110 virtual void regStats(const std::string name) = 0;
111
112 /**
113 * Update the tag pointer to when the tag moves.
114 * @param re The replacement entry of the tag.
115 * @param old_index The old tag pointer.
116 * @param new_index The new tag pointer.
117 * @return 1 if successful, 0 otherwise.
118 */
119 virtual int fixTag(void *re, unsigned long old_index,
120 unsigned long new_index) = 0;
121
122 /**
123 * Remove this entry from the replacement policy.
124 * @param re The replacement entry to remove
125 */
126 virtual void removeEntry(void *re) = 0;
127 };
128
129 #endif /* SMT_REPL_HH */