mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +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:
parent
c56f83f1a4
commit
f986e0d356
@ -3028,8 +3028,7 @@ CodeGenDAGPatterns::CodeGenDAGPatterns(RecordKeeper &R,
|
||||
: Records(R), Target(R), LegalVTS(Target.getLegalValueTypes()),
|
||||
PatternRewriter(PatternRewriter) {
|
||||
|
||||
Intrinsics = CodeGenIntrinsicTable(Records, false);
|
||||
TgtIntrinsics = CodeGenIntrinsicTable(Records, true);
|
||||
Intrinsics = CodeGenIntrinsicTable(Records);
|
||||
ParseNodeInfo();
|
||||
ParseNodeTransforms();
|
||||
ParseComplexPatterns();
|
||||
|
@ -1145,7 +1145,6 @@ class CodeGenDAGPatterns {
|
||||
RecordKeeper &Records;
|
||||
CodeGenTarget Target;
|
||||
CodeGenIntrinsicTable Intrinsics;
|
||||
CodeGenIntrinsicTable TgtIntrinsics;
|
||||
|
||||
std::map<Record*, SDNodeInfo, LessRecordByID> SDNodes;
|
||||
std::map<Record*, std::pair<Record*, std::string>, LessRecordByID>
|
||||
@ -1211,24 +1210,18 @@ public:
|
||||
const CodeGenIntrinsic &getIntrinsic(Record *R) const {
|
||||
for (unsigned i = 0, e = Intrinsics.size(); i != e; ++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!");
|
||||
}
|
||||
|
||||
const CodeGenIntrinsic &getIntrinsicInfo(unsigned IID) const {
|
||||
if (IID-1 < Intrinsics.size())
|
||||
return Intrinsics[IID-1];
|
||||
if (IID-Intrinsics.size()-1 < TgtIntrinsics.size())
|
||||
return TgtIntrinsics[IID-Intrinsics.size()-1];
|
||||
llvm_unreachable("Bad intrinsic ID!");
|
||||
}
|
||||
|
||||
unsigned getIntrinsicID(Record *R) const {
|
||||
for (unsigned i = 0, e = Intrinsics.size(); i != e; ++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!");
|
||||
}
|
||||
|
||||
@ -1285,8 +1278,6 @@ public:
|
||||
return intrinsic_wo_chain_sdnode;
|
||||
}
|
||||
|
||||
bool hasTargetIntrinsics() { return !TgtIntrinsics.empty(); }
|
||||
|
||||
unsigned allocateScope() { return ++NumScopes; }
|
||||
|
||||
bool operandHasDefault(Record *Op) const {
|
||||
|
@ -176,7 +176,7 @@ public:
|
||||
};
|
||||
std::vector<TargetSet> Targets;
|
||||
|
||||
explicit CodeGenIntrinsicTable(const RecordKeeper &RC, bool TargetOnly);
|
||||
explicit CodeGenIntrinsicTable(const RecordKeeper &RC);
|
||||
CodeGenIntrinsicTable() = default;
|
||||
|
||||
bool empty() const { return Intrinsics.empty(); }
|
||||
|
@ -574,17 +574,14 @@ ComplexPattern::ComplexPattern(Record *R) {
|
||||
// CodeGenIntrinsic Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
CodeGenIntrinsicTable::CodeGenIntrinsicTable(const RecordKeeper &RC,
|
||||
bool TargetOnly) {
|
||||
CodeGenIntrinsicTable::CodeGenIntrinsicTable(const RecordKeeper &RC) {
|
||||
std::vector<Record*> Defs = RC.getAllDerivedDefinitions("Intrinsic");
|
||||
|
||||
Intrinsics.reserve(Defs.size());
|
||||
|
||||
for (unsigned I = 0, e = Defs.size(); I != e; ++I) {
|
||||
bool isTarget = Defs[I]->getValueAsBit("isTarget");
|
||||
if (isTarget == TargetOnly)
|
||||
Intrinsics.push_back(CodeGenIntrinsic(Defs[I]));
|
||||
}
|
||||
for (unsigned I = 0, e = Defs.size(); I != e; ++I)
|
||||
Intrinsics.push_back(CodeGenIntrinsic(Defs[I]));
|
||||
|
||||
llvm::sort(Intrinsics,
|
||||
[](const CodeGenIntrinsic &LHS, const CodeGenIntrinsic &RHS) {
|
||||
return std::tie(LHS.TargetPrefix, LHS.Name) <
|
||||
|
@ -26,12 +26,9 @@ using namespace llvm;
|
||||
namespace {
|
||||
class IntrinsicEmitter {
|
||||
RecordKeeper &Records;
|
||||
bool TargetOnly;
|
||||
std::string TargetPrefix;
|
||||
|
||||
public:
|
||||
IntrinsicEmitter(RecordKeeper &R, bool T)
|
||||
: Records(R), TargetOnly(T) {}
|
||||
IntrinsicEmitter(RecordKeeper &R) : Records(R) {}
|
||||
|
||||
void run(raw_ostream &OS, bool Enums);
|
||||
|
||||
@ -58,10 +55,7 @@ public:
|
||||
void IntrinsicEmitter::run(raw_ostream &OS, bool Enums) {
|
||||
emitSourceFileHeader("Intrinsic Function Source Fragment", OS);
|
||||
|
||||
CodeGenIntrinsicTable Ints(Records, TargetOnly);
|
||||
|
||||
if (TargetOnly && !Ints.empty())
|
||||
TargetPrefix = Ints[0].TargetPrefix;
|
||||
CodeGenIntrinsicTable Ints(Records);
|
||||
|
||||
EmitPrefix(OS);
|
||||
|
||||
@ -588,11 +582,7 @@ void IntrinsicEmitter::EmitAttributes(const CodeGenIntrinsicTable &Ints,
|
||||
raw_ostream &OS) {
|
||||
OS << "// Add parameter attributes that are not common to all intrinsics.\n";
|
||||
OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n";
|
||||
if (TargetOnly)
|
||||
OS << "static AttributeList getAttributes(LLVMContext &C, " << TargetPrefix
|
||||
<< "Intrinsic::ID id) {\n";
|
||||
else
|
||||
OS << "AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id) {\n";
|
||||
OS << "AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id) {\n";
|
||||
|
||||
// Compute the maximum number of attribute arguments and the map
|
||||
typedef std::map<const CodeGenIntrinsic*, unsigned,
|
||||
@ -625,12 +615,7 @@ void IntrinsicEmitter::EmitAttributes(const CodeGenIntrinsicTable &Ints,
|
||||
OS << " AttributeList AS[" << maxArgAttrs + 1 << "];\n";
|
||||
OS << " unsigned NumAttrs = 0;\n";
|
||||
OS << " if (id != 0) {\n";
|
||||
OS << " switch(IntrinsicsToAttributesMap[id - ";
|
||||
if (TargetOnly)
|
||||
OS << "Intrinsic::num_intrinsics";
|
||||
else
|
||||
OS << "1";
|
||||
OS << "]) {\n";
|
||||
OS << " switch(IntrinsicsToAttributesMap[id - 1]) {\n";
|
||||
OS << " default: llvm_unreachable(\"Invalid attribute number\");\n";
|
||||
for (UniqAttrMapTy::const_iterator I = UniqAttributes.begin(),
|
||||
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 << "#ifdef GET_LLVM_INTRINSIC_FOR_" << CompilerName << "_BUILTIN\n";
|
||||
|
||||
if (TargetOnly) {
|
||||
OS << "static " << TargetPrefix << "Intrinsic::ID "
|
||||
<< "getIntrinsicFor" << CompilerName << "Builtin(const char "
|
||||
<< "*TargetPrefixStr, StringRef BuiltinNameStr) {\n";
|
||||
} else {
|
||||
OS << "Intrinsic::ID Intrinsic::getIntrinsicFor" << CompilerName
|
||||
<< "Builtin(const char "
|
||||
<< "*TargetPrefixStr, StringRef BuiltinNameStr) {\n";
|
||||
}
|
||||
OS << "Intrinsic::ID Intrinsic::getIntrinsicFor" << CompilerName
|
||||
<< "Builtin(const char "
|
||||
<< "*TargetPrefixStr, StringRef BuiltinNameStr) {\n";
|
||||
|
||||
if (Table.Empty()) {
|
||||
OS << " return ";
|
||||
if (!TargetPrefix.empty())
|
||||
OS << "(" << TargetPrefix << "Intrinsic::ID)";
|
||||
OS << "Intrinsic::not_intrinsic;\n";
|
||||
OS << " return Intrinsic::not_intrinsic;\n";
|
||||
OS << "}\n";
|
||||
OS << "#endif\n\n";
|
||||
return;
|
||||
@ -937,19 +913,15 @@ void IntrinsicEmitter::EmitIntrinsicToBuiltinMap(
|
||||
OS << " }\n";
|
||||
}
|
||||
OS << " return ";
|
||||
if (!TargetPrefix.empty())
|
||||
OS << "(" << TargetPrefix << "Intrinsic::ID)";
|
||||
OS << "Intrinsic::not_intrinsic;\n";
|
||||
OS << "}\n";
|
||||
OS << "#endif\n\n";
|
||||
}
|
||||
|
||||
void llvm::EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS,
|
||||
bool TargetOnly) {
|
||||
IntrinsicEmitter(RK, TargetOnly).run(OS, /*Enums=*/true);
|
||||
void llvm::EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS) {
|
||||
IntrinsicEmitter(RK).run(OS, /*Enums=*/true);
|
||||
}
|
||||
|
||||
void llvm::EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS,
|
||||
bool TargetOnly) {
|
||||
IntrinsicEmitter(RK, TargetOnly).run(OS, /*Enums=*/false);
|
||||
void llvm::EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS) {
|
||||
IntrinsicEmitter(RK).run(OS, /*Enums=*/false);
|
||||
}
|
||||
|
@ -40,8 +40,6 @@ enum ActionType {
|
||||
GenSubtarget,
|
||||
GenIntrinsicEnums,
|
||||
GenIntrinsicImpl,
|
||||
GenTgtIntrinsicEnums,
|
||||
GenTgtIntrinsicImpl,
|
||||
PrintEnums,
|
||||
PrintSets,
|
||||
GenOptParserDefs,
|
||||
@ -102,10 +100,6 @@ cl::opt<ActionType> Action(
|
||||
"Generate intrinsic enums"),
|
||||
clEnumValN(GenIntrinsicImpl, "gen-intrinsic-impl",
|
||||
"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(PrintSets, "print-sets",
|
||||
"Print expanded sets for testing DAG exprs"),
|
||||
@ -196,12 +190,6 @@ bool LLVMTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
|
||||
case GenIntrinsicImpl:
|
||||
EmitIntrinsicImpl(Records, OS);
|
||||
break;
|
||||
case GenTgtIntrinsicEnums:
|
||||
EmitIntrinsicEnums(Records, OS, true);
|
||||
break;
|
||||
case GenTgtIntrinsicImpl:
|
||||
EmitIntrinsicImpl(Records, OS, true);
|
||||
break;
|
||||
case GenOptParserDefs:
|
||||
EmitOptParser(Records, OS);
|
||||
break;
|
||||
|
@ -61,10 +61,8 @@ namespace llvm {
|
||||
class raw_ostream;
|
||||
class RecordKeeper;
|
||||
|
||||
void EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS,
|
||||
bool TargetOnly = false);
|
||||
void EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS,
|
||||
bool TargetOnly = false);
|
||||
void EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS);
|
||||
void EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS);
|
||||
void EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS);
|
||||
void EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS);
|
||||
void EmitCallingConv(RecordKeeper &RK, raw_ostream &OS);
|
||||
|
Loading…
Reference in New Issue
Block a user