pseudo.hh revision 12763:37c243ed1112
111731Sjason@lowepower.com/*
211731Sjason@lowepower.com * Copyright (c) 2014,2016,2018 ARM Limited
311731Sjason@lowepower.com * All rights reserved
411731Sjason@lowepower.com *
511731Sjason@lowepower.com * The license below extends only to copyright in the software and shall
611731Sjason@lowepower.com * not be construed as granting a license to any other intellectual
711731Sjason@lowepower.com * property including but not limited to intellectual property relating
811731Sjason@lowepower.com * to a hardware implementation of the functionality of the software
911731Sjason@lowepower.com * licensed hereunder.  You may use the software subject to the license
1011731Sjason@lowepower.com * terms below provided that you ensure that this notice is replicated
1111731Sjason@lowepower.com * unmodified and in its entirety in all distributions of the software,
1211731Sjason@lowepower.com * modified or unmodified, in source code or in binary form.
1311731Sjason@lowepower.com *
1411731Sjason@lowepower.com * Copyright (c) 2007-2008 The Florida State University
1511731Sjason@lowepower.com * All rights reserved.
1611731Sjason@lowepower.com *
1711731Sjason@lowepower.com * Redistribution and use in source and binary forms, with or without
1811731Sjason@lowepower.com * modification, are permitted provided that the following conditions are
1911731Sjason@lowepower.com * met: redistributions of source code must retain the above copyright
2011731Sjason@lowepower.com * notice, this list of conditions and the following disclaimer;
2111731Sjason@lowepower.com * redistributions in binary form must reproduce the above copyright
2211731Sjason@lowepower.com * notice, this list of conditions and the following disclaimer in the
2311731Sjason@lowepower.com * documentation and/or other materials provided with the distribution;
2411731Sjason@lowepower.com * neither the name of the copyright holders nor the names of its
2511731Sjason@lowepower.com * contributors may be used to endorse or promote products derived from
2611731Sjason@lowepower.com * this software without specific prior written permission.
2711731Sjason@lowepower.com *
2811731Sjason@lowepower.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2911731Sjason@lowepower.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3011731Sjason@lowepower.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3111731Sjason@lowepower.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3211731Sjason@lowepower.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3311731Sjason@lowepower.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3411731Sjason@lowepower.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3511731Sjason@lowepower.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3611731Sjason@lowepower.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3711731Sjason@lowepower.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3811731Sjason@lowepower.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3911731Sjason@lowepower.com *
4011731Sjason@lowepower.com * Authors: Andreas Sandberg
4111731Sjason@lowepower.com *          Stephen Hines
4211731Sjason@lowepower.com */
4311731Sjason@lowepower.com
4411731Sjason@lowepower.com#ifndef __ARCH_ARM_INSTS_PSEUDO_HH__
4511731Sjason@lowepower.com#define __ARCH_ARM_INSTS_PSEUDO_HH__
4611731Sjason@lowepower.com
4711731Sjason@lowepower.com#include "arch/arm/insts/static_inst.hh"
4811731Sjason@lowepower.com
4911731Sjason@lowepower.comclass DecoderFaultInst : public ArmStaticInst
5011731Sjason@lowepower.com{
5111731Sjason@lowepower.com  protected:
5211731Sjason@lowepower.com    DecoderFault faultId;
5311731Sjason@lowepower.com
5411731Sjason@lowepower.com    const char *faultName() const;
5511731Sjason@lowepower.com
5611731Sjason@lowepower.com  public:
5711731Sjason@lowepower.com    DecoderFaultInst(ExtMachInst _machInst);
5811731Sjason@lowepower.com
5911731Sjason@lowepower.com    Fault execute(ExecContext *xc,
6011731Sjason@lowepower.com                  Trace::InstRecord *traceData) const override;
6111731Sjason@lowepower.com
6211731Sjason@lowepower.com    std::string generateDisassembly(
6311731Sjason@lowepower.com            Addr pc, const SymbolTable *symtab) const override;
6411731Sjason@lowepower.com};
6511731Sjason@lowepower.com
6611731Sjason@lowepower.com/**
6711731Sjason@lowepower.com * Static instruction class for unimplemented instructions that
6811731Sjason@lowepower.com * cause simulator termination.  Note that these are recognized
6911731Sjason@lowepower.com * (legal) instructions that the simulator does not support; the
7011731Sjason@lowepower.com * 'Unknown' class is used for unrecognized/illegal instructions.
7111731Sjason@lowepower.com * This is a leaf class.
7211731Sjason@lowepower.com */
7311731Sjason@lowepower.comclass FailUnimplemented : public ArmStaticInst
7411731Sjason@lowepower.com{
7511731Sjason@lowepower.com  private:
7611731Sjason@lowepower.com    /// Full mnemonic for MRC and MCR instructions including the
7711731Sjason@lowepower.com    /// coproc. register name
7811731Sjason@lowepower.com    std::string fullMnemonic;
7911731Sjason@lowepower.com
8011731Sjason@lowepower.com  public:
8111731Sjason@lowepower.com    FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst);
8211731Sjason@lowepower.com    FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst,
8311731Sjason@lowepower.com                      const std::string& _fullMnemonic);
8411731Sjason@lowepower.com
8511731Sjason@lowepower.com    Fault execute(ExecContext *xc,
8611731Sjason@lowepower.com                  Trace::InstRecord *traceData) const override;
8711731Sjason@lowepower.com
8811731Sjason@lowepower.com    std::string generateDisassembly(
8911731Sjason@lowepower.com            Addr pc, const SymbolTable *symtab) const override;
9011731Sjason@lowepower.com};
9111731Sjason@lowepower.com
9211731Sjason@lowepower.com/**
9311731Sjason@lowepower.com * Base class for unimplemented instructions that cause a warning
9411731Sjason@lowepower.com * to be printed (but do not terminate simulation).  This
9511731Sjason@lowepower.com * implementation is a little screwy in that it will print a
9611731Sjason@lowepower.com * warning for each instance of a particular unimplemented machine
9711731Sjason@lowepower.com * instruction, not just for each unimplemented opcode.  Should
9811731Sjason@lowepower.com * probably make the 'warned' flag a static member of the derived
9911731Sjason@lowepower.com * class.
10011731Sjason@lowepower.com */
10111731Sjason@lowepower.comclass WarnUnimplemented : public ArmStaticInst
10211731Sjason@lowepower.com{
10311731Sjason@lowepower.com  private:
10411731Sjason@lowepower.com    /// Have we warned on this instruction yet?
10511731Sjason@lowepower.com    mutable bool warned;
10611731Sjason@lowepower.com    /// Full mnemonic for MRC and MCR instructions including the
10711731Sjason@lowepower.com    /// coproc. register name
10811731Sjason@lowepower.com    std::string fullMnemonic;
10911731Sjason@lowepower.com
11011731Sjason@lowepower.com  public:
11111731Sjason@lowepower.com    WarnUnimplemented(const char *_mnemonic, ExtMachInst _machInst);
11211731Sjason@lowepower.com    WarnUnimplemented(const char *_mnemonic, ExtMachInst _machInst,
11311731Sjason@lowepower.com                      const std::string& _fullMnemonic);
11411731Sjason@lowepower.com
11511731Sjason@lowepower.com    Fault execute(ExecContext *xc,
11611731Sjason@lowepower.com                  Trace::InstRecord *traceData) const override;
11711731Sjason@lowepower.com
11811731Sjason@lowepower.com    std::string generateDisassembly(
11911731Sjason@lowepower.com            Addr pc, const SymbolTable *symtab) const override;
12011731Sjason@lowepower.com};
12111731Sjason@lowepower.com
12211731Sjason@lowepower.com/**
12311731Sjason@lowepower.com * Certain mrc/mcr instructions act as nops or flush the pipe based on what
12411731Sjason@lowepower.com * register the instruction is trying to access. This inst/class exists so that
12511731Sjason@lowepower.com * we can still check for hyp traps, as the normal nop instruction
12611731Sjason@lowepower.com * does not.
12711731Sjason@lowepower.com */
12811731Sjason@lowepower.comclass McrMrcMiscInst : public ArmStaticInst
12911731Sjason@lowepower.com{
13011731Sjason@lowepower.com  protected:
13111731Sjason@lowepower.com    uint64_t iss;
13211731Sjason@lowepower.com    MiscRegIndex miscReg;
13311731Sjason@lowepower.com
13411731Sjason@lowepower.com  public:
13511731Sjason@lowepower.com    McrMrcMiscInst(const char *_mnemonic, ExtMachInst _machInst,
13611731Sjason@lowepower.com                   uint64_t _iss, MiscRegIndex _miscReg);
13711731Sjason@lowepower.com
13811731Sjason@lowepower.com    Fault execute(ExecContext *xc,
13911731Sjason@lowepower.com                  Trace::InstRecord *traceData) const override;
14011731Sjason@lowepower.com
14111731Sjason@lowepower.com    std::string generateDisassembly(
14211731Sjason@lowepower.com            Addr pc, const SymbolTable *symtab) const override;
14311731Sjason@lowepower.com
14411731Sjason@lowepower.com};
14511731Sjason@lowepower.com
14611731Sjason@lowepower.com/**
14711731Sjason@lowepower.com * This class is also used for IMPLEMENTATION DEFINED registers, whose mcr/mrc
14811731Sjason@lowepower.com * behaviour is trappable even for unimplemented registers.
14911731Sjason@lowepower.com */
15011731Sjason@lowepower.comclass McrMrcImplDefined : public McrMrcMiscInst
15111731Sjason@lowepower.com{
15211731Sjason@lowepower.com  public:
15311731Sjason@lowepower.com    McrMrcImplDefined(const char *_mnemonic, ExtMachInst _machInst,
15411731Sjason@lowepower.com                      uint64_t _iss, MiscRegIndex _miscReg);
15511731Sjason@lowepower.com
15611731Sjason@lowepower.com    Fault execute(ExecContext *xc,
15711731Sjason@lowepower.com                  Trace::InstRecord *traceData) const override;
15811731Sjason@lowepower.com
15911731Sjason@lowepower.com    std::string generateDisassembly(
16011731Sjason@lowepower.com            Addr pc, const SymbolTable *symtab) const override;
16111731Sjason@lowepower.com
16211731Sjason@lowepower.com};
16311731Sjason@lowepower.com
16411731Sjason@lowepower.com/**
16511731Sjason@lowepower.com * This class is modelling instructions which are not going to be
16611731Sjason@lowepower.com * executed since they are flagged as Illegal Execution Instructions
16711731Sjason@lowepower.com * (PSTATE.IL = 1 or CPSR.IL = 1).
16811731Sjason@lowepower.com * The sole purpose of this instruction is to generate an appropriate
16911731Sjason@lowepower.com * fault when executed.
17011731Sjason@lowepower.com */
17111731Sjason@lowepower.comclass IllegalExecInst : public ArmStaticInst
17211731Sjason@lowepower.com{
17311731Sjason@lowepower.com  public:
17411731Sjason@lowepower.com    IllegalExecInst(ExtMachInst _machInst);
17511731Sjason@lowepower.com
17611731Sjason@lowepower.com    Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const;
17711731Sjason@lowepower.com};
17811731Sjason@lowepower.com
17911731Sjason@lowepower.com#endif
18011731Sjason@lowepower.com