basic.isa revision 3275
12632Sstever@eecs.umich.edu// Copyright (c) 2006 The Regents of The University of Michigan
22632Sstever@eecs.umich.edu// All rights reserved.
32632Sstever@eecs.umich.edu//
42632Sstever@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
52632Sstever@eecs.umich.edu// modification, are permitted provided that the following conditions are
62632Sstever@eecs.umich.edu// met: redistributions of source code must retain the above copyright
72632Sstever@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
82632Sstever@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
92632Sstever@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
102632Sstever@eecs.umich.edu// documentation and/or other materials provided with the distribution;
112632Sstever@eecs.umich.edu// neither the name of the copyright holders nor the names of its
122632Sstever@eecs.umich.edu// contributors may be used to endorse or promote products derived from
132632Sstever@eecs.umich.edu// this software without specific prior written permission.
142632Sstever@eecs.umich.edu//
152632Sstever@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
162632Sstever@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172632Sstever@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182632Sstever@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
192632Sstever@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
202632Sstever@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
212632Sstever@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222632Sstever@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232632Sstever@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242632Sstever@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
252632Sstever@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262632Sstever@eecs.umich.edu//
272632Sstever@eecs.umich.edu// Authors: Ali Saidi
282632Sstever@eecs.umich.edu//          Gabe Black
292632Sstever@eecs.umich.edu//          Steve Reinhardt
302022SN/A
312022SN/A// Declarations for execute() methods.
322022SN/Adef template BasicExecDeclare {{
332022SN/A        Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const;
342022SN/A}};
352022SN/A
363275Sgblack@eecs.umich.edu// Definitions of execute methods that panic.
373275Sgblack@eecs.umich.edudef template BasicExecPanic {{
383275Sgblack@eecs.umich.edu        Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const
393275Sgblack@eecs.umich.edu        {
403275Sgblack@eecs.umich.edu            panic("Execute method called when it shouldn't!");
413275Sgblack@eecs.umich.edu        }
423275Sgblack@eecs.umich.edu}};
433275Sgblack@eecs.umich.edu
442022SN/A// Basic instruction class declaration template.
452022SN/Adef template BasicDeclare {{
462022SN/A        /**
472022SN/A         * Static instruction class for "%(mnemonic)s".
482022SN/A         */
492022SN/A        class %(class_name)s : public %(base_class)s
502022SN/A        {
512224SN/A          public:
522224SN/A            // Constructor.
532224SN/A            %(class_name)s(MachInst machInst);
542224SN/A            %(BasicExecDeclare)s
552224SN/A        };
562022SN/A}};
572022SN/A
582022SN/A// Basic instruction class constructor template.
592022SN/Adef template BasicConstructor {{
602224SN/A        inline %(class_name)s::%(class_name)s(MachInst machInst)
612224SN/A            : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
622022SN/A        {
632022SN/A                %(constructor)s;
642022SN/A        }
652022SN/A}};
662022SN/A
672022SN/A// Basic instruction class execute method template.
682022SN/Adef template BasicExecute {{
692224SN/A        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
702224SN/A                Trace::InstRecord *traceData) const
712022SN/A        {
722224SN/A            Fault fault = NoFault;
732022SN/A
742224SN/A            %(op_decl)s;
752224SN/A            %(op_rd)s;
762224SN/A            %(code)s;
772022SN/A
782224SN/A            if(fault == NoFault)
792224SN/A            {
802224SN/A                %(op_wb)s;
812224SN/A            }
822224SN/A            return fault;
832022SN/A        }
842022SN/A}};
852022SN/A
862022SN/A// Basic decode template.
872022SN/Adef template BasicDecode {{
882022SN/A        return new %(class_name)s(machInst);
892022SN/A}};
902022SN/A
913272Sgblack@eecs.umich.edu// Basic decode template, passing mnemonic in as string arg to constructor.
923272Sgblack@eecs.umich.edudef template BasicDecodeWithMnemonic {{
933272Sgblack@eecs.umich.edu    return new %(class_name)s("%(mnemonic)s", machInst);
943272Sgblack@eecs.umich.edu}};
953272Sgblack@eecs.umich.edu
962022SN/A// The most basic instruction format... used only for a few misc. insts
972022SN/Adef format BasicOperate(code, *flags) {{
982224SN/A        iop = InstObjParams(name, Name, 'SparcStaticInst',
992224SN/A                CodeBlock(code), flags)
1002022SN/A        header_output = BasicDeclare.subst(iop)
1012022SN/A        decoder_output = BasicConstructor.subst(iop)
1022022SN/A        decode_block = BasicDecode.subst(iop)
1032022SN/A        exec_output = BasicExecute.subst(iop)
1042022SN/A}};
105