2 * Copyright (c) 2007 MIPS Technologies, Inc.
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.
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.
28 * Authors: Korey Sewell
32 #ifndef CPU_INORDER_REG_DEP_MAP_HH
33 #define CPU_INORDER_REG_DEP_MAP_HH
39 #include "arch/isa_traits.hh"
40 #include "config/the_isa.hh"
41 #include "cpu/inorder/pipeline_traits.hh"
46 typedef ThePipeline::DynInstPtr DynInstPtr;
47 typedef TheISA::RegIndex RegIndex;
48 typedef uint8_t RegType;
50 RegDepMap(int size = TheISA::TotalNumRegs);
53 static std::string mapNames[];
57 void setCPU(InOrderCPU *_cpu);
59 /** Clear the Entire Map */
62 /** Insert all of a instruction's destination registers into map*/
63 void insert(DynInstPtr inst);
65 /** Remove all of a instruction's destination registers into map*/
66 void remove(DynInstPtr inst);
68 /** Remove Front instruction from a destination register */
69 void removeFront(uint8_t reg_type, RegIndex idx, DynInstPtr inst);
71 /** Is the current instruction able to read from this
72 * destination register?
74 bool canRead(uint8_t reg_type, RegIndex idx, DynInstPtr inst);
76 /** Is the current instruction able to get a forwarded value from
77 * another instruction for this destination register?
79 DynInstPtr canForward(uint8_t reg_type, unsigned reg_idx,
80 DynInstPtr inst, unsigned clean_idx);
82 /** find an instruction to forward/bypass a value from */
83 DynInstPtr findBypassInst(RegIndex idx);
85 /** Is the current instruction able to write to this
86 * destination register?
88 bool canWrite(uint8_t reg_type, RegIndex idx, DynInstPtr inst);
90 /** Size of Dependency of Map */
91 int depSize(RegIndex idx);
96 /** Insert an instruction into a specific destination register index
97 * onto map. This must be called w/the unflattened registered index
99 void insert(RegIndex idx, DynInstPtr inst);
101 /** Remove a specific instruction and dest. register index from map
102 * This must be called w/the unflattened registered index
104 void remove(RegIndex idx, DynInstPtr inst);
106 typedef std::vector<std::list<DynInstPtr> > DepMap;
107 std::vector<DepMap> regMap;