pred_inst.hh revision 7099
12SN/A/* Copyright (c) 2007-2008 The Florida State University
21762SN/A * All rights reserved.
32SN/A *
42SN/A * Redistribution and use in source and binary forms, with or without
52SN/A * modification, are permitted provided that the following conditions are
62SN/A * met: redistributions of source code must retain the above copyright
72SN/A * notice, this list of conditions and the following disclaimer;
82SN/A * redistributions in binary form must reproduce the above copyright
92SN/A * notice, this list of conditions and the following disclaimer in the
102SN/A * documentation and/or other materials provided with the distribution;
112SN/A * neither the name of the copyright holders nor the names of its
122SN/A * contributors may be used to endorse or promote products derived from
132SN/A * this software without specific prior written permission.
142SN/A *
152SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
162SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
192SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
202SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
212SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
252SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262SN/A *
272665Ssaidi@eecs.umich.edu * Authors: Stephen Hines
282665Ssaidi@eecs.umich.edu */
292665Ssaidi@eecs.umich.edu#ifndef __ARCH_ARM_INSTS_PREDINST_HH__
302665Ssaidi@eecs.umich.edu#define __ARCH_ARM_INSTS_PREDINST_HH__
312SN/A
322SN/A#include "arch/arm/insts/static_inst.hh"
332SN/A#include "base/trace.hh"
342SN/A
352521SN/Anamespace ArmISA
361110SN/A{
372521SN/Astatic inline uint32_t
381110SN/Arotate_imm(uint32_t immValue, int rotateValue)
392680Sktlim@umich.edu{
408232Snate@binkert.org    return ((immValue >> (rotateValue & 31)) |
418706Sandreas.hansson@arm.com            (immValue << (32 - (rotateValue & 31))));
422SN/A}
432SN/A
442SN/A/**
455568Snate@binkert.org * Base class for predicated integer operations.
465568Snate@binkert.org */
475568Snate@binkert.orgclass PredOp : public ArmStaticInst
488852Sandreas.hansson@arm.com{
492SN/A  protected:
501111SN/A
518852Sandreas.hansson@arm.com    ConditionCode condCode;
521111SN/A
532SN/A    /// Constructor
542SN/A    PredOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
552SN/A           ArmStaticInst(mnem, _machInst, __opClass),
562SN/A           condCode((ConditionCode)(unsigned)machInst.condCode)
571111SN/A    {
588852Sandreas.hansson@arm.com    }
591111SN/A};
602SN/A
612SN/A/**
622SN/A * Base class for predicated immediate operations.
632SN/A */
641111SN/Aclass PredImmOp : public PredOp
658852Sandreas.hansson@arm.com{
661111SN/A    protected:
671111SN/A
681111SN/A    uint32_t imm;
691111SN/A    uint32_t rotate;
701111SN/A    uint32_t rotated_imm;
712SN/A    uint32_t rotated_carry;
722SN/A
732SN/A    /// Constructor
745568Snate@binkert.org    PredImmOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
752SN/A              PredOp(mnem, _machInst, __opClass),
762SN/A              imm(machInst.imm), rotate(machInst.rotate << 1),
775568Snate@binkert.org              rotated_imm(0), rotated_carry(0)
782SN/A    {
795568Snate@binkert.org        rotated_imm = rotate_imm(imm, rotate);
805568Snate@binkert.org        if (rotate != 0)
812SN/A            rotated_carry = (rotated_imm >> 31) & 1;
822SN/A    }
832SN/A
842SN/A    std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
852SN/A};
862SN/A
872SN/A/**
882SN/A * Base class for predicated integer operations.
892SN/A */
905568Snate@binkert.orgclass PredIntOp : public PredOp
912SN/A{
925568Snate@binkert.org    protected:
935568Snate@binkert.org
942SN/A    uint32_t shift_size;
95924SN/A    uint32_t shift;
96924SN/A
975568Snate@binkert.org    /// Constructor
98924SN/A    PredIntOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
99924SN/A              PredOp(mnem, _machInst, __opClass),
1005568Snate@binkert.org              shift_size(machInst.shiftSize), shift(machInst.shift)
1015568Snate@binkert.org    {
102973SN/A    }
103973SN/A
104547SN/A    std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
1055568Snate@binkert.org};
1068706Sandreas.hansson@arm.com
1071111SN/A/**
1081111SN/A * Base class for predicated macro-operations.
109547SN/A */
110924SN/Aclass PredMacroOp : public PredOp
111924SN/A{
1122SN/A    protected:
1132SN/A
1142SN/A    uint32_t numMicroops;
1152SN/A    StaticInstPtr * microOps;
1162SN/A
1172SN/A    /// Constructor
1185568Snate@binkert.org    PredMacroOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
119                PredOp(mnem, _machInst, __opClass),
120                numMicroops(0)
121    {
122        // We rely on the subclasses of this object to handle the
123        // initialization of the micro-operations, since they are
124        // all of variable length
125        flags[IsMacroop] = true;
126    }
127
128    ~PredMacroOp()
129    {
130        if (numMicroops)
131            delete [] microOps;
132    }
133
134    StaticInstPtr
135    fetchMicroop(MicroPC microPC)
136    {
137        assert(microPC < numMicroops);
138        return microOps[microPC];
139    }
140
141    std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
142};
143
144/**
145 * Base class for predicated micro-operations.
146 */
147class PredMicroop : public PredOp
148{
149    /// Constructor
150    PredMicroop(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
151                PredOp(mnem, _machInst, __opClass)
152    {
153        flags[IsMicroop] = true;
154    }
155};
156}
157
158#endif //__ARCH_ARM_INSTS_PREDINST_HH__
159