42 #ifndef __ARCH_ARM_INSTS_STATICINST_HH__ 
   43 #define __ARCH_ARM_INSTS_STATICINST_HH__ 
   65                          uint32_t 
type, uint32_t cfval) 
const;
 
   67                         uint32_t 
type, uint32_t cfval) 
const;
 
   70                          uint32_t 
type, uint32_t cfval) 
const;
 
   72                         uint32_t 
type, uint32_t cfval) 
const;
 
   77                         uint64_t shiftAmt, uint8_t 
width) 
const;
 
   81     saturateOp(int32_t &res, int64_t op1, int64_t op2, 
bool sub=
false)
 
   83         int64_t midRes = sub ? (op1 - op2) : (op1 + op2);
 
   86                 res = (
LL(1) << (
width - 1)) - 1;
 
  100         if (op >= (
LL(1) << width)) {
 
  103         } 
else if (op < -(
LL(1) << width)) {
 
  114     uSaturateOp(uint32_t &res, int64_t op1, int64_t op2, 
bool sub=
false)
 
  116         int64_t midRes = sub ? (op1 - op2) : (op1 + op2);
 
  117         if (midRes >= (
LL(1) << 
width)) {
 
  120         } 
else if (midRes < 0) {
 
  132         if (op >= (
LL(1) << width)) {
 
  160                        const std::string &suffix = 
"",
 
  161                        bool withPred = 
true,
 
  162                        bool withCond64 = 
false,
 
  167                         bool noImplicit=
false) 
const;
 
  169                         const std::string &prefix, 
const Addr addr,
 
  170                         const std::string &suffix) 
const;
 
  172                            bool immShift, uint32_t shiftAmt,
 
  176                             int64_t shiftAmt) 
const;
 
  193     static inline uint32_t
 
  197         bool privileged   = (cpsr.mode != 
MODE_USER);
 
  202         uint32_t bitMask = 0;
 
  204         if (
bits(byteMask, 3)) {
 
  205             unsigned lowIdx = affectState ? 24 : 27;
 
  206             bitMask = bitMask | 
mask(31, lowIdx);
 
  208         if (
bits(byteMask, 2)) {
 
  209             bitMask = bitMask | 
mask(19, 16);
 
  211         if (
bits(byteMask, 1)) {
 
  212             unsigned highIdx = affectState ? 15 : 9;
 
  213             unsigned lowIdx = (privileged && (isSecure || scr.aw || haveVirt))
 
  215             bitMask = bitMask | 
mask(highIdx, lowIdx);
 
  217         if (
bits(byteMask, 0)) {
 
  220                 if ( (!nmfi || !((val >> 6) & 0x1)) &&
 
  221                      (isSecure || scr.fw || haveVirt) ) {
 
  228                     bool validModeChange = 
true;
 
  233                     if (!isSecure && newMode == 
MODE_MON)
 
  234                         validModeChange = 
false;
 
  235                     if (!isSecure && newMode == 
MODE_FIQ && nsacr.rfr == 
'1')
 
  236                         validModeChange = 
false;
 
  239                     if (scr.ns == 
'0' && newMode == 
MODE_HYP)
 
  240                         validModeChange = 
false;
 
  244                         validModeChange = 
false;
 
  248                         validModeChange = 
false;
 
  250                     if (!opModeIs64(oldMode) && opModeIs64(newMode))
 
  251                         validModeChange = 
false;
 
  255                     if (validModeChange) {
 
  256                         bitMask = bitMask | 
mask(5);
 
  258                         warn_once(
"Illegal change to CPSR mode attempted\n");
 
  261                     warn_once(
"Ignoring write of bad mode to CPSR.\n");
 
  265                 bitMask = bitMask | (1 << 5);
 
  268         return ((uint32_t)cpsr & ~bitMask) | (val & bitMask);
 
  271     static inline uint32_t
 
  273             uint8_t byteMask, 
bool affectState)
 
  275         uint32_t bitMask = 0;
 
  277         if (
bits(byteMask, 3))
 
  278             bitMask = bitMask | 
mask(31, 24);
 
  279         if (
bits(byteMask, 2))
 
  280             bitMask = bitMask | 
mask(19, 16);
 
  281         if (
bits(byteMask, 1))
 
  282             bitMask = bitMask | 
mask(15, 8);
 
  283         if (
bits(byteMask, 0))
 
  284             bitMask = bitMask | 
mask(7, 0);
 
  286         return ((spsr & ~bitMask) | (val & bitMask));
 
  293         return xc->pcState().instPC();
 
  316     template<
class T, 
class E>
 
  320         const unsigned count = 
sizeof(T) / 
sizeof(
E);
 
  325         conv.tVal = 
htog(val);
 
  327             for (
unsigned i = 0; 
i < 
count; 
i++) {
 
  328                 conv.eVals[
i] = 
gtobe(conv.eVals[
i]);
 
  331             for (
unsigned i = 0; 
i < 
count; 
i++) {
 
  332                 conv.eVals[
i] = 
gtole(conv.eVals[
i]);
 
  335         return gtoh(conv.tVal);
 
  362         return std::make_shared<UndefinedInstruction>(
machInst, 
false,
 
  394                                   CPSR cpsr, CPACR cpacr) 
const;
 
  403                                     CPSR cpsr, CPACR cpacr,
 
  404                                     NSACR nsacr, FPEXC fpexc,
 
  405                                     bool fpexc_check, 
bool advsimd) 
const;
 
  422 #endif //__ARCH_ARM_INSTS_STATICINST_HH__ 
void printExtendOperand(bool firstOperand, std::ostream &os, IntRegIndex rm, ArmExtendType type, int64_t shiftAmt) const 
 
static T cSwap(T val, bool big)
 
void printShiftOperand(std::ostream &os, IntRegIndex rm, bool immShift, uint32_t shiftAmt, IntRegIndex rs, ArmShiftType type) const 
 
void printDataInst(std::ostream &os, bool withImm) const 
 
#define LL(N)
int64_t constant 
 
ArmStaticInst(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
 
void printCondition(std::ostream &os, unsigned code, bool noImplicit=false) const 
 
void printMnemonic(std::ostream &os, const std::string &suffix="", bool withPred=true, bool withCond64=false, ConditionCode cond64=COND_UC) const 
 
static T cSwap(T val, bool big)
 
void printReg(std::ostream &os, int reg) const 
Print a register name for disassembly given the unique dependence tag number (FP or int)...
 
static void setNextPC(XC *xc, Addr val)
 
static bool saturateOp(int32_t &res, int64_t op1, int64_t op2, bool sub=false)
 
const char * mnemonic
Base mnemonic (e.g., "add"). 
 
virtual void annotateFault(ArmFault *fault)
 
void printMemSymbol(std::ostream &os, const SymbolTable *symtab, const std::string &prefix, const Addr addr, const std::string &suffix) const 
 
void printTarget(std::ostream &os, Addr target, const SymbolTable *symtab) const 
 
static uint32_t cpsrWriteByInstr(CPSR cpsr, uint32_t val, SCR scr, NSACR nsacr, uint8_t byteMask, bool affectState, bool nmfi, ThreadContext *tc)
 
static void setIWNextPC(XC *xc, Addr val)
 
ThreadContext is the external interface to all thread state for anything outside of the CPU...
 
Fault checkAdvSIMDOrFPEnabled32(ThreadContext *tc, CPSR cpsr, CPACR cpacr, NSACR nsacr, FPEXC fpexc, bool fpexc_check, bool advsimd) const 
Check if a VFP/SIMD access from aarch32 should be allowed. 
 
const ExtMachInst machInst
The binary machine instruction. 
 
Fault advSIMDFPAccessTrap64(ExceptionLevel el) const 
Trap an access to Advanced SIMD or FP registers due to access control bits. 
 
Fault checkFPAdvSIMDTrap64(ThreadContext *tc, CPSR cpsr) const 
Check an Advaned SIMD access against CPTR_EL2 and CPTR_EL3. 
 
int32_t shift_rm_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const 
 
static bool uSaturateOp(uint32_t &res, int64_t op1, int64_t op2, bool sub=false)
 
bool haveSecurity() const 
Returns true if this system implements the Security Extensions. 
 
uint64_t Addr
Address type This will probably be moved somewhere else in the near future. 
 
bool shift_carry_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const 
 
bool shift_carry_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const 
 
int64_t extendReg64(uint64_t base, ArmExtendType type, uint64_t shiftAmt, uint8_t width) const 
 
void advancePC(PCState &pcState) const 
 
static uint32_t spsrWriteByInstr(uint32_t spsr, uint32_t val, uint8_t byteMask, bool affectState)
 
static bool satInt(int32_t &res, int64_t op, int width)
 
Fault checkFPAdvSIMDEnabled64(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const 
Check an Advaned SIMD access against CPACR_EL1, CPTR_EL2, and CPTR_EL3. 
 
bool haveVirtualization() const 
Returns true if this system implements the virtualization Extensions. 
 
GenericISA::SimplePCState< MachInst > PCState
 
static void setAIWNextPC(XC *xc, Addr val)
 
int32_t shift_rm_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const 
 
int64_t shiftReg64(uint64_t base, uint64_t shiftAmt, ArmShiftType type, uint8_t width) const 
 
Base, ISA-independent static instruction class. 
 
TheISA::ExtMachInst ExtMachInst
Binary extended machine instruction type. 
 
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const 
Internal function to generate disassembly string. 
 
Fault disabledFault() const 
 
CPSR getPSTATEFromPSR(ThreadContext *tc, CPSR cpsr, CPSR spsr) const 
Get the new PSTATE from a SPSR register in preparation for an exception return. 
 
bool inSecureState(ThreadContext *tc)
 
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
 
static bool badMode(OperatingMode mode)
 
static Addr readPC(XC *xc)
 
std::shared_ptr< FaultBase > Fault
 
static bool uSatInt(int32_t &res, int64_t op, int width)