14120Sgblack@eecs.umich.edu/*
24120Sgblack@eecs.umich.edu * Copyright (c) 2007 The Hewlett-Packard Development Company
34120Sgblack@eecs.umich.edu * All rights reserved.
44120Sgblack@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.
134120Sgblack@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
224120Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
237087Snate@binkert.org * this software without specific prior written permission.
244120Sgblack@eecs.umich.edu *
254120Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
264120Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
274120Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
284120Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
294120Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
304120Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
314120Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
324120Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
334120Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
344120Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
354120Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
364120Sgblack@eecs.umich.edu *
374120Sgblack@eecs.umich.edu * Authors: Gabe Black
384120Sgblack@eecs.umich.edu */
394120Sgblack@eecs.umich.edu
404120Sgblack@eecs.umich.edu#ifndef __ARCH_X86_TYPES_HH__
414120Sgblack@eecs.umich.edu#define __ARCH_X86_TYPES_HH__
424120Sgblack@eecs.umich.edu
434182Sgblack@eecs.umich.edu#include <iostream>
444147Sgblack@eecs.umich.edu
457720Sgblack@eecs.umich.edu#include "arch/generic/types.hh"
464680Sgblack@eecs.umich.edu#include "base/bitunion.hh"
474276Sgblack@eecs.umich.edu#include "base/cprintf.hh"
486215Snate@binkert.org#include "base/types.hh"
497624Sgblack@eecs.umich.edu#include "sim/serialize.hh"
504276Sgblack@eecs.umich.edu
514120Sgblack@eecs.umich.edunamespace X86ISA
524120Sgblack@eecs.umich.edu{
539023Sgblack@eecs.umich.edu    //This really determines how many bytes are passed to the decoder.
544181Sgblack@eecs.umich.edu    typedef uint64_t MachInst;
554182Sgblack@eecs.umich.edu
564182Sgblack@eecs.umich.edu    enum Prefixes {
574342Sgblack@eecs.umich.edu        NoOverride,
584863Sgblack@eecs.umich.edu        ESOverride,
594342Sgblack@eecs.umich.edu        CSOverride,
604863Sgblack@eecs.umich.edu        SSOverride,
614342Sgblack@eecs.umich.edu        DSOverride,
624342Sgblack@eecs.umich.edu        FSOverride,
634342Sgblack@eecs.umich.edu        GSOverride,
644342Sgblack@eecs.umich.edu        RexPrefix,
654342Sgblack@eecs.umich.edu        OperandSizeOverride,
664342Sgblack@eecs.umich.edu        AddressSizeOverride,
674342Sgblack@eecs.umich.edu        Lock,
684342Sgblack@eecs.umich.edu        Rep,
6910924Snilay@cs.wisc.edu        Repne,
7010924Snilay@cs.wisc.edu        Vex2Prefix,
7110924Snilay@cs.wisc.edu        Vex3Prefix,
7210924Snilay@cs.wisc.edu        XopPrefix,
734342Sgblack@eecs.umich.edu    };
744342Sgblack@eecs.umich.edu
754342Sgblack@eecs.umich.edu    BitUnion8(LegacyPrefixVector)
764717Sgblack@eecs.umich.edu        Bitfield<7, 4> decodeVal;
774342Sgblack@eecs.umich.edu        Bitfield<7> repne;
784342Sgblack@eecs.umich.edu        Bitfield<6> rep;
794342Sgblack@eecs.umich.edu        Bitfield<5> lock;
804717Sgblack@eecs.umich.edu        Bitfield<4> op;
814717Sgblack@eecs.umich.edu        Bitfield<3> addr;
824182Sgblack@eecs.umich.edu        //There can be only one segment override, so they share the
834182Sgblack@eecs.umich.edu        //first 3 bits in the legacyPrefixes bitfield.
844342Sgblack@eecs.umich.edu        Bitfield<2,0> seg;
854342Sgblack@eecs.umich.edu    EndBitUnion(LegacyPrefixVector)
864182Sgblack@eecs.umich.edu
874276Sgblack@eecs.umich.edu    BitUnion8(ModRM)
884276Sgblack@eecs.umich.edu        Bitfield<7,6> mod;
894276Sgblack@eecs.umich.edu        Bitfield<5,3> reg;
904276Sgblack@eecs.umich.edu        Bitfield<2,0> rm;
914276Sgblack@eecs.umich.edu    EndBitUnion(ModRM)
924276Sgblack@eecs.umich.edu
934276Sgblack@eecs.umich.edu    BitUnion8(Sib)
944276Sgblack@eecs.umich.edu        Bitfield<7,6> scale;
954276Sgblack@eecs.umich.edu        Bitfield<5,3> index;
964276Sgblack@eecs.umich.edu        Bitfield<2,0> base;
974276Sgblack@eecs.umich.edu    EndBitUnion(Sib)
984276Sgblack@eecs.umich.edu
994276Sgblack@eecs.umich.edu    BitUnion8(Rex)
1004803Sgblack@eecs.umich.edu        //This bit doesn't mean anything according to the ISA, but in
1014803Sgblack@eecs.umich.edu        //this implementation, it being set means an REX prefix was present.
1024803Sgblack@eecs.umich.edu        Bitfield<6> present;
1034276Sgblack@eecs.umich.edu        Bitfield<3> w;
1044276Sgblack@eecs.umich.edu        Bitfield<2> r;
1054276Sgblack@eecs.umich.edu        Bitfield<1> x;
1064276Sgblack@eecs.umich.edu        Bitfield<0> b;
1074276Sgblack@eecs.umich.edu    EndBitUnion(Rex)
1084276Sgblack@eecs.umich.edu
10912045Sgabeblack@google.com    BitUnion8(Vex2Of3)
11012045Sgabeblack@google.com        // Inverted bits from the REX prefix.
11112045Sgabeblack@google.com        Bitfield<7> r;
11212045Sgabeblack@google.com        Bitfield<6> x;
11312045Sgabeblack@google.com        Bitfield<5> b;
11412045Sgabeblack@google.com        // Selector for what would be two or three byte opcode types.
11512045Sgabeblack@google.com        Bitfield<4, 0> m;
11612045Sgabeblack@google.com    EndBitUnion(Vex2Of3)
11710924Snilay@cs.wisc.edu
11812045Sgabeblack@google.com    BitUnion8(Vex3Of3)
11912045Sgabeblack@google.com        // Bit from the REX prefix.
12012045Sgabeblack@google.com        Bitfield<7> w;
12112045Sgabeblack@google.com        // Inverted extra register index.
12212045Sgabeblack@google.com        Bitfield<6, 3>  v;
12312045Sgabeblack@google.com        // Vector length specifier.
12412045Sgabeblack@google.com        Bitfield<2> l;
12512045Sgabeblack@google.com        // Implied 66, F2, or F3 opcode prefix.
12612045Sgabeblack@google.com        Bitfield<1, 0> p;
12712045Sgabeblack@google.com    EndBitUnion(Vex3Of3)
12812045Sgabeblack@google.com
12912045Sgabeblack@google.com    BitUnion8(Vex2Of2)
13012045Sgabeblack@google.com        // Inverted bit from the REX prefix.
13112045Sgabeblack@google.com        Bitfield<7> r;
13212045Sgabeblack@google.com        // Inverted extra register index.
13312045Sgabeblack@google.com        Bitfield<6, 3>  v;
13412045Sgabeblack@google.com        // Vector length specifier
13512045Sgabeblack@google.com        Bitfield<2> l;
13612045Sgabeblack@google.com        // Implied 66, F2, or F3 opcode prefix.
13712045Sgabeblack@google.com        Bitfield<1, 0> p;
13812045Sgabeblack@google.com    EndBitUnion(Vex2Of2)
13912045Sgabeblack@google.com
14012045Sgabeblack@google.com    BitUnion8(VexInfo)
14112045Sgabeblack@google.com        // Extra register index.
14212045Sgabeblack@google.com        Bitfield<6, 3> v;
14312045Sgabeblack@google.com        // Vector length specifier.
14412045Sgabeblack@google.com        Bitfield<2> l;
14512045Sgabeblack@google.com        // Whether the VEX prefix was used.
14612045Sgabeblack@google.com        Bitfield<0> present;
14712045Sgabeblack@google.com    EndBitUnion(VexInfo)
14810924Snilay@cs.wisc.edu
14910593Sgabeblack@google.com    enum OpcodeType {
15010593Sgabeblack@google.com        BadOpcode,
15110593Sgabeblack@google.com        OneByteOpcode,
15210593Sgabeblack@google.com        TwoByteOpcode,
15310593Sgabeblack@google.com        ThreeByte0F38Opcode,
15410924Snilay@cs.wisc.edu        ThreeByte0F3AOpcode,
15510593Sgabeblack@google.com    };
15610593Sgabeblack@google.com
15710593Sgabeblack@google.com    static inline const char *
15810593Sgabeblack@google.com    opcodeTypeToStr(OpcodeType type)
15910593Sgabeblack@google.com    {
16010593Sgabeblack@google.com        switch (type) {
16110593Sgabeblack@google.com          case BadOpcode:
16210593Sgabeblack@google.com            return "bad";
16310593Sgabeblack@google.com          case OneByteOpcode:
16410593Sgabeblack@google.com            return "one byte";
16510593Sgabeblack@google.com          case TwoByteOpcode:
16610593Sgabeblack@google.com            return "two byte";
16710593Sgabeblack@google.com          case ThreeByte0F38Opcode:
16810593Sgabeblack@google.com            return "three byte 0f38";
16910593Sgabeblack@google.com          case ThreeByte0F3AOpcode:
17010593Sgabeblack@google.com            return "three byte 0f3a";
17110593Sgabeblack@google.com          default:
17210593Sgabeblack@google.com            return "unrecognized!";
17310593Sgabeblack@google.com        }
17410593Sgabeblack@google.com    }
17510593Sgabeblack@google.com
1764276Sgblack@eecs.umich.edu    BitUnion8(Opcode)
1774276Sgblack@eecs.umich.edu        Bitfield<7,3> top5;
1784276Sgblack@eecs.umich.edu        Bitfield<2,0> bottom3;
1794276Sgblack@eecs.umich.edu    EndBitUnion(Opcode)
1804276Sgblack@eecs.umich.edu
1814569Sgblack@eecs.umich.edu    BitUnion8(OperatingMode)
1824569Sgblack@eecs.umich.edu        Bitfield<3> mode;
1834569Sgblack@eecs.umich.edu        Bitfield<2,0> submode;
1844569Sgblack@eecs.umich.edu    EndBitUnion(OperatingMode)
1854569Sgblack@eecs.umich.edu
1864569Sgblack@eecs.umich.edu    enum X86Mode {
1874569Sgblack@eecs.umich.edu        LongMode,
1884569Sgblack@eecs.umich.edu        LegacyMode
1894569Sgblack@eecs.umich.edu    };
1904569Sgblack@eecs.umich.edu
1914569Sgblack@eecs.umich.edu    enum X86SubMode {
1924569Sgblack@eecs.umich.edu        SixtyFourBitMode,
1934569Sgblack@eecs.umich.edu        CompatabilityMode,
1944569Sgblack@eecs.umich.edu        ProtectedMode,
1954569Sgblack@eecs.umich.edu        Virtual8086Mode,
1964569Sgblack@eecs.umich.edu        RealMode
1974569Sgblack@eecs.umich.edu    };
1984569Sgblack@eecs.umich.edu
1999023Sgblack@eecs.umich.edu    //The intermediate structure used by the x86 decoder.
2004181Sgblack@eecs.umich.edu    struct ExtMachInst
2014181Sgblack@eecs.umich.edu    {
20212895Sjason@lowepower.com        void reset() {
20312895Sjason@lowepower.com            memset(static_cast<void *>(this), 0, sizeof(*this));
20412895Sjason@lowepower.com        }
20512895Sjason@lowepower.com
2064276Sgblack@eecs.umich.edu        //Prefixes
2074342Sgblack@eecs.umich.edu        LegacyPrefixVector legacy;
2084276Sgblack@eecs.umich.edu        Rex rex;
20912045Sgabeblack@google.com        VexInfo vex;
21010924Snilay@cs.wisc.edu
2114276Sgblack@eecs.umich.edu        //This holds all of the bytes of the opcode
2124276Sgblack@eecs.umich.edu        struct
2134276Sgblack@eecs.umich.edu        {
21410593Sgabeblack@google.com            OpcodeType type;
2154276Sgblack@eecs.umich.edu            //The main opcode byte. The highest addressed byte in the opcode.
2164276Sgblack@eecs.umich.edu            Opcode op;
2174276Sgblack@eecs.umich.edu        } opcode;
2184276Sgblack@eecs.umich.edu        //Modifier bytes
2194276Sgblack@eecs.umich.edu        ModRM modRM;
2204601Sgblack@eecs.umich.edu        Sib sib;
2214276Sgblack@eecs.umich.edu        //Immediate fields
2224182Sgblack@eecs.umich.edu        uint64_t immediate;
2234182Sgblack@eecs.umich.edu        uint64_t displacement;
2244342Sgblack@eecs.umich.edu
2254342Sgblack@eecs.umich.edu        //The effective operand size.
2264342Sgblack@eecs.umich.edu        uint8_t opSize;
2274541Sgblack@eecs.umich.edu        //The effective address size.
2284541Sgblack@eecs.umich.edu        uint8_t addrSize;
2294587Sgblack@eecs.umich.edu        //The effective stack size.
2304587Sgblack@eecs.umich.edu        uint8_t stackSize;
2316437Sgblack@eecs.umich.edu        //The size of the displacement
2326437Sgblack@eecs.umich.edu        uint8_t dispSize;
2334569Sgblack@eecs.umich.edu
2344569Sgblack@eecs.umich.edu        //Mode information
2354569Sgblack@eecs.umich.edu        OperatingMode mode;
2364181Sgblack@eecs.umich.edu    };
2374181Sgblack@eecs.umich.edu
2384182Sgblack@eecs.umich.edu    inline static std::ostream &
2394182Sgblack@eecs.umich.edu        operator << (std::ostream & os, const ExtMachInst & emi)
2404182Sgblack@eecs.umich.edu    {
2414276Sgblack@eecs.umich.edu        ccprintf(os, "\n{\n\tleg = %#x,\n\trex = %#x,\n\t"
24210924Snilay@cs.wisc.edu                     "vex/xop = %#x,\n\t"
24310593Sgabeblack@google.com                     "op = {\n\t\ttype = %s,\n\t\top = %#x,\n\t\t},\n\t"
2444276Sgblack@eecs.umich.edu                     "modRM = %#x,\n\tsib = %#x,\n\t"
2456437Sgblack@eecs.umich.edu                     "immediate = %#x,\n\tdisplacement = %#x\n\t"
2466437Sgblack@eecs.umich.edu                     "dispSize = %d}\n",
2474707Sgblack@eecs.umich.edu                     (uint8_t)emi.legacy, (uint8_t)emi.rex,
24812045Sgabeblack@google.com                     (uint8_t)emi.vex,
24910593Sgabeblack@google.com                     opcodeTypeToStr(emi.opcode.type), (uint8_t)emi.opcode.op,
2504276Sgblack@eecs.umich.edu                     (uint8_t)emi.modRM, (uint8_t)emi.sib,
2516437Sgblack@eecs.umich.edu                     emi.immediate, emi.displacement, emi.dispSize);
2524182Sgblack@eecs.umich.edu        return os;
2534182Sgblack@eecs.umich.edu    }
2544182Sgblack@eecs.umich.edu
2554182Sgblack@eecs.umich.edu    inline static bool
2564182Sgblack@eecs.umich.edu        operator == (const ExtMachInst &emi1, const ExtMachInst &emi2)
2574181Sgblack@eecs.umich.edu    {
25811321Ssteve.reinhardt@amd.com        if (emi1.legacy != emi2.legacy)
2594334Sgblack@eecs.umich.edu            return false;
26011321Ssteve.reinhardt@amd.com        if (emi1.rex != emi2.rex)
2614334Sgblack@eecs.umich.edu            return false;
26212045Sgabeblack@google.com        if (emi1.vex != emi2.vex)
26312045Sgabeblack@google.com            return false;
26411321Ssteve.reinhardt@amd.com        if (emi1.opcode.type != emi2.opcode.type)
2654334Sgblack@eecs.umich.edu            return false;
26611321Ssteve.reinhardt@amd.com        if (emi1.opcode.op != emi2.opcode.op)
2674334Sgblack@eecs.umich.edu            return false;
26811321Ssteve.reinhardt@amd.com        if (emi1.modRM != emi2.modRM)
2694334Sgblack@eecs.umich.edu            return false;
27011321Ssteve.reinhardt@amd.com        if (emi1.sib != emi2.sib)
2714334Sgblack@eecs.umich.edu            return false;
27211321Ssteve.reinhardt@amd.com        if (emi1.immediate != emi2.immediate)
2734334Sgblack@eecs.umich.edu            return false;
27411321Ssteve.reinhardt@amd.com        if (emi1.displacement != emi2.displacement)
2754334Sgblack@eecs.umich.edu            return false;
27611321Ssteve.reinhardt@amd.com        if (emi1.mode != emi2.mode)
2774587Sgblack@eecs.umich.edu            return false;
27811321Ssteve.reinhardt@amd.com        if (emi1.opSize != emi2.opSize)
2794587Sgblack@eecs.umich.edu            return false;
28011321Ssteve.reinhardt@amd.com        if (emi1.addrSize != emi2.addrSize)
2814587Sgblack@eecs.umich.edu            return false;
28211321Ssteve.reinhardt@amd.com        if (emi1.stackSize != emi2.stackSize)
2834587Sgblack@eecs.umich.edu            return false;
28411321Ssteve.reinhardt@amd.com        if (emi1.dispSize != emi2.dispSize)
2856437Sgblack@eecs.umich.edu            return false;
2864181Sgblack@eecs.umich.edu        return true;
2874181Sgblack@eecs.umich.edu    }
2884122Sgblack@eecs.umich.edu
2897964Sgblack@eecs.umich.edu    class PCState : public GenericISA::UPCState<MachInst>
2907964Sgblack@eecs.umich.edu    {
2917964Sgblack@eecs.umich.edu      protected:
2927964Sgblack@eecs.umich.edu        typedef GenericISA::UPCState<MachInst> Base;
2937964Sgblack@eecs.umich.edu
2947964Sgblack@eecs.umich.edu        uint8_t _size;
2957964Sgblack@eecs.umich.edu
2967964Sgblack@eecs.umich.edu      public:
2977964Sgblack@eecs.umich.edu        void
2987964Sgblack@eecs.umich.edu        set(Addr val)
2997964Sgblack@eecs.umich.edu        {
3007964Sgblack@eecs.umich.edu            Base::set(val);
3017964Sgblack@eecs.umich.edu            _size = 0;
3027964Sgblack@eecs.umich.edu        }
3037964Sgblack@eecs.umich.edu
3047964Sgblack@eecs.umich.edu        PCState() {}
3057964Sgblack@eecs.umich.edu        PCState(Addr val) { set(val); }
3067964Sgblack@eecs.umich.edu
30711886Sbrandon.potter@amd.com        void
30811886Sbrandon.potter@amd.com        setNPC(Addr val)
30911886Sbrandon.potter@amd.com        {
31011886Sbrandon.potter@amd.com            Base::setNPC(val);
31111886Sbrandon.potter@amd.com            _size = 0;
31211886Sbrandon.potter@amd.com        }
31311886Sbrandon.potter@amd.com
3147964Sgblack@eecs.umich.edu        uint8_t size() const { return _size; }
3157964Sgblack@eecs.umich.edu        void size(uint8_t newSize) { _size = newSize; }
3167964Sgblack@eecs.umich.edu
3177971Sgblack@eecs.umich.edu        bool
3187971Sgblack@eecs.umich.edu        branching() const
3197971Sgblack@eecs.umich.edu        {
32011975Ssanti.galan@metempsy.com            return (this->npc() != this->pc() + size()) ||
32111975Ssanti.galan@metempsy.com                   (this->nupc() != this->upc() + 1);
3227971Sgblack@eecs.umich.edu        }
3237971Sgblack@eecs.umich.edu
3247964Sgblack@eecs.umich.edu        void
3257964Sgblack@eecs.umich.edu        advance()
3267964Sgblack@eecs.umich.edu        {
3277964Sgblack@eecs.umich.edu            Base::advance();
3287964Sgblack@eecs.umich.edu            _size = 0;
3297964Sgblack@eecs.umich.edu        }
3307964Sgblack@eecs.umich.edu
3317964Sgblack@eecs.umich.edu        void
3327964Sgblack@eecs.umich.edu        uEnd()
3337964Sgblack@eecs.umich.edu        {
3347964Sgblack@eecs.umich.edu            Base::uEnd();
3357964Sgblack@eecs.umich.edu            _size = 0;
3367964Sgblack@eecs.umich.edu        }
3377964Sgblack@eecs.umich.edu
3387964Sgblack@eecs.umich.edu        void
33910905Sandreas.sandberg@arm.com        serialize(CheckpointOut &cp) const
3407964Sgblack@eecs.umich.edu        {
34110905Sandreas.sandberg@arm.com            Base::serialize(cp);
3427964Sgblack@eecs.umich.edu            SERIALIZE_SCALAR(_size);
3437964Sgblack@eecs.umich.edu        }
3447964Sgblack@eecs.umich.edu
3457964Sgblack@eecs.umich.edu        void
34610905Sandreas.sandberg@arm.com        unserialize(CheckpointIn &cp)
3477964Sgblack@eecs.umich.edu        {
34810905Sandreas.sandberg@arm.com            Base::unserialize(cp);
3497964Sgblack@eecs.umich.edu            UNSERIALIZE_SCALAR(_size);
3507964Sgblack@eecs.umich.edu        }
3517964Sgblack@eecs.umich.edu    };
3527720Sgblack@eecs.umich.edu
3538902Sandreas.hansson@arm.com}
3544120Sgblack@eecs.umich.edu
35511168Sandreas.hansson@arm.comnamespace std {
3567680Sgblack@eecs.umich.edu    template<>
3577680Sgblack@eecs.umich.edu    struct hash<X86ISA::ExtMachInst> {
3587680Sgblack@eecs.umich.edu        size_t operator()(const X86ISA::ExtMachInst &emi) const {
35912045Sgabeblack@google.com            return (((uint64_t)emi.legacy << 48) |
36012045Sgabeblack@google.com                    ((uint64_t)emi.rex << 40) |
36112045Sgabeblack@google.com                    ((uint64_t)emi.vex << 32) |
36210593Sgabeblack@google.com                    ((uint64_t)emi.modRM << 24) |
36310593Sgabeblack@google.com                    ((uint64_t)emi.sib << 16) |
36410593Sgabeblack@google.com                    ((uint64_t)emi.opcode.type << 8) |
3657680Sgblack@eecs.umich.edu                    ((uint64_t)emi.opcode.op)) ^
3667680Sgblack@eecs.umich.edu                    emi.immediate ^ emi.displacement ^
3677680Sgblack@eecs.umich.edu                    emi.mode ^
3687680Sgblack@eecs.umich.edu                    emi.opSize ^ emi.addrSize ^
3697680Sgblack@eecs.umich.edu                    emi.stackSize ^ emi.dispSize;
3707680Sgblack@eecs.umich.edu        };
3717680Sgblack@eecs.umich.edu    };
37211168Sandreas.hansson@arm.com}
3737680Sgblack@eecs.umich.edu
3747624Sgblack@eecs.umich.edu// These two functions allow ExtMachInst to be used with SERIALIZE_SCALAR
3757624Sgblack@eecs.umich.edu// and UNSERIALIZE_SCALAR.
3767624Sgblack@eecs.umich.edutemplate <>
3777624Sgblack@eecs.umich.eduvoid
37810905Sandreas.sandberg@arm.comparamOut(CheckpointOut &cp, const std::string &name,
3797624Sgblack@eecs.umich.edu         const X86ISA::ExtMachInst &machInst);
3807624Sgblack@eecs.umich.edutemplate <>
3817624Sgblack@eecs.umich.eduvoid
38210905Sandreas.sandberg@arm.comparamIn(CheckpointIn &cp, const std::string &name,
38310905Sandreas.sandberg@arm.com        X86ISA::ExtMachInst &machInst);
3847624Sgblack@eecs.umich.edu
3854120Sgblack@eecs.umich.edu#endif // __ARCH_X86_TYPES_HH__
386