[llvm] 376b714 - [NFC][TableGen][DecoderEmitter] Use structured binding in range for loop (#144890)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 20 06:41:52 PDT 2025


Author: Rahul Joshi
Date: 2025-06-20T06:41:48-07:00
New Revision: 376b71442d03bcc8ec6e2244002e3d62916dcea4

URL: https://github.com/llvm/llvm-project/commit/376b71442d03bcc8ec6e2244002e3d62916dcea4
DIFF: https://github.com/llvm/llvm-project/commit/376b71442d03bcc8ec6e2244002e3d62916dcea4.diff

LOG: [NFC][TableGen][DecoderEmitter] Use structured binding in range for loop (#144890)

Also assign variable names to different elements of `OpMap` for better
readibility, and eliminate `NumberedEncodingsRef` as `std::vector` will
automatically get converted to an `ArrayRef`.

Added: 
    

Modified: 
    llvm/utils/TableGen/DecoderEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp
index 37814113b467a..2e8ff2aa47d96 100644
--- a/llvm/utils/TableGen/DecoderEmitter.cpp
+++ b/llvm/utils/TableGen/DecoderEmitter.cpp
@@ -2631,12 +2631,12 @@ namespace {
 
   DecoderTableInfo TableInfo;
   unsigned OpcodeMask = 0;
-  for (const auto &Opc : OpcMap) {
+  for (const auto &[NSAndByteSize, EncodingIDs] : OpcMap) {
+    const std::string &DecoderNamespace = NSAndByteSize.first;
+    const unsigned BitWidth = 8 * NSAndByteSize.second;
     // Emit the decoder for this namespace+width combination.
-    ArrayRef<EncodingAndInst> NumberedEncodingsRef(NumberedEncodings.data(),
-                                                   NumberedEncodings.size());
-    FilterChooser FC(NumberedEncodingsRef, Opc.second, Operands,
-                     IsVarLenInst ? MaxInstLen : 8 * Opc.first.second, this);
+    FilterChooser FC(NumberedEncodings, EncodingIDs, Operands,
+                     IsVarLenInst ? MaxInstLen : BitWidth, this);
 
     // The decode table is cleared for each top level decoder function. The
     // predicates and decoders themselves, however, are shared across all
@@ -2657,7 +2657,7 @@ namespace {
 
     // Print the table to the output stream.
     OpcodeMask |= emitTable(OS, TableInfo.Table, indent(0), FC.getBitWidth(),
-                            Opc.first.first, Opc.second);
+                            DecoderNamespace, EncodingIDs);
   }
 
   // For variable instruction, we emit a instruction length table


        


More information about the llvm-commits mailing list