basic.isa revision 3272
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
362022SN/A// Basic instruction class declaration template.
372022SN/Adef template BasicDeclare {{
382022SN/A        /**
392022SN/A         * Static instruction class for "%(mnemonic)s".
402022SN/A         */
412022SN/A        class %(class_name)s : public %(base_class)s
422022SN/A        {
432224SN/A          public:
442224SN/A            // Constructor.
452224SN/A            %(class_name)s(MachInst machInst);
462224SN/A            %(BasicExecDeclare)s
472224SN/A        };
482022SN/A}};
492022SN/A
502022SN/A// Basic instruction class constructor template.
512022SN/Adef template BasicConstructor {{
522224SN/A        inline %(class_name)s::%(class_name)s(MachInst machInst)
532224SN/A            : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
542022SN/A        {
552022SN/A                %(constructor)s;
562022SN/A        }
572022SN/A}};
582022SN/A
592022SN/A// Basic instruction class execute method template.
602022SN/Adef template BasicExecute {{
612224SN/A        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
622224SN/A                Trace::InstRecord *traceData) const
632022SN/A        {
642224SN/A            Fault fault = NoFault;
652022SN/A
662224SN/A            %(op_decl)s;
672224SN/A            %(op_rd)s;
682224SN/A            %(code)s;
692022SN/A
702224SN/A            if(fault == NoFault)
712224SN/A            {
722224SN/A                %(op_wb)s;
732224SN/A            }
742224SN/A            return fault;
752022SN/A        }
762022SN/A}};
772022SN/A
782022SN/A// Basic decode template.
792022SN/Adef template BasicDecode {{
802022SN/A        return new %(class_name)s(machInst);
812022SN/A}};
822022SN/A
833272Sgblack@eecs.umich.edu// Basic decode template, passing mnemonic in as string arg to constructor.
843272Sgblack@eecs.umich.edudef template BasicDecodeWithMnemonic {{
853272Sgblack@eecs.umich.edu    return new %(class_name)s("%(mnemonic)s", machInst);
863272Sgblack@eecs.umich.edu}};
873272Sgblack@eecs.umich.edu
882022SN/A// The most basic instruction format... used only for a few misc. insts
892022SN/Adef format BasicOperate(code, *flags) {{
902224SN/A        iop = InstObjParams(name, Name, 'SparcStaticInst',
912224SN/A                CodeBlock(code), flags)
922022SN/A        header_output = BasicDeclare.subst(iop)
932022SN/A        decoder_output = BasicConstructor.subst(iop)
942022SN/A        decode_block = BasicDecode.subst(iop)
952022SN/A        exec_output = BasicExecute.subst(iop)
962022SN/A}};
97