summaryrefslogtreecommitdiff
path: root/src/arch/arm/insts
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2010-06-02 12:58:06 -0500
committerGabe Black <gblack@eecs.umich.edu>2010-06-02 12:58:06 -0500
commitbe888e67e71ac2ce6b6c265c5652435f682970c6 (patch)
tree2e7fe0dbbe45437056e47052f331a34388c3e0a1 /src/arch/arm/insts
parent5495ebd68d10e9472543dcd9c95e8b5a7a58a36b (diff)
downloadgem5-be888e67e71ac2ce6b6c265c5652435f682970c6.tar.xz
ARM: Implement the unsigned saturating instructions.
Diffstat (limited to 'src/arch/arm/insts')
-rw-r--r--src/arch/arm/insts/static_inst.hh17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/arch/arm/insts/static_inst.hh b/src/arch/arm/insts/static_inst.hh
index 634cf0812..3ff1d20cd 100644
--- a/src/arch/arm/insts/static_inst.hh
+++ b/src/arch/arm/insts/static_inst.hh
@@ -77,6 +77,23 @@ class ArmStaticInst : public StaticInst
}
}
+ template<int width>
+ static bool
+ uSaturateOp(uint32_t &res, int64_t op1, int64_t op2, bool sub=false)
+ {
+ int64_t midRes = sub ? (op1 - op2) : (op1 + op2);
+ if (midRes >= (1 << width)) {
+ res = (1 << width) - 1;
+ return true;
+ } else if (midRes < 0) {
+ res = 0;
+ return true;
+ } else {
+ res = midRes;
+ return false;
+ }
+ }
+
// Constructor
ArmStaticInst(const char *mnem, ExtMachInst _machInst,
OpClass __opClass)