cpuid.isa revision 5659
15659Sgblack@eecs.umich.edu// Copyright (c) 2008 The Hewlett-Packard Development Company
25659Sgblack@eecs.umich.edu// All rights reserved.
35659Sgblack@eecs.umich.edu//
45659Sgblack@eecs.umich.edu// Redistribution and use of this software in source and binary forms,
55659Sgblack@eecs.umich.edu// with or without modification, are permitted provided that the
65659Sgblack@eecs.umich.edu// following conditions are met:
75659Sgblack@eecs.umich.edu//
85659Sgblack@eecs.umich.edu// The software must be used only for Non-Commercial Use which means any
95659Sgblack@eecs.umich.edu// use which is NOT directed to receiving any direct monetary
105659Sgblack@eecs.umich.edu// compensation for, or commercial advantage from such use.  Illustrative
115659Sgblack@eecs.umich.edu// examples of non-commercial use are academic research, personal study,
125659Sgblack@eecs.umich.edu// teaching, education and corporate research & development.
135659Sgblack@eecs.umich.edu// Illustrative examples of commercial use are distributing products for
145659Sgblack@eecs.umich.edu// commercial advantage and providing services using the software for
155659Sgblack@eecs.umich.edu// commercial advantage.
165659Sgblack@eecs.umich.edu//
175659Sgblack@eecs.umich.edu// If you wish to use this software or functionality therein that may be
185659Sgblack@eecs.umich.edu// covered by patents for commercial use, please contact:
195659Sgblack@eecs.umich.edu//     Director of Intellectual Property Licensing
205659Sgblack@eecs.umich.edu//     Office of Strategy and Technology
215659Sgblack@eecs.umich.edu//     Hewlett-Packard Company
225659Sgblack@eecs.umich.edu//     1501 Page Mill Road
235659Sgblack@eecs.umich.edu//     Palo Alto, California  94304
245659Sgblack@eecs.umich.edu//
255659Sgblack@eecs.umich.edu// Redistributions of source code must retain the above copyright notice,
265659Sgblack@eecs.umich.edu// this list of conditions and the following disclaimer.  Redistributions
275659Sgblack@eecs.umich.edu// in binary form must reproduce the above copyright notice, this list of
285659Sgblack@eecs.umich.edu// conditions and the following disclaimer in the documentation and/or
295659Sgblack@eecs.umich.edu// other materials provided with the distribution.  Neither the name of
305659Sgblack@eecs.umich.edu// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
315659Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from
325659Sgblack@eecs.umich.edu// this software without specific prior written permission.  No right of
335659Sgblack@eecs.umich.edu// sublicense is granted herewith.  Derivatives of the software and
345659Sgblack@eecs.umich.edu// output created using the software may be prepared, but only for
355659Sgblack@eecs.umich.edu// Non-Commercial Uses.  Derivatives of the software may be shared with
365659Sgblack@eecs.umich.edu// others provided: (i) the others agree to abide by the list of
375659Sgblack@eecs.umich.edu// conditions herein which includes the Non-Commercial Use restrictions;
385659Sgblack@eecs.umich.edu// and (ii) such Derivatives of the software include the above copyright
395659Sgblack@eecs.umich.edu// notice to acknowledge the contribution from this software where
405659Sgblack@eecs.umich.edu// applicable, this list of conditions and the disclaimer below.
415659Sgblack@eecs.umich.edu//
425659Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
435659Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
445659Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
455659Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
465659Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
475659Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
485659Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
495659Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
505659Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
515659Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
525659Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
535659Sgblack@eecs.umich.edu//
545659Sgblack@eecs.umich.edu// Authors: Gabe Black
555659Sgblack@eecs.umich.edu
565659Sgblack@eecs.umich.eduoutput header {{
575659Sgblack@eecs.umich.edu    class CPUIDInst : public X86ISA::X86StaticInst
585659Sgblack@eecs.umich.edu    {
595659Sgblack@eecs.umich.edu      public:
605659Sgblack@eecs.umich.edu        static const RegIndex foldOBit = 0;
615659Sgblack@eecs.umich.edu        /// Constructor
625659Sgblack@eecs.umich.edu        CPUIDInst(const char *_mnemonic, ExtMachInst _machInst,
635659Sgblack@eecs.umich.edu                OpClass __opClass) :
645659Sgblack@eecs.umich.edu            X86ISA::X86StaticInst(_mnemonic, _machInst, __opClass)
655659Sgblack@eecs.umich.edu        {
665659Sgblack@eecs.umich.edu        }
675659Sgblack@eecs.umich.edu
685659Sgblack@eecs.umich.edu        std::string generateDisassembly(Addr pc,
695659Sgblack@eecs.umich.edu                const SymbolTable *symtab) const;
705659Sgblack@eecs.umich.edu    };
715659Sgblack@eecs.umich.edu}};
725659Sgblack@eecs.umich.edu
735659Sgblack@eecs.umich.eduoutput decoder {{
745659Sgblack@eecs.umich.edu    std::string CPUIDInst::generateDisassembly(Addr PC,
755659Sgblack@eecs.umich.edu            const SymbolTable *symtab) const
765659Sgblack@eecs.umich.edu    {
775659Sgblack@eecs.umich.edu        std::stringstream response;
785659Sgblack@eecs.umich.edu
795659Sgblack@eecs.umich.edu        printMnemonic(response, mnemonic);
805659Sgblack@eecs.umich.edu        ccprintf(response, " ");
815659Sgblack@eecs.umich.edu        printReg(response, _srcRegIdx[0], machInst.opSize);
825659Sgblack@eecs.umich.edu        return response.str();
835659Sgblack@eecs.umich.edu    }
845659Sgblack@eecs.umich.edu}};
855659Sgblack@eecs.umich.edu
865659Sgblack@eecs.umich.edudef template CPUIDExecute {{
875659Sgblack@eecs.umich.edu    Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
885659Sgblack@eecs.umich.edu            Trace::InstRecord *traceData) const
895659Sgblack@eecs.umich.edu    {
905659Sgblack@eecs.umich.edu        // If the CPUID instruction used a valid function number, this will
915659Sgblack@eecs.umich.edu        // be set to true. Otherwise, the instruction does nothing.
925659Sgblack@eecs.umich.edu        bool success;
935659Sgblack@eecs.umich.edu        %(op_decl)s;
945659Sgblack@eecs.umich.edu        %(op_rd)s;
955659Sgblack@eecs.umich.edu        %(code)s;
965659Sgblack@eecs.umich.edu        if (success) {
975659Sgblack@eecs.umich.edu            %(op_wb)s;
985659Sgblack@eecs.umich.edu        }
995659Sgblack@eecs.umich.edu        return NoFault;
1005659Sgblack@eecs.umich.edu    }
1015659Sgblack@eecs.umich.edu}};
1025659Sgblack@eecs.umich.edu
1035659Sgblack@eecs.umich.edudef format CPUIDInst(code, *opt_flags) {{
1045659Sgblack@eecs.umich.edu    iop = InstObjParams(name, Name, 'CPUIDInst', code, opt_flags)
1055659Sgblack@eecs.umich.edu    header_output = BasicDeclare.subst(iop)
1065659Sgblack@eecs.umich.edu    decoder_output = BasicConstructor.subst(iop)
1075659Sgblack@eecs.umich.edu    decode_block = BasicDecode.subst(iop)
1085659Sgblack@eecs.umich.edu    exec_output = CPUIDExecute.subst(iop)
1095659Sgblack@eecs.umich.edu}};
1105659Sgblack@eecs.umich.edu
111