Revert "[SelectionDAGISel] Separate the operand numbers in OPC_EmitNode/MorphNodeTo into their own table. (#178722)"
This reverts commit caab98284166784459a2fb76df7bca3f1d35e41e. This is failing some build bots.
This commit is contained in:
parent
3ce60c4ff9
commit
19cf75c72f
@ -470,7 +470,7 @@ public:
|
||||
}
|
||||
|
||||
void SelectCodeCommon(SDNode *NodeToMatch, const uint8_t *MatcherTable,
|
||||
unsigned TableSize, const uint8_t *OperandLists);
|
||||
unsigned TableSize);
|
||||
|
||||
/// Return true if complex patterns for this target can mutate the
|
||||
/// DAG.
|
||||
|
||||
@ -3350,8 +3350,7 @@ public:
|
||||
|
||||
void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
|
||||
const uint8_t *MatcherTable,
|
||||
unsigned TableSize,
|
||||
const uint8_t *OperandLists) {
|
||||
unsigned TableSize) {
|
||||
// FIXME: Should these even be selected? Handle these cases in the caller?
|
||||
switch (NodeToMatch->getOpcode()) {
|
||||
default:
|
||||
@ -4308,22 +4307,14 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
|
||||
|
||||
// Get the operand list.
|
||||
unsigned NumOps = MatcherTable[MatcherIndex++];
|
||||
|
||||
SmallVector<SDValue, 8> Ops;
|
||||
if (NumOps != 0) {
|
||||
// Get the index into the OperandLists.
|
||||
uint64_t OperandIndex = MatcherTable[MatcherIndex++];
|
||||
if (OperandIndex & 128)
|
||||
OperandIndex = GetVBR(OperandIndex, MatcherTable, MatcherIndex);
|
||||
for (unsigned i = 0; i != NumOps; ++i) {
|
||||
unsigned RecNo = MatcherTable[MatcherIndex++];
|
||||
if (RecNo & 128)
|
||||
RecNo = GetVBR(RecNo, MatcherTable, MatcherIndex);
|
||||
|
||||
for (unsigned i = 0; i != NumOps; ++i) {
|
||||
unsigned RecNo = OperandLists[OperandIndex++];
|
||||
if (RecNo & 128)
|
||||
RecNo = GetVBR(RecNo, OperandLists, OperandIndex);
|
||||
|
||||
assert(RecNo < RecordedNodes.size() && "Invalid EmitNode");
|
||||
Ops.push_back(RecordedNodes[RecNo].first);
|
||||
}
|
||||
assert(RecNo < RecordedNodes.size() && "Invalid EmitNode");
|
||||
Ops.push_back(RecordedNodes[RecNo].first);
|
||||
}
|
||||
|
||||
// If there are variadic operands to add, handle them now.
|
||||
|
||||
@ -10,22 +10,18 @@
|
||||
// CHECK-NEXT:/* 6*/ OPC_Scope /*2 children */, 9, // ->17
|
||||
// CHECK-NEXT:/* 8*/ OPC_CheckChild1Type, /*MVT::c64*/4|128,2/*260*/,
|
||||
// CHECK-NEXT:/* 11*/ OPC_MorphNodeTo1None, TARGET_VAL(MyTarget::C64_TO_I64),
|
||||
// CHECK-NEXT: MVT::i64, 1/*#Ops*/, /*OperandList*/0, // Ops = #0
|
||||
// CHECK-NEXT: MVT::i64, 1/*#Ops*/, 0,
|
||||
// CHECK-NEXT: // Src: (intrinsic_wo_chain:{ *:[i64] } [[#]]:{ *:[iPTR] }, c64:{ *:[c64] }:$src) - Complexity = 8
|
||||
// CHECK-NEXT: // Dst: (C64_TO_I64:{ *:[i64] } ?:{ *:[c64] }:$src)
|
||||
// CHECK-NEXT:/* 17*/ /*Scope*/ 9, // ->27
|
||||
// CHECK-NEXT:/* 18*/ OPC_CheckChild1Type, /*MVT::c128*/5|128,2/*261*/,
|
||||
// CHECK-NEXT:/* 21*/ OPC_MorphNodeTo1None, TARGET_VAL(MyTarget::C128_TO_I64),
|
||||
// CHECK-NEXT: MVT::i64, 1/*#Ops*/, /*OperandList*/0, // Ops = #0
|
||||
// CHECK-NEXT: MVT::i64, 1/*#Ops*/, 0,
|
||||
// CHECK-NEXT: // Src: (intrinsic_wo_chain:{ *:[i64] } [[#]]:{ *:[iPTR] }, c128:{ *:[c128] }:$src) - Complexity = 8
|
||||
// CHECK-NEXT: // Dst: (C128_TO_I64:{ *:[i64] } ?:{ *:[c128] }:$src)
|
||||
// CHECK-NEXT:/* 27*/ 0, // End of Scope
|
||||
// CHECK-NEXT: }; // Total Array size is 28 bytes
|
||||
|
||||
// CHECK: static const uint8_t OperandLists[] = {
|
||||
// CHECK-NEXT: /* 0 */ 0,
|
||||
// CHECK-NEXT: }
|
||||
|
||||
include "llvm/Target/Target.td"
|
||||
|
||||
def my_cap_ty : LLVMQualPointerType<200> {
|
||||
|
||||
@ -212,7 +212,6 @@ include "Common/RegClassByHwModeCommon.td"
|
||||
// ISEL-SDAG-NEXT: OPC_CheckPredicate1, // Predicate_store
|
||||
// ISEL-SDAG-NEXT: OPC_EmitMergeInputChains1_0,
|
||||
// ISEL-SDAG-NEXT: OPC_MorphNodeTo0, TARGET_VAL(MyTarget::MY_STORE), 0|OPFL_Chain|OPFL_MemRefs,
|
||||
// ISEL-SDAG-NEXT: 2/*#Ops*/, /*OperandList*/1, // Ops = #1 #2
|
||||
|
||||
// ISEL-SDAG: /*SwitchOpcode*/ {{[0-9]+}}, TARGET_VAL(ISD::LOAD),
|
||||
// ISEL-SDAG-NEXT: OPC_RecordMemRef,
|
||||
@ -224,12 +223,6 @@ include "Common/RegClassByHwModeCommon.td"
|
||||
// ISEL-SDAG-NEXT: OPC_CheckTypeI64,
|
||||
// ISEL-SDAG-NEXT: OPC_EmitMergeInputChains1_0,
|
||||
// ISEL-SDAG-NEXT: OPC_MorphNodeToByHwMode, TARGET_VAL(MyTarget::MY_LOAD), 0|OPFL_Chain|OPFL_MemRefs,
|
||||
// ISEL-SDAG-NEXT: 1/*#VTs*/, /*{(*:i64),(m1:i64),(m2:i64)}*/0, 1/*#Ops*/, /*OperandList*/0, // Ops = #1
|
||||
|
||||
// ISEL-SDAG: static const uint8_t OperandLists[] = {
|
||||
// ISEL-SDAG-NEXT: /* 0 */ 1,
|
||||
// ISEL-SDAG-NEXT: /* 1 */ 1, 2,
|
||||
// ISEL-SDAG-NEXT: }
|
||||
|
||||
|
||||
|
||||
|
||||
@ -23,17 +23,17 @@ def GPRAbove127 : RegisterClass<"TestTarget", [i32], 32,
|
||||
|
||||
// CHECK: OPC_CheckOpcode, TARGET_VAL(ISD::ADD),
|
||||
// CHECK-NEXT: OPC_RecordChild0, // #0 = $src
|
||||
// CHECK-NEXT: OPC_Scope /*2 children */, 11, // ->17
|
||||
// CHECK-NEXT: OPC_Scope /*2 children */, 12, // ->18
|
||||
// CHECK-NEXT: OPC_CheckChild1Integer, 0,
|
||||
// CHECK-NEXT: OPC_EmitIntegerI32, 0|128,1/*128*/, // #1 = TestNamespace::GPRAbove127RegClassID
|
||||
// CHECK-NEXT: OPC_MorphNodeTo1None, TARGET_VAL(TargetOpcode::COPY_TO_REGCLASS),
|
||||
// CHECK-NEXT: MVT::i32, 2/*#Ops*/, /*OperandList*/0, // Ops = #1 #0
|
||||
// CHECK-NEXT: MVT::i32, 2/*#Ops*/, 1, 0,
|
||||
def : Pat<(i32 (add i32:$src, (i32 0))),
|
||||
(COPY_TO_REGCLASS GPRAbove127, GPR0:$src)>;
|
||||
|
||||
// CHECK: OPC_CheckChild1Integer, 1,
|
||||
// CHECK-NEXT: OPC_EmitIntegerI32, TestNamespace::GPR127RegClassID,
|
||||
// CHECK-NEXT: OPC_MorphNodeTo1None, TARGET_VAL(TargetOpcode::COPY_TO_REGCLASS),
|
||||
// CHECK-NEXT: MVT::i32, 2/*#Ops*/, /*OperandList*/0, // Ops = #1 #0
|
||||
// CHECK-NEXT: MVT::i32, 2/*#Ops*/, 1, 0,
|
||||
def : Pat<(i32 (add i32:$src, (i32 1))),
|
||||
(COPY_TO_REGCLASS GPR127, GPR0:$src)>;
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "Basic/SDNodeProperties.h"
|
||||
#include "Basic/SequenceToOffsetTable.h"
|
||||
#include "Common/CodeGenDAGPatterns.h"
|
||||
#include "Common/CodeGenInstruction.h"
|
||||
#include "Common/CodeGenRegisters.h"
|
||||
@ -74,8 +73,6 @@ class MatcherTableEmitter {
|
||||
|
||||
std::map<ValueTypeByHwMode, unsigned> ValueTypeMap;
|
||||
|
||||
SequenceToOffsetTable<std::vector<uint8_t>> OperandTable;
|
||||
|
||||
unsigned getPatternIdxFromTable(std::string &&P, std::string &&include_loc) {
|
||||
const auto [It, Inserted] =
|
||||
VecPatterns.try_emplace(std::move(P), VecPatterns.size());
|
||||
@ -88,8 +85,7 @@ class MatcherTableEmitter {
|
||||
|
||||
public:
|
||||
MatcherTableEmitter(const Matcher *TheMatcher, const CodeGenDAGPatterns &cgp)
|
||||
: CGP(cgp), OpcodeCounts(Matcher::HighestKind + 1, 0),
|
||||
OperandTable(std::nullopt) {
|
||||
: CGP(cgp), OpcodeCounts(Matcher::HighestKind + 1, 0) {
|
||||
// Record the usage of ComplexPattern.
|
||||
MapVector<const ComplexPattern *, unsigned> ComplexPatternUsage;
|
||||
// Record the usage of PatternPredicate.
|
||||
@ -115,26 +111,11 @@ public:
|
||||
++PatternPredicateUsage[CPPM->getPredicate()];
|
||||
else if (auto *PM = dyn_cast<CheckPredicateMatcher>(N))
|
||||
++PredicateUsage[PM->getPredicate().getOrigPatFragRecord()];
|
||||
|
||||
if (const auto *EN = dyn_cast<EmitNodeMatcherCommon>(N)) {
|
||||
ArrayRef<unsigned> Ops = EN->getOperandList();
|
||||
std::vector<uint8_t> OpBytes;
|
||||
for (unsigned Op : Ops) {
|
||||
uint8_t Buffer[5];
|
||||
unsigned Len = encodeULEB128(Op, Buffer);
|
||||
for (unsigned i = 0; i < Len; ++i)
|
||||
OpBytes.push_back(Buffer[i]);
|
||||
}
|
||||
OperandTable.add(OpBytes);
|
||||
}
|
||||
|
||||
N = N->getNext();
|
||||
}
|
||||
};
|
||||
Statistic(TheMatcher);
|
||||
|
||||
OperandTable.layout();
|
||||
|
||||
// Sort ComplexPatterns by usage.
|
||||
std::vector<std::pair<const ComplexPattern *, unsigned>> ComplexPatternList(
|
||||
ComplexPatternUsage.begin(), ComplexPatternUsage.end());
|
||||
@ -191,8 +172,6 @@ public:
|
||||
unsigned EmitMatcherList(const Matcher *N, const unsigned Indent,
|
||||
unsigned StartIdx, raw_ostream &OS);
|
||||
|
||||
void EmitOperandLists(raw_ostream &OS);
|
||||
|
||||
unsigned SizeMatcherList(Matcher *N, raw_ostream &OS);
|
||||
|
||||
void EmitPredicateFunctions(raw_ostream &OS);
|
||||
@ -1133,42 +1112,21 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
|
||||
}
|
||||
}
|
||||
|
||||
unsigned NumOps = EN->getNumOperands();
|
||||
OS << ' ' << NumOps;
|
||||
OS << ' ' << EN->getNumOperands();
|
||||
if (!OmitComments)
|
||||
OS << "/*#Ops*/";
|
||||
OS << ',';
|
||||
|
||||
unsigned NumOperandBytes = 0;
|
||||
if (NumOps != 0) {
|
||||
std::vector<uint8_t> OpBytes;
|
||||
for (unsigned i = 0, e = EN->getNumOperands(); i != e; ++i) {
|
||||
uint8_t Buffer[5];
|
||||
unsigned Len = encodeULEB128(EN->getOperand(i), Buffer);
|
||||
for (unsigned i = 0; i < Len; ++i)
|
||||
OpBytes.push_back(Buffer[i]);
|
||||
}
|
||||
unsigned Index = OperandTable.get(OpBytes);
|
||||
for (unsigned i = 0, e = EN->getNumOperands(); i != e; ++i) {
|
||||
OS << ' ';
|
||||
if (!OmitComments)
|
||||
OS << "/*OperandList*/";
|
||||
NumOperandBytes = EmitVBRValue(Index, OS);
|
||||
NumOperandBytes += EmitVBRValue(EN->getOperand(i), OS);
|
||||
}
|
||||
|
||||
if (!OmitComments) {
|
||||
// Print the operand #'s.
|
||||
ArrayRef<unsigned> Ops = EN->getOperandList();
|
||||
OS << " // Ops =";
|
||||
if (Ops.empty())
|
||||
OS << " None";
|
||||
else
|
||||
for (unsigned OpNo : Ops)
|
||||
OS << " #" << OpNo;
|
||||
|
||||
// Print the result #'s for EmitNode.
|
||||
if (const EmitNodeMatcher *E = dyn_cast<EmitNodeMatcher>(EN)) {
|
||||
if (unsigned NumResults = EN->getNumVTs()) {
|
||||
OS << " Results =";
|
||||
OS << " // Results =";
|
||||
unsigned First = E->getFirstResultSlot();
|
||||
for (unsigned i = 0; i != NumResults; ++i)
|
||||
OS << " #" << First + i;
|
||||
@ -1251,10 +1209,6 @@ unsigned MatcherTableEmitter::EmitMatcherList(const Matcher *N,
|
||||
return Size;
|
||||
}
|
||||
|
||||
void MatcherTableEmitter::EmitOperandLists(raw_ostream &OS) {
|
||||
OperandTable.emit(OS, [](raw_ostream &OS, uint8_t O) { OS << (unsigned)O; });
|
||||
}
|
||||
|
||||
void MatcherTableEmitter::EmitNodePredicatesFunction(
|
||||
const std::vector<TreePattern *> &Preds, StringRef Decl, raw_ostream &OS) {
|
||||
if (Preds.empty())
|
||||
@ -1590,14 +1544,9 @@ void llvm::EmitMatcherTable(Matcher *TheMatcher, const CodeGenDAGPatterns &CGP,
|
||||
|
||||
MatcherEmitter.EmitHistogram(OS);
|
||||
|
||||
OS << " static const uint8_t OperandLists[] = {\n";
|
||||
MatcherEmitter.EmitOperandLists(OS);
|
||||
OS << " };\n\n";
|
||||
|
||||
OS << " #undef COVERAGE_IDX_VAL\n";
|
||||
OS << " #undef TARGET_VAL\n";
|
||||
OS << " SelectCodeCommon(N, MatcherTable, sizeof(MatcherTable),\n";
|
||||
OS << " OperandLists);\n";
|
||||
OS << " SelectCodeCommon(N, MatcherTable, sizeof(MatcherTable));\n";
|
||||
OS << "}\n";
|
||||
EndEmitFunction(OS);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user