basic.isa revision 4276:f0030662ee2a
12SN/A// Copyright (c) 2007 The Regents of The University of Michigan
21762SN/A// All rights reserved.
32SN/A//
42SN/A// Redistribution and use in source and binary forms, with or without
52SN/A// modification, are permitted provided that the following conditions are
62SN/A// met: redistributions of source code must retain the above copyright
72SN/A// notice, this list of conditions and the following disclaimer;
82SN/A// redistributions in binary form must reproduce the above copyright
92SN/A// notice, this list of conditions and the following disclaimer in the
102SN/A// documentation and/or other materials provided with the distribution;
112SN/A// neither the name of the copyright holders nor the names of its
122SN/A// contributors may be used to endorse or promote products derived from
132SN/A// this software without specific prior written permission.
142SN/A//
152SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
162SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
192SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
202SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
212SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
252SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262SN/A//
272665Ssaidi@eecs.umich.edu// Authors: Gabe Black
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.edu// Copyright (c) 2007 The Hewlett-Packard Development Company
302665Ssaidi@eecs.umich.edu// All rights reserved.
312665Ssaidi@eecs.umich.edu//
322SN/A// Redistribution and use of this software in source and binary forms,
332SN/A// with or without modification, are permitted provided that the
342SN/A// following conditions are met:
352SN/A//
363506Ssaidi@eecs.umich.edu// The software must be used only for Non-Commercial Use which means any
373506Ssaidi@eecs.umich.edu// use which is NOT directed to receiving any direct monetary
382SN/A// compensation for, or commercial advantage from such use.  Illustrative
392973Sgblack@eecs.umich.edu// examples of non-commercial use are academic research, personal study,
403584Ssaidi@eecs.umich.edu// teaching, education and corporate research & development.
4156SN/A// Illustrative examples of commercial use are distributing products for
423614Sgblack@eecs.umich.edu// commercial advantage and providing services using the software for
431717SN/A// commercial advantage.
442518SN/A//
4556SN/A// If you wish to use this software or functionality therein that may be
462518SN/A// covered by patents for commercial use, please contact:
472518SN/A//     Director of Intellectual Property Licensing
482SN/A//     Office of Strategy and Technology
493614Sgblack@eecs.umich.edu//     Hewlett-Packard Company
503614Sgblack@eecs.umich.edu//     1501 Page Mill Road
513614Sgblack@eecs.umich.edu//     Palo Alto, California  94304
523614Sgblack@eecs.umich.edu//
533065Sgblack@eecs.umich.edu// Redistributions of source code must retain the above copyright notice,
543065Sgblack@eecs.umich.edu// this list of conditions and the following disclaimer.  Redistributions
553506Ssaidi@eecs.umich.edu// in binary form must reproduce the above copyright notice, this list of
563065Sgblack@eecs.umich.edu// conditions and the following disclaimer in the documentation and/or
572SN/A// other materials provided with the distribution.  Neither the name of
582973Sgblack@eecs.umich.edu// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
592SN/A// contributors may be used to endorse or promote products derived from
603840Shsul@eecs.umich.edu// this software without specific prior written permission.  No right of
613825Ssaidi@eecs.umich.edu// sublicense is granted herewith.  Derivatives of the software and
623903Ssaidi@eecs.umich.edu// output created using the software may be prepared, but only for
633840Shsul@eecs.umich.edu// Non-Commercial Uses.  Derivatives of the software may be shared with
643825Ssaidi@eecs.umich.edu// others provided: (i) the others agree to abide by the list of
653506Ssaidi@eecs.umich.edu// conditions herein which includes the Non-Commercial Use restrictions;
663506Ssaidi@eecs.umich.edu// and (ii) such Derivatives of the software include the above copyright
673506Ssaidi@eecs.umich.edu// notice to acknowledge the contribution from this software where
683506Ssaidi@eecs.umich.edu// applicable, this list of conditions and the disclaimer below.
692SN/A//
702SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
712SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
722SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
732SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
743748Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
753748Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
763748Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
773748Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
783748Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
793748Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
803748Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
813748Sgblack@eecs.umich.edu//
823748Sgblack@eecs.umich.edu// Authors: Gabe Black
833748Sgblack@eecs.umich.edu
843748Sgblack@eecs.umich.edu// Declarations for execute() methods.
853748Sgblack@eecs.umich.edudef template BasicExecDeclare {{
863748Sgblack@eecs.umich.edu        Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const;
873748Sgblack@eecs.umich.edu}};
883748Sgblack@eecs.umich.edu
893748Sgblack@eecs.umich.edu// Definitions of execute methods that panic.
903748Sgblack@eecs.umich.edudef template BasicExecPanic {{
913748Sgblack@eecs.umich.edu        Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const
923748Sgblack@eecs.umich.edu        {
933748Sgblack@eecs.umich.edu            panic("Execute method called when it shouldn't!");
943748Sgblack@eecs.umich.edu            M5_DUMMY_RETURN
953748Sgblack@eecs.umich.edu        }
963748Sgblack@eecs.umich.edu}};
973748Sgblack@eecs.umich.edu
983748Sgblack@eecs.umich.edu// Basic instruction class declaration template.
993748Sgblack@eecs.umich.edudef template BasicDeclare {{
1003748Sgblack@eecs.umich.edu        /**
1013748Sgblack@eecs.umich.edu         * Static instruction class for "%(mnemonic)s".
1023748Sgblack@eecs.umich.edu         */
1033748Sgblack@eecs.umich.edu        class %(class_name)s : public %(base_class)s
1043748Sgblack@eecs.umich.edu        {
1053748Sgblack@eecs.umich.edu          public:
1063748Sgblack@eecs.umich.edu            // Constructor.
1073748Sgblack@eecs.umich.edu            %(class_name)s(ExtMachInst machInst);
1083748Sgblack@eecs.umich.edu            %(BasicExecDeclare)s
1093748Sgblack@eecs.umich.edu        };
1103748Sgblack@eecs.umich.edu}};
1113748Sgblack@eecs.umich.edu
1123748Sgblack@eecs.umich.edu// Basic instruction class constructor template.
1133748Sgblack@eecs.umich.edudef template BasicConstructor {{
1143748Sgblack@eecs.umich.edu        inline %(class_name)s::%(class_name)s(ExtMachInst machInst)
1153748Sgblack@eecs.umich.edu            : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
1163748Sgblack@eecs.umich.edu        {
1173748Sgblack@eecs.umich.edu                %(constructor)s;
1183748Sgblack@eecs.umich.edu        }
1193748Sgblack@eecs.umich.edu}};
1203748Sgblack@eecs.umich.edu
1213748Sgblack@eecs.umich.edu// Basic instruction class execute method template.
1223748Sgblack@eecs.umich.edudef template BasicExecute {{
1233748Sgblack@eecs.umich.edu        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
1242SN/A                Trace::InstRecord *traceData) const
1252SN/A        {
1262SN/A            Fault fault = NoFault;
1272SN/A
1283903Ssaidi@eecs.umich.edu            %(fp_enable_check)s;
1292973Sgblack@eecs.umich.edu            %(op_decl)s;
1302973Sgblack@eecs.umich.edu            %(op_rd)s;
1313065Sgblack@eecs.umich.edu            %(code)s;
1323380Sgblack@eecs.umich.edu
1333380Sgblack@eecs.umich.edu            if(fault == NoFault)
1343380Sgblack@eecs.umich.edu            {
1353380Sgblack@eecs.umich.edu                %(op_wb)s;
1363380Sgblack@eecs.umich.edu            }
1373380Sgblack@eecs.umich.edu            return fault;
1383380Sgblack@eecs.umich.edu        }
1393380Sgblack@eecs.umich.edu}};
1403380Sgblack@eecs.umich.edu
1413380Sgblack@eecs.umich.edu// Basic decode template.
1423380Sgblack@eecs.umich.edudef template BasicDecode {{
1433380Sgblack@eecs.umich.edu        return new %(class_name)s(machInst);
1443380Sgblack@eecs.umich.edu}};
1453380Sgblack@eecs.umich.edu
1463065Sgblack@eecs.umich.edu// Basic decode template, passing mnemonic in as string arg to constructor.
1473588Sgblack@eecs.umich.edudef template BasicDecodeWithMnemonic {{
1483588Sgblack@eecs.umich.edu    return new %(class_name)s("%(mnemonic)s", machInst);
1493588Sgblack@eecs.umich.edu}};
1503380Sgblack@eecs.umich.edu
1513380Sgblack@eecs.umich.edu// The most basic instruction format... used only for a few misc. insts
1523059Sgblack@eecs.umich.edudef format BasicOperate(code, *flags) {{
1533588Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name, 'SparcStaticInst', code, flags)
1543380Sgblack@eecs.umich.edu        header_output = BasicDeclare.subst(iop)
1553380Sgblack@eecs.umich.edu        decoder_output = BasicConstructor.subst(iop)
1563380Sgblack@eecs.umich.edu        decode_block = BasicDecode.subst(iop)
1573380Sgblack@eecs.umich.edu        exec_output = BasicExecute.subst(iop)
1583380Sgblack@eecs.umich.edu}};
1593588Sgblack@eecs.umich.edu