control.isa revision 2754
12686Sksewell@umich.edu// -*- mode:c++ -*- 22686Sksewell@umich.edu 32754Sksewell@umich.edu// Copyright (c) 2006 The Regents of The University of Michigan 42706Sksewell@umich.edu// All rights reserved. 52706Sksewell@umich.edu// 62706Sksewell@umich.edu// Redistribution and use in source and binary forms, with or without 72706Sksewell@umich.edu// modification, are permitted provided that the following conditions are 82706Sksewell@umich.edu// met: redistributions of source code must retain the above copyright 92706Sksewell@umich.edu// notice, this list of conditions and the following disclaimer; 102706Sksewell@umich.edu// redistributions in binary form must reproduce the above copyright 112706Sksewell@umich.edu// notice, this list of conditions and the following disclaimer in the 122706Sksewell@umich.edu// documentation and/or other materials provided with the distribution; 132706Sksewell@umich.edu// neither the name of the copyright holders nor the names of its 142706Sksewell@umich.edu// contributors may be used to endorse or promote products derived from 152706Sksewell@umich.edu// this software without specific prior written permission. 162706Sksewell@umich.edu// 172706Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182706Sksewell@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192706Sksewell@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202706Sksewell@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212706Sksewell@umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222706Sksewell@umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232706Sksewell@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242706Sksewell@umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252706Sksewell@umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262706Sksewell@umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272706Sksewell@umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282706Sksewell@umich.edu// 292706Sksewell@umich.edu// Authors: Korey Sewell 302706Sksewell@umich.edu 312686Sksewell@umich.edu//////////////////////////////////////////////////////////////////// 322686Sksewell@umich.edu// 332686Sksewell@umich.edu// Integer operate instructions 342686Sksewell@umich.edu// 352686Sksewell@umich.edu 362686Sksewell@umich.edu//Outputs to decoder.hh 372686Sksewell@umich.eduoutput header {{ 382686Sksewell@umich.edu 392686Sksewell@umich.edu class Control : public MipsStaticInst 402686Sksewell@umich.edu { 412686Sksewell@umich.edu protected: 422686Sksewell@umich.edu 432686Sksewell@umich.edu /// Constructor 442686Sksewell@umich.edu Control(const char *mnem, MachInst _machInst, OpClass __opClass) : 452686Sksewell@umich.edu MipsStaticInst(mnem, _machInst, __opClass) 462686Sksewell@umich.edu { 472686Sksewell@umich.edu } 482686Sksewell@umich.edu 492686Sksewell@umich.edu std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 502686Sksewell@umich.edu }; 512686Sksewell@umich.edu 522686Sksewell@umich.edu class CP0Control : public Control 532686Sksewell@umich.edu { 542686Sksewell@umich.edu protected: 552686Sksewell@umich.edu 562686Sksewell@umich.edu /// Constructor 572686Sksewell@umich.edu CP0Control(const char *mnem, MachInst _machInst, OpClass __opClass) : 582686Sksewell@umich.edu Control(mnem, _machInst, __opClass) 592686Sksewell@umich.edu { 602686Sksewell@umich.edu } 612686Sksewell@umich.edu 622686Sksewell@umich.edu std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 632686Sksewell@umich.edu }; 642686Sksewell@umich.edu 652686Sksewell@umich.edu class CP1Control : public Control 662686Sksewell@umich.edu { 672686Sksewell@umich.edu protected: 682686Sksewell@umich.edu 692686Sksewell@umich.edu /// Constructor 702686Sksewell@umich.edu CP1Control(const char *mnem, MachInst _machInst, OpClass __opClass) : 712686Sksewell@umich.edu Control(mnem, _machInst, __opClass) 722686Sksewell@umich.edu { 732686Sksewell@umich.edu } 742686Sksewell@umich.edu 752686Sksewell@umich.edu std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 762686Sksewell@umich.edu }; 772686Sksewell@umich.edu 782686Sksewell@umich.edu}}; 792686Sksewell@umich.edu 802686Sksewell@umich.edu//Outputs to decoder.cc 812686Sksewell@umich.eduoutput decoder {{ 822686Sksewell@umich.edu std::string Control::generateDisassembly(Addr pc, const SymbolTable *symtab) const 832686Sksewell@umich.edu { 842686Sksewell@umich.edu std::stringstream ss; 852686Sksewell@umich.edu 862686Sksewell@umich.edu ccprintf(ss, "%-10s ", mnemonic); 872686Sksewell@umich.edu 882686Sksewell@umich.edu if (mnemonic == "mfc0" || mnemonic == "mtc0") { 892686Sksewell@umich.edu ccprintf(ss, "%-10s %d,%d,%d", mnemonic,RT,RD,SEL); 902686Sksewell@umich.edu } else { 912686Sksewell@umich.edu 922686Sksewell@umich.edu // just print the first dest... if there's a second one, 932686Sksewell@umich.edu // it's generally implicit 942686Sksewell@umich.edu if (_numDestRegs > 0) { 952686Sksewell@umich.edu printReg(ss, _destRegIdx[0]); 962686Sksewell@umich.edu } 972686Sksewell@umich.edu 982686Sksewell@umich.edu ss << ", "; 992686Sksewell@umich.edu 1002686Sksewell@umich.edu // just print the first two source regs... if there's 1012686Sksewell@umich.edu // a third one, it's a read-modify-write dest (Rc), 1022686Sksewell@umich.edu // e.g. for CMOVxx 1032686Sksewell@umich.edu if (_numSrcRegs > 0) { 1042686Sksewell@umich.edu printReg(ss, _srcRegIdx[0]); 1052686Sksewell@umich.edu } 1062686Sksewell@umich.edu 1072686Sksewell@umich.edu if (_numSrcRegs > 1) { 1082686Sksewell@umich.edu ss << ", "; 1092686Sksewell@umich.edu printReg(ss, _srcRegIdx[1]); 1102686Sksewell@umich.edu } 1112686Sksewell@umich.edu } 1122686Sksewell@umich.edu 1132686Sksewell@umich.edu return ss.str(); 1142686Sksewell@umich.edu } 1152686Sksewell@umich.edu 1162686Sksewell@umich.edu std::string CP0Control::generateDisassembly(Addr pc, const SymbolTable *symtab) const 1172686Sksewell@umich.edu { 1182686Sksewell@umich.edu std::stringstream ss; 1192686Sksewell@umich.edu ccprintf(ss, "%-10s r%d, r%d, %d", mnemonic, RT, RD, SEL); 1202686Sksewell@umich.edu return ss.str(); 1212686Sksewell@umich.edu } 1222686Sksewell@umich.edu 1232686Sksewell@umich.edu std::string CP1Control::generateDisassembly(Addr pc, const SymbolTable *symtab) const 1242686Sksewell@umich.edu { 1252686Sksewell@umich.edu std::stringstream ss; 1262686Sksewell@umich.edu ccprintf(ss, "%-10s r%d, f%d", mnemonic, RT, FS); 1272686Sksewell@umich.edu return ss.str(); 1282686Sksewell@umich.edu } 1292686Sksewell@umich.edu 1302686Sksewell@umich.edu}}; 1312686Sksewell@umich.edu 1322686Sksewell@umich.edudef format System(code, *flags) {{ 1332686Sksewell@umich.edu iop = InstObjParams(name, Name, 'Control', CodeBlock(code), flags) 1342686Sksewell@umich.edu header_output = BasicDeclare.subst(iop) 1352686Sksewell@umich.edu decoder_output = BasicConstructor.subst(iop) 1362686Sksewell@umich.edu decode_block = BasicDecode.subst(iop) 1372686Sksewell@umich.edu exec_output = BasicExecute.subst(iop) 1382686Sksewell@umich.edu}}; 1392686Sksewell@umich.edu 1402686Sksewell@umich.edudef format CP0Control(code, *flags) {{ 1412686Sksewell@umich.edu iop = InstObjParams(name, Name, 'CP0Control', CodeBlock(code), flags) 1422686Sksewell@umich.edu header_output = BasicDeclare.subst(iop) 1432686Sksewell@umich.edu decoder_output = BasicConstructor.subst(iop) 1442686Sksewell@umich.edu decode_block = BasicDecode.subst(iop) 1452686Sksewell@umich.edu exec_output = BasicExecute.subst(iop) 1462686Sksewell@umich.edu}}; 1472686Sksewell@umich.edu 1482686Sksewell@umich.edudef format CP1Control(code, *flags) {{ 1492686Sksewell@umich.edu iop = InstObjParams(name, Name, 'CP1Control', CodeBlock(code), flags) 1502686Sksewell@umich.edu header_output = BasicDeclare.subst(iop) 1512686Sksewell@umich.edu decoder_output = BasicConstructor.subst(iop) 1522686Sksewell@umich.edu decode_block = BasicDecode.subst(iop) 1532686Sksewell@umich.edu exec_output = BasicExecute.subst(iop) 1542686Sksewell@umich.edu}}; 1552686Sksewell@umich.edu 1562686Sksewell@umich.edu 157