arch-arm,cpu: Introduce a getEMI virtual method on StaticInst.
[gem5.git] / src / cpu / func_unit.cc
1 /*
2 * Copyright (c) 2002-2006 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
29 #include "cpu/func_unit.hh"
30
31 #include <sstream>
32
33 #include "base/logging.hh"
34
35 ////////////////////////////////////////////////////////////////////////////
36 //
37 // The funciton unit
38 //
39 FuncUnit::FuncUnit()
40 {
41 opLatencies.fill(0);
42 pipelined.fill(false);
43 capabilityList.reset();
44 }
45
46
47 // Copy constructor
48 FuncUnit::FuncUnit(const FuncUnit &fu)
49 {
50
51 for (int i = 0; i < Num_OpClasses; ++i) {
52 opLatencies[i] = fu.opLatencies[i];
53 pipelined[i] = fu.pipelined[i];
54 }
55
56 capabilityList = fu.capabilityList;
57 }
58
59
60 void
61 FuncUnit::addCapability(OpClass cap, unsigned oplat, bool pipeline)
62 {
63 if (oplat == 0)
64 panic("FuncUnit: you don't really want a zero-cycle latency do you?");
65
66 capabilityList.set(cap);
67
68 opLatencies[cap] = oplat;
69 pipelined[cap] = pipeline;
70 }
71
72 bool
73 FuncUnit::provides(OpClass capability)
74 {
75 return capabilityList[capability];
76 }
77
78 std::bitset<Num_OpClasses>
79 FuncUnit::capabilities()
80 {
81 return capabilityList;
82 }
83
84 unsigned &
85 FuncUnit::opLatency(OpClass cap)
86 {
87 return opLatencies[cap];
88 }
89
90 bool
91 FuncUnit::isPipelined(OpClass capability)
92 {
93 return pipelined[capability];
94 }