llvm.org GIT mirror llvm / 21022f9
[RISCV] Replace map with set in getReqFeatures Summary: Use a set in getReqFeatures() in RISCVCompressInstEmitter instead of a map because the index we save is not needed. This also fixes bug 41666. Reviewers: llvm-commits, apazos, asb, nickdesaulniers Reviewed By: asb Subscribers: Jim, nickdesaulniers, rbar, johnrusso, simoncook, niosHD, kito-cheng, shiva0217, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna Tags: #llvm Differential Revision: https://reviews.llvm.org/D61412 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362968 91177308-0d34-0410-b5e6-96231b3b80d8 Sameer AbuAsal 2 months ago
1 changed file(s) with 7 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
6363 #include "llvm/TableGen/Error.h"
6464 #include "llvm/TableGen/Record.h"
6565 #include "llvm/TableGen/TableGenBackend.h"
66 #include
6667 #include
6768 using namespace llvm;
6869
473474 SourceOperandMap, DestOperandMap));
474475 }
475476
476 static void getReqFeatures(std::map &FeaturesMap,
477 static void getReqFeatures(std::set &FeaturesSet,
477478 const std::vector &ReqFeatures) {
478479 for (auto &R : ReqFeatures) {
479480 StringRef AsmCondString = R->getValueAsString("AssemblerCondString");
482483 SmallVector Ops;
483484 SplitString(AsmCondString, Ops, ",");
484485 assert(!Ops.empty() && "AssemblerCondString cannot be empty");
485
486486 for (auto &Op : Ops) {
487487 assert(!Op.empty() && "Empty operator");
488 if (FeaturesMap.find(Op) == FeaturesMap.end())
489 FeaturesMap[Op] = FeaturesMap.size();
488 FeaturesSet.insert(Op);
490489 }
491490 }
492491 }
619618 CaseStream.indent(4) << "case " + Namespace + "::" + CurOp + ": {\n";
620619 }
621620
622 std::map FeaturesMap;
621 std::set FeaturesSet;
623622 // Add CompressPat required features.
624 getReqFeatures(FeaturesMap, CompressPat.PatReqFeatures);
623 getReqFeatures(FeaturesSet, CompressPat.PatReqFeatures);
625624
626625 // Add Dest instruction required features.
627626 std::vector ReqFeatures;
629628 copy_if(RF, std::back_inserter(ReqFeatures), [](Record *R) {
630629 return R->getValueAsBit("AssemblerMatcherPredicate");
631630 });
632 getReqFeatures(FeaturesMap, ReqFeatures);
631 getReqFeatures(FeaturesSet, ReqFeatures);
633632
634633 // Emit checks for all required features.
635 for (auto &F : FeaturesMap) {
636 StringRef Op = F.first;
634 for (auto &Op : FeaturesSet) {
637635 if (Op[0] == '!')
638636 CondStream.indent(6) << ("!STI.getFeatureBits()[" + Namespace +
639637 "::" + Op.substr(1) + "]")