microregop.hh revision 4713:c208cec7b5b3
12810SN/A/*
29614Srene.dejong@arm.com * Copyright (c) 2007 The Hewlett-Packard Development Company
38856Sandreas.hansson@arm.com * All rights reserved.
48856Sandreas.hansson@arm.com *
58856Sandreas.hansson@arm.com * Redistribution and use of this software in source and binary forms,
68856Sandreas.hansson@arm.com * with or without modification, are permitted provided that the
78856Sandreas.hansson@arm.com * following conditions are met:
88856Sandreas.hansson@arm.com *
98856Sandreas.hansson@arm.com * The software must be used only for Non-Commercial Use which means any
108856Sandreas.hansson@arm.com * use which is NOT directed to receiving any direct monetary
118856Sandreas.hansson@arm.com * compensation for, or commercial advantage from such use.  Illustrative
128856Sandreas.hansson@arm.com * examples of non-commercial use are academic research, personal study,
138856Sandreas.hansson@arm.com * teaching, education and corporate research & development.
142810SN/A * Illustrative examples of commercial use are distributing products for
152810SN/A * commercial advantage and providing services using the software for
162810SN/A * commercial advantage.
172810SN/A *
182810SN/A * If you wish to use this software or functionality therein that may be
192810SN/A * covered by patents for commercial use, please contact:
202810SN/A *     Director of Intellectual Property Licensing
212810SN/A *     Office of Strategy and Technology
222810SN/A *     Hewlett-Packard Company
232810SN/A *     1501 Page Mill Road
242810SN/A *     Palo Alto, California  94304
252810SN/A *
262810SN/A * Redistributions of source code must retain the above copyright notice,
272810SN/A * this list of conditions and the following disclaimer.  Redistributions
282810SN/A * in binary form must reproduce the above copyright notice, this list of
292810SN/A * conditions and the following disclaimer in the documentation and/or
302810SN/A * other materials provided with the distribution.  Neither the name of
312810SN/A * the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
322810SN/A * contributors may be used to endorse or promote products derived from
332810SN/A * this software without specific prior written permission.  No right of
342810SN/A * sublicense is granted herewith.  Derivatives of the software and
352810SN/A * output created using the software may be prepared, but only for
362810SN/A * Non-Commercial Uses.  Derivatives of the software may be shared with
372810SN/A * others provided: (i) the others agree to abide by the list of
382810SN/A * conditions herein which includes the Non-Commercial Use restrictions;
392810SN/A * and (ii) such Derivatives of the software include the above copyright
402810SN/A * notice to acknowledge the contribution from this software where
412810SN/A * applicable, this list of conditions and the disclaimer below.
422810SN/A *
432810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
442810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
452810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
462810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
472810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
488232Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
499152Satgutier@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
509795Sandreas.hansson@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
519795Sandreas.hansson@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5210263Satgutier@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
535338Sstever@gmail.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
549795Sandreas.hansson@arm.com *
555338Sstever@gmail.com * Authors: Gabe Black
568786Sgblack@eecs.umich.edu */
572810SN/A
582810SN/A#ifndef __ARCH_X86_INSTS_MICROREGOP_HH__
592810SN/A#define __ARCH_X86_INSTS_MICROREGOP_HH__
608856Sandreas.hansson@arm.com
618856Sandreas.hansson@arm.com#include "arch/x86/insts/microop.hh"
628856Sandreas.hansson@arm.com
638922Swilliam.wang@arm.comnamespace X86ISA
648914Sandreas.hansson@arm.com{
658856Sandreas.hansson@arm.com    namespace ConditionTests
668856Sandreas.hansson@arm.com    {
674475SN/A        enum CondTest {
685034SN/A            True,
695034SN/A            NotFalse = True,
7010360Sandreas.hansson@arm.com            ECF,
7110622Smitch.hayenga@arm.com            EZF,
7210622Smitch.hayenga@arm.com            SZnZF,
734628SN/A            MSTRZ,
749814Sandreas.hansson@arm.com            STRZ,
7510693SMarco.Balboni@ARM.com            MSTRC,
7610693SMarco.Balboni@ARM.com            STRZnZF,
7710693SMarco.Balboni@ARM.com            OF,
789263Smrinmoy.ghosh@arm.com            CF,
795034SN/A            ZF,
806122SSteve.Reinhardt@amd.com            CvZF,
818134SAli.Saidi@ARM.com            SF,
824626SN/A            PF,
8310360Sandreas.hansson@arm.com            SxOF,
844626SN/A            SxOvZF,
855034SN/A
868883SAli.Saidi@ARM.com            False,
878833Sdam.sunwoo@arm.com            NotTrue = False,
884458SN/A            NotECF,
892810SN/A            NotEZF,
902810SN/A            NotSZnZF,
913013SN/A            NotMSTRZ,
928856Sandreas.hansson@arm.com            NotSTRZ,
932810SN/A            NotMSTRC,
943013SN/A            NotSTRZnZF,
958856Sandreas.hansson@arm.com            NotOF,
962810SN/A            NotCF,
979614Srene.dejong@arm.com            NotZF,
989614Srene.dejong@arm.com            NotCvZF,
999614Srene.dejong@arm.com            NotSF,
10010345SCurtis.Dunham@arm.com            NotPF,
10110345SCurtis.Dunham@arm.com            NotSxOF,
10210345SCurtis.Dunham@arm.com            NotSxOvZF
1039614Srene.dejong@arm.com        };
1042810SN/A    }
1052810SN/A
1062810SN/A    /**
1078856Sandreas.hansson@arm.com     * Base classes for RegOps which provides a generateDisassembly method.
1082810SN/A     */
1093013SN/A    class RegOpBase : public X86MicroopBase
1108856Sandreas.hansson@arm.com    {
1113013SN/A      protected:
1128856Sandreas.hansson@arm.com        const RegIndex src1;
1134666SN/A        const RegIndex dest;
1148922Swilliam.wang@arm.com        const uint8_t dataSize;
1152897SN/A        const uint16_t ext;
1162810SN/A
1172810SN/A        // Constructor
11810344Sandreas.hansson@arm.com        RegOpBase(ExtMachInst _machInst,
11910344Sandreas.hansson@arm.com                const char *mnem, const char *_instMnem,
12010344Sandreas.hansson@arm.com                bool isMicro, bool isDelayed,
12110344Sandreas.hansson@arm.com                bool isFirst, bool isLast,
12210344Sandreas.hansson@arm.com                RegIndex _src1, RegIndex _dest,
12310344Sandreas.hansson@arm.com                uint8_t _dataSize, uint16_t _ext,
12410344Sandreas.hansson@arm.com                OpClass __opClass) :
12510713Sandreas.hansson@arm.com            X86MicroopBase(_machInst, mnem, _instMnem,
12610344Sandreas.hansson@arm.com                    isMicro, isDelayed, isFirst, isLast,
1272844SN/A                    __opClass),
1282810SN/A            src1(_src1), dest(_dest),
1292858SN/A            dataSize(_dataSize), ext(_ext)
1302858SN/A        {
1318856Sandreas.hansson@arm.com        }
1328922Swilliam.wang@arm.com
1338711Sandreas.hansson@arm.com        //Figure out what the condition code flags should be.
1342858SN/A        uint64_t genFlags(uint64_t oldFlags, uint64_t flagMask,
1352858SN/A                uint64_t _dest, uint64_t _src1, uint64_t _src2,
1369294Sandreas.hansson@arm.com                bool subtract = false) const;
1379294Sandreas.hansson@arm.com        bool checkCondition(uint64_t flags) const;
1388922Swilliam.wang@arm.com    };
1398922Swilliam.wang@arm.com
1408922Swilliam.wang@arm.com    class RegOp : public RegOpBase
1418922Swilliam.wang@arm.com    {
1428922Swilliam.wang@arm.com      protected:
1438922Swilliam.wang@arm.com        const RegIndex src2;
1448922Swilliam.wang@arm.com
1458922Swilliam.wang@arm.com        // Constructor
1469294Sandreas.hansson@arm.com        RegOp(ExtMachInst _machInst,
1479294Sandreas.hansson@arm.com                const char *mnem, const char *_instMnem,
1488922Swilliam.wang@arm.com                bool isMicro, bool isDelayed,
1498922Swilliam.wang@arm.com                bool isFirst, bool isLast,
1508922Swilliam.wang@arm.com                RegIndex _src1, RegIndex _src2, RegIndex _dest,
1518922Swilliam.wang@arm.com                uint8_t _dataSize, uint16_t _ext,
1528922Swilliam.wang@arm.com                OpClass __opClass) :
1538922Swilliam.wang@arm.com            RegOpBase(_machInst, mnem, _instMnem,
1548922Swilliam.wang@arm.com                    isMicro, isDelayed, isFirst, isLast,
1554628SN/A                    _src1, _dest, _dataSize, _ext,
1562858SN/A                    __opClass),
1572810SN/A            src2(_src2)
1582810SN/A        {
1592810SN/A        }
1602810SN/A
1612810SN/A        std::string generateDisassembly(Addr pc,
1624022SN/A            const SymbolTable *symtab) const;
1634022SN/A    };
1644022SN/A
1652810SN/A    class RegOpImm : public RegOpBase
1662810SN/A    {
1678833Sdam.sunwoo@arm.com      protected:
1682810SN/A        const uint8_t imm8;
1692810SN/A
1702810SN/A        // Constructor
1712810SN/A        RegOpImm(ExtMachInst _machInst,
1728833Sdam.sunwoo@arm.com                const char * mnem, const char *_instMnem,
1738833Sdam.sunwoo@arm.com                bool isMicro, bool isDelayed,
1748833Sdam.sunwoo@arm.com                bool isFirst, bool isLast,
1752810SN/A                RegIndex _src1, uint8_t _imm8, RegIndex _dest,
1762810SN/A                uint8_t _dataSize, uint16_t _ext,
1774871SN/A                OpClass __opClass) :
1784871SN/A            RegOpBase(_machInst, mnem, _instMnem,
1794871SN/A                    isMicro, isDelayed, isFirst, isLast,
1804871SN/A                    _src1, _dest, _dataSize, _ext,
1814871SN/A                    __opClass),
1824871SN/A            imm8(_imm8)
1834871SN/A        {
1844871SN/A        }
1854871SN/A
1864871SN/A        std::string generateDisassembly(Addr pc,
1872810SN/A            const SymbolTable *symtab) const;
1882810SN/A    };
1892810SN/A}
1908833Sdam.sunwoo@arm.com
1912810SN/A#endif //__ARCH_X86_INSTS_MICROREGOP_HH__
1924871SN/A