pseudo_inst.cc revision 711
112853Sgabeblack@google.com/* 212853Sgabeblack@google.com * Copyright (c) 2003 The Regents of The University of Michigan 312853Sgabeblack@google.com * All rights reserved. 412853Sgabeblack@google.com * 512853Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 612853Sgabeblack@google.com * modification, are permitted provided that the following conditions are 712853Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 812853Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 912853Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1012853Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1112853Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1212853Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1312853Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1412853Sgabeblack@google.com * this software without specific prior written permission. 1512853Sgabeblack@google.com * 1612853Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712853Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812853Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912853Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012853Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112853Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212853Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312853Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412853Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512853Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612853Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712853Sgabeblack@google.com */ 2812853Sgabeblack@google.com 2912853Sgabeblack@google.com#include <string> 3012853Sgabeblack@google.com 3112853Sgabeblack@google.com#include "arch/alpha/pseudo_inst.hh" 3212853Sgabeblack@google.com#include "cpu/exec_context.hh" 3312853Sgabeblack@google.com#include "sim/param.hh" 3412853Sgabeblack@google.com#include "sim/serialize.hh" 3512853Sgabeblack@google.com#include "sim/sim_exit.hh" 36#include "sim/stat_control.hh" 37#include "sim/stats.hh" 38 39using namespace std; 40using namespace Statistics; 41 42namespace AlphaPseudo 43{ 44 bool doStatisticsInsts; 45 bool doCheckpointInsts; 46 bool doQuiesce; 47 48 void 49 arm(ExecContext *xc) 50 { 51 xc->kernelStats.arm(); 52 } 53 54 void 55 quiesce(ExecContext *xc) 56 { 57 if (!doQuiesce) 58 return; 59 60 xc->suspend(); 61 xc->kernelStats.quiesce(); 62 } 63 64 void 65 ivlb(ExecContext *xc) 66 { 67 xc->kernelStats.ivlb(); 68 } 69 70 void 71 ivle(ExecContext *xc) 72 { 73 } 74 75 void 76 m5exit_old(ExecContext *xc) 77 { 78 SimExit(curTick, "m5_exit_old instruction encountered"); 79 } 80 81 void 82 m5exit(ExecContext *xc) 83 { 84 Tick delay = xc->regs.intRegFile[16]; 85 Tick when = curTick + NS2Ticks(delay); 86 SimExit(when, "m5_exit instruction encountered"); 87 } 88 89 void 90 resetstats(ExecContext *xc) 91 { 92 if (!doStatisticsInsts) 93 return; 94 95 Tick delay = xc->regs.intRegFile[16]; 96 Tick period = xc->regs.intRegFile[17]; 97 98 Tick when = curTick + NS2Ticks(delay); 99 Tick repeat = NS2Ticks(period); 100 101 using namespace Statistics; 102 SetupEvent(Reset, when, repeat); 103 } 104 105 void 106 dumpstats(ExecContext *xc) 107 { 108 if (!doStatisticsInsts) 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 using namespace Statistics; 118 SetupEvent(Dump, when, repeat); 119 } 120 121 void 122 dumpresetstats(ExecContext *xc) 123 { 124 if (!doStatisticsInsts) 125 return; 126 127 Tick delay = xc->regs.intRegFile[16]; 128 Tick period = xc->regs.intRegFile[17]; 129 130 Tick when = curTick + NS2Ticks(delay); 131 Tick repeat = NS2Ticks(period); 132 133 using namespace Statistics; 134 SetupEvent(Dump|Reset, when, repeat); 135 } 136 137 void 138 m5checkpoint(ExecContext *xc) 139 { 140 if (!doCheckpointInsts) 141 return; 142 143 Tick delay = xc->regs.intRegFile[16]; 144 Tick period = xc->regs.intRegFile[17]; 145 146 Tick when = curTick + NS2Ticks(delay); 147 Tick repeat = NS2Ticks(period); 148 149 Checkpoint::setup(when, repeat); 150 } 151 152 class Context : public ParamContext 153 { 154 public: 155 Context(const string §ion) : ParamContext(section) {} 156 void checkParams(); 157 }; 158 159 Context context("PseudoInsts"); 160 161 Param<bool> __quiesce(&context, "quiesce", 162 "enable quiesce instructions", 163 true); 164 Param<bool> __statistics(&context, "statistics", 165 "enable statistics pseudo instructions", 166 true); 167 Param<bool> __checkpoint(&context, "checkpoint", 168 "enable checkpoint pseudo instructions", 169 true); 170 171 void 172 Context::checkParams() 173 { 174 doQuiesce = __quiesce; 175 doStatisticsInsts = __statistics; 176 doCheckpointInsts = __checkpoint; 177 } 178} 179