summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2010-06-02 12:58:00 -0500
committerGabe Black <gblack@eecs.umich.edu>2010-06-02 12:58:00 -0500
commitbfe1a194ddf371a9520023765ade1070d89232d5 (patch)
tree9a947e5367e6a8af84f5a79de710452b133eb29d /src/arch
parent0116655674a93b1d05b97e531fe1849a5917dc9b (diff)
downloadgem5-bfe1a194ddf371a9520023765ade1070d89232d5.tar.xz
ARM: Add a function to decode 32 bit thumb immediate values.
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/arm/insts/static_inst.cc23
-rw-r--r--src/arch/arm/insts/static_inst.hh2
2 files changed, 25 insertions, 0 deletions
diff --git a/src/arch/arm/insts/static_inst.cc b/src/arch/arm/insts/static_inst.cc
index ffcef2508..77d329564 100644
--- a/src/arch/arm/insts/static_inst.cc
+++ b/src/arch/arm/insts/static_inst.cc
@@ -231,6 +231,29 @@ ArmStaticInstBase::arm_sub_overflow(int32_t result, int32_t lhs, int32_t rhs) co
return findOverflow(32, result, lhs, ~rhs);
}
+uint32_t
+ArmStaticInstBase::modified_imm(uint8_t ctrlImm, uint8_t dataImm) const
+{
+ uint32_t bigData = dataImm;
+ uint32_t bigCtrl = ctrlImm;
+ if (bigCtrl < 4) {
+ switch (bigCtrl) {
+ case 0:
+ return bigData;
+ case 1:
+ return bigData | (bigData << 16);
+ case 2:
+ return (bigData << 8) | (bigData << 24);
+ case 3:
+ return (bigData << 0) | (bigData << 8) |
+ (bigData << 16) | (bigData << 24);
+ }
+ }
+ bigCtrl = (bigCtrl << 1) | ((bigData >> 7) & 0x1);
+ bigData |= (1 << 7);
+ return bigData << (32 - bigCtrl);
+}
+
void
ArmStaticInstBase::printReg(std::ostream &os, int reg) const
{
diff --git a/src/arch/arm/insts/static_inst.hh b/src/arch/arm/insts/static_inst.hh
index 99fa819b5..ec33c73a2 100644
--- a/src/arch/arm/insts/static_inst.hh
+++ b/src/arch/arm/insts/static_inst.hh
@@ -66,6 +66,8 @@ class ArmStaticInstBase : public StaticInst
bool arm_add_overflow(int32_t result, int32_t lhs, int32_t rhs) const;
bool arm_sub_overflow(int32_t result, int32_t lhs, int32_t rhs) const;
+ uint32_t modified_imm(uint8_t ctrlImm, uint8_t dataImm) const;
+
// Constructor
ArmStaticInstBase(const char *mnem, ExtMachInst _machInst,
OpClass __opClass)