pred_inst.cc revision 7142
15450Sgblack@eecs.umich.edu/*
25450Sgblack@eecs.umich.edu * Copyright (c) 2010 ARM Limited
35450Sgblack@eecs.umich.edu * All rights reserved
45450Sgblack@eecs.umich.edu *
57087Snate@binkert.org * The license below extends only to copyright in the software and shall
67087Snate@binkert.org * not be construed as granting a license to any other intellectual
77087Snate@binkert.org * property including but not limited to intellectual property relating
87087Snate@binkert.org * to a hardware implementation of the functionality of the software
97087Snate@binkert.org * licensed hereunder.  You may use the software subject to the license
107087Snate@binkert.org * terms below provided that you ensure that this notice is replicated
117087Snate@binkert.org * unmodified and in its entirety in all distributions of the software,
127087Snate@binkert.org * modified or unmodified, in source code or in binary form.
135450Sgblack@eecs.umich.edu *
147087Snate@binkert.org * Copyright (c) 2007-2008 The Florida State University
157087Snate@binkert.org * All rights reserved.
167087Snate@binkert.org *
177087Snate@binkert.org * Redistribution and use in source and binary forms, with or without
187087Snate@binkert.org * modification, are permitted provided that the following conditions are
197087Snate@binkert.org * met: redistributions of source code must retain the above copyright
207087Snate@binkert.org * notice, this list of conditions and the following disclaimer;
217087Snate@binkert.org * redistributions in binary form must reproduce the above copyright
225450Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
237087Snate@binkert.org * documentation and/or other materials provided with the distribution;
245450Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
255450Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
265450Sgblack@eecs.umich.edu * this software without specific prior written permission.
275450Sgblack@eecs.umich.edu *
285450Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
295450Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
305450Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
315450Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
325450Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
335450Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
345450Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
355450Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
365450Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
375450Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
385450Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
395450Sgblack@eecs.umich.edu *
405450Sgblack@eecs.umich.edu * Authors: Stephen Hines
4111793Sbrandon.potter@amd.com */
425450Sgblack@eecs.umich.edu
438852Sandreas.hansson@arm.com#include "arch/arm/insts/pred_inst.hh"
445450Sgblack@eecs.umich.edu
455450Sgblack@eecs.umich.edunamespace ArmISA
465450Sgblack@eecs.umich.edu{
475450Sgblack@eecs.umich.edustd::string
485450Sgblack@eecs.umich.eduPredIntOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
495450Sgblack@eecs.umich.edu{
508852Sandreas.hansson@arm.com    std::stringstream ss;
515450Sgblack@eecs.umich.edu    unsigned rotate = machInst.rotate * 2;
525450Sgblack@eecs.umich.edu    uint32_t imm = machInst.imm;
538852Sandreas.hansson@arm.com    imm = (imm << (32 - rotate)) | (imm >> rotate);
545450Sgblack@eecs.umich.edu    printDataInst(ss, false, machInst.opcode4 == 0, machInst.sField,
555450Sgblack@eecs.umich.edu            (IntRegIndex)(uint32_t)machInst.rd,
565450Sgblack@eecs.umich.edu            (IntRegIndex)(uint32_t)machInst.rn,
578852Sandreas.hansson@arm.com            (IntRegIndex)(uint32_t)machInst.rm,
585450Sgblack@eecs.umich.edu            (IntRegIndex)(uint32_t)machInst.rs,
595450Sgblack@eecs.umich.edu            machInst.shiftSize, (ArmShiftType)(uint32_t)machInst.shift,
605450Sgblack@eecs.umich.edu            imm);
615450Sgblack@eecs.umich.edu    return ss.str();
625450Sgblack@eecs.umich.edu}
635450Sgblack@eecs.umich.edu
645450Sgblack@eecs.umich.edustd::string
655450Sgblack@eecs.umich.eduPredImmOpBase::generateDisassembly(Addr pc, const SymbolTable *symtab) const
665450Sgblack@eecs.umich.edu{
678852Sandreas.hansson@arm.com    std::stringstream ss;
685450Sgblack@eecs.umich.edu    unsigned rotate = machInst.rotate * 2;
695450Sgblack@eecs.umich.edu    uint32_t imm = machInst.imm;
708852Sandreas.hansson@arm.com    imm = (imm << (32 - rotate)) | (imm >> rotate);
718852Sandreas.hansson@arm.com    printDataInst(ss, true, machInst.opcode4 == 0, machInst.sField,
728852Sandreas.hansson@arm.com            (IntRegIndex)(uint32_t)machInst.rd,
735450Sgblack@eecs.umich.edu            (IntRegIndex)(uint32_t)machInst.rn,
745450Sgblack@eecs.umich.edu            (IntRegIndex)(uint32_t)machInst.rm,
755450Sgblack@eecs.umich.edu            (IntRegIndex)(uint32_t)machInst.rs,
765450Sgblack@eecs.umich.edu            machInst.shiftSize, (ArmShiftType)(uint32_t)machInst.shift,
775450Sgblack@eecs.umich.edu            imm);
785450Sgblack@eecs.umich.edu    return ss.str();
795450Sgblack@eecs.umich.edu}
805450Sgblack@eecs.umich.edu
815450Sgblack@eecs.umich.edustd::string
825450Sgblack@eecs.umich.eduDataImmOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
835450Sgblack@eecs.umich.edu{
845450Sgblack@eecs.umich.edu    std::stringstream ss;
855450Sgblack@eecs.umich.edu    printDataInst(ss, true, false, /*XXX not really s*/ false, dest, op1,
865450Sgblack@eecs.umich.edu                  INTREG_ZERO, INTREG_ZERO, 0, LSL, imm);
87    return ss.str();
88}
89
90std::string
91DataRegOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
92{
93    std::stringstream ss;
94    printDataInst(ss, false, true, /*XXX not really s*/ false, dest, op1,
95                  op2, INTREG_ZERO, shiftAmt, shiftType, 0);
96    return ss.str();
97}
98
99std::string
100DataRegRegOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
101{
102    std::stringstream ss;
103    printDataInst(ss, false, false, /*XXX not really s*/ false, dest, op1,
104                  op2, shift, 0, shiftType, 0);
105    return ss.str();
106}
107
108std::string
109PredMacroOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
110{
111    std::stringstream ss;
112
113    ccprintf(ss, "%-10s ", mnemonic);
114
115    return ss.str();
116}
117}
118