[llvm] [TableGen] Introduce a less aggressive suppression for HwMode Decoder… (PR #86060)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 21:40:25 PDT 2024
================
@@ -2417,21 +2436,67 @@ static bool Check(DecodeStatus &Out, DecodeStatus In) {
// Collect all HwModes referenced by the target for encoding purposes,
// returning a vector of corresponding names.
-static void
-collectHwModesReferencedForEncodings(const CodeGenHwModes &HWM,
- std::vector<StringRef> &Names) {
+static void collectHwModesReferencedForEncodings(
+ const CodeGenHwModes &HWM, std::vector<StringRef> &Names,
+ NamespacesHwModesMap &NamespacesWithHwModes) {
SmallBitVector BV(HWM.getNumModeIds());
for (const auto &MS : HWM.getHwModeSelects()) {
for (const HwModeSelect::PairType &P : MS.second.Items) {
- if (P.second->isSubClassOf("InstructionEncoding"))
+ if (P.second->isSubClassOf("InstructionEncoding")) {
+ std::string DecoderNamespace =
+ std::string(P.second->getValueAsString("DecoderNamespace"));
+ if (P.first == DefaultMode) {
+ NamespacesWithHwModes[DecoderNamespace][""] = 1;
+ } else {
+ NamespacesWithHwModes[DecoderNamespace][HWM.getMode(P.first).Name] =
+ 1;
+ }
BV.set(P.first);
+ }
}
}
transform(BV.set_bits(), std::back_inserter(Names), [&HWM](const int &M) {
+ if (M == DefaultMode)
+ return StringRef("");
return HWM.getModeName(M, /*IncludeDefault=*/true);
});
}
+static void
+handleHwModesUnrelatedEncodings(const CodeGenInstruction *Instr,
+ const std::vector<StringRef> &HwModeNames,
+ NamespacesHwModesMap &NamespacesWithHwModes,
+ std::vector<EncodingAndInst> &GlobalEncodings) {
+ const Record *InstDef = Instr->TheDef;
+
+ switch (DecoderEmitterSuppressDuplicates) {
+ case SUPPRESSION_DISABLE: {
+ for (StringRef HwModeName : HwModeNames)
+ GlobalEncodings.emplace_back(InstDef, Instr, HwModeName);
+ break;
+ }
+ case SUPPRESSION_LEVEL1: {
+ std::string DecoderNamespace =
+ std::string(InstDef->getValueAsString("DecoderNamespace"));
+ for (StringRef HwModeName : HwModeNames) {
+ if (NamespacesWithHwModes.count(DecoderNamespace) > 0) {
----------------
topperc wrote:
Can we do this map lookup outside the loop? It's independent of HwModeName
https://github.com/llvm/llvm-project/pull/86060
More information about the llvm-commits
mailing list