micromediaop.hh revision 12104:edd63f9c6184
16498Snate@binkert.org/* 26498Snate@binkert.org * Copyright (c) 2009 The Regents of The University of Michigan 36498Snate@binkert.org * All rights reserved. 46498Snate@binkert.org * 56498Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66498Snate@binkert.org * modification, are permitted provided that the following conditions are 76498Snate@binkert.org * met: redistributions of source code must retain the above copyright 86498Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96498Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106498Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116498Snate@binkert.org * documentation and/or other materials provided with the distribution; 126498Snate@binkert.org * neither the name of the copyright holders nor the names of its 136498Snate@binkert.org * contributors may be used to endorse or promote products derived from 146498Snate@binkert.org * this software without specific prior written permission. 156498Snate@binkert.org * 166498Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176498Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186498Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196498Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206498Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216498Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226498Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236498Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246498Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256498Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266498Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276498Snate@binkert.org * 286498Snate@binkert.org * Authors: Gabe Black 296498Snate@binkert.org */ 306498Snate@binkert.org 316498Snate@binkert.org#ifndef __ARCH_X86_INSTS_MICROMEDIAOP_HH__ 326498Snate@binkert.org#define __ARCH_X86_INSTS_MICROMEDIAOP_HH__ 336498Snate@binkert.org 346498Snate@binkert.org#include "arch/x86/insts/microop.hh" 356498Snate@binkert.org 366498Snate@binkert.orgnamespace X86ISA 376498Snate@binkert.org{ 386498Snate@binkert.org enum MediaFlag { 396498Snate@binkert.org MediaMultHiOp = 1, 406498Snate@binkert.org MediaSignedOp = 64, 416498Snate@binkert.org MediaScalarOp = 128 426498Snate@binkert.org }; 436498Snate@binkert.org 446498Snate@binkert.org class MediaOpBase : public X86MicroopBase 456498Snate@binkert.org { 466498Snate@binkert.org protected: 476498Snate@binkert.org const RegIndex src1; 486498Snate@binkert.org const RegIndex dest; 496498Snate@binkert.org const uint8_t srcSize; 506498Snate@binkert.org const uint8_t destSize; 51 const uint8_t ext; 52 static const RegIndex foldOBit = 0; 53 54 // Constructor 55 MediaOpBase(ExtMachInst _machInst, 56 const char *mnem, const char *_instMnem, uint64_t setFlags, 57 InstRegIndex _src1, InstRegIndex _dest, 58 uint8_t _srcSize, uint8_t _destSize, uint8_t _ext, 59 OpClass __opClass) : 60 X86MicroopBase(_machInst, mnem, _instMnem, setFlags, 61 __opClass), 62 src1(_src1.regIdx), dest(_dest.regIdx), 63 srcSize(_srcSize), destSize(_destSize), ext(_ext) 64 {} 65 66 bool 67 scalarOp() const 68 { 69 return ext & MediaScalarOp; 70 } 71 72 int 73 numItems(int size) const 74 { 75 return scalarOp() ? 1 : (sizeof(FloatRegBits) / size); 76 } 77 78 bool 79 multHi() const 80 { 81 return ext & MediaMultHiOp; 82 } 83 84 bool 85 signedOp() const 86 { 87 return ext & MediaSignedOp; 88 } 89 }; 90 91 class MediaOpReg : public MediaOpBase 92 { 93 protected: 94 const RegIndex src2; 95 96 // Constructor 97 MediaOpReg(ExtMachInst _machInst, 98 const char *mnem, const char *_instMnem, uint64_t setFlags, 99 InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest, 100 uint8_t _srcSize, uint8_t _destSize, uint8_t _ext, 101 OpClass __opClass) : 102 MediaOpBase(_machInst, mnem, _instMnem, setFlags, 103 _src1, _dest, _srcSize, _destSize, _ext, 104 __opClass), 105 src2(_src2.regIdx) 106 {} 107 108 std::string generateDisassembly(Addr pc, 109 const SymbolTable *symtab) const; 110 }; 111 112 class MediaOpImm : public MediaOpBase 113 { 114 protected: 115 uint8_t imm8; 116 117 // Constructor 118 MediaOpImm(ExtMachInst _machInst, 119 const char *mnem, const char *_instMnem, uint64_t setFlags, 120 InstRegIndex _src1, uint8_t _imm8, InstRegIndex _dest, 121 uint8_t _srcSize, uint8_t _destSize, uint8_t _ext, 122 OpClass __opClass) : 123 MediaOpBase(_machInst, mnem, _instMnem, setFlags, 124 _src1, _dest, _srcSize, _destSize, _ext, 125 __opClass), 126 imm8(_imm8) 127 {} 128 129 std::string generateDisassembly(Addr pc, 130 const SymbolTable *symtab) const; 131 }; 132} 133 134#endif //__ARCH_X86_INSTS_MICROMEDIAOP_HH__ 135