basic.isa revision 12234
17087Snate@binkert.org// Copyright (c) 2007 The Hewlett-Packard Development Company
27087Snate@binkert.org// All rights reserved.
37087Snate@binkert.org//
47087Snate@binkert.org// The license below extends only to copyright in the software and shall
57087Snate@binkert.org// not be construed as granting a license to any other intellectual
67087Snate@binkert.org// property including but not limited to intellectual property relating
77087Snate@binkert.org// to a hardware implementation of the functionality of the software
87087Snate@binkert.org// licensed hereunder.  You may use the software subject to the license
97087Snate@binkert.org// terms below provided that you ensure that this notice is replicated
107087Snate@binkert.org// unmodified and in its entirety in all distributions of the software,
117087Snate@binkert.org// modified or unmodified, in source code or in binary form.
127087Snate@binkert.org//
134158Sgblack@eecs.umich.edu// Copyright (c) 2007 The Regents of The University of Michigan
144158Sgblack@eecs.umich.edu// All rights reserved.
154158Sgblack@eecs.umich.edu//
164158Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
174158Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are
184158Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright
194158Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
204158Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
214158Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
224158Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution;
234158Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its
244158Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from
254158Sgblack@eecs.umich.edu// this software without specific prior written permission.
264158Sgblack@eecs.umich.edu//
274158Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
284158Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
294158Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
304158Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
314158Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
324158Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
334158Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
344158Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
354158Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
364158Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
374158Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
384158Sgblack@eecs.umich.edu//
394158Sgblack@eecs.umich.edu// Authors: Gabe Black
404158Sgblack@eecs.umich.edu
414158Sgblack@eecs.umich.edu// Declarations for execute() methods.
424158Sgblack@eecs.umich.edudef template BasicExecDeclare {{
4312234Sgabeblack@google.com        Fault execute(ExecContext *, Trace::InstRecord *) const;
444158Sgblack@eecs.umich.edu}};
454158Sgblack@eecs.umich.edu
464158Sgblack@eecs.umich.edu// Definitions of execute methods that panic.
474158Sgblack@eecs.umich.edudef template BasicExecPanic {{
4812234Sgabeblack@google.com        Fault execute(ExecContext *, Trace::InstRecord *) const
494158Sgblack@eecs.umich.edu        {
504158Sgblack@eecs.umich.edu            panic("Execute method called when it shouldn't!");
514158Sgblack@eecs.umich.edu            M5_DUMMY_RETURN
524158Sgblack@eecs.umich.edu        }
534158Sgblack@eecs.umich.edu}};
544158Sgblack@eecs.umich.edu
554158Sgblack@eecs.umich.edu// Basic instruction class declaration template.
564158Sgblack@eecs.umich.edudef template BasicDeclare {{
574158Sgblack@eecs.umich.edu        /**
584158Sgblack@eecs.umich.edu         * Static instruction class for "%(mnemonic)s".
594158Sgblack@eecs.umich.edu         */
604158Sgblack@eecs.umich.edu        class %(class_name)s : public %(base_class)s
614158Sgblack@eecs.umich.edu        {
624158Sgblack@eecs.umich.edu          public:
634158Sgblack@eecs.umich.edu            // Constructor.
644158Sgblack@eecs.umich.edu            %(class_name)s(ExtMachInst machInst);
654158Sgblack@eecs.umich.edu            %(BasicExecDeclare)s
664158Sgblack@eecs.umich.edu        };
674158Sgblack@eecs.umich.edu}};
684158Sgblack@eecs.umich.edu
694158Sgblack@eecs.umich.edu// Basic instruction class constructor template.
704158Sgblack@eecs.umich.edudef template BasicConstructor {{
7110184SCurtis.Dunham@arm.com        %(class_name)s::%(class_name)s(ExtMachInst machInst)
724158Sgblack@eecs.umich.edu            : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
734158Sgblack@eecs.umich.edu        {
744158Sgblack@eecs.umich.edu                %(constructor)s;
754158Sgblack@eecs.umich.edu        }
764158Sgblack@eecs.umich.edu}};
774158Sgblack@eecs.umich.edu
784158Sgblack@eecs.umich.edu// Basic instruction class execute method template.
794158Sgblack@eecs.umich.edudef template BasicExecute {{
8012234Sgabeblack@google.com        Fault %(class_name)s::execute(ExecContext *xc,
814158Sgblack@eecs.umich.edu                Trace::InstRecord *traceData) const
824158Sgblack@eecs.umich.edu        {
834158Sgblack@eecs.umich.edu            Fault fault = NoFault;
844158Sgblack@eecs.umich.edu
854158Sgblack@eecs.umich.edu            %(fp_enable_check)s;
864158Sgblack@eecs.umich.edu            %(op_decl)s;
874158Sgblack@eecs.umich.edu            %(op_rd)s;
884158Sgblack@eecs.umich.edu            %(code)s;
894158Sgblack@eecs.umich.edu
904158Sgblack@eecs.umich.edu            if(fault == NoFault)
914158Sgblack@eecs.umich.edu            {
924158Sgblack@eecs.umich.edu                %(op_wb)s;
934158Sgblack@eecs.umich.edu            }
944158Sgblack@eecs.umich.edu            return fault;
954158Sgblack@eecs.umich.edu        }
964158Sgblack@eecs.umich.edu}};
974158Sgblack@eecs.umich.edu
984158Sgblack@eecs.umich.edu// Basic decode template.
994158Sgblack@eecs.umich.edudef template BasicDecode {{
1004158Sgblack@eecs.umich.edu        return new %(class_name)s(machInst);
1014158Sgblack@eecs.umich.edu}};
1024158Sgblack@eecs.umich.edu
1034158Sgblack@eecs.umich.edu// Basic decode template, passing mnemonic in as string arg to constructor.
1044158Sgblack@eecs.umich.edudef template BasicDecodeWithMnemonic {{
1054158Sgblack@eecs.umich.edu    return new %(class_name)s("%(mnemonic)s", machInst);
1064158Sgblack@eecs.umich.edu}};
1075789Sgblack@eecs.umich.edu
1085789Sgblack@eecs.umich.edudef format BasicOperate(code, *flags) {{
1095789Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name, 'X86ISA::X86StaticInst', code, flags)
1105789Sgblack@eecs.umich.edu        header_output = BasicDeclare.subst(iop)
1115789Sgblack@eecs.umich.edu        decoder_output = BasicConstructor.subst(iop)
1125789Sgblack@eecs.umich.edu        decode_block = BasicDecode.subst(iop)
1135789Sgblack@eecs.umich.edu        exec_output = BasicExecute.subst(iop)
1145789Sgblack@eecs.umich.edu}};
115