summaryrefslogtreecommitdiff
path: root/src/arch/arm/decoder.cc
diff options
context:
space:
mode:
authorAndreas Sandberg <Andreas.Sandberg@ARM.com>2014-12-23 09:31:17 -0500
committerAndreas Sandberg <Andreas.Sandberg@ARM.com>2014-12-23 09:31:17 -0500
commitb33812ba430bba0ab5ff4e6372b47f4b323f0891 (patch)
tree64a538067d4daf9dbb5c4b94e7612a540af0d5b3 /src/arch/arm/decoder.cc
parent070b4a81dbf9cc040ecb771e128993ae519cf80f (diff)
downloadgem5-b33812ba430bba0ab5ff4e6372b47f4b323f0891.tar.xz
arm: Clean up and document decoder API
This changeset adds more documentation to the ArmISA::Decoder class and restructures it slightly to make API groups more obvious.
Diffstat (limited to 'src/arch/arm/decoder.cc')
-rw-r--r--src/arch/arm/decoder.cc52
1 files changed, 49 insertions, 3 deletions
diff --git a/src/arch/arm/decoder.cc b/src/arch/arm/decoder.cc
index 940d85b8e..f57e340de 100644
--- a/src/arch/arm/decoder.cc
+++ b/src/arch/arm/decoder.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 ARM Limited
+ * Copyright (c) 2012-2014 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -51,6 +51,23 @@ namespace ArmISA
GenericISA::BasicDecodeCache Decoder::defaultCache;
+Decoder::Decoder()
+ : data(0), fpscrLen(0), fpscrStride(0)
+{
+ reset();
+}
+
+void
+Decoder::reset()
+{
+ bigThumb = false;
+ offset = 0;
+ emi = 0;
+ instDone = false;
+ outOfBytes = true;
+ foundIt = false;
+}
+
void
Decoder::process()
{
@@ -118,8 +135,15 @@ Decoder::process()
}
}
-//Use this to give data to the decoder. This should be used
-//when there is control flow.
+void
+Decoder::consumeBytes(int numBytes)
+{
+ offset += numBytes;
+ assert(offset <= sizeof(MachInst));
+ if (offset == sizeof(MachInst))
+ outOfBytes = true;
+}
+
void
Decoder::moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
{
@@ -134,4 +158,26 @@ Decoder::moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
process();
}
+StaticInstPtr
+Decoder::decode(ArmISA::PCState &pc)
+{
+ if (!instDone)
+ return NULL;
+
+ const int inst_size((!emi.thumb || emi.bigThumb) ? 4 : 2);
+ ExtMachInst this_emi(emi);
+
+ pc.npc(pc.pc() + inst_size);
+ if (foundIt)
+ pc.nextItstate(itBits);
+ this_emi.itstate = pc.itstate();
+ pc.size(inst_size);
+
+ emi = 0;
+ instDone = false;
+ foundIt = false;
+
+ return decode(this_emi, pc.instAddr());
+}
+
}