// copy first instruction DWORD
instData = iFmt[0];
+ if (hasSecondDword(iFmt)) {
+ // copy second instruction DWORD into union
+ extData = ((MachInst)iFmt)[1];
+ _srcLiteral = *reinterpret_cast<uint32_t*>(&iFmt[1]);
+ varSize = 4 + 4;
+ } else {
+ varSize = 4;
+ } // if
} // Inst_SOPK
Inst_SOPK::~Inst_SOPK()
int
Inst_SOPK::instSize() const
{
- return 4;
+ return varSize;
} // instSize
+ bool
+ Inst_SOPK::hasSecondDword(InFmt_SOPK *iFmt)
+ {
+ /*
+ SOPK can be a 64-bit instruction, i.e., have a second dword:
+ S_SETREG_IMM32_B32 writes some or all of the LSBs of a 32-bit
+ literal constant into a hardware register;
+ the way to detect such special case is to explicitly check the
+ opcode (20/0x14)
+ */
+ if (iFmt->OP == 0x14)
+ return true;
+
+ return false;
+ }
+
+
void
Inst_SOPK::generateDisassembly()
{
std::stringstream dis_stream;
dis_stream << _opcode << " ";
- dis_stream << opSelectorToRegSym(instData.SDST) << ", ";
- dis_stream << "0x" << std::hex << std::setfill('0') << std::setw(4)
- << instData.SIMM16;
+ // S_SETREG_IMM32_B32 is a 64-bit instruction, using a
+ // 32-bit literal constant
+ if (instData.OP == 0x14) {
+ dis_stream << "0x" << std::hex << std::setfill('0')
+ << std::setw(8) << extData.imm_u32 << ", ";
+ } else {
+ dis_stream << opSelectorToRegSym(instData.SDST) << ", ";
+ }
+
+ dis_stream << "0x" << std::hex << std::setfill('0') << std::setw(4)
+ << instData.SIMM16;
disassembly = dis_stream.str();
}