static_inst.hh revision 12614
112275Sgabeblack@google.com/* 212275Sgabeblack@google.com * Copyright (c) 2006-2007 The Regents of The University of Michigan 312275Sgabeblack@google.com * All rights reserved. 412275Sgabeblack@google.com * Copyright 2017 Google Inc. 512275Sgabeblack@google.com * 612275Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 712275Sgabeblack@google.com * modification, are permitted provided that the following conditions are 812275Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 912275Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 1012275Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1112275Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1212275Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1312275Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1412275Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1512275Sgabeblack@google.com * this software without specific prior written permission. 1612275Sgabeblack@google.com * 1712275Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1812275Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1912275Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2012275Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2112275Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2212275Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2312275Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2412275Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2512275Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2612275Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2712275Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2812275Sgabeblack@google.com * 2912275Sgabeblack@google.com * Authors: Gabe Black 3012275Sgabeblack@google.com */ 3112275Sgabeblack@google.com#ifndef __ARCH_SPARC_INSTS_STATIC_INST_HH__ 3212275Sgabeblack@google.com#define __ARCH_SPARC_INSTS_STATIC_INST_HH__ 3312275Sgabeblack@google.com 3412275Sgabeblack@google.com#include <cstdint> 3512275Sgabeblack@google.com 3612275Sgabeblack@google.com#include "base/trace.hh" 3712275Sgabeblack@google.com#include "cpu/exec_context.hh" 3812275Sgabeblack@google.com#include "cpu/static_inst.hh" 3912275Sgabeblack@google.com 4012275Sgabeblack@google.comnamespace SparcISA 4112275Sgabeblack@google.com{ 4212275Sgabeblack@google.com 4312275Sgabeblack@google.comenum CondTest 4412275Sgabeblack@google.com{ 4512275Sgabeblack@google.com Always=0x8, 4612275Sgabeblack@google.com Never=0x0, 4712275Sgabeblack@google.com NotEqual=0x9, 4812275Sgabeblack@google.com Equal=0x1, 4912275Sgabeblack@google.com Greater=0xA, 5012275Sgabeblack@google.com LessOrEqual=0x2, 5112275Sgabeblack@google.com GreaterOrEqual=0xB, 5212275Sgabeblack@google.com Less=0x3, 5312275Sgabeblack@google.com GreaterUnsigned=0xC, 5412275Sgabeblack@google.com LessOrEqualUnsigned=0x4, 5512275Sgabeblack@google.com CarryClear=0xD, 5612275Sgabeblack@google.com CarrySet=0x5, 5712275Sgabeblack@google.com Positive=0xE, 5812275Sgabeblack@google.com Negative=0x6, 5912275Sgabeblack@google.com OverflowClear=0xF, 6012275Sgabeblack@google.com OverflowSet=0x7 6112275Sgabeblack@google.com}; 6212275Sgabeblack@google.com 6312275Sgabeblack@google.comextern const char *CondTestAbbrev[]; 6412275Sgabeblack@google.com 6512275Sgabeblack@google.comenum FpCondTest 6612275Sgabeblack@google.com{ 6712275Sgabeblack@google.com FAlways=0x8, 6812275Sgabeblack@google.com FNever=0x0, 6912275Sgabeblack@google.com FUnordered=0x7, 7012275Sgabeblack@google.com FGreater=0x6, 7112275Sgabeblack@google.com FUnorderedOrGreater=0x5, 7212275Sgabeblack@google.com FLess=0x4, 7312275Sgabeblack@google.com FUnorderedOrLess=0x3, 7412275Sgabeblack@google.com FLessOrGreater=0x2, 7512275Sgabeblack@google.com FNotEqual=0x1, 7612275Sgabeblack@google.com FEqual=0x9, 7712275Sgabeblack@google.com FUnorderedOrEqual=0xA, 7812275Sgabeblack@google.com FGreaterOrEqual=0xB, 7912275Sgabeblack@google.com FUnorderedOrGreaterOrEqual=0xC, 8012275Sgabeblack@google.com FLessOrEqual=0xD, 8112275Sgabeblack@google.com FUnorderedOrLessOrEqual=0xE, 8212275Sgabeblack@google.com FOrdered=0xF 8312275Sgabeblack@google.com}; 8412275Sgabeblack@google.com 8512275Sgabeblack@google.com/** 8612275Sgabeblack@google.com * Base class for all SPARC static instructions. 8712275Sgabeblack@google.com */ 8812275Sgabeblack@google.comclass SparcStaticInst : public StaticInst 8912275Sgabeblack@google.com{ 9012275Sgabeblack@google.com protected: 9112275Sgabeblack@google.com using StaticInst::StaticInst; 9212275Sgabeblack@google.com 9312275Sgabeblack@google.com std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 9412275Sgabeblack@google.com 9512275Sgabeblack@google.com static void printMnemonic(std::ostream &os, const char *mnemonic); 9612275Sgabeblack@google.com static void printReg(std::ostream &os, RegId reg); 9712275Sgabeblack@google.com 9812275Sgabeblack@google.com void printSrcReg(std::ostream &os, int reg) const; 9912275Sgabeblack@google.com void printDestReg(std::ostream &os, int reg) const; 10012275Sgabeblack@google.com 10112275Sgabeblack@google.com void printRegArray(std::ostream &os, 10212275Sgabeblack@google.com const RegId indexArray[], int num) const; 10312275Sgabeblack@google.com 10412275Sgabeblack@google.com void advancePC(PCState &pcState) const; 10512275Sgabeblack@google.com 10612275Sgabeblack@google.com static bool passesFpCondition(uint32_t fcc, uint32_t condition); 10712275Sgabeblack@google.com static bool passesCondition(uint32_t codes, uint32_t condition); 10812614Sgabeblack@google.com 10912614Sgabeblack@google.com size_t 11012614Sgabeblack@google.com asBytes(void *buf, size_t size) override 11112614Sgabeblack@google.com { 11212614Sgabeblack@google.com return simpleAsBytes(buf, size, machInst); 11312614Sgabeblack@google.com } 11412275Sgabeblack@google.com}; 11512275Sgabeblack@google.com 11612275Sgabeblack@google.com} 11712275Sgabeblack@google.com 11812275Sgabeblack@google.com#endif //__ARCH_SPARC_INSTS_STATIC_INST_HH__ 119