[llvm] 0bc68ca - [TableGen] Optimize SizeToOperandName iteration. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 27 12:41:59 PDT 2023
Author: Fangrui Song
Date: 2023-09-27T12:41:54-07:00
New Revision: 0bc68ca4278269dadd91f98a3cd0de62499d3ea3
URL: https://github.com/llvm/llvm-project/commit/0bc68ca4278269dadd91f98a3cd0de62499d3ea3
DIFF: https://github.com/llvm/llvm-project/commit/0bc68ca4278269dadd91f98a3cd0de62499d3ea3.diff
LOG: [TableGen] Optimize SizeToOperandName iteration. NFC
Added:
Modified:
llvm/utils/TableGen/InstrInfoEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp b/llvm/utils/TableGen/InstrInfoEmitter.cpp
index cfbea029020cc4d..b2250c0cf9897c5 100644
--- a/llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -22,6 +22,7 @@
#include "Types.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
@@ -474,7 +475,7 @@ void InstrInfoEmitter::emitOperandTypeMappings(
OS << "LLVM_READONLY\n";
OS << "static int getMemOperandSize(int OpType) {\n";
OS << " switch (OpType) {\n";
- std::map<int, std::vector<StringRef>> SizeToOperandName;
+ std::map<int, SmallVector<StringRef, 0>> SizeToOperandName;
for (const Record *Op : Operands) {
if (!Op->isSubClassOf("X86MemOperand"))
continue;
@@ -482,7 +483,7 @@ void InstrInfoEmitter::emitOperandTypeMappings(
SizeToOperandName[Size].push_back(Op->getName());
}
OS << " default: return 0;\n";
- for (auto KV : SizeToOperandName) {
+ for (const auto &KV : SizeToOperandName) {
for (const StringRef &OperandName : KV.second)
OS << " case OpTypes::" << OperandName << ":\n";
OS << " return " << KV.first << ";\n\n";
More information about the llvm-commits
mailing list