gem5  v20.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
timing_expr.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 ARM Limited
3  * All rights reserved.
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 /*
39  * These classes define an expression language over uint64_t with only
40  * a few operators. This can be used to form expressions for the extra
41  * delay required in variable execution time instructions.
42  *
43  * Expressions, in evaluation, will have access to the ThreadContext and
44  * a StaticInst.
45  */
46 
47 #ifndef __CPU_TIMING_EXPR_HH__
48 #define __CPU_TIMING_EXPR_HH__
49 
50 #include "cpu/static_inst.hh"
51 #include "cpu/thread_context.hh"
52 #include "enums/TimingExprOp.hh"
53 #include "params/TimingExpr.hh"
54 #include "params/TimingExprBin.hh"
55 #include "params/TimingExprIf.hh"
56 #include "params/TimingExprLet.hh"
57 #include "params/TimingExprLiteral.hh"
58 #include "params/TimingExprReadIntReg.hh"
59 #include "params/TimingExprRef.hh"
60 #include "params/TimingExprSrcReg.hh"
61 #include "params/TimingExprUn.hh"
62 #include "sim/sim_object.hh"
63 
67 class TimingExprLet;
68 
71 {
72  public:
76 
83 
85  ThreadContext *thread_, TimingExprLet *let_);
86 };
87 
88 class TimingExpr : public SimObject
89 {
90  public:
91  TimingExpr(const TimingExprParams *params) :
92  SimObject(params)
93  { }
94 
95  virtual uint64_t eval(TimingExprEvalContext &context) = 0;
96 };
97 
99 {
100  public:
101  uint64_t value;
102 
103  TimingExprLiteral(const TimingExprLiteralParams *params) :
104  TimingExpr(params),
105  value(params->value)
106  { }
107 
108  uint64_t eval(TimingExprEvalContext &context) { return value; }
109 };
110 
112 {
113  public:
114  unsigned int index;
115 
116  TimingExprSrcReg(const TimingExprSrcRegParams *params) :
117  TimingExpr(params),
118  index(params->index)
119  { }
120 
121  uint64_t eval(TimingExprEvalContext &context);
122 };
123 
125 {
126  public:
128 
129  TimingExprReadIntReg(const TimingExprReadIntRegParams *params) :
130  TimingExpr(params),
131  reg(params->reg)
132  { }
133 
134  uint64_t eval(TimingExprEvalContext &context);
135 };
136 
137 class TimingExprLet : public TimingExpr
138 {
139  public:
142 
143  TimingExprLet(const TimingExprLetParams *params) :
144  TimingExpr(params),
145  defns(params->defns),
146  expr(params->expr)
147  { }
148 
149  uint64_t eval(TimingExprEvalContext &context);
150 };
151 
152 class TimingExprRef : public TimingExpr
153 {
154  public:
155  unsigned int index;
156 
157  TimingExprRef(const TimingExprRefParams *params) :
158  TimingExpr(params),
159  index(params->index)
160  { }
161 
162  uint64_t eval(TimingExprEvalContext &context);
163 };
164 
165 class TimingExprUn : public TimingExpr
166 {
167  public:
168  Enums::TimingExprOp op;
170 
171  TimingExprUn(const TimingExprUnParams *params) :
172  TimingExpr(params),
173  op(params->op),
174  arg(params->arg)
175  { }
176 
177  uint64_t eval(TimingExprEvalContext &context);
178 };
179 
180 class TimingExprBin : public TimingExpr
181 {
182  public:
183  Enums::TimingExprOp op;
186 
187  TimingExprBin(const TimingExprBinParams *params) :
188  TimingExpr(params),
189  op(params->op),
190  left(params->left),
191  right(params->right)
192  { }
193 
194  uint64_t eval(TimingExprEvalContext &context);
195 };
196 
197 class TimingExprIf : public TimingExpr
198 {
199  public:
203 
204  TimingExprIf(const TimingExprIfParams *params) :
205  TimingExpr(params),
206  cond(params->cond),
207  trueExpr(params->trueExpr),
208  falseExpr(params->falseExpr)
209  { }
210 
211  uint64_t eval(TimingExprEvalContext &context);
212 };
213 
214 #endif
TimingExprBin(const TimingExprBinParams *params)
Definition: timing_expr.hh:187
Enums::TimingExprOp op
Definition: timing_expr.hh:183
TimingExpr * expr
Definition: timing_expr.hh:141
TimingExprEvalContext(const StaticInstPtr &inst_, ThreadContext *thread_, TimingExprLet *let_)
Definition: timing_expr.cc:42
TimingExpr * arg
Definition: timing_expr.hh:169
TimingExprUn(const TimingExprUnParams *params)
Definition: timing_expr.hh:171
TimingExprLet(const TimingExprLetParams *params)
Definition: timing_expr.hh:143
Object to gather the visible context for evaluation.
Definition: timing_expr.hh:70
TimingExpr * right
Definition: timing_expr.hh:185
TimingExpr * cond
Definition: timing_expr.hh:200
ThreadContext is the external interface to all thread state for anything outside of the CPU...
std::vector< uint64_t > results
Definition: timing_expr.hh:81
TimingExprRef(const TimingExprRefParams *params)
Definition: timing_expr.hh:157
TimingExprLet * let
Context visible as sub expressions.
Definition: timing_expr.hh:80
TimingExprSrcReg(const TimingExprSrcRegParams *params)
Definition: timing_expr.hh:116
unsigned int index
Definition: timing_expr.hh:114
std::vector< bool > resultAvailable
Definition: timing_expr.hh:82
TimingExpr * left
Definition: timing_expr.hh:184
TimingExpr * trueExpr
Definition: timing_expr.hh:201
const StaticInstPtr & inst
Special visible context.
Definition: timing_expr.hh:74
unsigned int index
Definition: timing_expr.hh:155
TimingExprReadIntReg(const TimingExprReadIntRegParams *params)
Definition: timing_expr.hh:129
uint64_t eval(TimingExprEvalContext &context)
Definition: timing_expr.hh:108
ThreadContext * thread
Definition: timing_expr.hh:75
TimingExprLiteral(const TimingExprLiteralParams *params)
Definition: timing_expr.hh:103
TimingExprIf(const TimingExprIfParams *params)
Definition: timing_expr.hh:204
TimingExpr(const TimingExprParams *params)
Definition: timing_expr.hh:91
Enums::TimingExprOp op
Definition: timing_expr.hh:168
std::vector< TimingExpr * > defns
Definition: timing_expr.hh:140
Abstract superclass for simulation objects.
Definition: sim_object.hh:93
TimingExpr * falseExpr
Definition: timing_expr.hh:202

Generated on Thu May 28 2020 16:21:31 for gem5 by doxygen 1.8.13