base.isa revision 11320:42ecb523c64a
19814Sandreas.hansson@arm.com// -*- mode:c++ -*-
22292SN/A
39383SAli.Saidi@ARM.com// Copyright (c) 2007 The Hewlett-Packard Development Company
47597Sminkyu.jeong@arm.com// All rights reserved.
57597Sminkyu.jeong@arm.com//
67597Sminkyu.jeong@arm.com// The license below extends only to copyright in the software and shall
77597Sminkyu.jeong@arm.com// not be construed as granting a license to any other intellectual
87597Sminkyu.jeong@arm.com// property including but not limited to intellectual property relating
97597Sminkyu.jeong@arm.com// to a hardware implementation of the functionality of the software
107597Sminkyu.jeong@arm.com// licensed hereunder.  You may use the software subject to the license
117597Sminkyu.jeong@arm.com// terms below provided that you ensure that this notice is replicated
127597Sminkyu.jeong@arm.com// unmodified and in its entirety in all distributions of the software,
137597Sminkyu.jeong@arm.com// modified or unmodified, in source code or in binary form.
147597Sminkyu.jeong@arm.com//
152292SN/A// Redistribution and use in source and binary forms, with or without
162292SN/A// modification, are permitted provided that the following conditions are
172292SN/A// met: redistributions of source code must retain the above copyright
182292SN/A// notice, this list of conditions and the following disclaimer;
192292SN/A// redistributions in binary form must reproduce the above copyright
202292SN/A// notice, this list of conditions and the following disclaimer in the
212292SN/A// documentation and/or other materials provided with the distribution;
222292SN/A// neither the name of the copyright holders nor the names of its
232292SN/A// contributors may be used to endorse or promote products derived from
242292SN/A// this software without specific prior written permission.
252292SN/A//
262292SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
272292SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
282292SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
292292SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
302292SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
312292SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
322292SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
332292SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
342292SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
352292SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
362292SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
372292SN/A//
382292SN/A// Authors: Gabe Black
392292SN/A
402689Sktlim@umich.edulet {{
412689Sktlim@umich.edu    # This will be populated with mappings between microop mnemonics and
422689Sktlim@umich.edu    # the classes that represent them.
432292SN/A    microopClasses = {}
442292SN/A}};
458591Sgblack@eecs.umich.edu
463326Sktlim@umich.edu//////////////////////////////////////////////////////////////////////////
478229Snate@binkert.org//
486658Snate@binkert.org// Base class for the python representation of x86 microops
498887Sgeoffrey.blake@arm.com//
502907Sktlim@umich.edu//////////////////////////////////////////////////////////////////////////
512292SN/A
528232Snate@binkert.orglet {{
538232Snate@binkert.org    class X86Microop(object):
548232Snate@binkert.org
559527SMatt.Horsnell@arm.com        generatorNameTemplate = "generate_%s_%d"
562722Sktlim@umich.edu
572669Sktlim@umich.edu        generatorTemplate = '''
582292SN/A            StaticInstPtr
592669Sktlim@umich.edu            ''' + generatorNameTemplate + '''(StaticInstPtr curMacroop)
602678Sktlim@umich.edu            {
612678Sktlim@umich.edu                static const char *macrocodeBlock = romMnemonic;
628581Ssteve.reinhardt@amd.com                static const ExtMachInst dummyExtMachInst = \
638581Ssteve.reinhardt@amd.com                    X86ISA::NoopMachInst;
642292SN/A                static const EmulEnv dummyEmulEnv(0, 0, 1, 1, 1);
652292SN/A
662292SN/A                Macroop * macroop = dynamic_cast<Macroop *>(curMacroop.get());
672669Sktlim@umich.edu                const ExtMachInst &machInst =
682292SN/A                    macroop ? macroop->getExtMachInst() : dummyExtMachInst;
692678Sktlim@umich.edu                const EmulEnv &env =
702292SN/A                    macroop ? macroop->getEmulEnv() : dummyEmulEnv;
719444SAndreas.Sandberg@ARM.com                // env may not be used in the microop's constructor.
729444SAndreas.Sandberg@ARM.com                InstRegIndex reg(env.reg);
739444SAndreas.Sandberg@ARM.com                reg = reg;
744319Sktlim@umich.edu                using namespace RomLabels;
754319Sktlim@umich.edu                return %s;
764319Sktlim@umich.edu            }
774319Sktlim@umich.edu        '''
784319Sktlim@umich.edu
792678Sktlim@umich.edu        def __init__(self, name):
802678Sktlim@umich.edu            self.name = name
812292SN/A
822678Sktlim@umich.edu        def microFlagsText(self, flags):
832678Sktlim@umich.edu            wrapped = ("(1ULL << StaticInst::%s)" % flag for flag in flags)
845336Shines@cs.fsu.edu            return " | ".join(wrapped)
852678Sktlim@umich.edu
864873Sstever@eecs.umich.edu        def getGeneratorDef(self, micropc):
872678Sktlim@umich.edu            return self.generatorTemplate % \
882292SN/A                (self.className, micropc, \
892678Sktlim@umich.edu                 self.getAllocator(["IsMicroop", "IsDelayedCommit"]))
902678Sktlim@umich.edu
912678Sktlim@umich.edu        def getGenerator(self, micropc):
922678Sktlim@umich.edu            return self.generatorNameTemplate % (self.className, micropc)
932678Sktlim@umich.edu}};
942678Sktlim@umich.edu