basic.isa revision 7167:a28390624772
15353Svilas.sridharan@gmail.com// -*- mode:c++ -*-
23395Shsul@eecs.umich.edu
33395Shsul@eecs.umich.edu// Copyright (c) 2007-2008 The Florida State University
43395Shsul@eecs.umich.edu// All rights reserved.
53395Shsul@eecs.umich.edu//
63395Shsul@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
73395Shsul@eecs.umich.edu// modification, are permitted provided that the following conditions are
83395Shsul@eecs.umich.edu// met: redistributions of source code must retain the above copyright
93395Shsul@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
103395Shsul@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
113395Shsul@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
123395Shsul@eecs.umich.edu// documentation and/or other materials provided with the distribution;
133395Shsul@eecs.umich.edu// neither the name of the copyright holders nor the names of its
143395Shsul@eecs.umich.edu// contributors may be used to endorse or promote products derived from
153395Shsul@eecs.umich.edu// this software without specific prior written permission.
163395Shsul@eecs.umich.edu//
173395Shsul@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
183395Shsul@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
193395Shsul@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
203395Shsul@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
213395Shsul@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
223395Shsul@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
233395Shsul@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
243395Shsul@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
253395Shsul@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
263395Shsul@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
273395Shsul@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
283395Shsul@eecs.umich.edu//
293395Shsul@eecs.umich.edu// Authors: Stephen Hines
303395Shsul@eecs.umich.edu
313395Shsul@eecs.umich.edu// Declarations for execute() methods.
325869Sksewell@umich.edudef template BasicExecDeclare {{
335361Srstrong@cs.ucsd.edu        Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const;
343395Shsul@eecs.umich.edu}};
354455Ssaidi@eecs.umich.edu
364968Sacolyte@umich.edu// Basic instruction class declaration template.
373395Shsul@eecs.umich.edudef template BasicDeclare {{
383395Shsul@eecs.umich.edu        /**
393395Shsul@eecs.umich.edu         * Static instruction class for "%(mnemonic)s".
403395Shsul@eecs.umich.edu         */
413395Shsul@eecs.umich.edu        class %(class_name)s : public %(base_class)s
423395Shsul@eecs.umich.edu        {
433395Shsul@eecs.umich.edu          public:
443395Shsul@eecs.umich.edu                /// Constructor.
455361Srstrong@cs.ucsd.edu                %(class_name)s(ExtMachInst machInst);
465361Srstrong@cs.ucsd.edu                %(BasicExecDeclare)s
475361Srstrong@cs.ucsd.edu        };
485361Srstrong@cs.ucsd.edu}};
495361Srstrong@cs.ucsd.edu
505361Srstrong@cs.ucsd.edu// Basic instruction class constructor template.
515361Srstrong@cs.ucsd.edudef template BasicConstructor {{
525361Srstrong@cs.ucsd.edu        inline %(class_name)s::%(class_name)s(ExtMachInst machInst)  : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
533395Shsul@eecs.umich.edu        {
543395Shsul@eecs.umich.edu                %(constructor)s;
553395Shsul@eecs.umich.edu        }
563395Shsul@eecs.umich.edu}};
575361Srstrong@cs.ucsd.edu
585361Srstrong@cs.ucsd.edu
593445Shsul@eecs.umich.edu// Basic instruction class execute method template.
605361Srstrong@cs.ucsd.edudef template BasicExecute {{
615361Srstrong@cs.ucsd.edu        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
625361Srstrong@cs.ucsd.edu        {
635361Srstrong@cs.ucsd.edu                Fault fault = NoFault;
645361Srstrong@cs.ucsd.edu
655361Srstrong@cs.ucsd.edu                %(op_decl)s;
665361Srstrong@cs.ucsd.edu                %(op_rd)s;
675361Srstrong@cs.ucsd.edu                %(code)s;
685361Srstrong@cs.ucsd.edu
695361Srstrong@cs.ucsd.edu                if (fault == NoFault)
705361Srstrong@cs.ucsd.edu                {
715361Srstrong@cs.ucsd.edu                    %(op_wb)s;
725361Srstrong@cs.ucsd.edu                }
735361Srstrong@cs.ucsd.edu                return fault;
745361Srstrong@cs.ucsd.edu        }
755361Srstrong@cs.ucsd.edu}};
765361Srstrong@cs.ucsd.edu
775361Srstrong@cs.ucsd.edu// Basic decode template.
785361Srstrong@cs.ucsd.edudef template BasicDecode {{
795361Srstrong@cs.ucsd.edu        return new %(class_name)s(machInst);
80}};
81
82// Basic decode template, passing mnemonic in as string arg to constructor.
83def template BasicDecodeWithMnemonic {{
84        return new %(class_name)s("%(mnemonic)s", machInst);
85}};
86
87// Definitions of execute methods that panic.
88def template BasicExecPanic {{
89Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const
90{
91        panic("Execute method called when it shouldn't!");
92}
93}};
94