types.cc revision 4182
12207SN/A/*
22207SN/A * Copyright (c) 2007 The Hewlett-Packard Development Company
32207SN/A * All rights reserved.
42207SN/A *
52207SN/A * Redistribution and use of this software in source and binary forms,
62207SN/A * with or without modification, are permitted provided that the
72207SN/A * following conditions are met:
82207SN/A *
92207SN/A * The software must be used only for Non-Commercial Use which means any
102207SN/A * use which is NOT directed to receiving any direct monetary
112207SN/A * compensation for, or commercial advantage from such use.  Illustrative
122207SN/A * examples of non-commercial use are academic research, personal study,
132207SN/A * teaching, education and corporate research & development.
142207SN/A * Illustrative examples of commercial use are distributing products for
152207SN/A * commercial advantage and providing services using the software for
162207SN/A * commercial advantage.
172207SN/A *
182207SN/A * If you wish to use this software or functionality therein that may be
192207SN/A * covered by patents for commercial use, please contact:
202207SN/A *     Director of Intellectual Property Licensing
212207SN/A *     Office of Strategy and Technology
222207SN/A *     Hewlett-Packard Company
232207SN/A *     1501 Page Mill Road
242207SN/A *     Palo Alto, California  94304
252207SN/A *
262207SN/A * Redistributions of source code must retain the above copyright notice,
272665Ssaidi@eecs.umich.edu * this list of conditions and the following disclaimer.  Redistributions
282665Ssaidi@eecs.umich.edu * in binary form must reproduce the above copyright notice, this list of
292665Ssaidi@eecs.umich.edu * conditions and the following disclaimer in the documentation and/or
302207SN/A * other materials provided with the distribution.  Neither the name of
312207SN/A * the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
322972Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
332207SN/A * this software without specific prior written permission.  No right of
342454SN/A * sublicense is granted herewith.  Derivatives of the software and
355759Shsul@eecs.umich.edu * output created using the software may be prepared, but only for
362454SN/A * Non-Commercial Uses.  Derivatives of the software may be shared with
372680Sktlim@umich.edu * others provided: (i) the others agree to abide by the list of
385759Shsul@eecs.umich.edu * conditions herein which includes the Non-Commercial Use restrictions;
397678Sgblack@eecs.umich.edu * and (ii) such Derivatives of the software include the above copyright
405759Shsul@eecs.umich.edu * notice to acknowledge the contribution from this software where
412474SN/A * applicable, this list of conditions and the disclaimer below.
422207SN/A *
432474SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
442474SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
452474SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
465569Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
475569Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
485154Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
492474SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
502474SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
512474SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
522474SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
532474SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
542474SN/A *
552474SN/A * Authors: Gabe Black
562474SN/A */
572474SN/A
582474SN/A#ifndef __ARCH_X86_TYPES_HH__
592474SN/A#define __ARCH_X86_TYPES_HH__
602474SN/A
612474SN/A#include <inttypes.h>
622474SN/A#include <iostream>
632474SN/A
642474SN/Anamespace X86ISA
652474SN/A{
662474SN/A    //This really determines how many bytes are passed to the predecoder.
675759Shsul@eecs.umich.edu    typedef uint64_t MachInst;
685759Shsul@eecs.umich.edu
695759Shsul@eecs.umich.edu    enum Prefixes {
705759Shsul@eecs.umich.edu        NoOverride = 0,
715771Shsul@eecs.umich.edu        CSOverride = 1,
725759Shsul@eecs.umich.edu        DSOverride = 2,
735759Shsul@eecs.umich.edu        ESOverride = 3,
745759Shsul@eecs.umich.edu        FSOverride = 4,
755759Shsul@eecs.umich.edu        GSOverride = 5,
765759Shsul@eecs.umich.edu        SSOverride = 6,
775759Shsul@eecs.umich.edu        //The Rex prefix obviously doesn't fit in with the above, but putting
785759Shsul@eecs.umich.edu        //it here lets us save double the space the enums take up.
795759Shsul@eecs.umich.edu        Rex = 7,
805759Shsul@eecs.umich.edu        //There can be only one segment override, so they share the
815759Shsul@eecs.umich.edu        //first 3 bits in the legacyPrefixes bitfield.
825759Shsul@eecs.umich.edu        SegmentOverride = 0x7,
835759Shsul@eecs.umich.edu        OperandSizeOverride = 8,
845759Shsul@eecs.umich.edu        AddressSizeOverride = 16,
855759Shsul@eecs.umich.edu        Lock = 32,
865759Shsul@eecs.umich.edu        Rep = 64,
875759Shsul@eecs.umich.edu        Repne = 128
885759Shsul@eecs.umich.edu    };
895759Shsul@eecs.umich.edu
905759Shsul@eecs.umich.edu    //The intermediate structure the x86 predecoder returns.
915759Shsul@eecs.umich.edu    struct ExtMachInst
925759Shsul@eecs.umich.edu    {
935759Shsul@eecs.umich.edu      public: //XXX These should be hidden in the future
945759Shsul@eecs.umich.edu
955759Shsul@eecs.umich.edu        uint8_t legacyPrefixes;
965759Shsul@eecs.umich.edu        uint8_t rexPrefix;
975759Shsul@eecs.umich.edu        bool twoByteOpcode;
985759Shsul@eecs.umich.edu        uint8_t opcode;
995759Shsul@eecs.umich.edu        uint64_t immediate;
1005759Shsul@eecs.umich.edu        uint64_t displacement;
1015759Shsul@eecs.umich.edu
1025759Shsul@eecs.umich.edu      public:
1035759Shsul@eecs.umich.edu
1046227Snate@binkert.org        //These are to pacify the decoder for now. This will go away once
1055759Shsul@eecs.umich.edu        //it can handle non integer inputs, and in the mean time allow me to
1065759Shsul@eecs.umich.edu        //excercise the predecoder a little.
1075759Shsul@eecs.umich.edu        operator unsigned int()
1086227Snate@binkert.org        {
1095759Shsul@eecs.umich.edu            return 0;
1105759Shsul@eecs.umich.edu        }
1115759Shsul@eecs.umich.edu
1125759Shsul@eecs.umich.edu        ExtMachInst(unsigned int)
1135759Shsul@eecs.umich.edu        {;}
1145759Shsul@eecs.umich.edu
1155759Shsul@eecs.umich.edu        ExtMachInst()
1165759Shsul@eecs.umich.edu        {;}
1175759Shsul@eecs.umich.edu    };
1185759Shsul@eecs.umich.edu
1195759Shsul@eecs.umich.edu    inline static std::ostream &
1205759Shsul@eecs.umich.edu        operator << (std::ostream & os, const ExtMachInst & emi)
1215759Shsul@eecs.umich.edu    {
1225759Shsul@eecs.umich.edu        os << "{X86 ExtMachInst}";
1235759Shsul@eecs.umich.edu        return os;
1245759Shsul@eecs.umich.edu    }
1255759Shsul@eecs.umich.edu
1265759Shsul@eecs.umich.edu    inline static bool
1275759Shsul@eecs.umich.edu        operator == (const ExtMachInst &emi1, const ExtMachInst &emi2)
1285759Shsul@eecs.umich.edu    {
1295759Shsul@eecs.umich.edu        //Since this is empty, it's always equal
1305759Shsul@eecs.umich.edu        return true;
1315759Shsul@eecs.umich.edu    }
1325759Shsul@eecs.umich.edu
1335759Shsul@eecs.umich.edu    typedef uint64_t IntReg;
1345759Shsul@eecs.umich.edu    //XXX Should this be a 128 bit structure for XMM memory ops?
1355759Shsul@eecs.umich.edu    typedef uint64_t LargestRead;
1365759Shsul@eecs.umich.edu    typedef uint64_t MiscReg;
1375759Shsul@eecs.umich.edu
1385759Shsul@eecs.umich.edu    //These floating point types are correct for mmx, but not
1395759Shsul@eecs.umich.edu    //technically for x87 (80 bits) or at all for xmm (128 bits)
1405759Shsul@eecs.umich.edu    typedef double FloatReg;
1415759Shsul@eecs.umich.edu    typedef uint64_t FloatRegBits;
1425759Shsul@eecs.umich.edu    typedef union
1435759Shsul@eecs.umich.edu    {
1445759Shsul@eecs.umich.edu        IntReg intReg;
1455759Shsul@eecs.umich.edu        FloatReg fpReg;
1465759Shsul@eecs.umich.edu        MiscReg ctrlReg;
1475759Shsul@eecs.umich.edu    } AnyReg;
1485759Shsul@eecs.umich.edu
1495759Shsul@eecs.umich.edu    //XXX This is very hypothetical. X87 instructions would need to
1505759Shsul@eecs.umich.edu    //change their "context" constantly. It's also not clear how
1515759Shsul@eecs.umich.edu    //this would be handled as far as out of order execution.
1526227Snate@binkert.org    //Maybe x87 instructions are in order?
1535759Shsul@eecs.umich.edu    enum RegContextParam
1545759Shsul@eecs.umich.edu    {
1555759Shsul@eecs.umich.edu        CONTEXT_X87_TOP
1565759Shsul@eecs.umich.edu    };
1575759Shsul@eecs.umich.edu
1585759Shsul@eecs.umich.edu    typedef int RegContextVal;
1595759Shsul@eecs.umich.edu
1605759Shsul@eecs.umich.edu    typedef uint8_t RegIndex;
1615958Sgblack@eecs.umich.edu};
1625958Sgblack@eecs.umich.edu
1635759Shsul@eecs.umich.edu#endif // __ARCH_X86_TYPES_HH__
1645759Shsul@eecs.umich.edu