mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
when parsing instructions remember information about the types taken and
returned. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23367 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4ac85b3e94
commit
ae6d828de8
@ -805,6 +805,7 @@ void DAGISelEmitter::ParseInstructions() {
|
|||||||
CodeGenInstruction &CGI = Target.getInstruction(Instrs[i]->getName());
|
CodeGenInstruction &CGI = Target.getInstruction(Instrs[i]->getName());
|
||||||
|
|
||||||
// Check that all of the results occur first in the list.
|
// Check that all of the results occur first in the list.
|
||||||
|
std::vector<MVT::ValueType> ResultTypes;
|
||||||
for (unsigned i = 0; i != NumResults; ++i) {
|
for (unsigned i = 0; i != NumResults; ++i) {
|
||||||
if (i == CGI.OperandList.size())
|
if (i == CGI.OperandList.size())
|
||||||
I->error("'" + InstResults.begin()->first +
|
I->error("'" + InstResults.begin()->first +
|
||||||
@ -820,6 +821,9 @@ void DAGISelEmitter::ParseInstructions() {
|
|||||||
if (CGI.OperandList[i].Rec != R)
|
if (CGI.OperandList[i].Rec != R)
|
||||||
I->error("Operand $" + OpName + " class mismatch!");
|
I->error("Operand $" + OpName + " class mismatch!");
|
||||||
|
|
||||||
|
// Remember the return type.
|
||||||
|
ResultTypes.push_back(CGI.OperandList[i].Ty);
|
||||||
|
|
||||||
// Okay, this one checks out.
|
// Okay, this one checks out.
|
||||||
InstResults.erase(OpName);
|
InstResults.erase(OpName);
|
||||||
}
|
}
|
||||||
@ -829,6 +833,7 @@ void DAGISelEmitter::ParseInstructions() {
|
|||||||
std::map<std::string, TreePatternNode*> InstInputsCheck(InstInputs);
|
std::map<std::string, TreePatternNode*> InstInputsCheck(InstInputs);
|
||||||
|
|
||||||
std::vector<TreePatternNode*> ResultNodeOperands;
|
std::vector<TreePatternNode*> ResultNodeOperands;
|
||||||
|
std::vector<MVT::ValueType> OperandTypes;
|
||||||
for (unsigned i = NumResults, e = CGI.OperandList.size(); i != e; ++i) {
|
for (unsigned i = NumResults, e = CGI.OperandList.size(); i != e; ++i) {
|
||||||
const std::string &OpName = CGI.OperandList[i].Name;
|
const std::string &OpName = CGI.OperandList[i].Name;
|
||||||
if (OpName.empty())
|
if (OpName.empty())
|
||||||
@ -842,6 +847,7 @@ void DAGISelEmitter::ParseInstructions() {
|
|||||||
if (CGI.OperandList[i].Ty != InVal->getType())
|
if (CGI.OperandList[i].Ty != InVal->getType())
|
||||||
I->error("Operand $" + OpName +
|
I->error("Operand $" + OpName +
|
||||||
"'s type disagrees between the operand and pattern");
|
"'s type disagrees between the operand and pattern");
|
||||||
|
OperandTypes.push_back(InVal->getType());
|
||||||
|
|
||||||
// Construct the result for the dest-pattern operand list.
|
// Construct the result for the dest-pattern operand list.
|
||||||
TreePatternNode *OpNode = InVal->clone();
|
TreePatternNode *OpNode = InVal->clone();
|
||||||
@ -867,10 +873,8 @@ void DAGISelEmitter::ParseInstructions() {
|
|||||||
TreePatternNode *ResultPattern =
|
TreePatternNode *ResultPattern =
|
||||||
new TreePatternNode(I->getRecord(), ResultNodeOperands);
|
new TreePatternNode(I->getRecord(), ResultNodeOperands);
|
||||||
|
|
||||||
unsigned NumOperands = CGI.OperandList.size()-NumResults;
|
|
||||||
|
|
||||||
DEBUG(I->dump());
|
DEBUG(I->dump());
|
||||||
Instructions.push_back(DAGInstruction(I, NumResults, NumOperands,
|
Instructions.push_back(DAGInstruction(I, ResultTypes, OperandTypes,
|
||||||
ResultPattern));
|
ResultPattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,16 +279,30 @@ namespace llvm {
|
|||||||
TreePattern *Pattern;
|
TreePattern *Pattern;
|
||||||
unsigned NumResults;
|
unsigned NumResults;
|
||||||
unsigned NumOperands;
|
unsigned NumOperands;
|
||||||
|
std::vector<MVT::ValueType> ResultTypes;
|
||||||
|
std::vector<MVT::ValueType> OperandTypes;
|
||||||
TreePatternNode *ResultPattern;
|
TreePatternNode *ResultPattern;
|
||||||
public:
|
public:
|
||||||
DAGInstruction(TreePattern *TP, unsigned results, unsigned ops,
|
DAGInstruction(TreePattern *TP,
|
||||||
|
const std::vector<MVT::ValueType> &resultTypes,
|
||||||
|
const std::vector<MVT::ValueType> &operandTypes,
|
||||||
TreePatternNode *resultPattern)
|
TreePatternNode *resultPattern)
|
||||||
: Pattern(TP), NumResults(results), NumOperands(ops),
|
: Pattern(TP), ResultTypes(resultTypes), OperandTypes(operandTypes),
|
||||||
ResultPattern(resultPattern) {}
|
ResultPattern(resultPattern) {}
|
||||||
|
|
||||||
TreePattern *getPattern() const { return Pattern; }
|
TreePattern *getPattern() const { return Pattern; }
|
||||||
unsigned getNumResults() const { return NumResults; }
|
unsigned getNumResults() const { return ResultTypes.size(); }
|
||||||
unsigned getNumOperands() const { return NumOperands; }
|
unsigned getNumOperands() const { return OperandTypes.size(); }
|
||||||
|
|
||||||
|
MVT::ValueType getResultType(unsigned RN) const {
|
||||||
|
assert(RN < ResultTypes.size());
|
||||||
|
return ResultTypes[RN];
|
||||||
|
}
|
||||||
|
|
||||||
|
MVT::ValueType getOperandType(unsigned ON) const {
|
||||||
|
assert(ON < OperandTypes.size());
|
||||||
|
return OperandTypes[ON];
|
||||||
|
}
|
||||||
TreePatternNode *getResultPattern() const { return ResultPattern; }
|
TreePatternNode *getResultPattern() const { return ResultPattern; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user