[llvm] [TableGen] Use StringMap in getValueType instead of StringSwitch (PR #213229)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 31 04:22:02 PDT 2026


================
@@ -43,12 +43,13 @@ static cl::opt<unsigned>
 /// Returns the MVT that the specified TableGen
 /// record corresponds to.
 MVT llvm::getValueType(const Record *Rec) {
-  return StringSwitch<MVT>(Rec->getValueAsString("LLVMName"))
+  static const StringMap<MVT> ValueTypes = {
----------------
aengelke wrote:

StringMap stores copies of the strings, which seems unnecessary here for constant strings? If StringMap is faster than DenseMap<StringRef>, this should be investigated separately.

https://github.com/llvm/llvm-project/pull/213229


More information about the llvm-commits mailing list