pseudo_inst.cc revision 299
1/*
2 * Copyright (c) 2003 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 <string>
30
31#include "arch/alpha/pseudo_inst.hh"
32#include "cpu/exec_context.hh"
33#include "sim/param.hh"
34#include "sim/serialize.hh"
35#include "sim/sim_exit.hh"
36#include "sim/sim_stats.hh"
37
38using namespace std;
39using namespace Statistics;
40
41namespace AlphaPseudo
42{
43    bool doStatisticsInsts;
44    bool doCheckpointInsts;
45
46    void
47    m5exit_old(ExecContext *xc)
48    {
49        SimExit(curTick, "m5_exit_old instruction encountered");
50    }
51
52    void
53    m5exit(ExecContext *xc)
54    {
55        Tick delay = xc->regs.intRegFile[16];
56        Tick when = curTick + NS2Ticks(delay);
57        SimExit(when, "m5_exit instruction encountered");
58    }
59
60    void
61    resetstats(ExecContext *xc)
62    {
63        if (!doStatisticsInsts)
64            return;
65
66        Tick delay = xc->regs.intRegFile[16];
67        Tick period = xc->regs.intRegFile[17];
68
69        Tick when = curTick + NS2Ticks(delay);
70        Tick repeat = NS2Ticks(period);
71
72        SetupEvent(Reset, when, repeat);
73    }
74
75    void
76    dumpstats(ExecContext *xc)
77    {
78        if (!doStatisticsInsts)
79            return;
80
81        Tick delay = xc->regs.intRegFile[16];
82        Tick period = xc->regs.intRegFile[17];
83
84        Tick when = curTick + NS2Ticks(delay);
85        Tick repeat = NS2Ticks(period);
86
87        SetupEvent(Dump, when, repeat);
88    }
89
90    void
91    dumpresetstats(ExecContext *xc)
92    {
93        if (!doStatisticsInsts)
94            return;
95
96        Tick delay = xc->regs.intRegFile[16];
97        Tick period = xc->regs.intRegFile[17];
98
99        Tick when = curTick + NS2Ticks(delay);
100        Tick repeat = NS2Ticks(period);
101
102        SetupEvent(Dump|Reset, when, repeat);
103    }
104
105    void
106    m5checkpoint(ExecContext *xc)
107    {
108        if (!doCheckpointInsts)
109            return;
110
111        Tick delay = xc->regs.intRegFile[16];
112        Tick period = xc->regs.intRegFile[17];
113
114        Tick when = curTick + NS2Ticks(delay);
115        Tick repeat = NS2Ticks(period);
116
117        SetupCheckpoint(when, repeat);
118    }
119
120    class Context : public ParamContext
121    {
122      public:
123        Context(const string &section) : ParamContext(section) {}
124        void checkParams();
125    };
126
127    Context context("PseudoInsts");
128
129    Param<bool> __statistics(&context, "statistics", "yes");
130    Param<bool> __checkpoint(&context, "checkpoint", "yes");
131
132    void
133    Context::checkParams()
134    {
135        doStatisticsInsts = __statistics;
136        doCheckpointInsts = __checkpoint;
137    }
138}
139