diff options
Diffstat (limited to 'src/arch/arm/decoder.cc')
-rw-r--r-- | src/arch/arm/decoder.cc | 52 |
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()); +} + } |