basic.isa revision 2935
15647Sgblack@eecs.umich.edu// -*- mode:c++ -*- 29544Sandreas.hansson@arm.com 38922Swilliam.wang@arm.com// Copyright (c) 2006 The Regents of The University of Michigan 48922Swilliam.wang@arm.com// All rights reserved. 58922Swilliam.wang@arm.com// 68922Swilliam.wang@arm.com// Redistribution and use in source and binary forms, with or without 78922Swilliam.wang@arm.com// modification, are permitted provided that the following conditions are 88922Swilliam.wang@arm.com// met: redistributions of source code must retain the above copyright 98922Swilliam.wang@arm.com// notice, this list of conditions and the following disclaimer; 108922Swilliam.wang@arm.com// redistributions in binary form must reproduce the above copyright 118922Swilliam.wang@arm.com// notice, this list of conditions and the following disclaimer in the 128922Swilliam.wang@arm.com// documentation and/or other materials provided with the distribution; 138922Swilliam.wang@arm.com// neither the name of the copyright holders nor the names of its 145647Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from 155647Sgblack@eecs.umich.edu// this software without specific prior written permission. 165647Sgblack@eecs.umich.edu// 177087Snate@binkert.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 187087Snate@binkert.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 197087Snate@binkert.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 207087Snate@binkert.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 217087Snate@binkert.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 227087Snate@binkert.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 237087Snate@binkert.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 247087Snate@binkert.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255647Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 267087Snate@binkert.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 277087Snate@binkert.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 287087Snate@binkert.org// 297087Snate@binkert.org// Authors: Steve Reinhardt 307087Snate@binkert.org// Korey Sewell 317087Snate@binkert.org 327087Snate@binkert.org// Declarations for execute() methods. 337087Snate@binkert.orgdef template BasicExecDeclare {{ 345647Sgblack@eecs.umich.edu Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const; 357087Snate@binkert.org}}; 365647Sgblack@eecs.umich.edu 375647Sgblack@eecs.umich.edu// Basic instruction class declaration template. 385647Sgblack@eecs.umich.edudef template BasicDeclare {{ 395647Sgblack@eecs.umich.edu /** 405647Sgblack@eecs.umich.edu * Static instruction class for "%(mnemonic)s". 415647Sgblack@eecs.umich.edu */ 425647Sgblack@eecs.umich.edu class %(class_name)s : public %(base_class)s 435647Sgblack@eecs.umich.edu { 445647Sgblack@eecs.umich.edu public: 455647Sgblack@eecs.umich.edu /// Constructor. 465647Sgblack@eecs.umich.edu %(class_name)s(MachInst machInst); 475647Sgblack@eecs.umich.edu %(BasicExecDeclare)s 485647Sgblack@eecs.umich.edu }; 495647Sgblack@eecs.umich.edu}}; 505647Sgblack@eecs.umich.edu 515647Sgblack@eecs.umich.edu// Basic instruction class constructor template. 5211793Sbrandon.potter@amd.comdef template BasicConstructor {{ 5311793Sbrandon.potter@amd.com inline %(class_name)s::%(class_name)s(MachInst machInst) : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s) 5410474Sandreas.hansson@arm.com { 5510474Sandreas.hansson@arm.com %(constructor)s; 5611793Sbrandon.potter@amd.com } 578229Snate@binkert.org}}; 585647Sgblack@eecs.umich.edu 598232Snate@binkert.org 606137Sgblack@eecs.umich.edu// Basic instruction class execute method template. 616137Sgblack@eecs.umich.edudef template BasicExecute {{ 626137Sgblack@eecs.umich.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 635654Sgblack@eecs.umich.edu { 6411793Sbrandon.potter@amd.com Fault fault = NoFault; 656046Sgblack@eecs.umich.edu 665647Sgblack@eecs.umich.edu %(fp_enable_check)s; 675648Sgblack@eecs.umich.edu %(op_decl)s; 685648Sgblack@eecs.umich.edu %(op_rd)s; 695647Sgblack@eecs.umich.edu %(code)s; 705647Sgblack@eecs.umich.edu 715647Sgblack@eecs.umich.edu if(fault == NoFault) 725647Sgblack@eecs.umich.edu { 735647Sgblack@eecs.umich.edu %(op_wb)s; 745647Sgblack@eecs.umich.edu } 755647Sgblack@eecs.umich.edu return fault; 765647Sgblack@eecs.umich.edu } 775647Sgblack@eecs.umich.edu}}; 785648Sgblack@eecs.umich.edu 795647Sgblack@eecs.umich.edu// Basic decode template. 805648Sgblack@eecs.umich.edudef template BasicDecode {{ 815648Sgblack@eecs.umich.edu return new %(class_name)s(machInst); 825648Sgblack@eecs.umich.edu}}; 835648Sgblack@eecs.umich.edu 845648Sgblack@eecs.umich.edu// Basic decode template, passing mnemonic in as string arg to constructor. 855648Sgblack@eecs.umich.edudef template BasicDecodeWithMnemonic {{ 865648Sgblack@eecs.umich.edu return new %(class_name)s("%(mnemonic)s", machInst); 875648Sgblack@eecs.umich.edu}}; 885648Sgblack@eecs.umich.edu 895648Sgblack@eecs.umich.edu// The most basic instruction format... 905648Sgblack@eecs.umich.edudef format BasicOp(code, *flags) {{ 915648Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'MipsStaticInst', CodeBlock(code), flags) 925648Sgblack@eecs.umich.edu header_output = BasicDeclare.subst(iop) 935648Sgblack@eecs.umich.edu decoder_output = BasicConstructor.subst(iop) 945648Sgblack@eecs.umich.edu decode_block = BasicDecode.subst(iop) 955648Sgblack@eecs.umich.edu exec_output = BasicExecute.subst(iop) 965648Sgblack@eecs.umich.edu}}; 975648Sgblack@eecs.umich.edu