From: Craig Topper Date: Fri, 16 Mar 2012 06:52:56 +0000 (+0000) Subject: More const-correcting of FixedLenDecoderEmitter. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=5a4c790c06a8884b208611f63d8623da9a93b7e7;p=oota-llvm.git More const-correcting of FixedLenDecoderEmitter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152906 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp index 357dca94e8f..10e04a60ddd 100644 --- a/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -126,7 +126,7 @@ typedef std::vector insn_t; /// version and return the Opcode since the two have the same Asm format string. class Filter { protected: - FilterChooser *Owner; // points to the FilterChooser who owns this filter + const FilterChooser *Owner;// points to the FilterChooser who owns this filter unsigned StartBit; // the starting bit position unsigned NumBits; // number of bits to filter bool Mixed; // a mixed region contains both set and unset bits @@ -214,10 +214,10 @@ protected: const std::vector &AllInstructions; // Vector of uid's for this filter chooser to work on. - const std::vector Opcodes; + const std::vector &Opcodes; // Lookup table for the operand decoding of instructions. - std::map > &Operands; + const std::map > &Operands; // Vector of candidate filters. std::vector Filters; @@ -227,7 +227,7 @@ protected: std::vector FilterBitValues; // Links to the FilterChooser above us in the decoding tree. - FilterChooser *Parent; + const FilterChooser *Parent; // Index of the best filter from Filters. int BestIndex; @@ -248,7 +248,7 @@ public: FilterChooser(const std::vector &Insts, const std::vector &IDs, - std::map > &Ops, + const std::map > &Ops, unsigned BW, const FixedLenDecoderEmitter *E) : AllInstructions(Insts), Opcodes(IDs), Operands(Ops), Filters(), @@ -261,9 +261,9 @@ public: FilterChooser(const std::vector &Insts, const std::vector &IDs, - std::map > &Ops, - std::vector &ParentFilterBitValues, - FilterChooser &parent) + const std::map > &Ops, + const std::vector &ParentFilterBitValues, + const FilterChooser &parent) : AllInstructions(Insts), Opcodes(IDs), Operands(Ops), Filters(), FilterBitValues(ParentFilterBitValues), Parent(&parent), BestIndex(-1), BitWidth(parent.BitWidth), @@ -903,8 +903,10 @@ bool FilterChooser::emitSingletonDecoder(raw_ostream &o, unsigned &Indentation, o << ") {\n"; emitSoftFailCheck(o, Indentation+2, Opc); o.indent(Indentation) << " MI.setOpcode(" << Opc << ");\n"; - std::vector& InsnOperands = Operands[Opc]; - for (std::vector::iterator + std::map >::const_iterator OpIter = + Operands.find(Opc); + const std::vector& InsnOperands = OpIter->second; + for (std::vector::const_iterator I = InsnOperands.begin(), E = InsnOperands.end(); I != E; ++I) { // If a custom instruction decoder was specified, use that. if (I->numFields() == 0 && I->Decoder.size()) { @@ -954,8 +956,10 @@ bool FilterChooser::emitSingletonDecoder(raw_ostream &o, unsigned &Indentation, } emitSoftFailCheck(o, Indentation+2, Opc); o.indent(Indentation) << " MI.setOpcode(" << Opc << ");\n"; - std::vector& InsnOperands = Operands[Opc]; - for (std::vector::iterator + std::map >::const_iterator OpIter = + Operands.find(Opc); + const std::vector& InsnOperands = OpIter->second; + for (std::vector::const_iterator I = InsnOperands.begin(), E = InsnOperands.end(); I != E; ++I) { // If a custom instruction decoder was specified, use that. if (I->numFields() == 0 && I->Decoder.size()) { @@ -1372,7 +1376,7 @@ static bool populateInstruction(const CodeGenInstruction &CGI, unsigned Opc, } // For each operand, see if we can figure out where it is encoded. - for (std::vector >::iterator + for (std::vector >::const_iterator NI = InOutOperands.begin(), NE = InOutOperands.end(); NI != NE; ++NI) { std::string Decoder = "";