inorder: add types for dependency checks
[gem5.git] / src / cpu / inorder / reg_dep_map.hh
1 /*
2 * Copyright (c) 2007 MIPS Technologies, Inc.
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: Korey Sewell
29 *
30 */
31
32 #ifndef CPU_INORDER_REG_DEP_MAP_HH
33 #define CPU_INORDER_REG_DEP_MAP_HH
34
35 #include <list>
36 #include <vector>
37 #include <string>
38
39 #include "arch/isa_traits.hh"
40 #include "config/the_isa.hh"
41 #include "cpu/inorder/pipeline_traits.hh"
42
43 class RegDepMap
44 {
45 public:
46 typedef ThePipeline::DynInstPtr DynInstPtr;
47 typedef TheISA::RegIndex RegIndex;
48 typedef uint8_t RegType;
49
50 RegDepMap(int size = TheISA::TotalNumRegs);
51 ~RegDepMap();
52
53 static std::string mapNames[];
54
55 std::string name();
56
57 void setCPU(InOrderCPU *_cpu);
58
59 /** Clear the Entire Map */
60 void clear();
61
62 /** Insert all of a instruction's destination registers into map*/
63 void insert(DynInstPtr inst);
64
65 /** Remove all of a instruction's destination registers into map*/
66 void remove(DynInstPtr inst);
67
68 /** Remove Front instruction from a destination register */
69 void removeFront(uint8_t reg_type, RegIndex idx, DynInstPtr inst);
70
71 /** Is the current instruction able to read from this
72 * destination register?
73 */
74 bool canRead(uint8_t reg_type, RegIndex idx, DynInstPtr inst);
75
76 /** Is the current instruction able to get a forwarded value from
77 * another instruction for this destination register?
78 */
79 DynInstPtr canForward(uint8_t reg_type, unsigned reg_idx,
80 DynInstPtr inst, unsigned clean_idx);
81
82 /** find an instruction to forward/bypass a value from */
83 DynInstPtr findBypassInst(RegIndex idx);
84
85 /** Is the current instruction able to write to this
86 * destination register?
87 */
88 bool canWrite(uint8_t reg_type, RegIndex idx, DynInstPtr inst);
89
90 /** Size of Dependency of Map */
91 int depSize(RegIndex idx);
92
93 void dump();
94
95 private:
96 /** Insert an instruction into a specific destination register index
97 * onto map. This must be called w/the unflattened registered index
98 */
99 void insert(RegIndex idx, DynInstPtr inst);
100
101 /** Remove a specific instruction and dest. register index from map
102 * This must be called w/the unflattened registered index
103 */
104 void remove(RegIndex idx, DynInstPtr inst);
105
106 typedef std::vector<std::list<DynInstPtr> > DepMap;
107 std::vector<DepMap> regMap;
108
109 InOrderCPU *cpu;
110 };
111
112 #endif
113
114
115
116
117
118
119