[PATCH] D92423: [llvm-tblgen] Fixed 64-bit filters being sliced to 32 bits in FixedLenDecoderEmitter

Cameron via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 1 13:03:17 PST 2020


cameron314 created this revision.
cameron314 added a reviewer: Paul-C-Anagnostopoulos.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
cameron314 requested review of this revision.

When using the FixedLenDecoderEmitter, llvm-tblgen emits tables with (OPC_ExtractField, OPC_ExtractFilterValue) opcode sequences to match the contiguous fixed bits of a given instruction's encoding. This encoding is represented in a 64-bit integer. However, the filter values were represented in a 32-bit integer. As such, instructions with fixed 64-bit encodings (a rare case, but one which occurs in our backend) resulted in a table with an OPC_ExtractField for all 64 bits, followed by an OPC_ExtractFilterValue containing just the low 32 bits of their encoding, causing the filter never to match.

The exact point at which the slicing occurred is line 631.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92423

Files:
  llvm/utils/TableGen/FixedLenDecoderEmitter.cpp


Index: llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
===================================================================
--- llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
+++ llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
@@ -279,7 +279,7 @@
   std::vector<EncodingIDAndOpcode> VariableInstructions;
 
   // Map of well-known segment value to its delegate.
-  std::map<unsigned, std::unique_ptr<const FilterChooser>> FilterChooserMap;
+  std::map<uint64_t, std::unique_ptr<const FilterChooser>> FilterChooserMap;
 
   // Number of instructions which fall under FilteredInstructions category.
   unsigned NumFiltered;
@@ -305,7 +305,7 @@
   const FilterChooser &getVariableFC() const {
     assert(NumFiltered == 1);
     assert(FilterChooserMap.size() == 1);
-    return *(FilterChooserMap.find((unsigned)-1)->second);
+    return *(FilterChooserMap.find((uint64_t)-1)->second);
   }
 
   // Divides the decoding task into sub tasks and delegates them to the
@@ -603,7 +603,7 @@
     // Delegates to an inferior filter chooser for further processing on this
     // group of instructions whose segment values are variable.
     FilterChooserMap.insert(
-        std::make_pair(-1U, std::make_unique<FilterChooser>(
+        std::make_pair(-1ULL, std::make_unique<FilterChooser>(
                                 Owner->AllInstructions, VariableInstructions,
                                 Owner->Operands, BitValueArray, *Owner)));
   }
@@ -674,7 +674,7 @@
   for (auto &Filter : FilterChooserMap) {
     // Field value -1 implies a non-empty set of variable instructions.
     // See also recurse().
-    if (Filter.first == (unsigned)-1) {
+    if (Filter.first == (uint64_t)-1) {
       HasFallthrough = true;
 
       // Each scope should always have at least one filter value to check


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92423.308746.patch
Type: text/x-patch
Size: 1794 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201201/6d6ac0c3/attachment.bin>


More information about the llvm-commits mailing list