[Lldb-commits] [lldb] r125329 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h
Johnny Chen
johnny.chen at apple.com
Thu Feb 10 17:29:53 PST 2011
Author: johnny
Date: Thu Feb 10 19:29:53 2011
New Revision: 125329
URL: http://llvm.org/viewvc/llvm-project?rev=125329&view=rev
Log:
Add a helper method AddWithCarry() to the EmulateInstructionARM class.
Modified:
lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125329&r1=125328&r2=125329&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original)
+++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Thu Feb 10 19:29:53 2011
@@ -2595,6 +2595,27 @@
return (ArchVersion() >= ARMv7);
}
+// The main addition and subtraction instructions can produce status information
+// about both unsigned carry and signed overflow conditions. This status
+// information can be used to synthesize multi-word additions and subtractions.
+EmulateInstructionARM::AddWithCarryResult
+EmulateInstructionARM::AddWithCarry (uint32_t x, uint32_t y, uint8_t carry_in)
+{
+ uint32_t result;
+ uint8_t carry_out;
+ uint8_t overflow;
+
+ uint64_t unsigned_sum = x + y + carry_in;
+ int64_t signed_sum = (int32_t)x + (int32_t)y + (int32_t)carry_in;
+
+ result = UnsignedBits(unsigned_sum, 31, 0);
+ carry_out = (result == unsigned_sum ? 0 : 1);
+ overflow = ((int32_t)result == signed_sum ? 0 : 1);
+
+ AddWithCarryResult res = { result, carry_out, overflow };
+ return res;
+}
+
bool
EmulateInstructionARM::EvaluateInstruction ()
{
Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125329&r1=125328&r2=125329&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original)
+++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Thu Feb 10 19:29:53 2011
@@ -169,6 +169,16 @@
bool
UnalignedSupport();
+ typedef struct
+ {
+ uint32_t result;
+ uint8_t carry_out;
+ uint8_t overflow;
+ } AddWithCarryResult;
+
+ AddWithCarryResult
+ AddWithCarry(uint32_t x, uint32_t y, uint8_t carry_in);
+
protected:
// Typedef for the callback function used during the emulation.
More information about the lldb-commits
mailing list