112294Sgabeblack@google.com/*
212294Sgabeblack@google.com * Copyright (c) 2006-2007 The Regents of The University of Michigan
312294Sgabeblack@google.com * All rights reserved.
412294Sgabeblack@google.com *
512294Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
612294Sgabeblack@google.com * modification, are permitted provided that the following conditions are
712294Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
812294Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
912294Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1012294Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1112294Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1212294Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1312294Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1412294Sgabeblack@google.com * this software without specific prior written permission.
1512294Sgabeblack@google.com *
1612294Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712294Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812294Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912294Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012294Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112294Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212294Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312294Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412294Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512294Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612294Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712294Sgabeblack@google.com *
2812294Sgabeblack@google.com * Authors: Ali Saidi
2912294Sgabeblack@google.com *          Gabe Black
3012294Sgabeblack@google.com *          Steve Reinhardt
3112294Sgabeblack@google.com */
3212294Sgabeblack@google.com
3312294Sgabeblack@google.com#include "arch/sparc/insts/mem.hh"
3412294Sgabeblack@google.com
3512294Sgabeblack@google.comnamespace SparcISA
3612294Sgabeblack@google.com{
3712294Sgabeblack@google.com
3812294Sgabeblack@google.comstd::string
3912294Sgabeblack@google.comMem::generateDisassembly(Addr pc, const SymbolTable *symtab) const
4012294Sgabeblack@google.com{
4112294Sgabeblack@google.com    std::stringstream response;
4212294Sgabeblack@google.com    bool load = flags[IsLoad];
4312294Sgabeblack@google.com    bool store = flags[IsStore];
4412294Sgabeblack@google.com
4512294Sgabeblack@google.com    printMnemonic(response, mnemonic);
4612294Sgabeblack@google.com    if (store) {
4712294Sgabeblack@google.com        printReg(response, _srcRegIdx[0]);
4812294Sgabeblack@google.com        ccprintf(response, ", ");
4912294Sgabeblack@google.com    }
5012294Sgabeblack@google.com    ccprintf(response, "[");
5112294Sgabeblack@google.com    if (_srcRegIdx[!store ? 0 : 1].index() != 0) {
5212294Sgabeblack@google.com        printSrcReg(response, !store ? 0 : 1);
5312294Sgabeblack@google.com        ccprintf(response, " + ");
5412294Sgabeblack@google.com    }
5512294Sgabeblack@google.com    printSrcReg(response, !store ? 1 : 2);
5612294Sgabeblack@google.com    ccprintf(response, "]");
5712294Sgabeblack@google.com    if (load) {
5812294Sgabeblack@google.com        ccprintf(response, ", ");
5912294Sgabeblack@google.com        printReg(response, _destRegIdx[0]);
6012294Sgabeblack@google.com    }
6112294Sgabeblack@google.com
6212294Sgabeblack@google.com    return response.str();
6312294Sgabeblack@google.com}
6412294Sgabeblack@google.com
6512294Sgabeblack@google.comstd::string
6612294Sgabeblack@google.comMemImm::generateDisassembly(Addr pc, const SymbolTable *symtab) const
6712294Sgabeblack@google.com{
6812294Sgabeblack@google.com    std::stringstream response;
6912294Sgabeblack@google.com    bool load = flags[IsLoad];
7012294Sgabeblack@google.com    bool save = flags[IsStore];
7112294Sgabeblack@google.com
7212294Sgabeblack@google.com    printMnemonic(response, mnemonic);
7312294Sgabeblack@google.com    if (save) {
7412294Sgabeblack@google.com        printReg(response, _srcRegIdx[0]);
7512294Sgabeblack@google.com        ccprintf(response, ", ");
7612294Sgabeblack@google.com    }
7712294Sgabeblack@google.com    ccprintf(response, "[");
7812294Sgabeblack@google.com    if (_srcRegIdx[!save ? 0 : 1].index() != 0) {
7912294Sgabeblack@google.com        printReg(response, _srcRegIdx[!save ? 0 : 1]);
8012294Sgabeblack@google.com        ccprintf(response, " + ");
8112294Sgabeblack@google.com    }
8212294Sgabeblack@google.com    if (imm >= 0)
8312294Sgabeblack@google.com        ccprintf(response, "%#x]", imm);
8412294Sgabeblack@google.com    else
8512294Sgabeblack@google.com        ccprintf(response, "-%#x]", -imm);
8612294Sgabeblack@google.com    if (load) {
8712294Sgabeblack@google.com        ccprintf(response, ", ");
8812294Sgabeblack@google.com        printReg(response, _destRegIdx[0]);
8912294Sgabeblack@google.com    }
9012294Sgabeblack@google.com
9112294Sgabeblack@google.com    return response.str();
9212294Sgabeblack@google.com}
9312294Sgabeblack@google.com
9412294Sgabeblack@google.com}
95