Skip to content

Commit bea0791

Browse files
jurahultmsri
authored andcommitted
[LLVM][TableGen] Change FastISelEmitter to use const RecordKeeper (llvm#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
1 parent 47a7644 commit bea0791

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

llvm/utils/TableGen/FastISelEmitter.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ struct OperandsSignature {
272272
DefInit *OpDI = dyn_cast<DefInit>(Op.getLeafValue());
273273
if (!OpDI)
274274
return false;
275-
Record *OpLeafRec = OpDI->getDef();
275+
const Record *OpLeafRec = OpDI->getDef();
276276

277277
// For now, the only other thing we accept is register operands.
278278
const CodeGenRegisterClass *RC = nullptr;
@@ -407,7 +407,7 @@ class FastISelMap {
407407
public:
408408
explicit FastISelMap(StringRef InstNS);
409409

410-
void collectPatterns(CodeGenDAGPatterns &CGP);
410+
void collectPatterns(const CodeGenDAGPatterns &CGP);
411411
void printImmediatePredicates(raw_ostream &OS);
412412
void printFunctionDefinitions(raw_ostream &OS);
413413

@@ -417,7 +417,8 @@ class FastISelMap {
417417
};
418418
} // End anonymous namespace
419419

420-
static std::string getOpcodeName(const Record *Op, CodeGenDAGPatterns &CGP) {
420+
static std::string getOpcodeName(const Record *Op,
421+
const CodeGenDAGPatterns &CGP) {
421422
return std::string(CGP.getSDNodeInfo(Op).getEnumName());
422423
}
423424

@@ -437,7 +438,7 @@ static std::string PhyRegForNode(TreePatternNode &Op,
437438
if (!Op.isLeaf())
438439
return PhysReg;
439440

440-
Record *OpLeafRec = cast<DefInit>(Op.getLeafValue())->getDef();
441+
const Record *OpLeafRec = cast<DefInit>(Op.getLeafValue())->getDef();
441442
if (!OpLeafRec->isSubClassOf("Register"))
442443
return PhysReg;
443444

@@ -448,7 +449,7 @@ static std::string PhyRegForNode(TreePatternNode &Op,
448449
return PhysReg;
449450
}
450451

451-
void FastISelMap::collectPatterns(CodeGenDAGPatterns &CGP) {
452+
void FastISelMap::collectPatterns(const CodeGenDAGPatterns &CGP) {
452453
const CodeGenTarget &Target = CGP.getTargetInfo();
453454

454455
// Scan through all the patterns and record the simple ones.
@@ -864,8 +865,8 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
864865
// TODO: SignaturesWithConstantForms should be empty here.
865866
}
866867

867-
static void EmitFastISel(RecordKeeper &RK, raw_ostream &OS) {
868-
CodeGenDAGPatterns CGP(RK);
868+
static void EmitFastISel(const RecordKeeper &RK, raw_ostream &OS) {
869+
const CodeGenDAGPatterns CGP(RK);
869870
const CodeGenTarget &Target = CGP.getTargetInfo();
870871
emitSourceFileHeader("\"Fast\" Instruction Selector for the " +
871872
Target.getName().str() + " target",

0 commit comments

Comments
 (0)