From: Craig Topper Date: Sun, 17 Jan 2021 05:18:52 +0000 (-0800) Subject: [RISCV] Remove an extra map lookup from RISCVCompressInstEmitter. NFC X-Git-Tag: llvmorg-13-init~988 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=061f681c0dfa4d279dc656802bf81f3b9bfa3d34;p=platform%2Fupstream%2Fllvm.git [RISCV] Remove an extra map lookup from RISCVCompressInstEmitter. NFC When we looked up the map to see if the entry already existed, this created the new entry for us. So save a reference to it so we can use it to update the entry instead of looking it up again. Also remove unnecessary StringRef constructors around string literals on calls to this function. --- diff --git a/llvm/utils/TableGen/RISCVCompressInstEmitter.cpp b/llvm/utils/TableGen/RISCVCompressInstEmitter.cpp index 8f781c9..beb9266 100644 --- a/llvm/utils/TableGen/RISCVCompressInstEmitter.cpp +++ b/llvm/utils/TableGen/RISCVCompressInstEmitter.cpp @@ -509,14 +509,13 @@ getReqFeatures(std::set> &FeaturesSet, static unsigned getPredicates(DenseMap &PredicateMap, std::vector &Predicates, Record *Rec, StringRef Name) { - unsigned Entry = PredicateMap[Rec]; + unsigned &Entry = PredicateMap[Rec]; if (Entry) return Entry; if (!Rec->isValueUnset(Name)) { Predicates.push_back(Rec); Entry = Predicates.size(); - PredicateMap[Rec] = Entry; return Entry; } @@ -751,14 +750,16 @@ void RISCVCompressInstEmitter::emitCompressInstEmitter(raw_ostream &o, } else { // Handling immediate operands. if (CompressOrUncompress) { - unsigned Entry = getPredicates(MCOpPredicateMap, MCOpPredicates, - DestOperand.Rec, StringRef("MCOperandPredicate")); + unsigned Entry = + getPredicates(MCOpPredicateMap, MCOpPredicates, DestOperand.Rec, + "MCOperandPredicate"); CondStream.indent(6) << Namespace << "ValidateMCOperand(" << "MI.getOperand(" << OpIdx << "), STI, " << Entry << ") &&\n"; } else { - unsigned Entry = getPredicates(ImmLeafPredicateMap, ImmLeafPredicates, - DestOperand.Rec, StringRef("ImmediateCode")); + unsigned Entry = + getPredicates(ImmLeafPredicateMap, ImmLeafPredicates, + DestOperand.Rec, "ImmediateCode"); CondStream.indent(6) << "MI.getOperand(" << OpIdx << ").isImm() &&\n"; CondStream.indent(6) << Namespace << "ValidateMachineOperand(" @@ -774,14 +775,14 @@ void RISCVCompressInstEmitter::emitCompressInstEmitter(raw_ostream &o, case OpData::Imm: { if (CompressOrUncompress) { unsigned Entry = getPredicates(MCOpPredicateMap, MCOpPredicates, - DestOperand.Rec, StringRef("MCOperandPredicate")); + DestOperand.Rec, "MCOperandPredicate"); CondStream.indent(6) << Namespace << "ValidateMCOperand(" << "MCOperand::createImm(" << DestOperandMap[OpNo].Data.Imm << "), STI, " << Entry << ") &&\n"; } else { unsigned Entry = getPredicates(ImmLeafPredicateMap, ImmLeafPredicates, - DestOperand.Rec, StringRef("ImmediateCode")); + DestOperand.Rec, "ImmediateCode"); CondStream.indent(6) << Namespace << "ValidateMachineOperand(MachineOperand::CreateImm("