[llvm] [TableGen] Rework `EmitIntrinsicToBuiltinMap` (PR #104681)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 17:02:10 PDT 2024


================
@@ -596,89 +598,178 @@ void IntrinsicEmitter::EmitIntrinsicToBuiltinMap(
     const CodeGenIntrinsicTable &Ints, bool IsClang, raw_ostream &OS) {
   StringRef CompilerName = IsClang ? "Clang" : "MS";
   StringRef UpperCompilerName = IsClang ? "CLANG" : "MS";
-  // map<TargetPrefix, map<BuiltinName, EnumName>>. Note that we iterate over
-  // both maps in the code below. For the inner map, entries need to be emitted
-  // in the sorted order of `BuiltinName` because we use std::lower_bound to
-  // search these entries. For the outer map, it doesn't need be be sorted, but
-  // we use a map to eliminate non-determinism in the emitted code.
-  typedef std::map<StringRef, std::map<StringRef, StringRef>> BIMTy;
-  BIMTy BuiltinMap;
-  StringToOffsetTable Table;
+
+  // map<TargetPrefix, pair<map<BuiltinName, EnumName>, CommonPrefix>.
+  // Note that we iterate over both the maps in the code below and both
+  // iterations need to iterate in sorted key order. For the inner map, entries
+  // need to be emitted in the sorted order of `BuiltinName - CommonPrefix`
----------------
Artem-B wrote:

> in the sorted order of `BuiltinName - CommonPrefix`

This notation is confusing. I guess it may have been intended to mean "BuiltinString without CommonPrefix",  IIUIC, the intent is that  we still need to sort by the builtin name, but we'll optimize the search a bit by skipping the common prefix. If that's the case, perhaps we should rephrase it to make it clear. Subtraction as an operation on strings is not particularly intuitive. 

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


More information about the llvm-commits mailing list