mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
hoist some funky logic into CodeGenInstruction
from two places in CodeGenDAGPatterns.cpp, and use it in DAGISelMatcherGen.cpp instead of using an incorrect predicate that happened to get lucky on our current targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99726 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0be6fe7139
commit
9414ae5291
@ -779,15 +779,9 @@ static unsigned GetNumNodeResults(Record *Operator, CodeGenDAGPatterns &CDP) {
|
|||||||
// FIXME: Should allow access to all the results here.
|
// FIXME: Should allow access to all the results here.
|
||||||
unsigned NumDefsToAdd = InstInfo.NumDefs ? 1 : 0;
|
unsigned NumDefsToAdd = InstInfo.NumDefs ? 1 : 0;
|
||||||
|
|
||||||
if (!InstInfo.ImplicitDefs.empty()) {
|
// Add on one implicit def if it has a resolvable type.
|
||||||
// Add on one implicit def if it has a resolvable type.
|
if (InstInfo.HasOneImplicitDefWithKnownVT(CDP.getTargetInfo()) !=MVT::Other)
|
||||||
Record *FirstImplicitDef = InstInfo.ImplicitDefs[0];
|
++NumDefsToAdd;
|
||||||
assert(FirstImplicitDef->isSubClassOf("Register"));
|
|
||||||
const std::vector<MVT::SimpleValueType> &RegVTs =
|
|
||||||
CDP.getTargetInfo().getRegisterVTs(FirstImplicitDef);
|
|
||||||
if (RegVTs.size() == 1)
|
|
||||||
return NumDefsToAdd+1;
|
|
||||||
}
|
|
||||||
return NumDefsToAdd;
|
return NumDefsToAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1279,12 +1273,13 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
|
|||||||
if (!InstInfo.ImplicitDefs.empty()) {
|
if (!InstInfo.ImplicitDefs.empty()) {
|
||||||
unsigned ResNo = NumResultsToAdd;
|
unsigned ResNo = NumResultsToAdd;
|
||||||
|
|
||||||
Record *FirstImplicitDef = InstInfo.ImplicitDefs[0];
|
// FIXME: Generalize to multiple possible types and multiple possible
|
||||||
assert(FirstImplicitDef->isSubClassOf("Register"));
|
// ImplicitDefs.
|
||||||
const std::vector<MVT::SimpleValueType> &RegVTs =
|
MVT::SimpleValueType VT =
|
||||||
CDP.getTargetInfo().getRegisterVTs(FirstImplicitDef);
|
InstInfo.HasOneImplicitDefWithKnownVT(CDP.getTargetInfo());
|
||||||
if (RegVTs.size() == 1) // FIXME: Generalize.
|
|
||||||
MadeChange |= UpdateNodeType(ResNo, EEVT::TypeSet(RegVTs), TP);
|
if (VT != MVT::Other)
|
||||||
|
MadeChange |= UpdateNodeType(ResNo, VT, TP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is an INSERT_SUBREG, constrain the source and destination VTs to
|
// If this is an INSERT_SUBREG, constrain the source and destination VTs to
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "CodeGenInstruction.h"
|
#include "CodeGenInstruction.h"
|
||||||
|
#include "CodeGenTarget.h"
|
||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
@ -294,3 +295,22 @@ CodeGenInstruction::ParseOperandName(const std::string &Op,
|
|||||||
// Otherwise, didn't find it!
|
// Otherwise, didn't find it!
|
||||||
throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'";
|
throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// HasOneImplicitDefWithKnownVT - If the instruction has at least one
|
||||||
|
/// implicit def and it has a known VT, return the VT, otherwise return
|
||||||
|
/// MVT::Other.
|
||||||
|
MVT::SimpleValueType CodeGenInstruction::
|
||||||
|
HasOneImplicitDefWithKnownVT(const CodeGenTarget &TargetInfo) const {
|
||||||
|
if (ImplicitDefs.empty()) return MVT::Other;
|
||||||
|
|
||||||
|
// Check to see if the first implicit def has a resolvable type.
|
||||||
|
Record *FirstImplicitDef = ImplicitDefs[0];
|
||||||
|
assert(FirstImplicitDef->isSubClassOf("Register"));
|
||||||
|
const std::vector<MVT::SimpleValueType> &RegVTs =
|
||||||
|
TargetInfo.getRegisterVTs(FirstImplicitDef);
|
||||||
|
if (RegVTs.size() == 1)
|
||||||
|
return RegVTs[0];
|
||||||
|
return MVT::Other;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
class Record;
|
class Record;
|
||||||
class DagInit;
|
class DagInit;
|
||||||
|
class CodeGenTarget;
|
||||||
|
|
||||||
class CodeGenInstruction {
|
class CodeGenInstruction {
|
||||||
public:
|
public:
|
||||||
@ -183,6 +184,12 @@ namespace llvm {
|
|||||||
/// non-empty name. If the instruction does not have an operand with the
|
/// non-empty name. If the instruction does not have an operand with the
|
||||||
/// specified name, throw an exception.
|
/// specified name, throw an exception.
|
||||||
unsigned getOperandNamed(const std::string &Name) const;
|
unsigned getOperandNamed(const std::string &Name) const;
|
||||||
|
|
||||||
|
/// HasOneImplicitDefWithKnownVT - If the instruction has at least one
|
||||||
|
/// implicit def and it has a known VT, return the VT, otherwise return
|
||||||
|
/// MVT::Other.
|
||||||
|
MVT::SimpleValueType
|
||||||
|
HasOneImplicitDefWithKnownVT(const CodeGenTarget &TargetInfo) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,8 +733,7 @@ EmitResultInstructionAsOperand(const TreePatternNode *N,
|
|||||||
// If the root came from an implicit def in the instruction handling stuff,
|
// If the root came from an implicit def in the instruction handling stuff,
|
||||||
// don't re-add it.
|
// don't re-add it.
|
||||||
Record *HandledReg = 0;
|
Record *HandledReg = 0;
|
||||||
if (N->getNumTypes() != 0 &&
|
if (II.HasOneImplicitDefWithKnownVT(CGT) != MVT::Other)
|
||||||
!II.ImplicitDefs.empty())
|
|
||||||
HandledReg = II.ImplicitDefs[0];
|
HandledReg = II.ImplicitDefs[0];
|
||||||
|
|
||||||
for (unsigned i = 0; i != Pattern.getDstRegs().size(); ++i) {
|
for (unsigned i = 0; i != Pattern.getDstRegs().size(); ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user