1/*
2 * Copyright (c) 2006-2007 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Gabe Black
29 */
30
31#ifndef __ARCH_SPARC_INSTS_MICRO_HH__
32#define __ARCH_SPARC_INSTS_MICRO_HH__
33
34#include "arch/sparc/insts/static_inst.hh"
35
36namespace SparcISA
37{
38
39class SparcMacroInst : public SparcStaticInst
40{
41  protected:
42    const uint32_t numMicroops;
43
44    // Constructor.
45    SparcMacroInst(const char *mnem, ExtMachInst _machInst,
46                   OpClass __opClass, uint32_t _numMicroops) :
47            SparcStaticInst(mnem, _machInst, __opClass),
48            numMicroops(_numMicroops)
49    {
50        assert(numMicroops);
51        microops = new StaticInstPtr[numMicroops];
52        flags[IsMacroop] = true;
53    }
54
55    ~SparcMacroInst()
56    {
57        delete [] microops;
58    }
59
60    std::string generateDisassembly(
61        Addr pc, const SymbolTable *symtab) const override;
62
63    StaticInstPtr *microops;
64
65    StaticInstPtr
66    fetchMicroop(MicroPC upc) const override
67    {
68        assert(upc < numMicroops);
69        return microops[upc];
70    }
71
72    Fault
73    execute(ExecContext *, Trace::InstRecord *) const override
74    {
75        panic("Tried to execute a macroop directly!\n");
76    }
77
78    Fault
79    initiateAcc(ExecContext *, Trace::InstRecord *) const override
80    {
81        panic("Tried to execute a macroop directly!\n");
82    }
83
84    Fault
85    completeAcc(PacketPtr, ExecContext *, Trace::InstRecord *) const override
86    {
87        panic("Tried to execute a macroop directly!\n");
88    }
89};
90
91class SparcMicroInst : public SparcStaticInst
92{
93  protected:
94    // Constructor.
95    SparcMicroInst(const char *mnem, ExtMachInst _machInst,
96                   OpClass __opClass) :
97            SparcStaticInst(mnem, _machInst, __opClass)
98    {
99        flags[IsMicroop] = true;
100    }
101
102    void
103    advancePC(SparcISA::PCState &pcState) const override
104    {
105        if (flags[IsLastMicroop])
106            pcState.uEnd();
107        else
108            pcState.uAdvance();
109    }
110};
111
112class SparcDelayedMicroInst : public SparcMicroInst
113{
114  protected:
115    // Constructor.
116    SparcDelayedMicroInst(const char *mnem, ExtMachInst _machInst,
117                          OpClass __opClass) :
118            SparcMicroInst(mnem, _machInst, __opClass)
119    {
120        flags[IsDelayedCommit] = true;
121    }
122};
123
124}
125
126#endif // __ARCH_SPARC_INSTS_MICRO_HH__
127