Fold direction into memory format
Jeffrey Pfau jeffrey@endrift.com
Fri, 11 Jul 2014 01:27:32 -0700
2 files changed,
18 insertions(+),
21 deletions(-)
M
src/arm/decoder-thumb.c
→
src/arm/decoder-thumb.c
@@ -226,12 +226,11 @@ info->memory.baseReg = RN; \
info->op1.immediate = (opcode & 0xFF) | ADDITIONAL_REG; \ info->branches = info->op1.immediate & (1 << ARM_PC); \ info->operandFormat = ARM_OPERAND_MEMORY_1; \ - info->memory.direction = DIRECTION; \ info->memory.format = ARM_MEMORY_REGISTER_BASE | \ - ARM_MEMORY_POST_INCREMENT;) + ARM_MEMORY_POST_INCREMENT | DIRECTION;) #define DEFINE_LOAD_STORE_MULTIPLE_THUMB(NAME) \ - COUNT_3(DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB, NAME ## IA_R, NAME, ARM_INCREMENT_AFTER, 0) + COUNT_3(DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB, NAME ## IA_R, NAME, ARM_MEMORY_INCREMENT_AFTER, 0) DEFINE_LOAD_STORE_MULTIPLE_THUMB(LDM) DEFINE_LOAD_STORE_MULTIPLE_THUMB(STM)@@ -270,10 +269,10 @@
DEFINE_SP_MODIFY_THUMB(ADD7, ADD) DEFINE_SP_MODIFY_THUMB(SUB4, SUB) -DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(POP, ARM_SP, LDM, ARM_INCREMENT_AFTER, 0) -DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(POPR, ARM_SP, LDM, ARM_INCREMENT_AFTER, 1 << ARM_PC) -DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(PUSH, ARM_SP, STM, ARM_DECREMENT_BEFORE, 0) -DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(PUSHR, ARM_SP, STM, ARM_DECREMENT_BEFORE, 1 << ARM_LR) +DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(POP, ARM_SP, LDM, ARM_MEMORY_INCREMENT_AFTER, 0) +DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(POPR, ARM_SP, LDM, ARM_MEMORY_INCREMENT_AFTER, 1 << ARM_PC) +DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(PUSH, ARM_SP, STM, ARM_MEMORY_DECREMENT_BEFORE, 0) +DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(PUSHR, ARM_SP, STM, ARM_MEMORY_DECREMENT_BEFORE, 1 << ARM_LR) DEFINE_THUMB_DECODER(ILL, ILL, info->traps = 1;) DEFINE_THUMB_DECODER(BKPT, BKPT, info->traps = 1;)@@ -396,11 +395,11 @@ const char* flags = "";
switch (info.mnemonic) { case ARM_MN_LDM: case ARM_MN_STM: - flags = armDirectionStrings[info.memory.direction]; + flags = armDirectionStrings[MEMORY_FORMAT_TO_DIRECTION(info.memory.format)]; break; case ARM_MN_LDR: case ARM_MN_STR: - flags = armAccessTypeStrings[info.memory.direction]; + flags = armAccessTypeStrings[info.memory.width]; break; default: break;
M
src/arm/decoder.h
→
src/arm/decoder.h
@@ -43,8 +43,16 @@ ARM_MEMORY_REGISTER_OFFSET = 0x0004,
ARM_MEMORY_SHIFTED_OFFSET = 0x0008, ARM_MEMORY_PRE_INCREMENT = 0x0010, ARM_MEMORY_POST_INCREMENT = 0x0020, - ARM_MEMORY_OFFSET_SUBTRACT = 0x0040 + ARM_MEMORY_OFFSET_SUBTRACT = 0x0040, + + ARM_MEMORY_WRITEBACK = 0x0080, + ARM_MEMORY_DECREMENT_AFTER = 0x0000, + ARM_MEMORY_INCREMENT_AFTER = 0x0100, + ARM_MEMORY_DECREMENT_BEFORE = 0x0200, + ARM_MEMORY_INCREMENT_BEFORE = 0x0300, }; + +#define MEMORY_FORMAT_TO_DIRECTION(F) (((F) >> 8) & 0x7) enum ARMCondition { ARM_CONDITION_EQ = 0x0,@@ -77,13 +85,6 @@ };
int32_t immediate; }; -enum ARMMultipleDirection { - ARM_DECREMENT_AFTER = 0, - ARM_INCREMENT_AFTER = 1, - ARM_DECREMENT_BEFORE = 2, - ARM_INCREMENT_BEFORE = 3, -}; - enum ARMMemoryAccessType { ARM_ACCESS_WORD = 4, ARM_ACCESS_HALFWORD = 2,@@ -96,10 +97,7 @@ struct ARMMemoryAccess {
uint8_t baseReg; uint16_t format; union ARMOperand offset; - union { - enum ARMMultipleDirection direction; - enum ARMMemoryAccessType width; - }; + enum ARMMemoryAccessType width; }; enum ARMMnemonic {