Skip to content

Commit ef455e6

Browse files
authored
[TableGen] Replace all lingering uses of getName with getEnumName
The former is a wrapper for the latter with two differences: Other is mapped to "UNKNOWN" (rather than "MVT::Other"), and iPTR(Any) are mapped to "TLI.getPointerTy()" rather than "MVT::iPTR(Any)". The only uses are in FastISelMap::printFunctionDefinitions. Most of these uses are just a form of name mangling to ensure uniqueness, so the actual string isn't important (and, in the case of MVT::iPTR(Any), were both to be used, they would clash). Two uses are for a case statement, which requires the expression to be a constant (of the right type), but neither UNKNOWN nor TLI.getPointerTy() are constants, so would not work there. The remaining uses are where an expression is needed, so UNKNOWN similarly doesn't work, though TLI.getPointerTy() could in this case. However, neither iPTR nor iPTRAny are supposed to make it this far through TableGen, and should instead have been replaced with concrete types, so this case should not be hit. Moreover, for almost all of these uses, the name is passed to getLegalCName, which will strip an MVT:: prefix but will leave TLI.getPointerTy() unchanged, which is not a valid C identifier, nor component thereof. Thus, delete this unnecessary, and mostly-broken, wrapper and just use the underlying getEnumName. This has been verified to have no effect on the generated files for any in-tree target, including experimental ones. Reviewers: arsenm Reviewed By: arsenm Pull Request: #113731
1 parent 3c02fea commit ef455e6

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

llvm/utils/TableGen/Common/CodeGenTarget.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,6 @@ MVT::SimpleValueType llvm::getValueType(const Record *Rec) {
4747
return (MVT::SimpleValueType)Rec->getValueAsInt("Value");
4848
}
4949

50-
StringRef llvm::getName(MVT::SimpleValueType T) {
51-
switch (T) {
52-
case MVT::Other:
53-
return "UNKNOWN";
54-
case MVT::iPTR:
55-
return "TLI.getPointerTy()";
56-
case MVT::iPTRAny:
57-
return "TLI.getPointerTy()";
58-
default:
59-
return getEnumName(T);
60-
}
61-
}
62-
6350
StringRef llvm::getEnumName(MVT::SimpleValueType T) {
6451
// clang-format off
6552
switch (T) {

llvm/utils/TableGen/Common/CodeGenTarget.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class CodeGenSubRegIndex;
4646
/// record corresponds to.
4747
MVT::SimpleValueType getValueType(const Record *Rec);
4848

49-
StringRef getName(MVT::SimpleValueType T);
5049
StringRef getEnumName(MVT::SimpleValueType T);
5150

5251
/// getQualifiedName - Return the name of the specified record, with a

llvm/utils/TableGen/FastISelEmitter.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -718,19 +718,20 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
718718
const PredMap &PM = RI.second;
719719

720720
OS << "unsigned fastEmit_" << getLegalCName(Opcode) << "_"
721-
<< getLegalCName(std::string(getName(VT))) << "_"
722-
<< getLegalCName(std::string(getName(RetVT))) << "_";
721+
<< getLegalCName(std::string(getEnumName(VT))) << "_"
722+
<< getLegalCName(std::string(getEnumName(RetVT))) << "_";
723723
Operands.PrintManglingSuffix(OS, ImmediatePredicates);
724724
OS << "(";
725725
Operands.PrintParameters(OS);
726726
OS << ") {\n";
727727

728-
emitInstructionCode(OS, Operands, PM, std::string(getName(RetVT)));
728+
emitInstructionCode(OS, Operands, PM,
729+
std::string(getEnumName(RetVT)));
729730
}
730731

731732
// Emit one function for the type that demultiplexes on return type.
732733
OS << "unsigned fastEmit_" << getLegalCName(Opcode) << "_"
733-
<< getLegalCName(std::string(getName(VT))) << "_";
734+
<< getLegalCName(std::string(getEnumName(VT))) << "_";
734735
Operands.PrintManglingSuffix(OS, ImmediatePredicates);
735736
OS << "(MVT RetVT";
736737
if (!Operands.empty())
@@ -739,10 +740,10 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
739740
OS << ") {\nswitch (RetVT.SimpleTy) {\n";
740741
for (const auto &RI : RM) {
741742
MVT::SimpleValueType RetVT = RI.first;
742-
OS << " case " << getName(RetVT) << ": return fastEmit_"
743+
OS << " case " << getEnumName(RetVT) << ": return fastEmit_"
743744
<< getLegalCName(Opcode) << "_"
744-
<< getLegalCName(std::string(getName(VT))) << "_"
745-
<< getLegalCName(std::string(getName(RetVT))) << "_";
745+
<< getLegalCName(std::string(getEnumName(VT))) << "_"
746+
<< getLegalCName(std::string(getEnumName(RetVT))) << "_";
746747
Operands.PrintManglingSuffix(OS, ImmediatePredicates);
747748
OS << "(";
748749
Operands.PrintArguments(OS);
@@ -753,15 +754,15 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
753754
} else {
754755
// Non-variadic return type.
755756
OS << "unsigned fastEmit_" << getLegalCName(Opcode) << "_"
756-
<< getLegalCName(std::string(getName(VT))) << "_";
757+
<< getLegalCName(std::string(getEnumName(VT))) << "_";
757758
Operands.PrintManglingSuffix(OS, ImmediatePredicates);
758759
OS << "(MVT RetVT";
759760
if (!Operands.empty())
760761
OS << ", ";
761762
Operands.PrintParameters(OS);
762763
OS << ") {\n";
763764

764-
OS << " if (RetVT.SimpleTy != " << getName(RM.begin()->first)
765+
OS << " if (RetVT.SimpleTy != " << getEnumName(RM.begin()->first)
765766
<< ")\n return 0;\n";
766767

767768
const PredMap &PM = RM.begin()->second;
@@ -781,7 +782,7 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
781782
OS << " switch (VT.SimpleTy) {\n";
782783
for (const auto &TI : TM) {
783784
MVT::SimpleValueType VT = TI.first;
784-
std::string TypeName = std::string(getName(VT));
785+
std::string TypeName = std::string(getEnumName(VT));
785786
OS << " case " << TypeName << ": return fastEmit_"
786787
<< getLegalCName(Opcode) << "_" << getLegalCName(TypeName) << "_";
787788
Operands.PrintManglingSuffix(OS, ImmediatePredicates);

0 commit comments

Comments
 (0)