/*
+ * Copyright (c) 2010 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
* Copyright (c) 2006 The Regents of The University of Michigan
* Copyright (c) 2007-2008 The Florida State University
* All rights reserved.
#define __ARCH_ARM_PREDECODER_HH__
#include "arch/arm/types.hh"
-#include "base/misc.hh"
-#include "sim/host.hh"
+#include "arch/arm/miscregs.hh"
+#include "base/types.hh"
class ThreadContext;
ThreadContext * tc;
//The extended machine instruction being generated
ExtMachInst emi;
+ MachInst data;
+ bool bigThumb;
+ int offset;
+ ITSTATE itstate;
public:
- Predecoder(ThreadContext * _tc) : tc(_tc)
- {}
+ void reset()
+ {
+ bigThumb = false;
+ offset = 0;
+ emi = 0;
+ }
+
+ Predecoder(ThreadContext * _tc) :
+ tc(_tc), data(0)
+ {
+ reset();
+ }
ThreadContext * getTC()
{
return tc;
}
- void setTC(ThreadContext * _tc)
+ void
+ setTC(ThreadContext * _tc)
{
tc = _tc;
}
- void process()
- {}
-
- void reset()
- {}
+ void advanceThumbCond();
+ void process();
//Use this to give data to the predecoder. This should be used
//when there is control flow.
- void moreBytes(Addr pc, Addr fetchPC, MachInst inst)
- {
- emi = inst;
- }
+ void moreBytes(Addr pc, Addr fetchPC, MachInst inst);
//Use this to give data to the predecoder. This should be used
//when instructions are executed in order.
bool needMoreBytes()
{
- return true;
+ return sizeof(MachInst) > offset;
}
bool extMachInstReady()
{
- return true;
+ // The only way an instruction wouldn't be ready is if this is a
+ // 32 bit ARM instruction that's not 32 bit aligned.
+ return !bigThumb;
+ }
+
+ int getInstSize()
+ {
+ return (!emi.thumb || emi.bigThumb) ? 4 : 2;
}
//This returns a constant reference to the ExtMachInst to avoid a copy
- const ExtMachInst & getExtMachInst()
+ ExtMachInst getExtMachInst()
{
- return emi;
+ ExtMachInst thisEmi = emi;
+ emi = 0;
+ return thisEmi;
}
};
};