static_inst.hh revision 12614
12497SN/A/*
212776Snikos.nikoleris@arm.com * Copyright (c) 2009 The University of Edinburgh
38711SN/A * All rights reserved.
48711SN/A *
58711SN/A * Redistribution and use in source and binary forms, with or without
68711SN/A * modification, are permitted provided that the following conditions are
78711SN/A * met: redistributions of source code must retain the above copyright
88711SN/A * notice, this list of conditions and the following disclaimer;
98711SN/A * redistributions in binary form must reproduce the above copyright
108711SN/A * notice, this list of conditions and the following disclaimer in the
118711SN/A * documentation and/or other materials provided with the distribution;
128711SN/A * neither the name of the copyright holders nor the names of its
138711SN/A * contributors may be used to endorse or promote products derived from
142497SN/A * this software without specific prior written permission.
152497SN/A *
162497SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172497SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182497SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192497SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202497SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212497SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222497SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232497SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242497SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252497SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262497SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272497SN/A *
282497SN/A * Authors: Timothy M. Jones
292497SN/A */
302497SN/A
312497SN/A#ifndef __ARCH_POWER_INSTS_STATICINST_HH__
322497SN/A#define __ARCH_POWER_INSTS_STATICINST_HH__
332497SN/A
342497SN/A#include "base/trace.hh"
352497SN/A#include "cpu/static_inst.hh"
362497SN/A
372497SN/Anamespace PowerISA
382497SN/A{
392665SN/A
402665SN/Aclass PowerStaticInst : public StaticInst
418715SN/A{
428922SN/A  protected:
432497SN/A
442497SN/A    // Constructor
452497SN/A    PowerStaticInst(const char *mnem, MachInst _machInst, OpClass __opClass)
462982SN/A        : StaticInst(mnem, _machInst, __opClass)
4710405Sandreas.hansson@arm.com    {
482497SN/A    }
492497SN/A
5011793Sbrandon.potter@amd.com    // Insert a condition value into a CR (condition register) field
5111793Sbrandon.potter@amd.com    inline uint32_t
5212334Sgabeblack@google.com    insertCRField(uint32_t cr, uint32_t bf, uint32_t value) const
532548SN/A    {
5410405Sandreas.hansson@arm.com        uint32_t bits = value << ((7 - bf) * 4);
559152SN/A        uint32_t mask = ~(0xf << ((7 - bf) * 4));
5610405Sandreas.hansson@arm.com        return (cr & mask) | bits;
572497SN/A    }
5810405Sandreas.hansson@arm.com
5913892Sgabeblack@google.com    /// Print a register name for disassembly given the unique
6010719SMarco.Balboni@ARM.com    /// dependence tag number (FP or int).
6110719SMarco.Balboni@ARM.com    void
6210719SMarco.Balboni@ARM.com    printReg(std::ostream &os, RegId reg) const;
6310719SMarco.Balboni@ARM.com
649279SN/A    std::string
659279SN/A    generateDisassembly(Addr pc, const SymbolTable *symtab) const;
669279SN/A
679814SN/A    void
689240SN/A    advancePC(PowerISA::PCState &pcState) const
698851SN/A    {
7010405Sandreas.hansson@arm.com        pcState.advance();
719036SN/A    }
7210405Sandreas.hansson@arm.com
7310405Sandreas.hansson@arm.com    size_t
748851SN/A    asBytes(void *buf, size_t max_size) override
7510405Sandreas.hansson@arm.com    {
7610405Sandreas.hansson@arm.com        return simpleAsBytes(buf, max_size, machInst);
777523SN/A    }
787523SN/A};
7913784Sgabeblack@google.com
8013784Sgabeblack@google.com} // namespace PowerISA
812640SN/A
828948SN/A#endif //__ARCH_POWER_INSTS_STATICINST_HH__
838948SN/A