}
format PredOp {
// ARM System Call (SoftWare Interrupt)
- 1: swi({{ if (arm_predicate(xc->readMiscReg(ArmISA::CPSR),
+ 1: swi({{ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR),
condCode))
{
//xc->syscall(R7);
else:
inst_flags += ('IsCondControl', )
- icode = 'if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode)) {\n'
+ icode = 'if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode)) {\n'
icode += code
icode += ' NPC = NPC + 4 + disp;\n'
icode += '} else {\n'
#Condition code
- icode = 'if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode)) {\n'
+ icode = 'if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode)) {\n'
icode += code
icode += ' NPC = Rm & 0xfffffffe; // Masks off bottom bit\n'
icode += '} else {\n'
%(code)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode) &&
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode) &&
fault == NoFault)
{
%(op_wb)s;
%(op_rd)s;
%(ea_code)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
if (fault == NoFault) {
%(op_wb)s;
%(op_rd)s;
EA = xc->getEA();
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
if (fault == NoFault) {
fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags);
%(op_rd)s;
%(ea_code)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
if (fault == NoFault) {
fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags);
%(op_rd)s;
%(ea_code)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
if (fault == NoFault) {
fault = xc->read(EA, (uint%(mem_acc_size)d_t &)Mem, memAccessFlags);
%(op_decl)s;
%(op_rd)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
// ARM instructions will not have a pkt if the predicate is false
Mem = pkt->get<typeof(Mem)>();
%(op_decl)s;
%(op_rd)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
EA = xc->getEA();
%(op_rd)s;
%(ea_code)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
if (fault == NoFault) {
%(memacc_code)s;
%(op_rd)s;
%(ea_code)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
if (fault == NoFault) {
%(memacc_code)s;
%(fp_enable_check)s;
%(op_dest_decl)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
if (fault == NoFault) {
%(op_wb)s;
%(fp_enable_check)s;
%(op_dest_decl)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
if (fault == NoFault) {
%(op_wb)s;
%(op_decl)s;
%(op_rd)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
EA = xc->getEA();
%(op_rd)s;
%(ea_code)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
if (fault == NoFault) {
%(memacc_code)s;
output header {{
#include <iostream>
- enum ArmPredicateBits {
- COND_EQ = 0,
- COND_NE, // 1
- COND_CS, // 2
- COND_CC, // 3
- COND_MI, // 4
- COND_PL, // 5
- COND_VS, // 6
- COND_VC, // 7
- COND_HI, // 8
- COND_LS, // 9
- COND_GE, // 10
- COND_LT, // 11
- COND_GT, // 12
- COND_LE, // 13
- COND_AL, // 14
- COND_NV // 15
- };
-
inline uint32_t
rotate_imm(uint32_t immValue, uint32_t rotateValue)
{
(immValue << (32 - (int)(rotateValue & 31))));
}
- inline uint32_t nSet(uint32_t cpsr) { return cpsr & (1<<31); }
- inline uint32_t zSet(uint32_t cpsr) { return cpsr & (1<<30); }
- inline uint32_t cSet(uint32_t cpsr) { return cpsr & (1<<29); }
- inline uint32_t vSet(uint32_t cpsr) { return cpsr & (1<<28); }
-
- inline bool arm_predicate(uint32_t cpsr, uint32_t predBits)
- {
-
- enum ArmPredicateBits armPredBits = (enum ArmPredicateBits) predBits;
- uint32_t result = 0;
- switch (armPredBits)
- {
- case COND_EQ:
- result = zSet(cpsr); break;
- case COND_NE:
- result = !zSet(cpsr); break;
- case COND_CS:
- result = cSet(cpsr); break;
- case COND_CC:
- result = !cSet(cpsr); break;
- case COND_MI:
- result = nSet(cpsr); break;
- case COND_PL:
- result = !nSet(cpsr); break;
- case COND_VS:
- result = vSet(cpsr); break;
- case COND_VC:
- result = !vSet(cpsr); break;
- case COND_HI:
- result = cSet(cpsr) && !zSet(cpsr); break;
- case COND_LS:
- result = !cSet(cpsr) || zSet(cpsr); break;
- case COND_GE:
- result = (!nSet(cpsr) && !vSet(cpsr)) || (nSet(cpsr) && vSet(cpsr)); break;
- case COND_LT:
- result = (nSet(cpsr) && !vSet(cpsr)) || (!nSet(cpsr) && vSet(cpsr)); break;
- case COND_GT:
- result = (!nSet(cpsr) && !vSet(cpsr) && !zSet(cpsr)) || (nSet(cpsr) && vSet(cpsr) && !zSet(cpsr)); break;
- case COND_LE:
- result = (nSet(cpsr) && !vSet(cpsr)) || (!nSet(cpsr) && vSet(cpsr)) || zSet(cpsr); break;
- case COND_AL: result = 1; break;
- case COND_NV: result = 0; break;
- default:
- fprintf(stderr, "Unhandled predicate condition: %d\n", armPredBits);
- exit(1);
- }
- if (result)
- return true;
- else
- return false;
- }
-
-
/**
* Base class for predicated integer operations.
*/
class PredOp : public ArmStaticInst
{
- protected:
+ protected:
- uint32_t condCode;
+ ArmISA::ConditionCode condCode;
- /// Constructor
- PredOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
- ArmStaticInst(mnem, _machInst, __opClass),
- condCode(COND_CODE)
- {
- }
+ /// Constructor
+ PredOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
+ ArmStaticInst(mnem, _machInst, __opClass),
+ condCode((ArmISA::ConditionCode)COND_CODE)
+ {
+ }
- std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
+ std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
};
/**
%(op_rd)s;
%(code)s;
- if (arm_predicate(xc->readMiscReg(ArmISA::CPSR), condCode))
+ if (testPredicate(xc->readMiscReg(ArmISA::MISCREG_CPSR), condCode))
{
if (fault == NoFault)
{
#Memory Operand
'Mem': ('Mem', 'uw', None, ('IsMemRef', 'IsLoad', 'IsStore'), 8),
- 'Cpsr': ('ControlReg', 'uw', 'CPSR', 'IsInteger', 7),
- 'Fpsr': ('ControlReg', 'uw', 'FPSR', 'IsInteger', 7),
+ 'Cpsr': ('ControlReg', 'uw', 'MISCREG_CPSR', 'IsInteger', 7),
+ 'Fpsr': ('ControlReg', 'uw', 'MISCREG_FPSR', 'IsInteger', 7),
'NPC': ('NPC', 'uw', None, (None, None, 'IsControl'), 9),
'NNPC': ('NNPC', 'uw', None, (None, None, 'IsControl'), 9),
--- /dev/null
+/*
+ * Copyright (c) 2009 The Regents of The University of Michigan
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Gabe Black
+ */
+#ifndef __ARCH_ARM_MISCREGS_HH__
+#define __ARCH_ARM_MISCREGS_HH__
+
+#include "base/bitunion.hh"
+
+namespace ArmISA
+{
+ enum ConditionCode {
+ COND_EQ = 0,
+ COND_NE, // 1
+ COND_CS, // 2
+ COND_CC, // 3
+ COND_MI, // 4
+ COND_PL, // 5
+ COND_VS, // 6
+ COND_VC, // 7
+ COND_HI, // 8
+ COND_LS, // 9
+ COND_GE, // 10
+ COND_LT, // 11
+ COND_GT, // 12
+ COND_LE, // 13
+ COND_AL, // 14
+ COND_NV // 15
+ };
+
+ enum MiscRegIndex {
+ MISCREG_CPSR = 0,
+ MISCREG_SPSR_FIQ,
+ MISCREG_SPSR_IRQ,
+ MISCREG_SPSR_SVC,
+ MISCREG_SPSR_UND,
+ MISCREG_SPSR_ABT,
+ MISCREG_FPSR
+ };
+
+ BitUnion32(CPSR)
+ Bitfield<31> n;
+ Bitfield<30> z;
+ Bitfield<29> c;
+ Bitfield<28> v;
+ Bitfield<27> q;
+ Bitfield<24> j;
+ Bitfield<19, 16> ge;
+ Bitfield<9> e;
+ Bitfield<8> a;
+ Bitfield<7> i;
+ Bitfield<6> f;
+ Bitfield<5> t;
+ Bitfield<4, 0> mode;
+ EndBitUnion(CPSR)
+};
+
+#endif // __ARCH_ARM_MISCREGS_HH__
return "";
}
- //Coprocessor 0 Register Names
- enum MiscRegTags {
- // Status Registers for the ARM
- //
- // CPSR Layout
- // 31302928 ... 7 6 5 4 3 2 1 0
- // N Z C V ... I F T { MODE }
- CPSR = 0,
- SPSR_FIQ,
- SPSR_IRQ,
- SPSR_SVC,
- SPSR_UND,
- SPSR_ABT,
- FPSR
- };
-
class MiscRegFile {
protected:
#ifndef __ARCH_ARM_UTILITY_HH__
#define __ARCH_ARM_UTILITY_HH__
+#include "arch/arm/miscregs.hh"
#include "arch/arm/types.hh"
#include "base/misc.hh"
#include "base/types.hh"
namespace ArmISA {
+ inline bool
+ testPredicate(CPSR cpsr, ConditionCode code)
+ {
+ switch (code)
+ {
+ case COND_EQ: return cpsr.z;
+ case COND_NE: return !cpsr.z;
+ case COND_CS: return cpsr.c;
+ case COND_CC: return !cpsr.c;
+ case COND_MI: return cpsr.n;
+ case COND_PL: return !cpsr.n;
+ case COND_VS: return cpsr.v;
+ case COND_VC: return !cpsr.v;
+ case COND_HI: return (cpsr.c && !cpsr.z);
+ case COND_LS: return !(cpsr.c && !cpsr.z);
+ case COND_GE: return !(cpsr.n ^ cpsr.v);
+ case COND_LT: return (cpsr.n ^ cpsr.v);
+ case COND_GT: return !(cpsr.n ^ cpsr.v || cpsr.z);
+ case COND_LE: return (cpsr.n ^ cpsr.v || cpsr.z);
+ case COND_AL: return true;
+ case COND_NV: return false;
+ default:
+ panic("Unhandled predicate condition: %d\n", code);
+ }
+ }
+
//Floating Point Utility Functions
uint64_t fpConvert(ConvertType cvt_type, double fp_val);
double roundFP(double val, int digits);