112295Sgabeblack@google.com/* 212295Sgabeblack@google.com * Copyright (c) 2006-2007 The Regents of The University of Michigan 312295Sgabeblack@google.com * All rights reserved. 412295Sgabeblack@google.com * 512295Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 612295Sgabeblack@google.com * modification, are permitted provided that the following conditions are 712295Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 812295Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 912295Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1012295Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1112295Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1212295Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1312295Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1412295Sgabeblack@google.com * this software without specific prior written permission. 1512295Sgabeblack@google.com * 1612295Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712295Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812295Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912295Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012295Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112295Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212295Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312295Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412295Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512295Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612295Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712295Sgabeblack@google.com * 2812295Sgabeblack@google.com * Authors: Ali Saidi 2912295Sgabeblack@google.com * Gabe Black 3012295Sgabeblack@google.com * Steve Reinhardt 3112295Sgabeblack@google.com */ 3212295Sgabeblack@google.com 3312295Sgabeblack@google.com#include "arch/sparc/insts/integer.hh" 3412295Sgabeblack@google.com 3512295Sgabeblack@google.comnamespace SparcISA 3612295Sgabeblack@google.com{ 3712295Sgabeblack@google.com 3812295Sgabeblack@google.com//////////////////////////////////////////////////////////////////// 3912295Sgabeblack@google.com// 4012295Sgabeblack@google.com// Integer operate instructions 4112295Sgabeblack@google.com// 4212295Sgabeblack@google.com 4312295Sgabeblack@google.combool 4412295Sgabeblack@google.comIntOp::printPseudoOps(std::ostream &os, Addr pc, 4512295Sgabeblack@google.com const SymbolTable *symbab) const 4612295Sgabeblack@google.com{ 4712295Sgabeblack@google.com if (!std::strcmp(mnemonic, "or") && _srcRegIdx[0].index() == 0) { 4812295Sgabeblack@google.com printMnemonic(os, "mov"); 4912295Sgabeblack@google.com printSrcReg(os, 1); 5012295Sgabeblack@google.com ccprintf(os, ", "); 5112295Sgabeblack@google.com printDestReg(os, 0); 5212295Sgabeblack@google.com return true; 5312295Sgabeblack@google.com } 5412295Sgabeblack@google.com return false; 5512295Sgabeblack@google.com} 5612295Sgabeblack@google.com 5712295Sgabeblack@google.combool 5812295Sgabeblack@google.comIntOpImm::printPseudoOps(std::ostream &os, Addr pc, 5912295Sgabeblack@google.com const SymbolTable *symbab) const 6012295Sgabeblack@google.com{ 6112295Sgabeblack@google.com if (!std::strcmp(mnemonic, "or")) { 6212295Sgabeblack@google.com if (_numSrcRegs > 0 && _srcRegIdx[0].index() == 0) { 6312295Sgabeblack@google.com if (imm == 0) { 6412295Sgabeblack@google.com printMnemonic(os, "clr"); 6512295Sgabeblack@google.com } else { 6612295Sgabeblack@google.com printMnemonic(os, "mov"); 6712295Sgabeblack@google.com ccprintf(os, " %#x, ", imm); 6812295Sgabeblack@google.com } 6912295Sgabeblack@google.com printDestReg(os, 0); 7012295Sgabeblack@google.com return true; 7112295Sgabeblack@google.com } else if (imm == 0) { 7212295Sgabeblack@google.com printMnemonic(os, "mov"); 7312295Sgabeblack@google.com printSrcReg(os, 0); 7412295Sgabeblack@google.com ccprintf(os, ", "); 7512295Sgabeblack@google.com printDestReg(os, 0); 7612295Sgabeblack@google.com return true; 7712295Sgabeblack@google.com } 7812295Sgabeblack@google.com } 7912295Sgabeblack@google.com return false; 8012295Sgabeblack@google.com} 8112295Sgabeblack@google.com 8212295Sgabeblack@google.comstd::string 8312295Sgabeblack@google.comIntOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const 8412295Sgabeblack@google.com{ 8512295Sgabeblack@google.com std::stringstream response; 8612295Sgabeblack@google.com 8712295Sgabeblack@google.com if (printPseudoOps(response, pc, symtab)) 8812295Sgabeblack@google.com return response.str(); 8912295Sgabeblack@google.com printMnemonic(response, mnemonic); 9012295Sgabeblack@google.com printRegArray(response, _srcRegIdx, _numSrcRegs); 9112295Sgabeblack@google.com if (_numDestRegs && _numSrcRegs) 9212295Sgabeblack@google.com response << ", "; 9312295Sgabeblack@google.com printDestReg(response, 0); 9412295Sgabeblack@google.com return response.str(); 9512295Sgabeblack@google.com} 9612295Sgabeblack@google.com 9712295Sgabeblack@google.comstd::string 9812295Sgabeblack@google.comIntOpImm::generateDisassembly(Addr pc, const SymbolTable *symtab) const 9912295Sgabeblack@google.com{ 10012295Sgabeblack@google.com std::stringstream response; 10112295Sgabeblack@google.com 10212295Sgabeblack@google.com if (printPseudoOps(response, pc, symtab)) 10312295Sgabeblack@google.com return response.str(); 10412295Sgabeblack@google.com printMnemonic(response, mnemonic); 10512295Sgabeblack@google.com printRegArray(response, _srcRegIdx, _numSrcRegs); 10612295Sgabeblack@google.com if (_numSrcRegs > 0) 10712295Sgabeblack@google.com response << ", "; 10812295Sgabeblack@google.com ccprintf(response, "%#x", imm); 10912295Sgabeblack@google.com if (_numDestRegs > 0) 11012295Sgabeblack@google.com response << ", "; 11112295Sgabeblack@google.com printDestReg(response, 0); 11212295Sgabeblack@google.com return response.str(); 11312295Sgabeblack@google.com} 11412295Sgabeblack@google.com 11512295Sgabeblack@google.comstd::string 11612295Sgabeblack@google.comSetHi::generateDisassembly(Addr pc, const SymbolTable *symtab) const 11712295Sgabeblack@google.com{ 11812295Sgabeblack@google.com std::stringstream response; 11912295Sgabeblack@google.com 12012295Sgabeblack@google.com printMnemonic(response, mnemonic); 12112295Sgabeblack@google.com ccprintf(response, "%%hi(%#x), ", imm); 12212295Sgabeblack@google.com printDestReg(response, 0); 12312295Sgabeblack@google.com return response.str(); 12412295Sgabeblack@google.com} 12512295Sgabeblack@google.com 12612295Sgabeblack@google.com} 127