From 780ff8e00ee7c9fcafd03c240219b616ecc046bd Mon Sep 17 00:00:00 2001 From: MerryMage Date: Wed, 23 Nov 2016 19:47:35 +0000 Subject: [PATCH] status_register_access: SEL: Use GetGEFlags --- .../translate_arm/status_register_access.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/frontend/translate/translate_arm/status_register_access.cpp b/src/frontend/translate/translate_arm/status_register_access.cpp index 12f75856..a8e52089 100644 --- a/src/frontend/translate/translate_arm/status_register_access.cpp +++ b/src/frontend/translate/translate_arm/status_register_access.cpp @@ -82,13 +82,7 @@ bool ArmTranslatorVisitor::arm_SEL(Cond cond, Reg n, Reg d, Reg m) { return UnpredictableInstruction(); if (ConditionPassed(cond)) { - auto cpsr = ir.GetCpsr(); - auto to = ir.GetRegister(m); - auto from = ir.GetRegister(n); - auto zero = ir.Imm1(false); - - // Extract bits 16:19 from the CPSR - auto bits = ir.And(ir.LogicalShiftRight(cpsr, ir.Imm8(16), zero).result, ir.Imm32(0xF)); + auto ge = ir.GetGEFlags(); // Perform some arithmetic to expand 0bXYZW into 0bXXXXXXXXYYYYYYYYZZZZZZZZWWWWWWWW => 0xXXYYZZWW // The logic behind this is as follows: @@ -97,10 +91,12 @@ bool ArmTranslatorVisitor::arm_SEL(Cond cond, Reg n, Reg d, Reg m) { // 0000 000x 0000 000y | 0000 000z 0000 000w (x & 0x01010101) // xxxx xxxx yyyy yyyy | zzzz zzzz wwww wwww (x * 0xff) - auto x2 = ir.Mul(bits, ir.Imm32(0x00204081)); + auto x2 = ir.Mul(ge, ir.Imm32(0x00204081)); auto x3 = ir.And(x2, ir.Imm32(0x01010101)); auto mask = ir.Mul(x3, ir.Imm32(0xFF)); + auto to = ir.GetRegister(m); + auto from = ir.GetRegister(n); auto result = ir.Or(ir.And(from, mask), ir.And(to, ir.Not(mask))); ir.SetRegister(d, result); }