mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-05 14:34:55 +00:00
disolve a hack, having CodeGenInstAlias decode the alias in the .td
file instead of the asmmatcher. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118324 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2a301704ea
commit
225549f775
@ -355,12 +355,8 @@ struct MatchableInfo {
|
|||||||
MatchableInfo(const CodeGenInstAlias *Alias)
|
MatchableInfo(const CodeGenInstAlias *Alias)
|
||||||
: TheDef(Alias->TheDef), DefRec(Alias), TheOperandList(Alias->Operands),
|
: TheDef(Alias->TheDef), DefRec(Alias), TheOperandList(Alias->Operands),
|
||||||
AsmString(Alias->AsmString) {
|
AsmString(Alias->AsmString) {
|
||||||
|
// FIXME: InstrName should be a CGI.
|
||||||
// FIXME: Huge hack.
|
InstrName = Alias->ResultInst->TheDef->getName();
|
||||||
DefInit *DI = dynamic_cast<DefInit*>(Alias->Result->getOperator());
|
|
||||||
assert(DI);
|
|
||||||
|
|
||||||
InstrName = DI->getDef()->getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(const AsmMatcherInfo &Info,
|
void Initialize(const AsmMatcherInfo &Info,
|
||||||
@ -1066,7 +1062,7 @@ void AsmMatcherInfo::BuildInfo() {
|
|||||||
std::vector<Record*> AllInstAliases =
|
std::vector<Record*> AllInstAliases =
|
||||||
Records.getAllDerivedDefinitions("InstAlias");
|
Records.getAllDerivedDefinitions("InstAlias");
|
||||||
for (unsigned i = 0, e = AllInstAliases.size(); i != e; ++i) {
|
for (unsigned i = 0, e = AllInstAliases.size(); i != e; ++i) {
|
||||||
CodeGenInstAlias *Alias = new CodeGenInstAlias(AllInstAliases[i]);
|
CodeGenInstAlias *Alias = new CodeGenInstAlias(AllInstAliases[i], Target);
|
||||||
|
|
||||||
OwningPtr<MatchableInfo> II(new MatchableInfo(Alias));
|
OwningPtr<MatchableInfo> II(new MatchableInfo(Alias));
|
||||||
|
|
||||||
@ -1117,11 +1113,9 @@ void AsmMatcherInfo::BuildInfo() {
|
|||||||
OperandName = Token.substr(1);
|
OperandName = Token.substr(1);
|
||||||
|
|
||||||
if (II->DefRec.is<const CodeGenInstruction*>())
|
if (II->DefRec.is<const CodeGenInstruction*>())
|
||||||
BuildInstructionOperandReference(II,
|
BuildInstructionOperandReference(II, OperandName, Op);
|
||||||
OperandName, Op);
|
|
||||||
else
|
else
|
||||||
BuildAliasOperandReference(II,
|
BuildAliasOperandReference(II, OperandName, Op);
|
||||||
OperandName, Op);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
II->BuildResultOperands();
|
II->BuildResultOperands();
|
||||||
|
@ -388,8 +388,16 @@ FlattenAsmStringVariants(StringRef Cur, unsigned Variant) {
|
|||||||
/// CodeGenInstAlias Implementation
|
/// CodeGenInstAlias Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
CodeGenInstAlias::CodeGenInstAlias(Record *R) : TheDef(R), Operands(R) {
|
CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T)
|
||||||
|
: TheDef(R), Operands(R) {
|
||||||
AsmString = R->getValueAsString("AsmString");
|
AsmString = R->getValueAsString("AsmString");
|
||||||
|
|
||||||
Result = R->getValueAsDag("ResultInst");
|
Result = R->getValueAsDag("ResultInst");
|
||||||
|
|
||||||
|
// Verify that the root of the result is an instruction.
|
||||||
|
DefInit *DI = dynamic_cast<DefInit*>(Result->getOperator());
|
||||||
|
if (DI == 0 || !DI->getDef()->isSubClassOf("Instruction"))
|
||||||
|
throw TGError(R->getLoc(), "result of inst alias should be an instruction");
|
||||||
|
|
||||||
|
ResultInst = &T.getInstruction(DI->getDef());
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#define CODEGEN_INSTRUCTION_H
|
#define CODEGEN_INSTRUCTION_H
|
||||||
|
|
||||||
#include "llvm/CodeGen/ValueTypes.h"
|
#include "llvm/CodeGen/ValueTypes.h"
|
||||||
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -264,7 +265,22 @@ namespace llvm {
|
|||||||
/// Result - The result instruction.
|
/// Result - The result instruction.
|
||||||
DagInit *Result;
|
DagInit *Result;
|
||||||
|
|
||||||
CodeGenInstAlias(Record *R);
|
/// ResultInst - The instruction generated by the alias (decoded from
|
||||||
|
/// Result).
|
||||||
|
CodeGenInstruction *ResultInst;
|
||||||
|
|
||||||
|
|
||||||
|
struct ResultOperand {
|
||||||
|
StringRef Name;
|
||||||
|
Record *R;
|
||||||
|
|
||||||
|
ResultOperand(StringRef N, Record *r) : Name(N), R(r) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// ResultOperands - The decoded operands for the result instruction.
|
||||||
|
std::vector<ResultOperand> ResultOperands;
|
||||||
|
|
||||||
|
CodeGenInstAlias(Record *R, CodeGenTarget &T);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user