basic.isa revision 12234
14120SN/A// -*- mode:c++ -*-
24120SN/A
34120SN/A// -*- mode:c++ -*-
44120SN/A
57087Snate@binkert.org// Copyright (c) 2003-2005 The Regents of The University of Michigan
67087Snate@binkert.org// All rights reserved.
77087Snate@binkert.org//
87087Snate@binkert.org// Redistribution and use in source and binary forms, with or without
97087Snate@binkert.org// modification, are permitted provided that the following conditions are
107087Snate@binkert.org// met: redistributions of source code must retain the above copyright
117087Snate@binkert.org// notice, this list of conditions and the following disclaimer;
127087Snate@binkert.org// redistributions in binary form must reproduce the above copyright
134120SN/A// notice, this list of conditions and the following disclaimer in the
147087Snate@binkert.org// documentation and/or other materials provided with the distribution;
157087Snate@binkert.org// neither the name of the copyright holders nor the names of its
167087Snate@binkert.org// contributors may be used to endorse or promote products derived from
177087Snate@binkert.org// this software without specific prior written permission.
187087Snate@binkert.org//
197087Snate@binkert.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
207087Snate@binkert.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
217087Snate@binkert.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
224120SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
237087Snate@binkert.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
244120SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
254120SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
264120SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
274120SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
284120SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
294120SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
304120SN/A//
314120SN/A// Authors: Steve Reinhardt
324120SN/A//          Korey Sewell
334120SN/A
344120SN/A// Declarations for execute() methods.
354120SN/Adef template BasicExecDeclare {{
364120SN/A        Fault execute(ExecContext *, Trace::InstRecord *) const;
374120SN/A}};
384120SN/A
394120SN/A// Basic instruction class declaration template.
406329Sgblack@eecs.umich.edudef template BasicDeclare {{
416329Sgblack@eecs.umich.edu        /**
426216SN/A         * Static instruction class for "%(mnemonic)s".
436329Sgblack@eecs.umich.edu         */
447629Sgblack@eecs.umich.edu        class %(class_name)s : public %(base_class)s
457629Sgblack@eecs.umich.edu        {
466315SN/A          public:
474137SN/A                /// Constructor.
484120SN/A                %(class_name)s(MachInst machInst);
494120SN/A                %(BasicExecDeclare)s
506329Sgblack@eecs.umich.edu        };
516329Sgblack@eecs.umich.edu}};
526329Sgblack@eecs.umich.edu
536329Sgblack@eecs.umich.edu// Basic instruction class constructor template.
546313SN/Adef template BasicConstructor {{
556329Sgblack@eecs.umich.edu        %(class_name)s::%(class_name)s(MachInst machInst)  : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
566329Sgblack@eecs.umich.edu        {
576329Sgblack@eecs.umich.edu                %(constructor)s;
586329Sgblack@eecs.umich.edu        }
596319SN/A}};
606329Sgblack@eecs.umich.edu
616329Sgblack@eecs.umich.edu
626329Sgblack@eecs.umich.edu// Basic instruction class execute method template.
636329Sgblack@eecs.umich.edudef template BasicExecute {{
646315SN/A        Fault %(class_name)s::execute(
656329Sgblack@eecs.umich.edu            ExecContext *xc, Trace::InstRecord *traceData) const
666329Sgblack@eecs.umich.edu        {
676329Sgblack@eecs.umich.edu                Fault fault = NoFault;
686329Sgblack@eecs.umich.edu
696329Sgblack@eecs.umich.edu                %(fp_enable_check)s;
706329Sgblack@eecs.umich.edu                %(op_decl)s;
716329Sgblack@eecs.umich.edu                %(op_rd)s;
726329Sgblack@eecs.umich.edu                if(fault == NoFault)
736329Sgblack@eecs.umich.edu                {
746329Sgblack@eecs.umich.edu                  %(code)s;
756329Sgblack@eecs.umich.edu                  if(fault == NoFault){
766329Sgblack@eecs.umich.edu                    %(op_wb)s;
776329Sgblack@eecs.umich.edu                  }
786329Sgblack@eecs.umich.edu                }
796329Sgblack@eecs.umich.edu                return fault;
806329Sgblack@eecs.umich.edu        }
814137SN/A}};
826329Sgblack@eecs.umich.edu
836329Sgblack@eecs.umich.edu// Basic decode template.
846329Sgblack@eecs.umich.edudef template BasicDecode {{
856329Sgblack@eecs.umich.edu        return new %(class_name)s(machInst);
866329Sgblack@eecs.umich.edu}};
876329Sgblack@eecs.umich.edu
886329Sgblack@eecs.umich.edu// Basic decode template, passing mnemonic in as string arg to constructor.
896329Sgblack@eecs.umich.edudef template BasicDecodeWithMnemonic {{
904137SN/A        return new %(class_name)s("%(mnemonic)s", machInst);
916329Sgblack@eecs.umich.edu}};
926329Sgblack@eecs.umich.edu
936329Sgblack@eecs.umich.edu// The most basic instruction format...
946329Sgblack@eecs.umich.edudef format BasicOp(code, *flags) {{
956329Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags)
966329Sgblack@eecs.umich.edu        header_output = BasicDeclare.subst(iop)
976329Sgblack@eecs.umich.edu        decoder_output = BasicConstructor.subst(iop)
986329Sgblack@eecs.umich.edu        decode_block = BasicDecode.subst(iop)
996329Sgblack@eecs.umich.edu        exec_output = BasicExecute.subst(iop)
1006329Sgblack@eecs.umich.edu}};
1016329Sgblack@eecs.umich.edu