LocationCode parseLocationCode(const char* s) { if (!*s) return InvalidLocationCode; switch (*s) { case 'L': return LL; case 'C': return LC; case 'H': return LH; case 'R': return LR; default: int incr = (s[1] == 'C'); switch (*s) { case 'G': return LocationCode(LGL + incr); case 'N': return LocationCode(LNL + incr); case 'S': return LocationCode(LSL + incr); } return InvalidLocationCode; } }
const uint8_t* ImmVector::findLastMember() const { assert(m_length > 0); // Loop that does basically the same as numStackValues(), except // stop at the last. const uint8_t* vec = m_start; const LocationCode locCode = LocationCode(*vec++); const int numLocImms = numLocationCodeImms(locCode); for (int i = 0; i < numLocImms; ++i) { decodeVariableSizeImm(&vec); } for (;;) { const uint8_t* ret = vec; MemberCode code = MemberCode(*vec++); if (memberCodeHasImm(code)) { decodeMemberCodeImm(&vec, code); } if (vec - m_start == m_length) { return ret; } assert(vec - m_start < m_length); } NOT_REACHED(); }
MInstrLocation getMLocation(const Op* opcode) { auto immVec = getImmVector(opcode); auto vec = immVec.vec(); auto const lcode = LocationCode(*vec++); auto const imm = numLocationCodeImms(lcode) ? decodeVariableSizeImm(&vec) : 0; return {lcode, imm}; }
std::vector<MVectorItem> getMVector(const Op* opcode) { auto immVec = getImmVector(opcode); std::vector<MVectorItem> result; auto it = immVec.vec(); auto end = it + immVec.size(); // Skip the LocationCode and its immediate auto const lcode = LocationCode(*it++); if (numLocationCodeImms(lcode)) decodeVariableSizeImm(&it); while (it < end) { auto const mcode = MemberCode(*it++); auto const imm = memberCodeHasImm(mcode) ? decodeMemberCodeImm(&it, mcode) : 0; result.push_back({mcode, imm}); } return result; }