[llvm] [NFC][DecoderEmitter] Arrange functions by class 1/N (PR #157107)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 5 06:34:30 PDT 2025
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/157107
None
>From 162a6ecf2ddccea3eee1377cf3e606162b4dc759 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Fri, 5 Sep 2025 06:28:35 -0700
Subject: [PATCH] [NFC][DecoderEmitter] Move some Filter/FilterChooser members
---
llvm/utils/TableGen/DecoderEmitter.cpp | 52 +++++++++++---------------
1 file changed, 21 insertions(+), 31 deletions(-)
diff --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp
index ebb7deb757c44..1fb8032716c7b 100644
--- a/llvm/utils/TableGen/DecoderEmitter.cpp
+++ b/llvm/utils/TableGen/DecoderEmitter.cpp
@@ -407,10 +407,6 @@ class DecoderEmitter {
void parseInstructionEncodings();
};
-} // end anonymous namespace
-
-namespace {
-
/// Filter - Filter works with FilterChooser to produce the decoding tree for
/// the ISA.
///
@@ -665,11 +661,8 @@ class DecoderTableBuilder {
} // end anonymous namespace
-///////////////////////////
-// //
-// Filter Implementation //
-// //
-///////////////////////////
+//------------------------------------------------------------------------------
+// Filter Implementation
Filter::Filter(ArrayRef<InstructionEncoding> Encodings,
ArrayRef<unsigned> EncodingIDs, unsigned StartBit,
@@ -697,6 +690,15 @@ Filter::Filter(ArrayRef<InstructionEncoding> Encodings,
"Filter returns no instruction categories");
}
+// Returns the number of fanout produced by the filter. More fanout implies
+// the filter distinguishes more categories of instructions.
+unsigned Filter::usefulness() const {
+ return FilteredIDs.size() + VariableIDs.empty();
+}
+
+//------------------------------------------------------------------------------
+// FilterChooser Implementation
+
void FilterChooser::applyFilter(const Filter &F) {
StartBit = F.StartBit;
NumBits = F.NumBits;
@@ -724,18 +726,18 @@ void FilterChooser::applyFilter(const Filter &F) {
}
}
-// Returns the number of fanout produced by the filter. More fanout implies
-// the filter distinguishes more categories of instructions.
-unsigned Filter::usefulness() const {
- return FilteredIDs.size() + VariableIDs.empty();
+/// dumpStack - dumpStack traverses the filter chooser chain and calls
+/// dumpFilterArray on each filter chooser up to the top level one.
+void FilterChooser::dumpStack(raw_ostream &OS, indent Indent,
+ unsigned PadToWidth) const {
+ if (Parent)
+ Parent->dumpStack(OS, Indent, PadToWidth);
+ assert(PadToWidth >= FilterBits.getBitWidth());
+ OS << Indent << indent(PadToWidth - FilterBits.getBitWidth());
+ printKnownBits(OS, FilterBits, '.');
+ OS << '\n';
}
-//////////////////////////////////
-// //
-// Filterchooser Implementation //
-// //
-//////////////////////////////////
-
// Emit the decoder state machine table. Returns a mask of MCD decoder ops
// that were emitted.
unsigned DecoderEmitter::emitTable(formatted_raw_ostream &OS,
@@ -1057,18 +1059,6 @@ void DecoderEmitter::emitDecoderFunction(formatted_raw_ostream &OS,
OS << "}\n";
}
-/// dumpStack - dumpStack traverses the filter chooser chain and calls
-/// dumpFilterArray on each filter chooser up to the top level one.
-void FilterChooser::dumpStack(raw_ostream &OS, indent Indent,
- unsigned PadToWidth) const {
- if (Parent)
- Parent->dumpStack(OS, Indent, PadToWidth);
- assert(PadToWidth >= FilterBits.getBitWidth());
- OS << Indent << indent(PadToWidth - FilterBits.getBitWidth());
- printKnownBits(OS, FilterBits, '.');
- OS << '\n';
-}
-
// Calculates the island(s) needed to decode the instruction.
// This returns a list of undecoded bits of an instructions, for example,
// Inst{20} = 1 && Inst{3-0} == 0b1111 represents two islands of yet-to-be
More information about the llvm-commits
mailing list