basic.isa revision 8737
16019SN/A// -*- mode:c++ -*-
26019SN/A
36019SN/A// Copyright (c) 2007-2008 The Florida State University
46019SN/A// All rights reserved.
56019SN/A//
66019SN/A// Redistribution and use in source and binary forms, with or without
76019SN/A// modification, are permitted provided that the following conditions are
86019SN/A// met: redistributions of source code must retain the above copyright
96019SN/A// notice, this list of conditions and the following disclaimer;
106019SN/A// redistributions in binary form must reproduce the above copyright
116019SN/A// notice, this list of conditions and the following disclaimer in the
126019SN/A// documentation and/or other materials provided with the distribution;
136019SN/A// neither the name of the copyright holders nor the names of its
146019SN/A// contributors may be used to endorse or promote products derived from
156019SN/A// this software without specific prior written permission.
166019SN/A//
176019SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186019SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196019SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206019SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216019SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226019SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236019SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246019SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256019SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266019SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276019SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286019SN/A//
296019SN/A// Authors: Stephen Hines
306019SN/A
316019SN/A// Declarations for execute() methods.
326019SN/Adef template BasicExecDeclare {{
336019SN/A        Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const;
346019SN/A}};
356019SN/A
366019SN/A// Basic instruction class declaration template.
376019SN/Adef template BasicDeclare {{
386019SN/A        /**
396019SN/A         * Static instruction class for "%(mnemonic)s".
406019SN/A         */
416019SN/A        class %(class_name)s : public %(base_class)s
426019SN/A        {
436019SN/A          public:
446019SN/A                /// Constructor.
456250SN/A                %(class_name)s(ExtMachInst machInst);
466019SN/A                %(BasicExecDeclare)s
476019SN/A        };
486019SN/A}};
496019SN/A
506019SN/A// Basic instruction class constructor template.
516019SN/Adef template BasicConstructor {{
528737Skoansin.tan@gmail.com        %(class_name)s::%(class_name)s(ExtMachInst machInst)  : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
536019SN/A        {
546019SN/A                %(constructor)s;
557848SAli.Saidi@ARM.com                if (!(condCode == COND_AL || condCode == COND_UC)) {
567848SAli.Saidi@ARM.com                    for (int x = 0; x < _numDestRegs; x++) {
577848SAli.Saidi@ARM.com                        _srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
587848SAli.Saidi@ARM.com                    }
597848SAli.Saidi@ARM.com                }
606019SN/A        }
616019SN/A}};
626019SN/A
636019SN/A
646019SN/A// Basic instruction class execute method template.
656019SN/Adef template BasicExecute {{
666019SN/A        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
676019SN/A        {
686019SN/A                Fault fault = NoFault;
696019SN/A
706019SN/A                %(op_decl)s;
716019SN/A                %(op_rd)s;
726019SN/A                %(code)s;
736019SN/A
746019SN/A                if (fault == NoFault)
756019SN/A                {
766019SN/A                    %(op_wb)s;
776019SN/A                }
786019SN/A                return fault;
796019SN/A        }
806019SN/A}};
816019SN/A
826019SN/A// Basic decode template.
836019SN/Adef template BasicDecode {{
846019SN/A        return new %(class_name)s(machInst);
856019SN/A}};
866019SN/A
876019SN/A// Basic decode template, passing mnemonic in as string arg to constructor.
886019SN/Adef template BasicDecodeWithMnemonic {{
896019SN/A        return new %(class_name)s("%(mnemonic)s", machInst);
906019SN/A}};
916019SN/A
926019SN/A// Definitions of execute methods that panic.
936019SN/Adef template BasicExecPanic {{
946019SN/AFault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const
956019SN/A{
966019SN/A        panic("Execute method called when it shouldn't!");
977168SAli.Saidi@ARM.com        // GCC < 4.3 fail to recognize the above panic as no return
987168SAli.Saidi@ARM.com        return NoFault;
996019SN/A}
1006019SN/A}};
101