1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[TableGen] Remove unused target intrinsic generation logic

AMDGPU was the last in tree target to use this tablegen mode. I plan to
split up the global intrinsic enum similar to the way that clang
diagnostics are split up today. I don't plan to build on this mode.

Reviewers: arsenm, echristo, efriedma

Reviewed By: echristo

Differential Revision: https://reviews.llvm.org/D71318
This commit is contained in:
Reid Kleckner 2019-12-11 07:37:16 -08:00
parent c56f83f1a4
commit f986e0d356
7 changed files with 20 additions and 75 deletions

View File

@ -3028,8 +3028,7 @@ CodeGenDAGPatterns::CodeGenDAGPatterns(RecordKeeper &R,
: Records(R), Target(R), LegalVTS(Target.getLegalValueTypes()), : Records(R), Target(R), LegalVTS(Target.getLegalValueTypes()),
PatternRewriter(PatternRewriter) { PatternRewriter(PatternRewriter) {
Intrinsics = CodeGenIntrinsicTable(Records, false); Intrinsics = CodeGenIntrinsicTable(Records);
TgtIntrinsics = CodeGenIntrinsicTable(Records, true);
ParseNodeInfo(); ParseNodeInfo();
ParseNodeTransforms(); ParseNodeTransforms();
ParseComplexPatterns(); ParseComplexPatterns();

View File

@ -1145,7 +1145,6 @@ class CodeGenDAGPatterns {
RecordKeeper &Records; RecordKeeper &Records;
CodeGenTarget Target; CodeGenTarget Target;
CodeGenIntrinsicTable Intrinsics; CodeGenIntrinsicTable Intrinsics;
CodeGenIntrinsicTable TgtIntrinsics;
std::map<Record*, SDNodeInfo, LessRecordByID> SDNodes; std::map<Record*, SDNodeInfo, LessRecordByID> SDNodes;
std::map<Record*, std::pair<Record*, std::string>, LessRecordByID> std::map<Record*, std::pair<Record*, std::string>, LessRecordByID>
@ -1211,24 +1210,18 @@ public:
const CodeGenIntrinsic &getIntrinsic(Record *R) const { const CodeGenIntrinsic &getIntrinsic(Record *R) const {
for (unsigned i = 0, e = Intrinsics.size(); i != e; ++i) for (unsigned i = 0, e = Intrinsics.size(); i != e; ++i)
if (Intrinsics[i].TheDef == R) return Intrinsics[i]; if (Intrinsics[i].TheDef == R) return Intrinsics[i];
for (unsigned i = 0, e = TgtIntrinsics.size(); i != e; ++i)
if (TgtIntrinsics[i].TheDef == R) return TgtIntrinsics[i];
llvm_unreachable("Unknown intrinsic!"); llvm_unreachable("Unknown intrinsic!");
} }
const CodeGenIntrinsic &getIntrinsicInfo(unsigned IID) const { const CodeGenIntrinsic &getIntrinsicInfo(unsigned IID) const {
if (IID-1 < Intrinsics.size()) if (IID-1 < Intrinsics.size())
return Intrinsics[IID-1]; return Intrinsics[IID-1];
if (IID-Intrinsics.size()-1 < TgtIntrinsics.size())
return TgtIntrinsics[IID-Intrinsics.size()-1];
llvm_unreachable("Bad intrinsic ID!"); llvm_unreachable("Bad intrinsic ID!");
} }
unsigned getIntrinsicID(Record *R) const { unsigned getIntrinsicID(Record *R) const {
for (unsigned i = 0, e = Intrinsics.size(); i != e; ++i) for (unsigned i = 0, e = Intrinsics.size(); i != e; ++i)
if (Intrinsics[i].TheDef == R) return i; if (Intrinsics[i].TheDef == R) return i;
for (unsigned i = 0, e = TgtIntrinsics.size(); i != e; ++i)
if (TgtIntrinsics[i].TheDef == R) return i + Intrinsics.size();
llvm_unreachable("Unknown intrinsic!"); llvm_unreachable("Unknown intrinsic!");
} }
@ -1285,8 +1278,6 @@ public:
return intrinsic_wo_chain_sdnode; return intrinsic_wo_chain_sdnode;
} }
bool hasTargetIntrinsics() { return !TgtIntrinsics.empty(); }
unsigned allocateScope() { return ++NumScopes; } unsigned allocateScope() { return ++NumScopes; }
bool operandHasDefault(Record *Op) const { bool operandHasDefault(Record *Op) const {

View File

@ -176,7 +176,7 @@ public:
}; };
std::vector<TargetSet> Targets; std::vector<TargetSet> Targets;
explicit CodeGenIntrinsicTable(const RecordKeeper &RC, bool TargetOnly); explicit CodeGenIntrinsicTable(const RecordKeeper &RC);
CodeGenIntrinsicTable() = default; CodeGenIntrinsicTable() = default;
bool empty() const { return Intrinsics.empty(); } bool empty() const { return Intrinsics.empty(); }

View File

@ -574,17 +574,14 @@ ComplexPattern::ComplexPattern(Record *R) {
// CodeGenIntrinsic Implementation // CodeGenIntrinsic Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
CodeGenIntrinsicTable::CodeGenIntrinsicTable(const RecordKeeper &RC, CodeGenIntrinsicTable::CodeGenIntrinsicTable(const RecordKeeper &RC) {
bool TargetOnly) {
std::vector<Record*> Defs = RC.getAllDerivedDefinitions("Intrinsic"); std::vector<Record*> Defs = RC.getAllDerivedDefinitions("Intrinsic");
Intrinsics.reserve(Defs.size()); Intrinsics.reserve(Defs.size());
for (unsigned I = 0, e = Defs.size(); I != e; ++I) { for (unsigned I = 0, e = Defs.size(); I != e; ++I)
bool isTarget = Defs[I]->getValueAsBit("isTarget"); Intrinsics.push_back(CodeGenIntrinsic(Defs[I]));
if (isTarget == TargetOnly)
Intrinsics.push_back(CodeGenIntrinsic(Defs[I]));
}
llvm::sort(Intrinsics, llvm::sort(Intrinsics,
[](const CodeGenIntrinsic &LHS, const CodeGenIntrinsic &RHS) { [](const CodeGenIntrinsic &LHS, const CodeGenIntrinsic &RHS) {
return std::tie(LHS.TargetPrefix, LHS.Name) < return std::tie(LHS.TargetPrefix, LHS.Name) <

View File

@ -26,12 +26,9 @@ using namespace llvm;
namespace { namespace {
class IntrinsicEmitter { class IntrinsicEmitter {
RecordKeeper &Records; RecordKeeper &Records;
bool TargetOnly;
std::string TargetPrefix;
public: public:
IntrinsicEmitter(RecordKeeper &R, bool T) IntrinsicEmitter(RecordKeeper &R) : Records(R) {}
: Records(R), TargetOnly(T) {}
void run(raw_ostream &OS, bool Enums); void run(raw_ostream &OS, bool Enums);
@ -58,10 +55,7 @@ public:
void IntrinsicEmitter::run(raw_ostream &OS, bool Enums) { void IntrinsicEmitter::run(raw_ostream &OS, bool Enums) {
emitSourceFileHeader("Intrinsic Function Source Fragment", OS); emitSourceFileHeader("Intrinsic Function Source Fragment", OS);
CodeGenIntrinsicTable Ints(Records, TargetOnly); CodeGenIntrinsicTable Ints(Records);
if (TargetOnly && !Ints.empty())
TargetPrefix = Ints[0].TargetPrefix;
EmitPrefix(OS); EmitPrefix(OS);
@ -588,11 +582,7 @@ void IntrinsicEmitter::EmitAttributes(const CodeGenIntrinsicTable &Ints,
raw_ostream &OS) { raw_ostream &OS) {
OS << "// Add parameter attributes that are not common to all intrinsics.\n"; OS << "// Add parameter attributes that are not common to all intrinsics.\n";
OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n"; OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n";
if (TargetOnly) OS << "AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id) {\n";
OS << "static AttributeList getAttributes(LLVMContext &C, " << TargetPrefix
<< "Intrinsic::ID id) {\n";
else
OS << "AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id) {\n";
// Compute the maximum number of attribute arguments and the map // Compute the maximum number of attribute arguments and the map
typedef std::map<const CodeGenIntrinsic*, unsigned, typedef std::map<const CodeGenIntrinsic*, unsigned,
@ -625,12 +615,7 @@ void IntrinsicEmitter::EmitAttributes(const CodeGenIntrinsicTable &Ints,
OS << " AttributeList AS[" << maxArgAttrs + 1 << "];\n"; OS << " AttributeList AS[" << maxArgAttrs + 1 << "];\n";
OS << " unsigned NumAttrs = 0;\n"; OS << " unsigned NumAttrs = 0;\n";
OS << " if (id != 0) {\n"; OS << " if (id != 0) {\n";
OS << " switch(IntrinsicsToAttributesMap[id - "; OS << " switch(IntrinsicsToAttributesMap[id - 1]) {\n";
if (TargetOnly)
OS << "Intrinsic::num_intrinsics";
else
OS << "1";
OS << "]) {\n";
OS << " default: llvm_unreachable(\"Invalid attribute number\");\n"; OS << " default: llvm_unreachable(\"Invalid attribute number\");\n";
for (UniqAttrMapTy::const_iterator I = UniqAttributes.begin(), for (UniqAttrMapTy::const_iterator I = UniqAttributes.begin(),
E = UniqAttributes.end(); I != E; ++I) { E = UniqAttributes.end(); I != E; ++I) {
@ -875,21 +860,12 @@ void IntrinsicEmitter::EmitIntrinsicToBuiltinMap(
OS << "// in as TargetPrefix. The result is assigned to 'IntrinsicID'.\n"; OS << "// in as TargetPrefix. The result is assigned to 'IntrinsicID'.\n";
OS << "#ifdef GET_LLVM_INTRINSIC_FOR_" << CompilerName << "_BUILTIN\n"; OS << "#ifdef GET_LLVM_INTRINSIC_FOR_" << CompilerName << "_BUILTIN\n";
if (TargetOnly) { OS << "Intrinsic::ID Intrinsic::getIntrinsicFor" << CompilerName
OS << "static " << TargetPrefix << "Intrinsic::ID " << "Builtin(const char "
<< "getIntrinsicFor" << CompilerName << "Builtin(const char " << "*TargetPrefixStr, StringRef BuiltinNameStr) {\n";
<< "*TargetPrefixStr, StringRef BuiltinNameStr) {\n";
} else {
OS << "Intrinsic::ID Intrinsic::getIntrinsicFor" << CompilerName
<< "Builtin(const char "
<< "*TargetPrefixStr, StringRef BuiltinNameStr) {\n";
}
if (Table.Empty()) { if (Table.Empty()) {
OS << " return "; OS << " return Intrinsic::not_intrinsic;\n";
if (!TargetPrefix.empty())
OS << "(" << TargetPrefix << "Intrinsic::ID)";
OS << "Intrinsic::not_intrinsic;\n";
OS << "}\n"; OS << "}\n";
OS << "#endif\n\n"; OS << "#endif\n\n";
return; return;
@ -937,19 +913,15 @@ void IntrinsicEmitter::EmitIntrinsicToBuiltinMap(
OS << " }\n"; OS << " }\n";
} }
OS << " return "; OS << " return ";
if (!TargetPrefix.empty())
OS << "(" << TargetPrefix << "Intrinsic::ID)";
OS << "Intrinsic::not_intrinsic;\n"; OS << "Intrinsic::not_intrinsic;\n";
OS << "}\n"; OS << "}\n";
OS << "#endif\n\n"; OS << "#endif\n\n";
} }
void llvm::EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS, void llvm::EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS) {
bool TargetOnly) { IntrinsicEmitter(RK).run(OS, /*Enums=*/true);
IntrinsicEmitter(RK, TargetOnly).run(OS, /*Enums=*/true);
} }
void llvm::EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS, void llvm::EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS) {
bool TargetOnly) { IntrinsicEmitter(RK).run(OS, /*Enums=*/false);
IntrinsicEmitter(RK, TargetOnly).run(OS, /*Enums=*/false);
} }

View File

@ -40,8 +40,6 @@ enum ActionType {
GenSubtarget, GenSubtarget,
GenIntrinsicEnums, GenIntrinsicEnums,
GenIntrinsicImpl, GenIntrinsicImpl,
GenTgtIntrinsicEnums,
GenTgtIntrinsicImpl,
PrintEnums, PrintEnums,
PrintSets, PrintSets,
GenOptParserDefs, GenOptParserDefs,
@ -102,10 +100,6 @@ cl::opt<ActionType> Action(
"Generate intrinsic enums"), "Generate intrinsic enums"),
clEnumValN(GenIntrinsicImpl, "gen-intrinsic-impl", clEnumValN(GenIntrinsicImpl, "gen-intrinsic-impl",
"Generate intrinsic information"), "Generate intrinsic information"),
clEnumValN(GenTgtIntrinsicEnums, "gen-tgt-intrinsic-enums",
"Generate target intrinsic enums"),
clEnumValN(GenTgtIntrinsicImpl, "gen-tgt-intrinsic-impl",
"Generate target intrinsic information"),
clEnumValN(PrintEnums, "print-enums", "Print enum values for a class"), clEnumValN(PrintEnums, "print-enums", "Print enum values for a class"),
clEnumValN(PrintSets, "print-sets", clEnumValN(PrintSets, "print-sets",
"Print expanded sets for testing DAG exprs"), "Print expanded sets for testing DAG exprs"),
@ -196,12 +190,6 @@ bool LLVMTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
case GenIntrinsicImpl: case GenIntrinsicImpl:
EmitIntrinsicImpl(Records, OS); EmitIntrinsicImpl(Records, OS);
break; break;
case GenTgtIntrinsicEnums:
EmitIntrinsicEnums(Records, OS, true);
break;
case GenTgtIntrinsicImpl:
EmitIntrinsicImpl(Records, OS, true);
break;
case GenOptParserDefs: case GenOptParserDefs:
EmitOptParser(Records, OS); EmitOptParser(Records, OS);
break; break;

View File

@ -61,10 +61,8 @@ namespace llvm {
class raw_ostream; class raw_ostream;
class RecordKeeper; class RecordKeeper;
void EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS, void EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS);
bool TargetOnly = false); void EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS);
void EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS,
bool TargetOnly = false);
void EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS); void EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS);
void EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS); void EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS);
void EmitCallingConv(RecordKeeper &RK, raw_ostream &OS); void EmitCallingConv(RecordKeeper &RK, raw_ostream &OS);