base.isa revision 11320:42ecb523c64a
12623SN/A// -*- mode:c++ -*-
22623SN/A
32623SN/A// Copyright (c) 2007 The Hewlett-Packard Development Company
42623SN/A// All rights reserved.
52623SN/A//
62623SN/A// The license below extends only to copyright in the software and shall
72623SN/A// not be construed as granting a license to any other intellectual
82623SN/A// property including but not limited to intellectual property relating
92623SN/A// to a hardware implementation of the functionality of the software
102623SN/A// licensed hereunder.  You may use the software subject to the license
112623SN/A// terms below provided that you ensure that this notice is replicated
122623SN/A// unmodified and in its entirety in all distributions of the software,
132623SN/A// modified or unmodified, in source code or in binary form.
142623SN/A//
152623SN/A// Redistribution and use in source and binary forms, with or without
162623SN/A// modification, are permitted provided that the following conditions are
172623SN/A// met: redistributions of source code must retain the above copyright
182623SN/A// notice, this list of conditions and the following disclaimer;
192623SN/A// redistributions in binary form must reproduce the above copyright
202623SN/A// notice, this list of conditions and the following disclaimer in the
212623SN/A// documentation and/or other materials provided with the distribution;
222623SN/A// neither the name of the copyright holders nor the names of its
232623SN/A// contributors may be used to endorse or promote products derived from
242623SN/A// this software without specific prior written permission.
252623SN/A//
262623SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
272665Ssaidi@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
282665Ssaidi@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
292623SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
302623SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
312623SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
322623SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
332623SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
342623SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
352623SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
362623SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
372623SN/A//
382623SN/A// Authors: Gabe Black
392623SN/A
402623SN/Alet {{
412623SN/A    # This will be populated with mappings between microop mnemonics and
422623SN/A    # the classes that represent them.
432623SN/A    microopClasses = {}
442623SN/A}};
452623SN/A
462623SN/A//////////////////////////////////////////////////////////////////////////
472623SN/A//
482623SN/A// Base class for the python representation of x86 microops
492623SN/A//
502623SN/A//////////////////////////////////////////////////////////////////////////
512623SN/A
522623SN/Alet {{
532623SN/A    class X86Microop(object):
542623SN/A
552623SN/A        generatorNameTemplate = "generate_%s_%d"
562623SN/A
572623SN/A        generatorTemplate = '''
582623SN/A            StaticInstPtr
592623SN/A            ''' + generatorNameTemplate + '''(StaticInstPtr curMacroop)
602623SN/A            {
612623SN/A                static const char *macrocodeBlock = romMnemonic;
622623SN/A                static const ExtMachInst dummyExtMachInst = \
632623SN/A                    X86ISA::NoopMachInst;
642623SN/A                static const EmulEnv dummyEmulEnv(0, 0, 1, 1, 1);
652623SN/A
662623SN/A                Macroop * macroop = dynamic_cast<Macroop *>(curMacroop.get());
672839Sktlim@umich.edu                const ExtMachInst &machInst =
682798Sktlim@umich.edu                    macroop ? macroop->getExtMachInst() : dummyExtMachInst;
692867Sktlim@umich.edu                const EmulEnv &env =
702867Sktlim@umich.edu                    macroop ? macroop->getEmulEnv() : dummyEmulEnv;
712623SN/A                // env may not be used in the microop's constructor.
722623SN/A                InstRegIndex reg(env.reg);
732623SN/A                reg = reg;
742623SN/A                using namespace RomLabels;
752623SN/A                return %s;
762623SN/A            }
772948Ssaidi@eecs.umich.edu        '''
782623SN/A
792623SN/A        def __init__(self, name):
802623SN/A            self.name = name
812948Ssaidi@eecs.umich.edu
822948Ssaidi@eecs.umich.edu        def microFlagsText(self, flags):
832623SN/A            wrapped = ("(1ULL << StaticInst::%s)" % flag for flag in flags)
842623SN/A            return " | ".join(wrapped)
852623SN/A
862623SN/A        def getGeneratorDef(self, micropc):
872630SN/A            return self.generatorTemplate % \
882623SN/A                (self.className, micropc, \
892630SN/A                 self.getAllocator(["IsMicroop", "IsDelayedCommit"]))
902623SN/A
912623SN/A        def getGenerator(self, micropc):
922623SN/A            return self.generatorNameTemplate % (self.className, micropc)
932623SN/A}};
942623SN/A