112287Sgabeblack@google.com/* 212287Sgabeblack@google.com * Copyright (c) 2006-2007 The Regents of The University of Michigan 312287Sgabeblack@google.com * All rights reserved 412287Sgabeblack@google.com * Copyright 2017 Google Inc. 512287Sgabeblack@google.com * 612287Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 712287Sgabeblack@google.com * modification, are permitted provided that the following conditions are 812287Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 912287Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 1012287Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1112287Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1212287Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1312287Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1412287Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1512287Sgabeblack@google.com * this software without specific prior written permission. 1612287Sgabeblack@google.com * 1712287Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1812287Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1912287Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2012287Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2112287Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2212287Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2312287Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2412287Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2512287Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2612287Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2712287Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2812287Sgabeblack@google.com * 2912287Sgabeblack@google.com * Authors: Ali Saidi 3012287Sgabeblack@google.com * Gabe Black 3112287Sgabeblack@google.com * Steve Reinhardt 3212287Sgabeblack@google.com */ 3312287Sgabeblack@google.com 3412287Sgabeblack@google.com#include "arch/sparc/insts/priv.hh" 3512287Sgabeblack@google.com 3612287Sgabeblack@google.comnamespace SparcISA 3712287Sgabeblack@google.com{ 3812287Sgabeblack@google.com 3912287Sgabeblack@google.comstd::string 4012287Sgabeblack@google.comPriv::generateDisassembly(Addr pc, const SymbolTable *symtab) const 4112287Sgabeblack@google.com{ 4212287Sgabeblack@google.com std::stringstream response; 4312287Sgabeblack@google.com 4412287Sgabeblack@google.com printMnemonic(response, mnemonic); 4512287Sgabeblack@google.com 4612287Sgabeblack@google.com return response.str(); 4712287Sgabeblack@google.com} 4812287Sgabeblack@google.com 4912287Sgabeblack@google.comstd::string 5012287Sgabeblack@google.comRdPriv::generateDisassembly(Addr pc, const SymbolTable *symtab) const 5112287Sgabeblack@google.com{ 5212287Sgabeblack@google.com std::stringstream response; 5312287Sgabeblack@google.com 5412287Sgabeblack@google.com printMnemonic(response, mnemonic); 5512287Sgabeblack@google.com 5612287Sgabeblack@google.com ccprintf(response, " %%%s, ", regName); 5712287Sgabeblack@google.com printDestReg(response, 0); 5812287Sgabeblack@google.com 5912287Sgabeblack@google.com return response.str(); 6012287Sgabeblack@google.com} 6112287Sgabeblack@google.com 6212287Sgabeblack@google.comstd::string 6312287Sgabeblack@google.comWrPriv::generateDisassembly(Addr pc, const SymbolTable *symtab) const 6412287Sgabeblack@google.com{ 6512287Sgabeblack@google.com std::stringstream response; 6612287Sgabeblack@google.com 6712287Sgabeblack@google.com printMnemonic(response, mnemonic); 6812287Sgabeblack@google.com 6912287Sgabeblack@google.com ccprintf(response, " "); 7012287Sgabeblack@google.com // If the first reg is %g0, don't print it. 7112287Sgabeblack@google.com // This improves readability 7212287Sgabeblack@google.com if (_srcRegIdx[0].index() != 0) { 7312287Sgabeblack@google.com printSrcReg(response, 0); 7412287Sgabeblack@google.com ccprintf(response, ", "); 7512287Sgabeblack@google.com } 7612287Sgabeblack@google.com printSrcReg(response, 1); 7712287Sgabeblack@google.com ccprintf(response, ", %%%s", regName); 7812287Sgabeblack@google.com 7912287Sgabeblack@google.com return response.str(); 8012287Sgabeblack@google.com} 8112287Sgabeblack@google.com 8212287Sgabeblack@google.comstd::string 8312287Sgabeblack@google.comWrPrivImm::generateDisassembly(Addr pc, const SymbolTable *symtab) const 8412287Sgabeblack@google.com{ 8512287Sgabeblack@google.com std::stringstream response; 8612287Sgabeblack@google.com 8712287Sgabeblack@google.com printMnemonic(response, mnemonic); 8812287Sgabeblack@google.com 8912287Sgabeblack@google.com ccprintf(response, " "); 9012287Sgabeblack@google.com // If the first reg is %g0, don't print it. 9112287Sgabeblack@google.com // This improves readability 9212287Sgabeblack@google.com if (_srcRegIdx[0].index() != 0) { 9312287Sgabeblack@google.com printSrcReg(response, 0); 9412287Sgabeblack@google.com ccprintf(response, ", "); 9512287Sgabeblack@google.com } 9612287Sgabeblack@google.com ccprintf(response, "%#x, %%%s", imm, regName); 9712287Sgabeblack@google.com 9812287Sgabeblack@google.com return response.str(); 9912287Sgabeblack@google.com} 10012287Sgabeblack@google.com 10112287Sgabeblack@google.com} 102