basic.isa revision 10037
16019SN/A// -*- mode:c++ -*-
26019SN/A
310037SARM gem5 Developers// Copyright (c) 2011 ARM Limited
410037SARM gem5 Developers// All rights reserved
510037SARM gem5 Developers//
610037SARM gem5 Developers// The license below extends only to copyright in the software and shall
710037SARM gem5 Developers// not be construed as granting a license to any other intellectual
810037SARM gem5 Developers// property including but not limited to intellectual property relating
910037SARM gem5 Developers// to a hardware implementation of the functionality of the software
1010037SARM gem5 Developers// licensed hereunder.  You may use the software subject to the license
1110037SARM gem5 Developers// terms below provided that you ensure that this notice is replicated
1210037SARM gem5 Developers// unmodified and in its entirety in all distributions of the software,
1310037SARM gem5 Developers// modified or unmodified, in source code or in binary form.
1410037SARM gem5 Developers//
156019SN/A// Copyright (c) 2007-2008 The Florida State University
166019SN/A// All rights reserved.
176019SN/A//
186019SN/A// Redistribution and use in source and binary forms, with or without
196019SN/A// modification, are permitted provided that the following conditions are
206019SN/A// met: redistributions of source code must retain the above copyright
216019SN/A// notice, this list of conditions and the following disclaimer;
226019SN/A// redistributions in binary form must reproduce the above copyright
236019SN/A// notice, this list of conditions and the following disclaimer in the
246019SN/A// documentation and/or other materials provided with the distribution;
256019SN/A// neither the name of the copyright holders nor the names of its
266019SN/A// contributors may be used to endorse or promote products derived from
276019SN/A// this software without specific prior written permission.
286019SN/A//
296019SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
306019SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
316019SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
326019SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
336019SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
346019SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
356019SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
366019SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
376019SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
386019SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
396019SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
406019SN/A//
416019SN/A// Authors: Stephen Hines
426019SN/A
436019SN/A// Declarations for execute() methods.
446019SN/Adef template BasicExecDeclare {{
456019SN/A        Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const;
466019SN/A}};
476019SN/A
486019SN/A// Basic instruction class declaration template.
496019SN/Adef template BasicDeclare {{
506019SN/A        /**
516019SN/A         * Static instruction class for "%(mnemonic)s".
526019SN/A         */
536019SN/A        class %(class_name)s : public %(base_class)s
546019SN/A        {
556019SN/A          public:
566019SN/A                /// Constructor.
576250SN/A                %(class_name)s(ExtMachInst machInst);
586019SN/A                %(BasicExecDeclare)s
596019SN/A        };
606019SN/A}};
616019SN/A
626019SN/A// Basic instruction class constructor template.
636019SN/Adef template BasicConstructor {{
648737Skoansin.tan@gmail.com        %(class_name)s::%(class_name)s(ExtMachInst machInst)  : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
656019SN/A        {
666019SN/A                %(constructor)s;
677848SAli.Saidi@ARM.com                if (!(condCode == COND_AL || condCode == COND_UC)) {
687848SAli.Saidi@ARM.com                    for (int x = 0; x < _numDestRegs; x++) {
697848SAli.Saidi@ARM.com                        _srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
707848SAli.Saidi@ARM.com                    }
717848SAli.Saidi@ARM.com                }
726019SN/A        }
736019SN/A}};
746019SN/A
7510037SARM gem5 Developersdef template BasicConstructor64 {{
7610037SARM gem5 Developers        inline %(class_name)s::%(class_name)s(ExtMachInst machInst)  : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
7710037SARM gem5 Developers        {
7810037SARM gem5 Developers            %(constructor)s;
7910037SARM gem5 Developers        }
8010037SARM gem5 Developers}};
8110037SARM gem5 Developers
826019SN/A
836019SN/A// Basic instruction class execute method template.
846019SN/Adef template BasicExecute {{
856019SN/A        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
866019SN/A        {
876019SN/A                Fault fault = NoFault;
886019SN/A
896019SN/A                %(op_decl)s;
906019SN/A                %(op_rd)s;
916019SN/A                %(code)s;
926019SN/A
936019SN/A                if (fault == NoFault)
946019SN/A                {
956019SN/A                    %(op_wb)s;
966019SN/A                }
976019SN/A                return fault;
986019SN/A        }
996019SN/A}};
1006019SN/A
1016019SN/A// Basic decode template.
1026019SN/Adef template BasicDecode {{
1036019SN/A        return new %(class_name)s(machInst);
1046019SN/A}};
1056019SN/A
1066019SN/A// Basic decode template, passing mnemonic in as string arg to constructor.
1076019SN/Adef template BasicDecodeWithMnemonic {{
1086019SN/A        return new %(class_name)s("%(mnemonic)s", machInst);
1096019SN/A}};
1106019SN/A
1116019SN/A// Definitions of execute methods that panic.
1126019SN/Adef template BasicExecPanic {{
1136019SN/AFault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const
1146019SN/A{
1156019SN/A        panic("Execute method called when it shouldn't!");
1167168SAli.Saidi@ARM.com        // GCC < 4.3 fail to recognize the above panic as no return
1177168SAli.Saidi@ARM.com        return NoFault;
1186019SN/A}
1196019SN/A}};
120