-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[TableGen][DecoderEmitter] Remove PredicateNamespace (NFC) #155211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
s-barannikov
merged 1 commit into
llvm:main
from
s-barannikov:tablegen/decoder/remove-predicate-namespace
Aug 25, 2025
Merged
[TableGen][DecoderEmitter] Remove PredicateNamespace (NFC) #155211
s-barannikov
merged 1 commit into
llvm:main
from
s-barannikov:tablegen/decoder/remove-predicate-namespace
Aug 25, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There is no target object named Thumb, so there is no need to make a special case for it. As part of this change, pass CodeGenTarget instead of DecoderEmitter to FilterChooser to remove dependency between the latter two.
@llvm/pr-subscribers-tablegen Author: Sergei Barannikov (s-barannikov) ChangesThere is no target named Thumb, so there is no need to make a special case for it. As part of this change, pass CodeGenTarget instead of DecoderEmitter to FilterChooser to remove dependency between the latter two. Full diff: https://github.com/llvm/llvm-project/pull/155211.diff 3 Files Affected:
diff --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp
index 4f6eeb3922f9a..773f6a63c675b 100644
--- a/llvm/utils/TableGen/DecoderEmitter.cpp
+++ b/llvm/utils/TableGen/DecoderEmitter.cpp
@@ -340,7 +340,7 @@ class DecoderEmitter {
SmallDenseMap<unsigned, std::vector<unsigned>> EncodingIDsByHwMode;
public:
- DecoderEmitter(const RecordKeeper &RK, StringRef PredicateNamespace);
+ explicit DecoderEmitter(const RecordKeeper &RK);
const CodeGenTarget &getTarget() const { return Target; }
@@ -370,9 +370,6 @@ class DecoderEmitter {
NamespacesHwModesMap &NamespacesWithHwModes);
void parseInstructionEncodings();
-
-public:
- StringRef PredicateNamespace;
};
} // end anonymous namespace
@@ -487,8 +484,7 @@ class FilterChooser {
/// This field allows us to ignore the extra bits.
unsigned MaxFilterWidth;
- // Parent emitter
- const DecoderEmitter *Emitter;
+ const CodeGenTarget &Target;
/// If the selected filter matches multiple encodings, then this is the
/// starting position and the width of the filtered range.
@@ -524,9 +520,9 @@ class FilterChooser {
/// Constructs a top-level filter chooser.
FilterChooser(ArrayRef<InstructionEncoding> Encodings,
ArrayRef<unsigned> EncodingIDs, unsigned MaxFilterWidth,
- const DecoderEmitter *E)
+ const CodeGenTarget &Target)
: Encodings(Encodings), EncodingIDs(EncodingIDs), Parent(nullptr),
- MaxFilterWidth(MaxFilterWidth), Emitter(E) {
+ MaxFilterWidth(MaxFilterWidth), Target(Target) {
// Sort encoding IDs once.
stable_sort(this->EncodingIDs, LessEncodingIDByWidth(Encodings));
// Filter width is the width of the smallest encoding.
@@ -542,7 +538,7 @@ class FilterChooser {
ArrayRef<unsigned> EncodingIDs, const KnownBits &FilterBits,
const FilterChooser &Parent)
: Encodings(Encodings), EncodingIDs(EncodingIDs), Parent(&Parent),
- MaxFilterWidth(Parent.MaxFilterWidth), Emitter(Parent.Emitter) {
+ MaxFilterWidth(Parent.MaxFilterWidth), Target(Parent.Target) {
// Inferior filter choosers are created from sorted array of encoding IDs.
assert(is_sorted(EncodingIDs, LessEncodingIDByWidth(Encodings)));
assert(!FilterBits.hasConflict() && "Broken filter");
@@ -1155,8 +1151,7 @@ bool FilterChooser::emitPredicateMatchAux(const Init &Val, bool ParenIfBinOp,
if (const auto *D = dyn_cast<DefInit>(&Val)) {
if (!D->getDef()->isSubClassOf("SubtargetFeature"))
return true;
- OS << "Bits[" << Emitter->PredicateNamespace << "::" << D->getAsString()
- << "]";
+ OS << "Bits[" << Target.getName() << "::" << D->getAsString() << "]";
return false;
}
if (const auto *D = dyn_cast<DagInit>(&Val)) {
@@ -1350,7 +1345,7 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo,
: MCD::OPC_TryDecode;
TableInfo.Table.insertOpcode(DecoderOp);
const Record *InstDef = Encodings[EncodingID].getInstruction()->TheDef;
- TableInfo.Table.insertULEB128(Emitter->getTarget().getInstrIntValue(InstDef));
+ TableInfo.Table.insertULEB128(Target.getInstrIntValue(InstDef));
TableInfo.Table.insertULEB128(DIdx);
if (DecoderOp == MCD::OPC_TryDecode) {
@@ -2502,10 +2497,8 @@ void DecoderEmitter::parseInstructionEncodings() {
NumEncodings = NumEncodingsSupported + NumEncodingsOmitted;
}
-DecoderEmitter::DecoderEmitter(const RecordKeeper &RK,
- StringRef PredicateNamespace)
- : RK(RK), Target(RK), CGH(Target.getHwModes()),
- PredicateNamespace(PredicateNamespace) {
+DecoderEmitter::DecoderEmitter(const RecordKeeper &RK)
+ : RK(RK), Target(RK), CGH(Target.getHwModes()) {
Target.reverseBitsForLittleEndianEncoding();
parseInstructionEncodings();
}
@@ -2560,7 +2553,7 @@ namespace {
auto [DecoderNamespace, HwModeID, Size] = Key;
const unsigned BitWidth = IsVarLenInst ? MaxInstLen : 8 * Size;
// Emit the decoder for this (namespace, hwmode, width) combination.
- FilterChooser FC(Encodings, EncodingIDs, BitWidth, this);
+ FilterChooser FC(Encodings, EncodingIDs, BitWidth, Target);
// The decode table is cleared for each top level decoder function. The
// predicates and decoders themselves, however, are shared across all
@@ -2603,7 +2596,6 @@ namespace {
OS << "\n} // namespace\n";
}
-void llvm::EmitDecoder(const RecordKeeper &RK, raw_ostream &OS,
- StringRef PredicateNamespace) {
- DecoderEmitter(RK, PredicateNamespace).run(OS);
+void llvm::EmitDecoder(const RecordKeeper &RK, raw_ostream &OS) {
+ DecoderEmitter(RK).run(OS);
}
diff --git a/llvm/utils/TableGen/DisassemblerEmitter.cpp b/llvm/utils/TableGen/DisassemblerEmitter.cpp
index 15a11a3a99406..5bc259a5fc8a4 100644
--- a/llvm/utils/TableGen/DisassemblerEmitter.cpp
+++ b/llvm/utils/TableGen/DisassemblerEmitter.cpp
@@ -123,10 +123,7 @@ static void emitDisassembler(const RecordKeeper &Records, raw_ostream &OS) {
return;
}
- StringRef PredicateNamespace = Target.getName();
- if (PredicateNamespace == "Thumb")
- PredicateNamespace = "ARM";
- EmitDecoder(Records, OS, PredicateNamespace);
+ EmitDecoder(Records, OS);
}
cl::OptionCategory DisassemblerEmitterCat("Options for -gen-disassembler");
diff --git a/llvm/utils/TableGen/TableGenBackends.h b/llvm/utils/TableGen/TableGenBackends.h
index d1cbc5d1605d8..6e13864d12e16 100644
--- a/llvm/utils/TableGen/TableGenBackends.h
+++ b/llvm/utils/TableGen/TableGenBackends.h
@@ -64,8 +64,7 @@ class RecordKeeper;
void EmitMapTable(const RecordKeeper &RK, raw_ostream &OS);
// Defined in DecoderEmitter.cpp
-void EmitDecoder(const RecordKeeper &RK, raw_ostream &OS,
- StringRef PredicateNamespace);
+void EmitDecoder(const RecordKeeper &RK, raw_ostream &OS);
} // namespace llvm
|
jurahul
approved these changes
Aug 25, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is no target named Thumb, so there is no need to make a special case for it.
As part of this change, pass CodeGenTarget instead of DecoderEmitter to FilterChooser to remove dependency between the latter two.