static_inst.cc revision 10934:5af8f40d8f2c
110719SMarco.Balboni@ARM.com/*
29036SN/A * Copyright (c) 2009 The University of Edinburgh
39036SN/A * Copyright (c) 2013 Advanced Micro Devices, Inc.
49036SN/A * All rights reserved.
59036SN/A *
69036SN/A * Redistribution and use in source and binary forms, with or without
79036SN/A * modification, are permitted provided that the following conditions are
89036SN/A * met: redistributions of source code must retain the above copyright
99036SN/A * notice, this list of conditions and the following disclaimer;
109036SN/A * redistributions in binary form must reproduce the above copyright
119036SN/A * notice, this list of conditions and the following disclaimer in the
129036SN/A * documentation and/or other materials provided with the distribution;
135354SN/A * neither the name of the copyright holders nor the names of its
144486SN/A * contributors may be used to endorse or promote products derived from
154486SN/A * this software without specific prior written permission.
164486SN/A *
174486SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184486SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194486SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204486SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214486SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224486SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234486SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244486SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254486SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264486SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274486SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284486SN/A *
294486SN/A * Authors: Timothy M. Jones
304486SN/A */
314486SN/A
324486SN/A#include "arch/power/insts/static_inst.hh"
334486SN/A#include "cpu/reg_class.hh"
344486SN/A
354486SN/Ausing namespace PowerISA;
364486SN/A
374486SN/Avoid
384486SN/APowerStaticInst::printReg(std::ostream &os, int reg) const
394486SN/A{
409036SN/A    RegIndex rel_reg;
414486SN/A
429036SN/A    switch (regIdxToClass(reg, &rel_reg)) {
439524SN/A      case IntRegClass:
443102SN/A        ccprintf(os, "r%d", rel_reg);
459524SN/A        break;
4610399SN/A      case FloatRegClass:
474486SN/A        ccprintf(os, "f%d", rel_reg);
4810405Sandreas.hansson@arm.com        break;
4910405Sandreas.hansson@arm.com      case MiscRegClass:
509036SN/A        switch (rel_reg) {
5110405Sandreas.hansson@arm.com          case 0: ccprintf(os, "cr"); break;
5210719SMarco.Balboni@ARM.com          case 1: ccprintf(os, "xer"); break;
5310719SMarco.Balboni@ARM.com          case 2: ccprintf(os, "lr"); break;
5410719SMarco.Balboni@ARM.com          case 3: ccprintf(os, "ctr"); break;
5510719SMarco.Balboni@ARM.com          default: ccprintf(os, "unknown_reg");
5610719SMarco.Balboni@ARM.com            break;
5710719SMarco.Balboni@ARM.com        }
5810719SMarco.Balboni@ARM.com      case CCRegClass:
5910719SMarco.Balboni@ARM.com        panic("printReg: POWER does not implement CCRegClass\n");
6010719SMarco.Balboni@ARM.com      case VectorRegClass:
6110719SMarco.Balboni@ARM.com        panic("printReg: POWER does not implement VectorRegClass\n");
6210719SMarco.Balboni@ARM.com    }
6310719SMarco.Balboni@ARM.com}
6410719SMarco.Balboni@ARM.com
6510719SMarco.Balboni@ARM.comstd::string
6610719SMarco.Balboni@ARM.comPowerStaticInst::generateDisassembly(Addr pc,
6710719SMarco.Balboni@ARM.com                                       const SymbolTable *symtab) const
6810719SMarco.Balboni@ARM.com{
6910720Sandreas.hansson@arm.com    std::stringstream ss;
7010720Sandreas.hansson@arm.com
7110720Sandreas.hansson@arm.com    ccprintf(ss, "%-10s ", mnemonic);
7210719SMarco.Balboni@ARM.com
7310719SMarco.Balboni@ARM.com    return ss.str();
7410720Sandreas.hansson@arm.com}
759036SN/A