Index: FixedLenDecoderEmitter.cpp =================================================================== --- FixedLenDecoderEmitter.cpp (revision 292532) +++ FixedLenDecoderEmitter.cpp (working copy) @@ -1701,6 +1701,22 @@ } } +static std::set all_rc; + +static void needRCDecode(Record *RC) { + all_rc.insert(RC); +} + +static void emitRCDecoders(formatted_raw_ostream &OS) { +#if 0 + while (not all_rc.empty()) + { + // Record *RC = *all_rc.begin(); + + } +#endif +} + static std::string findOperandDecoderMethod(TypedInit *TI) { std::string Decoder; @@ -1721,6 +1737,7 @@ if (TypeRecord->isSubClassOf("RegisterClass")) { Decoder = "Decode" + TypeRecord->getName().str() + "RegisterClass"; + needRCDecode(TypeRecord); } else if (TypeRecord->isSubClassOf("PointerLikeRegClass")) { Decoder = "DecodePointerLikeRegClass" + utostr(TypeRecord->getValueAsInt("RegClassKind")); @@ -1892,6 +1909,7 @@ TypeRecord = TypeRecord->getValueAsDef("RegClass"); if (TypeRecord->isSubClassOf("RegisterClass")) { Decoder = "Decode" + TypeRecord->getName().str() + "RegisterClass"; + needRCDecode(TypeRecord); isReg = true; } else if (TypeRecord->isSubClassOf("PointerLikeRegClass")) { Decoder = "DecodePointerLikeRegClass" + @@ -2302,6 +2320,8 @@ // Emit the predicate function. emitPredicateFunction(OS, TableInfo.Predicates, 0); + emitRCDecoders(OS); + // Emit the decoder function. emitDecoderFunction(OS, TableInfo.Decoders, 0); Index: RegisterInfoEmitter.cpp =================================================================== --- RegisterInfoEmitter.cpp (revision 292532) +++ RegisterInfoEmitter.cpp (working copy) @@ -1060,6 +1060,64 @@ } OS << "};\n"; // End of HW encoding table + // Emit Reg decoding tables + for (const auto &RC : RegisterClasses) { + ArrayRef Order = RC.getOrder(); + unsigned HWEncodingWidth; + int e = Order.size(); + for (HWEncodingWidth = 1; + (1L<getValueAsBitsInit("HWEncoding"); + uint64_t Value = 0; + for (unsigned b = 0, be = BI->getNumBits(); b != be; ++b) { + if (BitInit *B = dyn_cast(BI->getBit(b))) + Value |= (uint64_t)B->getValue() << b; + } + Value &= mask; + if (Value >= max) + max = Value; + } + for (uint64_t HWE = 0; HWE <= max; ++HWE) + { + bool found = false; + for (unsigned i = 0, e = Order.size(); i != e; ++i) { + auto Reg = Order[i]; + BitsInit *BI = Reg->getValueAsBitsInit("HWEncoding"); + uint64_t Value = 0; + for (unsigned b = 0, be = BI->getNumBits(); b != be; ++b) { + if (BitInit *B = dyn_cast(BI->getBit(b))) + Value |= (uint64_t)B->getValue() << b; + } + Value &= mask; + if (HWE == Value) { + // First of any aliases wins. + OS << " /* [" << Value << "] = */ " << getQualifiedName(Reg) <<",\n"; + found = true; + break; + } + } + if (not found) + OS << " 0,\n"; + } + OS << "};\n"; // End of HW decoding tables + } + // Emit the main register decoding table + OS << "const uint16_t *" << TargetName; + OS << "RegDecodingTable[] = {\n"; + for (const auto &RC : RegisterClasses) { + const std::string &Name = RC.getName(); + OS << " " << TargetName << "RegDecodingTable_" << Name << ",\n"; + } + OS << "};\n"; // End of the main register decoding table + // MCRegisterInfo initialization routine. OS << "static inline void Init" << TargetName << "MCRegisterInfo(MCRegisterInfo *RI, unsigned RA, "