[llvm] r259336 - [TableGen] Store result of getInstructionsByEnumValue in an ArrayRef instead of accidentally copying to a vector.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 31 17:33:42 PST 2016
Author: ctopper
Date: Sun Jan 31 19:33:42 2016
New Revision: 259336
URL: http://llvm.org/viewvc/llvm-project?rev=259336&view=rev
Log:
[TableGen] Store result of getInstructionsByEnumValue in an ArrayRef instead of accidentally copying to a vector.
Modified:
llvm/trunk/utils/TableGen/CodeEmitterGen.cpp
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/trunk/utils/TableGen/CodeGenMapTable.cpp
llvm/trunk/utils/TableGen/DisassemblerEmitter.cpp
llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=259336&r1=259335&r2=259336&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Sun Jan 31 19:33:42 2016
@@ -227,7 +227,7 @@ void CodeEmitterGen::run(raw_ostream &o)
// For little-endian instruction bit encodings, reverse the bit order
Target.reverseBitsForLittleEndianEncoding();
- const std::vector<const CodeGenInstruction*> &NumberedInstructions =
+ ArrayRef<const CodeGenInstruction*> NumberedInstructions =
Target.getInstructionsByEnumValue();
// Emit function declaration
@@ -238,11 +238,7 @@ void CodeEmitterGen::run(raw_ostream &o)
// Emit instruction base values
o << " static const uint64_t InstBits[] = {\n";
- for (std::vector<const CodeGenInstruction*>::const_iterator
- IN = NumberedInstructions.begin(),
- EN = NumberedInstructions.end();
- IN != EN; ++IN) {
- const CodeGenInstruction *CGI = *IN;
+ for (const CodeGenInstruction *CGI : NumberedInstructions) {
Record *R = CGI->TheDef;
if (R->getValueAsString("Namespace") == "TargetOpcode" ||
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=259336&r1=259335&r2=259336&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Sun Jan 31 19:33:42 2016
@@ -3249,7 +3249,7 @@ void CodeGenDAGPatterns::AddPatternToMat
void CodeGenDAGPatterns::InferInstructionFlags() {
- const std::vector<const CodeGenInstruction*> &Instructions =
+ ArrayRef<const CodeGenInstruction*> Instructions =
Target.getInstructionsByEnumValue();
// First try to infer flags from the primary instruction pattern, if any.
Modified: llvm/trunk/utils/TableGen/CodeGenMapTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenMapTable.cpp?rev=259336&r1=259335&r2=259336&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenMapTable.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenMapTable.cpp Sun Jan 31 19:33:42 2016
@@ -355,7 +355,7 @@ Record *MapTableEmitter::getInstrForColu
unsigned MapTableEmitter::emitBinSearchTable(raw_ostream &OS) {
- const std::vector<const CodeGenInstruction*> &NumberedInstructions =
+ ArrayRef<const CodeGenInstruction*> NumberedInstructions =
Target.getInstructionsByEnumValue();
std::string TargetName = Target.getName();
const std::vector<ListInit*> &ValueCols = InstrMapDesc.getValueCols();
Modified: llvm/trunk/utils/TableGen/DisassemblerEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DisassemblerEmitter.cpp?rev=259336&r1=259335&r2=259336&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DisassemblerEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/DisassemblerEmitter.cpp Sun Jan 31 19:33:42 2016
@@ -111,7 +111,7 @@ void EmitDisassembler(RecordKeeper &Reco
if (Target.getName() == "X86") {
DisassemblerTables Tables;
- const std::vector<const CodeGenInstruction*> &numberedInstructions =
+ ArrayRef<const CodeGenInstruction*> numberedInstructions =
Target.getInstructionsByEnumValue();
for (unsigned i = 0, e = numberedInstructions.size(); i != e; ++i)
Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=259336&r1=259335&r2=259336&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Sun Jan 31 19:33:42 2016
@@ -59,12 +59,12 @@ private:
raw_ostream &OS);
void emitOperandTypesEnum(raw_ostream &OS, const CodeGenTarget &Target);
void initOperandMapData(
- const std::vector<const CodeGenInstruction *> &NumberedInstructions,
+ ArrayRef<const CodeGenInstruction *> NumberedInstructions,
const std::string &Namespace,
std::map<std::string, unsigned> &Operands,
OpNameMapTy &OperandMap);
void emitOperandNameMappings(raw_ostream &OS, const CodeGenTarget &Target,
- const std::vector<const CodeGenInstruction*> &NumberedInstructions);
+ ArrayRef<const CodeGenInstruction*> NumberedInstructions);
// Operand information.
void EmitOperandInfo(raw_ostream &OS, OperandInfoMapTy &OperandInfoIDs);
@@ -198,7 +198,7 @@ void InstrInfoEmitter::EmitOperandInfo(r
/// each instructions. This is used to generate the OperandMap table as
/// well as the getNamedOperandIdx() function.
void InstrInfoEmitter::initOperandMapData(
- const std::vector<const CodeGenInstruction *> &NumberedInstructions,
+ ArrayRef<const CodeGenInstruction *> NumberedInstructions,
const std::string &Namespace,
std::map<std::string, unsigned> &Operands,
OpNameMapTy &OperandMap) {
@@ -234,7 +234,7 @@ void InstrInfoEmitter::initOperandMapDat
/// OpName enum
void InstrInfoEmitter::emitOperandNameMappings(raw_ostream &OS,
const CodeGenTarget &Target,
- const std::vector<const CodeGenInstruction*> &NumberedInstructions) {
+ ArrayRef<const CodeGenInstruction*> NumberedInstructions) {
const std::string &Namespace = Target.getInstNamespace();
std::string OpNameNS = "OpName";
@@ -380,7 +380,7 @@ void InstrInfoEmitter::run(raw_ostream &
// Emit all of the MCInstrDesc records in their ENUM ordering.
//
OS << "\nextern const MCInstrDesc " << TargetName << "Insts[] = {\n";
- const std::vector<const CodeGenInstruction*> &NumberedInstructions =
+ ArrayRef<const CodeGenInstruction*> NumberedInstructions =
Target.getInstructionsByEnumValue();
SequenceToOffsetTable<std::string> InstrNames;
@@ -577,7 +577,7 @@ void InstrInfoEmitter::emitEnums(raw_ost
if (Namespace.empty())
PrintFatalError("No instructions defined!");
- const std::vector<const CodeGenInstruction*> &NumberedInstructions =
+ ArrayRef<const CodeGenInstruction*> NumberedInstructions =
Target.getInstructionsByEnumValue();
OS << "namespace " << Namespace << " {\n";
More information about the llvm-commits
mailing list