gem5  v20.1.0.0
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) :
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) :
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) :
118  index(params->index)
119  { }
120 
121  uint64_t eval(TimingExprEvalContext &context);
122 };
123 
125 {
126  public:
128 
129  TimingExprReadIntReg(const TimingExprReadIntRegParams *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) :
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) :
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) :
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) :
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) :
206  cond(params->cond),
209  { }
210 
211  uint64_t eval(TimingExprEvalContext &context);
212 };
213 
214 #endif
TimingExprIf::trueExpr
TimingExpr * trueExpr
Definition: timing_expr.hh:201
TimingExprBin::left
TimingExpr * left
Definition: timing_expr.hh:184
TimingExprLet::defns
std::vector< TimingExpr * > defns
Definition: timing_expr.hh:140
TimingExprSrcReg::TimingExprSrcReg
TimingExprSrcReg(const TimingExprSrcRegParams *params)
Definition: timing_expr.hh:116
TimingExprEvalContext
Object to gather the visible context for evaluation.
Definition: timing_expr.hh:70
TimingExprBin::TimingExprBin
TimingExprBin(const TimingExprBinParams *params)
Definition: timing_expr.hh:187
TimingExprEvalContext::let
TimingExprLet * let
Context visible as sub expressions.
Definition: timing_expr.hh:80
TimingExprSrcReg::index
unsigned int index
Definition: timing_expr.hh:114
TimingExprIf::falseExpr
TimingExpr * falseExpr
Definition: timing_expr.hh:202
TimingExprLiteral
Definition: timing_expr.hh:98
TimingExprLet::TimingExprLet
TimingExprLet(const TimingExprLetParams *params)
Definition: timing_expr.hh:143
std::vector< uint64_t >
TimingExprEvalContext::inst
const StaticInstPtr & inst
Special visible context.
Definition: timing_expr.hh:74
TimingExpr
Definition: timing_expr.hh:88
TimingExprRef::eval
uint64_t eval(TimingExprEvalContext &context)
Definition: timing_expr.cc:75
TimingExprIf
Definition: timing_expr.hh:197
TimingExprUn::TimingExprUn
TimingExprUn(const TimingExprUnParams *params)
Definition: timing_expr.hh:171
TimingExprIf::TimingExprIf
TimingExprIf(const TimingExprIfParams *params)
Definition: timing_expr.hh:204
TimingExprBin::op
Enums::TimingExprOp op
Definition: timing_expr.hh:183
TimingExprUn::op
Enums::TimingExprOp op
Definition: timing_expr.hh:168
TimingExprReadIntReg::TimingExprReadIntReg
TimingExprReadIntReg(const TimingExprReadIntRegParams *params)
Definition: timing_expr.hh:129
TimingExprEvalContext::TimingExprEvalContext
TimingExprEvalContext(const StaticInstPtr &inst_, ThreadContext *thread_, TimingExprLet *let_)
Definition: timing_expr.cc:42
TimingExprIf::cond
TimingExpr * cond
Definition: timing_expr.hh:200
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
TimingExprBin::eval
uint64_t eval(TimingExprEvalContext &context)
Definition: timing_expr.cc:122
TimingExprLet
Definition: timing_expr.hh:137
sim_object.hh
TimingExprRef::index
unsigned int index
Definition: timing_expr.hh:155
TimingExprLiteral::eval
uint64_t eval(TimingExprEvalContext &context)
Definition: timing_expr.hh:108
TimingExprLet::eval
uint64_t eval(TimingExprEvalContext &context)
Definition: timing_expr.cc:67
TimingExprReadIntReg::eval
uint64_t eval(TimingExprEvalContext &context)
Definition: timing_expr.cc:62
TimingExprReadIntReg
Definition: timing_expr.hh:124
static_inst.hh
SimObject::params
const Params * params() const
Definition: sim_object.hh:119
TimingExprLiteral::value
uint64_t value
Definition: timing_expr.hh:101
TimingExprUn::eval
uint64_t eval(TimingExprEvalContext &context)
Definition: timing_expr.cc:87
TimingExpr::eval
virtual uint64_t eval(TimingExprEvalContext &context)=0
TimingExprRef
Definition: timing_expr.hh:152
TimingExprSrcReg
Definition: timing_expr.hh:111
TimingExprLet::expr
TimingExpr * expr
Definition: timing_expr.hh:141
TimingExprUn
Definition: timing_expr.hh:165
TimingExprBin
Definition: timing_expr.hh:180
TimingExprBin::right
TimingExpr * right
Definition: timing_expr.hh:185
TimingExprEvalContext::results
std::vector< uint64_t > results
Definition: timing_expr.hh:81
TimingExprIf::eval
uint64_t eval(TimingExprEvalContext &context)
Definition: timing_expr.cc:191
TimingExprRef::TimingExprRef
TimingExprRef(const TimingExprRefParams *params)
Definition: timing_expr.hh:157
RefCountingPtr< StaticInst >
TimingExprReadIntReg::reg
TimingExpr * reg
Definition: timing_expr.hh:127
TimingExprLiteral::TimingExprLiteral
TimingExprLiteral(const TimingExprLiteralParams *params)
Definition: timing_expr.hh:103
TimingExprEvalContext::resultAvailable
std::vector< bool > resultAvailable
Definition: timing_expr.hh:82
TimingExprEvalContext::thread
ThreadContext * thread
Definition: timing_expr.hh:75
thread_context.hh
TimingExprSrcReg::eval
uint64_t eval(TimingExprEvalContext &context)
Definition: timing_expr.cc:57
TimingExprUn::arg
TimingExpr * arg
Definition: timing_expr.hh:169
TimingExpr::TimingExpr
TimingExpr(const TimingExprParams *params)
Definition: timing_expr.hh:91
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:10 for gem5 by doxygen 1.8.17