[llvm-commits] [llvm] r118324 - in /llvm/trunk/utils/TableGen: AsmMatcherEmitter.cpp CodeGenInstruction.cpp CodeGenInstruction.h
Chris Lattner
sabre at nondot.org
Fri Nov 5 23:39:48 PDT 2010
Author: lattner
Date: Sat Nov 6 01:39:47 2010
New Revision: 118324
URL: http://llvm.org/viewvc/llvm-project?rev=118324&view=rev
Log:
disolve a hack, having CodeGenInstAlias decode the alias in the .td
file instead of the asmmatcher.
Modified:
llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
llvm/trunk/utils/TableGen/CodeGenInstruction.h
Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=118324&r1=118323&r2=118324&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Sat Nov 6 01:39:47 2010
@@ -355,12 +355,8 @@
MatchableInfo(const CodeGenInstAlias *Alias)
: TheDef(Alias->TheDef), DefRec(Alias), TheOperandList(Alias->Operands),
AsmString(Alias->AsmString) {
-
- // FIXME: Huge hack.
- DefInit *DI = dynamic_cast<DefInit*>(Alias->Result->getOperator());
- assert(DI);
-
- InstrName = DI->getDef()->getName();
+ // FIXME: InstrName should be a CGI.
+ InstrName = Alias->ResultInst->TheDef->getName();
}
void Initialize(const AsmMatcherInfo &Info,
@@ -1066,7 +1062,7 @@
std::vector<Record*> AllInstAliases =
Records.getAllDerivedDefinitions("InstAlias");
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));
@@ -1117,11 +1113,9 @@
OperandName = Token.substr(1);
if (II->DefRec.is<const CodeGenInstruction*>())
- BuildInstructionOperandReference(II,
- OperandName, Op);
+ BuildInstructionOperandReference(II, OperandName, Op);
else
- BuildAliasOperandReference(II,
- OperandName, Op);
+ BuildAliasOperandReference(II, OperandName, Op);
}
II->BuildResultOperands();
Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=118324&r1=118323&r2=118324&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Sat Nov 6 01:39:47 2010
@@ -388,8 +388,16 @@
/// CodeGenInstAlias Implementation
//===----------------------------------------------------------------------===//
-CodeGenInstAlias::CodeGenInstAlias(Record *R) : TheDef(R), Operands(R) {
+CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T)
+ : TheDef(R), Operands(R) {
AsmString = R->getValueAsString("AsmString");
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());
}
Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.h?rev=118324&r1=118323&r2=118324&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.h Sat Nov 6 01:39:47 2010
@@ -15,6 +15,7 @@
#define CODEGEN_INSTRUCTION_H
#include "llvm/CodeGen/ValueTypes.h"
+#include "llvm/ADT/StringRef.h"
#include <string>
#include <vector>
#include <utility>
@@ -264,7 +265,22 @@
/// Result - The result instruction.
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);
};
}
More information about the llvm-commits
mailing list