From: Sandipan Das Date: Sat, 6 Feb 2021 11:51:45 +0000 (+0530) Subject: arch-power: Fix disassembly for shift instructions X-Git-Tag: develop-gem5-snapshot~25 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b576984bcebe4fc83dd6598823581679c081488e;p=gem5.git arch-power: Fix disassembly for shift instructions This fixes disassembly generated for integer shift instructions based on the type of operand used for the specifying the shift amount. Change-Id: I4985334e6eaa9c09ce2d4e79b23e1ae7a9cd28c3 Signed-off-by: Sandipan Das --- diff --git a/src/arch/power/insts/integer.cc b/src/arch/power/insts/integer.cc index 4c62f37ba..12344b3d9 100644 --- a/src/arch/power/insts/integer.cc +++ b/src/arch/power/insts/integer.cc @@ -584,8 +584,21 @@ IntShiftOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; + bool printSecondSrc = true; + bool printShift = false; - ccprintf(ss, "%-10s ", mnemonic); + // Generate the correct mnemonic + std::string myMnemonic(mnemonic); + + // Special cases + if (!myMnemonic.compare("srawi")) { + printSecondSrc = false; + printShift = true; + } + + // Additional characters depending on isa bits being set + if (rcSet) myMnemonic = myMnemonic + "."; + ccprintf(ss, "%-10s ", myMnemonic); // Print the first destination only if (_numDestRegs > 0) { @@ -598,10 +611,32 @@ IntShiftOp::generateDisassembly( ss << ", "; } printReg(ss, srcRegIdx(0)); + + // Print the second source register + if (printSecondSrc) { + + // If the instruction updates the CR, the destination register + // Ra is read and thus, it becomes the second source register + // due to its higher precedence over Rb. In this case, it must + // be skipped. + if (rcSet) { + if (_numSrcRegs > 2) { + ss << ", "; + printReg(ss, srcRegIdx(2)); + } + } else { + if (_numSrcRegs > 1) { + ss << ", "; + printReg(ss, srcRegIdx(1)); + } + } + } } - // Print the shift - ss << ", " << sh; + // Print the shift value + if (printShift) { + ss << ", " << shift; + } return ss.str(); }