Go to the documentation of this file.
41 #ifndef __ARCH_ARM_INSTS_STATICINST_HH__
42 #define __ARCH_ARM_INSTS_STATICINST_HH__
70 uint32_t
type, uint32_t cfval)
const;
72 uint32_t
type, uint32_t cfval)
const;
75 uint32_t
type, uint32_t cfval)
const;
77 uint32_t
type, uint32_t cfval)
const;
82 uint64_t shiftAmt, uint8_t
width)
const;
86 saturateOp(int32_t &res, int64_t op1, int64_t op2,
bool sub=
false)
88 int64_t midRes = sub ? (op1 - op2) : (op1 + op2);
91 res = (1LL << (
width - 1)) - 1;
93 res = -(1LL << (
width - 1));
106 res = (1LL <<
width) - 1;
108 }
else if (
op < -(1LL <<
width)) {
109 res = -(1LL <<
width);
119 uSaturateOp(uint32_t &res, int64_t op1, int64_t op2,
bool sub=
false)
121 int64_t midRes = sub ? (op1 - op2) : (op1 + op2);
122 if (midRes >= (1LL <<
width)) {
123 res = (1LL <<
width) - 1;
125 }
else if (midRes < 0) {
138 res = (1LL <<
width) - 1;
166 uint8_t opWidth = 0)
const;
169 bool isSveVecReg =
false)
const;
174 const std::string &suffix =
"",
175 bool withPred =
true,
176 bool withCond64 =
false,
181 bool noImplicit=
false)
const;
183 const std::string &prefix,
const Addr addr,
184 const std::string &suffix)
const;
186 bool immShift, uint32_t shiftAmt,
187 IntRegIndex
rs, ArmShiftType
type)
const;
190 int64_t shiftAmt)
const;
195 IntRegIndex
rd, IntRegIndex
rn, IntRegIndex
rm,
196 IntRegIndex
rs, uint32_t shiftAmt, ArmShiftType
type,
225 static inline uint32_t
229 bool privileged = (cpsr.mode !=
MODE_USER);
233 uint32_t bitMask = 0;
235 if (affectState && byteMask==0xF){
238 if (
bits(byteMask, 3)) {
239 unsigned lowIdx = affectState ? 24 : 27;
240 bitMask = bitMask |
mask(31, lowIdx);
242 if (
bits(byteMask, 2)) {
243 bitMask = bitMask |
mask(19, 16);
245 if (
bits(byteMask, 1)) {
246 unsigned highIdx = affectState ? 15 : 9;
247 unsigned lowIdx = (privileged && (
isSecure || scr.aw || haveVirt))
249 bitMask = bitMask |
mask(highIdx, lowIdx);
251 if (
bits(byteMask, 0)) {
254 if ( (!
nmfi || !((
val >> 6) & 0x1)) &&
255 (
isSecure || scr.fw || haveVirt) ) {
262 bool validModeChange =
true;
268 validModeChange =
false;
270 validModeChange =
false;
273 if (scr.ns == 0 && newMode ==
MODE_HYP)
274 validModeChange =
false;
278 validModeChange =
false;
282 validModeChange =
false;
284 if (!opModeIs64(oldMode) && opModeIs64(newMode))
285 validModeChange =
false;
289 if (validModeChange) {
290 bitMask = bitMask |
mask(5);
292 warn_once(
"Illegal change to CPSR mode attempted\n");
295 warn_once(
"Ignoring write of bad mode to CPSR.\n");
299 bitMask = bitMask | (1 << 5);
302 return ((uint32_t)cpsr & ~bitMask) | (
val & bitMask);
305 static inline uint32_t
307 uint8_t byteMask,
bool affectState)
309 uint32_t bitMask = 0;
311 if (
bits(byteMask, 3))
312 bitMask = bitMask |
mask(31, 24);
313 if (
bits(byteMask, 2))
314 bitMask = bitMask |
mask(19, 16);
315 if (
bits(byteMask, 1))
316 bitMask = bitMask |
mask(15, 8);
317 if (
bits(byteMask, 0))
318 bitMask = bitMask |
mask(7, 0);
320 return ((spsr & ~bitMask) | (
val & bitMask));
348 template<
class T,
class E>
352 const unsigned count =
sizeof(T) /
sizeof(
E);
360 for (
unsigned i = 0;
i <
count;
i++) {
361 conv.eVals[
i] =
letobe(conv.eVals[
i]);
364 for (
unsigned i = 0;
i <
count;
i++) {
365 conv.eVals[
i] = conv.eVals[
i];
368 return letoh(conv.tVal);
393 return std::make_shared<UndefinedInstruction>(
machInst,
false,
438 CPSR cpsr, CPACR cpacr)
const;
447 CPSR cpsr, CPACR cpacr,
448 NSACR nsacr, FPEXC fpexc,
449 bool fpexc_check,
bool advsimd)
const;
584 #endif //__ARCH_ARM_INSTS_STATICINST_HH__
void printShiftOperand(std::ostream &os, IntRegIndex rm, bool immShift, uint32_t shiftAmt, IntRegIndex rs, ArmShiftType type) const
static void setNextPC(ExecContext *xc, Addr val)
void printVecReg(std::ostream &os, RegIndex reg_idx, bool isSveVecReg=false) const
Fault advSIMDFPAccessTrap64(ExceptionLevel el) const
Trap an access to Advanced SIMD or FP registers due to access control bits.
CPSR getPSTATEFromPSR(ThreadContext *tc, CPSR cpsr, CPSR spsr) const
Get the new PSTATE from a SPSR register in preparation for an exception return.
static bool uSatInt(int32_t &res, int64_t op, int width)
Bitfield< 23, 20 > advsimd
static T cSwap(T val, bool big)
Fault undefinedFault32(ThreadContext *tc, ExceptionLevel el) const
UNDEFINED behaviour in AArch32.
static void setIWNextPC(ExecContext *xc, Addr val)
bool shift_carry_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
void printMnemonic(std::ostream &os, const std::string &suffix="", bool withPred=true, bool withCond64=false, ConditionCode cond64=COND_UC) const
static unsigned getCurSveVecLenInQWords(ThreadContext *tc)
size_t simpleAsBytes(void *buf, size_t max_size, const T &t)
uint64_t getEMI() const override
PCState buildRetPC(const PCState &curPC, const PCState &callPC) const override
Fault disabledFault() const
static unsigned getCurSveVecLenInBits(ThreadContext *tc)
void printCCReg(std::ostream &os, RegIndex reg_idx) const
bool badMode(ThreadContext *tc, OperatingMode mode)
badMode is checking if the execution mode provided as an argument is valid and implemented.
MachInst encoding() const
Returns the real encoding of the instruction: the machInst field is in fact always 64 bit wide and co...
Fault trapWFx(ThreadContext *tc, CPSR cpsr, SCR scr, bool isWfe) const
WFE/WFI trapping helper function.
int32_t shift_rm_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
Fault softwareBreakpoint32(ExecContext *xc, uint16_t imm) const
Trigger a Software Breakpoint.
void printTarget(std::ostream &os, Addr target, const loader::SymbolTable *symtab) const
static bool saturateOp(int32_t &res, int64_t op1, int64_t op2, bool sub=false)
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.
static uint32_t cpsrWriteByInstr(CPSR cpsr, uint32_t val, SCR scr, NSACR nsacr, uint8_t byteMask, bool affectState, bool nmfi, ThreadContext *tc)
void printCondition(std::ostream &os, unsigned code, bool noImplicit=false) const
static Addr readPC(ExecContext *xc)
void printExtendOperand(bool firstOperand, std::ostream &os, IntRegIndex rm, ArmExtendType type, int64_t shiftAmt) const
void advancePC(PCState &pcState) const override
size_t asBytes(void *buf, size_t max_size) override
Instruction classes can override this function to return a a representation of themselves as a blob o...
Fault checkSETENDEnabled(ThreadContext *tc, CPSR cpsr) const
Check if SETEND instruction execution in aarch32 should be trapped.
static T cSwap(T val, bool big)
Base, ISA-independent static instruction class.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
std::shared_ptr< FaultBase > Fault
Fault undefinedFault64(ThreadContext *tc, ExceptionLevel el) const
UNDEFINED behaviour in AArch64.
void printMemSymbol(std::ostream &os, const loader::SymbolTable *symtab, const std::string &prefix, const Addr addr, const std::string &suffix) const
int64_t shiftReg64(uint64_t base, uint64_t shiftAmt, ArmShiftType type, uint8_t width) const
static bool uSaturateOp(uint32_t &res, int64_t op1, int64_t op2, bool sub=false)
Fault checkForWFxTrap64(ThreadContext *tc, ExceptionLevel tgtEl, bool isWfe) const
Check if WFE/WFI instruction execution in aarch64 should be trapped.
virtual TheISA::PCState pcState() const =0
static void activateBreakpoint(ThreadContext *tc)
bool isWFxTrapping(ThreadContext *tc, ExceptionLevel targetEL, bool isWfe) const
static unsigned getCurSveVecLen(ThreadContext *tc)
ArmStaticInst(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
static void setAIWNextPC(ExecContext *xc, Addr val)
bool shift_carry_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
Fault checkForWFxTrap32(ThreadContext *tc, ExceptionLevel tgtEl, bool isWfe) const
Check if WFE/WFI instruction execution in aarch32 should be trapped.
void printVecPredReg(std::ostream &os, RegIndex reg_idx) const
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Fault checkSveEnabled(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const
Check an SVE access against CPACR_EL1, CPTR_EL2, and CPTR_EL3.
bool isSecure(ThreadContext *tc)
bool generalExceptionsToAArch64(ThreadContext *tc, ExceptionLevel pstateEL) const
Return true if exceptions normally routed to EL1 are being handled at an Exception level using AArch6...
int64_t extendReg64(uint64_t base, ArmExtendType type, uint64_t shiftAmt, uint8_t width) const
Fault checkFPAdvSIMDEnabled64(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const
Check an Advaned SIMD access against CPACR_EL1, CPTR_EL2, and CPTR_EL3.
void printDataInst(std::ostream &os, bool withImm) const
void printFloatReg(std::ostream &os, RegIndex reg_idx) const
int32_t shift_rm_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
SelfDebug * getSelfDebug() const
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
void printMiscReg(std::ostream &os, RegIndex reg_idx) const
static bool satInt(int32_t &res, int64_t op, int width)
void printIntReg(std::ostream &os, RegIndex reg_idx, uint8_t opWidth=0) const
Print a register name for disassembly given the unique dependence tag number (FP or int).
const char * mnemonic
Base mnemonic (e.g., "add").
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
ssize_t instSize() const
Returns the byte size of current instruction.
virtual void annotateFault(ArmFault *fault)
uint8_t getIntWidth() const
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
Fault sveAccessTrap(ExceptionLevel el) const
Trap an access to SVE registers due to access control bits.
void printPFflags(std::ostream &os, int flag) const
static uint32_t spsrWriteByInstr(uint32_t spsr, uint32_t val, uint8_t byteMask, bool affectState)
Fault checkFPAdvSIMDTrap64(ThreadContext *tc, CPSR cpsr) const
Check an Advaned SIMD access against CPTR_EL2 and CPTR_EL3.
Generated on Tue Sep 21 2021 12:24:35 for gem5 by doxygen 1.8.17