112293Sgabeblack@google.com/*
212293Sgabeblack@google.com * Copyright (c) 2006-2007 The Regents of The University of Michigan
312293Sgabeblack@google.com * All rights reserved.
412293Sgabeblack@google.com *
512293Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
612293Sgabeblack@google.com * modification, are permitted provided that the following conditions are
712293Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
812293Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
912293Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1012293Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1112293Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1212293Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1312293Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1412293Sgabeblack@google.com * this software without specific prior written permission.
1512293Sgabeblack@google.com *
1612293Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712293Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812293Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912293Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012293Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112293Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212293Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312293Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412293Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512293Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612293Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712293Sgabeblack@google.com *
2812293Sgabeblack@google.com * Authors: Gabe Black
2912293Sgabeblack@google.com */
3012293Sgabeblack@google.com
3112293Sgabeblack@google.com#ifndef __ARCH_SPARC_INSTS_MICRO_HH__
3212293Sgabeblack@google.com#define __ARCH_SPARC_INSTS_MICRO_HH__
3312293Sgabeblack@google.com
3412293Sgabeblack@google.com#include "arch/sparc/insts/static_inst.hh"
3512293Sgabeblack@google.com
3612293Sgabeblack@google.comnamespace SparcISA
3712293Sgabeblack@google.com{
3812293Sgabeblack@google.com
3912293Sgabeblack@google.comclass SparcMacroInst : public SparcStaticInst
4012293Sgabeblack@google.com{
4112293Sgabeblack@google.com  protected:
4212293Sgabeblack@google.com    const uint32_t numMicroops;
4312293Sgabeblack@google.com
4412293Sgabeblack@google.com    // Constructor.
4512293Sgabeblack@google.com    SparcMacroInst(const char *mnem, ExtMachInst _machInst,
4612293Sgabeblack@google.com                   OpClass __opClass, uint32_t _numMicroops) :
4712293Sgabeblack@google.com            SparcStaticInst(mnem, _machInst, __opClass),
4812293Sgabeblack@google.com            numMicroops(_numMicroops)
4912293Sgabeblack@google.com    {
5012293Sgabeblack@google.com        assert(numMicroops);
5112293Sgabeblack@google.com        microops = new StaticInstPtr[numMicroops];
5212293Sgabeblack@google.com        flags[IsMacroop] = true;
5312293Sgabeblack@google.com    }
5412293Sgabeblack@google.com
5512293Sgabeblack@google.com    ~SparcMacroInst()
5612293Sgabeblack@google.com    {
5712293Sgabeblack@google.com        delete [] microops;
5812293Sgabeblack@google.com    }
5912293Sgabeblack@google.com
6012293Sgabeblack@google.com    std::string generateDisassembly(
6112293Sgabeblack@google.com        Addr pc, const SymbolTable *symtab) const override;
6212293Sgabeblack@google.com
6312293Sgabeblack@google.com    StaticInstPtr *microops;
6412293Sgabeblack@google.com
6512293Sgabeblack@google.com    StaticInstPtr
6612293Sgabeblack@google.com    fetchMicroop(MicroPC upc) const override
6712293Sgabeblack@google.com    {
6812293Sgabeblack@google.com        assert(upc < numMicroops);
6912293Sgabeblack@google.com        return microops[upc];
7012293Sgabeblack@google.com    }
7112293Sgabeblack@google.com
7212293Sgabeblack@google.com    Fault
7312293Sgabeblack@google.com    execute(ExecContext *, Trace::InstRecord *) const override
7412293Sgabeblack@google.com    {
7512293Sgabeblack@google.com        panic("Tried to execute a macroop directly!\n");
7612293Sgabeblack@google.com    }
7712293Sgabeblack@google.com
7812293Sgabeblack@google.com    Fault
7912293Sgabeblack@google.com    initiateAcc(ExecContext *, Trace::InstRecord *) const override
8012293Sgabeblack@google.com    {
8112293Sgabeblack@google.com        panic("Tried to execute a macroop directly!\n");
8212293Sgabeblack@google.com    }
8312293Sgabeblack@google.com
8412293Sgabeblack@google.com    Fault
8512293Sgabeblack@google.com    completeAcc(PacketPtr, ExecContext *, Trace::InstRecord *) const override
8612293Sgabeblack@google.com    {
8712293Sgabeblack@google.com        panic("Tried to execute a macroop directly!\n");
8812293Sgabeblack@google.com    }
8912293Sgabeblack@google.com};
9012293Sgabeblack@google.com
9112293Sgabeblack@google.comclass SparcMicroInst : public SparcStaticInst
9212293Sgabeblack@google.com{
9312293Sgabeblack@google.com  protected:
9412293Sgabeblack@google.com    // Constructor.
9512293Sgabeblack@google.com    SparcMicroInst(const char *mnem, ExtMachInst _machInst,
9612293Sgabeblack@google.com                   OpClass __opClass) :
9712293Sgabeblack@google.com            SparcStaticInst(mnem, _machInst, __opClass)
9812293Sgabeblack@google.com    {
9912293Sgabeblack@google.com        flags[IsMicroop] = true;
10012293Sgabeblack@google.com    }
10112293Sgabeblack@google.com
10212293Sgabeblack@google.com    void
10312293Sgabeblack@google.com    advancePC(SparcISA::PCState &pcState) const override
10412293Sgabeblack@google.com    {
10512293Sgabeblack@google.com        if (flags[IsLastMicroop])
10612293Sgabeblack@google.com            pcState.uEnd();
10712293Sgabeblack@google.com        else
10812293Sgabeblack@google.com            pcState.uAdvance();
10912293Sgabeblack@google.com    }
11012293Sgabeblack@google.com};
11112293Sgabeblack@google.com
11212293Sgabeblack@google.comclass SparcDelayedMicroInst : public SparcMicroInst
11312293Sgabeblack@google.com{
11412293Sgabeblack@google.com  protected:
11512293Sgabeblack@google.com    // Constructor.
11612293Sgabeblack@google.com    SparcDelayedMicroInst(const char *mnem, ExtMachInst _machInst,
11712293Sgabeblack@google.com                          OpClass __opClass) :
11812293Sgabeblack@google.com            SparcMicroInst(mnem, _machInst, __opClass)
11912293Sgabeblack@google.com    {
12012293Sgabeblack@google.com        flags[IsDelayedCommit] = true;
12112293Sgabeblack@google.com    }
12212293Sgabeblack@google.com};
12312293Sgabeblack@google.com
12412293Sgabeblack@google.com}
12512293Sgabeblack@google.com
12612293Sgabeblack@google.com#endif // __ARCH_SPARC_INSTS_MICRO_HH__
127