[llvm] ab2b333 - [LLVM][TableGen] Change FastISelEmitter to use const RecordKeeper (#109060)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 09:58:07 PDT 2024
Author: Rahul Joshi
Date: 2024-09-18T09:58:04-07:00
New Revision: ab2b333f0db50c4124f422343db3cc8c9e075787
URL: https://github.com/llvm/llvm-project/commit/ab2b333f0db50c4124f422343db3cc8c9e075787
DIFF: https://github.com/llvm/llvm-project/commit/ab2b333f0db50c4124f422343db3cc8c9e075787.diff
LOG: [LLVM][TableGen] Change FastISelEmitter to use const RecordKeeper (#109060)
Change FastISelEmitter to use const RecordKeeper.
This is a part of effort to have better const correctness in TableGen
backends:
https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
Added:
Modified:
llvm/utils/TableGen/FastISelEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/FastISelEmitter.cpp b/llvm/utils/TableGen/FastISelEmitter.cpp
index 01df873ece1fcf..af05496a7b6ab9 100644
--- a/llvm/utils/TableGen/FastISelEmitter.cpp
+++ b/llvm/utils/TableGen/FastISelEmitter.cpp
@@ -272,7 +272,7 @@ struct OperandsSignature {
DefInit *OpDI = dyn_cast<DefInit>(Op.getLeafValue());
if (!OpDI)
return false;
- Record *OpLeafRec = OpDI->getDef();
+ const Record *OpLeafRec = OpDI->getDef();
// For now, the only other thing we accept is register operands.
const CodeGenRegisterClass *RC = nullptr;
@@ -407,7 +407,7 @@ class FastISelMap {
public:
explicit FastISelMap(StringRef InstNS);
- void collectPatterns(CodeGenDAGPatterns &CGP);
+ void collectPatterns(const CodeGenDAGPatterns &CGP);
void printImmediatePredicates(raw_ostream &OS);
void printFunctionDefinitions(raw_ostream &OS);
@@ -417,7 +417,8 @@ class FastISelMap {
};
} // End anonymous namespace
-static std::string getOpcodeName(const Record *Op, CodeGenDAGPatterns &CGP) {
+static std::string getOpcodeName(const Record *Op,
+ const CodeGenDAGPatterns &CGP) {
return std::string(CGP.getSDNodeInfo(Op).getEnumName());
}
@@ -437,7 +438,7 @@ static std::string PhyRegForNode(TreePatternNode &Op,
if (!Op.isLeaf())
return PhysReg;
- Record *OpLeafRec = cast<DefInit>(Op.getLeafValue())->getDef();
+ const Record *OpLeafRec = cast<DefInit>(Op.getLeafValue())->getDef();
if (!OpLeafRec->isSubClassOf("Register"))
return PhysReg;
@@ -448,7 +449,7 @@ static std::string PhyRegForNode(TreePatternNode &Op,
return PhysReg;
}
-void FastISelMap::collectPatterns(CodeGenDAGPatterns &CGP) {
+void FastISelMap::collectPatterns(const CodeGenDAGPatterns &CGP) {
const CodeGenTarget &Target = CGP.getTargetInfo();
// Scan through all the patterns and record the simple ones.
@@ -864,8 +865,8 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
// TODO: SignaturesWithConstantForms should be empty here.
}
-static void EmitFastISel(RecordKeeper &RK, raw_ostream &OS) {
- CodeGenDAGPatterns CGP(RK);
+static void EmitFastISel(const RecordKeeper &RK, raw_ostream &OS) {
+ const CodeGenDAGPatterns CGP(RK);
const CodeGenTarget &Target = CGP.getTargetInfo();
emitSourceFileHeader("\"Fast\" Instruction Selector for the " +
Target.getName().str() + " target",
More information about the llvm-commits
mailing list