SPARC: Get rid of the copy/pasted StackTrace stolen from Alpha.
[gem5.git] / src / arch / arm / predecoder.hh
index 86d344b057d49e91f01cfae5c7d2909bbd0f8c6a..2db55002438ab8648598441cfe7d5286bcf02fba 100644 (file)
@@ -1,4 +1,16 @@
 /*
+ * 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.
@@ -34,8 +46,8 @@
 #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;
 
@@ -47,33 +59,42 @@ namespace ArmISA
         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.
@@ -84,18 +105,27 @@ namespace ArmISA
 
         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;
         }
     };
 };