basic.isa revision 7168
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 {{
526250SN/A        inline %(class_name)s::%(class_name)s(ExtMachInst machInst)  : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
536019SN/A        {
546019SN/A                %(constructor)s;
556019SN/A        }
566019SN/A}};
576019SN/A
586019SN/A
596019SN/A// Basic instruction class execute method template.
606019SN/Adef template BasicExecute {{
616019SN/A        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
626019SN/A        {
636019SN/A                Fault fault = NoFault;
646019SN/A
656019SN/A                %(op_decl)s;
666019SN/A                %(op_rd)s;
676019SN/A                %(code)s;
686019SN/A
696019SN/A                if (fault == NoFault)
706019SN/A                {
716019SN/A                    %(op_wb)s;
726019SN/A                }
736019SN/A                return fault;
746019SN/A        }
756019SN/A}};
766019SN/A
776019SN/A// Basic decode template.
786019SN/Adef template BasicDecode {{
796019SN/A        return new %(class_name)s(machInst);
806019SN/A}};
816019SN/A
826019SN/A// Basic decode template, passing mnemonic in as string arg to constructor.
836019SN/Adef template BasicDecodeWithMnemonic {{
846019SN/A        return new %(class_name)s("%(mnemonic)s", machInst);
856019SN/A}};
866019SN/A
876019SN/A// Definitions of execute methods that panic.
886019SN/Adef template BasicExecPanic {{
896019SN/AFault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const
906019SN/A{
916019SN/A        panic("Execute method called when it shouldn't!");
927168SAli.Saidi@ARM.com        // GCC < 4.3 fail to recognize the above panic as no return
937168SAli.Saidi@ARM.com        return NoFault;
946019SN/A}
956019SN/A}};
96