14679Sgblack@eecs.umich.edu/* 24679Sgblack@eecs.umich.edu * Copyright (c) 2007 The Hewlett-Packard Development Company 34679Sgblack@eecs.umich.edu * All rights reserved. 44679Sgblack@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. 134679Sgblack@eecs.umich.edu * 147087Snate@binkert.org * Redistribution and use in source and binary forms, with or without 157087Snate@binkert.org * modification, are permitted provided that the following conditions are 167087Snate@binkert.org * met: redistributions of source code must retain the above copyright 177087Snate@binkert.org * notice, this list of conditions and the following disclaimer; 187087Snate@binkert.org * redistributions in binary form must reproduce the above copyright 197087Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 207087Snate@binkert.org * documentation and/or other materials provided with the distribution; 217087Snate@binkert.org * neither the name of the copyright holders nor the names of its 224679Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 237087Snate@binkert.org * this software without specific prior written permission. 244679Sgblack@eecs.umich.edu * 254679Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 264679Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 274679Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 284679Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 294679Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 304679Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 314679Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 324679Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 334679Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 344679Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 354679Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 364679Sgblack@eecs.umich.edu * 374679Sgblack@eecs.umich.edu * Authors: Gabe Black 384679Sgblack@eecs.umich.edu */ 394679Sgblack@eecs.umich.edu 404679Sgblack@eecs.umich.edu#ifndef __ARCH_X86_INSTS_MICROOP_HH__ 414679Sgblack@eecs.umich.edu#define __ARCH_X86_INSTS_MICROOP_HH__ 424679Sgblack@eecs.umich.edu 434679Sgblack@eecs.umich.edu#include "arch/x86/insts/static_inst.hh" 444679Sgblack@eecs.umich.edu 454679Sgblack@eecs.umich.edunamespace X86ISA 464679Sgblack@eecs.umich.edu{ 475083Sgblack@eecs.umich.edu namespace ConditionTests 485083Sgblack@eecs.umich.edu { 495083Sgblack@eecs.umich.edu enum CondTest { 505083Sgblack@eecs.umich.edu True, 515083Sgblack@eecs.umich.edu NotFalse = True, 525083Sgblack@eecs.umich.edu ECF, 535083Sgblack@eecs.umich.edu EZF, 545083Sgblack@eecs.umich.edu SZnZF, 555083Sgblack@eecs.umich.edu MSTRZ, 565083Sgblack@eecs.umich.edu STRZ, 575083Sgblack@eecs.umich.edu MSTRC, 585083Sgblack@eecs.umich.edu STRZnEZF, 595083Sgblack@eecs.umich.edu OF, 605083Sgblack@eecs.umich.edu CF, 615083Sgblack@eecs.umich.edu ZF, 625083Sgblack@eecs.umich.edu CvZF, 635083Sgblack@eecs.umich.edu SF, 645083Sgblack@eecs.umich.edu PF, 655083Sgblack@eecs.umich.edu SxOF, 665083Sgblack@eecs.umich.edu SxOvZF, 675083Sgblack@eecs.umich.edu 685083Sgblack@eecs.umich.edu False, 695083Sgblack@eecs.umich.edu NotTrue = False, 705083Sgblack@eecs.umich.edu NotECF, 715083Sgblack@eecs.umich.edu NotEZF, 725083Sgblack@eecs.umich.edu NotSZnZF, 735083Sgblack@eecs.umich.edu NotMSTRZ, 745083Sgblack@eecs.umich.edu NotSTRZ, 755083Sgblack@eecs.umich.edu NotMSTRC, 765083Sgblack@eecs.umich.edu STRnZnEZF, 775083Sgblack@eecs.umich.edu NotOF, 785083Sgblack@eecs.umich.edu NotCF, 795083Sgblack@eecs.umich.edu NotZF, 805083Sgblack@eecs.umich.edu NotCvZF, 815083Sgblack@eecs.umich.edu NotSF, 825083Sgblack@eecs.umich.edu NotPF, 835083Sgblack@eecs.umich.edu NotSxOF, 845083Sgblack@eecs.umich.edu NotSxOvZF 855083Sgblack@eecs.umich.edu }; 865083Sgblack@eecs.umich.edu } 875083Sgblack@eecs.umich.edu 884679Sgblack@eecs.umich.edu //A class which is the base of all x86 micro ops. It provides a function to 894679Sgblack@eecs.umich.edu //set necessary flags appropriately. 904679Sgblack@eecs.umich.edu class X86MicroopBase : public X86StaticInst 914679Sgblack@eecs.umich.edu { 924679Sgblack@eecs.umich.edu protected: 934679Sgblack@eecs.umich.edu const char * instMnem; 944679Sgblack@eecs.umich.edu uint8_t opSize; 954679Sgblack@eecs.umich.edu uint8_t addrSize; 964679Sgblack@eecs.umich.edu 974679Sgblack@eecs.umich.edu X86MicroopBase(ExtMachInst _machInst, 984679Sgblack@eecs.umich.edu const char *mnem, const char *_instMnem, 997620Sgblack@eecs.umich.edu uint64_t setFlags, OpClass __opClass) : 1004679Sgblack@eecs.umich.edu X86ISA::X86StaticInst(mnem, _machInst, __opClass), 1014679Sgblack@eecs.umich.edu instMnem(_instMnem) 1024679Sgblack@eecs.umich.edu { 1038536Sgblack@eecs.umich.edu const int ChunkSize = sizeof(unsigned long); 1048536Sgblack@eecs.umich.edu const int Chunks = sizeof(setFlags) / ChunkSize; 1058536Sgblack@eecs.umich.edu 1068536Sgblack@eecs.umich.edu // Since the bitset constructor can only handle unsigned long 1078536Sgblack@eecs.umich.edu // sized chunks, feed it those one at a time while oring them in. 1088536Sgblack@eecs.umich.edu for (int i = 0; i < Chunks; i++) { 1098536Sgblack@eecs.umich.edu unsigned shift = i * ChunkSize * 8; 11010201SAndrew.Bardsley@arm.com flags |= (std::bitset<Num_Flags>(setFlags >> shift) << shift); 1118536Sgblack@eecs.umich.edu } 1124679Sgblack@eecs.umich.edu } 1134679Sgblack@eecs.umich.edu 1144679Sgblack@eecs.umich.edu std::string generateDisassembly(Addr pc, 1154679Sgblack@eecs.umich.edu const SymbolTable *symtab) const 1164679Sgblack@eecs.umich.edu { 1174679Sgblack@eecs.umich.edu std::stringstream ss; 1184679Sgblack@eecs.umich.edu 1194679Sgblack@eecs.umich.edu ccprintf(ss, "\t%s.%s", instMnem, mnemonic); 1204679Sgblack@eecs.umich.edu 1214679Sgblack@eecs.umich.edu return ss.str(); 1224679Sgblack@eecs.umich.edu } 1235083Sgblack@eecs.umich.edu 1245083Sgblack@eecs.umich.edu bool checkCondition(uint64_t flags, int condition) const; 1257720Sgblack@eecs.umich.edu 1267720Sgblack@eecs.umich.edu void 1277720Sgblack@eecs.umich.edu advancePC(PCState &pcState) const 1287720Sgblack@eecs.umich.edu { 1297720Sgblack@eecs.umich.edu if (flags[IsLastMicroop]) 1307720Sgblack@eecs.umich.edu pcState.uEnd(); 1317720Sgblack@eecs.umich.edu else 1327720Sgblack@eecs.umich.edu pcState.uAdvance(); 1337720Sgblack@eecs.umich.edu } 1344679Sgblack@eecs.umich.edu }; 1354679Sgblack@eecs.umich.edu} 1364679Sgblack@eecs.umich.edu 1374679Sgblack@eecs.umich.edu#endif //__ARCH_X86_INSTS_MICROOP_HH__ 138