[llvm-commits] [llvm] r67330 - in /llvm/branches/Apple/Dib: lib/Target/Alpha/AlphaInstrInfo.td utils/TableGen/CodeGenDAGPatterns.cpp utils/TableGen/Record.cpp utils/TableGen/Record.h utils/TableGen/TGParser.cpp
Bill Wendling
isanbard at gmail.com
Thu Mar 19 12:59:04 PDT 2009
Author: void
Date: Thu Mar 19 14:59:04 2009
New Revision: 67330
URL: http://llvm.org/viewvc/llvm-project?rev=67330&view=rev
Log:
--- Merging (from foreign repository) r67286 into '.':
U utils/TableGen/Record.h
U utils/TableGen/TGParser.cpp
U utils/TableGen/CodeGenDAGPatterns.cpp
U utils/TableGen/Record.cpp
U lib/Target/Alpha/AlphaInstrInfo.td
Add support to tablegen for naming the nodes themselves, not just the operands,
in selectiondag patterns. This is required for the upcoming shuffle_vector rewrite,
and as it turns out, cleans up a hack in the Alpha instruction info.
Modified:
llvm/branches/Apple/Dib/lib/Target/Alpha/AlphaInstrInfo.td
llvm/branches/Apple/Dib/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/branches/Apple/Dib/utils/TableGen/Record.cpp
llvm/branches/Apple/Dib/utils/TableGen/Record.h
llvm/branches/Apple/Dib/utils/TableGen/TGParser.cpp
Modified: llvm/branches/Apple/Dib/lib/Target/Alpha/AlphaInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Target/Alpha/AlphaInstrInfo.td?rev=67330&r1=67329&r2=67330&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/lib/Target/Alpha/AlphaInstrInfo.td (original)
+++ llvm/branches/Apple/Dib/lib/Target/Alpha/AlphaInstrInfo.td Thu Mar 19 14:59:04 2009
@@ -337,7 +337,7 @@
def ZAPNOTi : OFormL<0x12, 0x31, "zapnot $RA,$L,$RC", [], s_ishf>;
// Define the pattern that produces ZAPNOTi.
-def : Pat<(i64 (zappat GPRC:$RA):$imm),
+def : Pat<(zappat:$imm GPRC:$RA),
(ZAPNOTi GPRC:$RA, (iZAPX GPRC:$imm))>;
Modified: llvm/branches/Apple/Dib/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/utils/TableGen/CodeGenDAGPatterns.cpp?rev=67330&r1=67329&r2=67330&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/branches/Apple/Dib/utils/TableGen/CodeGenDAGPatterns.cpp Thu Mar 19 14:59:04 2009
@@ -1132,7 +1132,7 @@
if (DefInit *DI = dynamic_cast<DefInit*>(Arg)) {
Record *R = DI->getDef();
if (R->isSubClassOf("SDNode") || R->isSubClassOf("PatFrag")) {
- Dag->setArg(0, new DagInit(DI,
+ Dag->setArg(0, new DagInit(DI, "",
std::vector<std::pair<Init*, std::string> >()));
return ParseTreePattern(Dag);
}
@@ -1160,12 +1160,14 @@
// Apply the type cast.
New->UpdateNodeType(getValueType(Operator), *this);
- New->setName(Dag->getArgName(0));
+ if (New->getNumChildren() == 0)
+ New->setName(Dag->getArgName(0));
return New;
}
// Verify that this is something that makes sense for an operator.
- if (!Operator->isSubClassOf("PatFrag") && !Operator->isSubClassOf("SDNode") &&
+ if (!Operator->isSubClassOf("PatFrag") &&
+ !Operator->isSubClassOf("SDNode") &&
!Operator->isSubClassOf("Instruction") &&
!Operator->isSubClassOf("SDNodeXForm") &&
!Operator->isSubClassOf("Intrinsic") &&
@@ -1192,7 +1194,7 @@
// Direct reference to a leaf DagNode or PatFrag? Turn it into a
// TreePatternNode if its own.
if (R->isSubClassOf("SDNode") || R->isSubClassOf("PatFrag")) {
- Dag->setArg(i, new DagInit(DefI,
+ Dag->setArg(i, new DagInit(DefI, "",
std::vector<std::pair<Init*, std::string> >()));
--i; // Revisit this node...
} else {
@@ -1253,7 +1255,9 @@
Children.insert(Children.begin(), IIDNode);
}
- return new TreePatternNode(Operator, Children);
+ TreePatternNode *Result = new TreePatternNode(Operator, Children);
+ Result->setName(Dag->getName());
+ return Result;
}
/// InferAllTypes - Infer/propagate as many types throughout the expression
@@ -1482,7 +1486,7 @@
for (unsigned op = 0, e = DefaultInfo->getNumArgs(); op != e; ++op)
Ops.push_back(std::make_pair(DefaultInfo->getArg(op),
DefaultInfo->getArgName(op)));
- DagInit *DI = new DagInit(SomeSDNode, Ops);
+ DagInit *DI = new DagInit(SomeSDNode, "", Ops);
// Create a TreePattern to parse this.
TreePattern P(DefaultOps[iter][i], DI, false, *this);
@@ -1527,7 +1531,6 @@
I->error("Input " + DI->getDef()->getName() + " must be named!");
else if (DI && DI->getDef()->isSubClassOf("Register"))
InstImpInputs.push_back(DI->getDef());
- ;
}
return false;
}
@@ -1538,7 +1541,6 @@
if (!DI) I->error("Input $" + Pat->getName() + " must be an identifier!");
Rec = DI->getDef();
} else {
- assert(Pat->getNumChildren() == 0 && "can't be a use with children!");
Rec = Pat->getOperator();
}
@@ -1605,9 +1607,7 @@
// If this is a non-leaf node with no children, treat it basically as if
// it were a leaf. This handles nodes like (imm).
- bool isUse = false;
- if (Pat->getNumChildren() == 0)
- isUse = HandleUse(I, Pat, InstInputs, InstImpInputs);
+ bool isUse = HandleUse(I, Pat, InstInputs, InstImpInputs);
if (!isUse && Pat->getTransformFn())
I->error("Cannot specify a transform function for a non-input value!");
Modified: llvm/branches/Apple/Dib/utils/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/utils/TableGen/Record.cpp?rev=67330&r1=67329&r2=67330&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/utils/TableGen/Record.cpp (original)
+++ llvm/branches/Apple/Dib/utils/TableGen/Record.cpp Thu Mar 19 14:59:04 2009
@@ -426,7 +426,7 @@
Args.push_back(RHSs->getArg(i));
ArgNames.push_back(RHSs->getArgName(i));
}
- return new DagInit(LHSs->getOperator(), Args, ArgNames);
+ return new DagInit(LHSs->getOperator(), "", Args, ArgNames);
}
break;
}
@@ -679,7 +679,7 @@
Init *Op = Val->resolveReferences(R, RV);
if (Args != NewArgs || Op != Val)
- return new DagInit(Op, NewArgs, ArgNames);
+ return new DagInit(Op, "", NewArgs, ArgNames);
return this;
}
@@ -687,6 +687,8 @@
std::string DagInit::getAsString() const {
std::string Result = "(" + Val->getAsString();
+ if (!ValName.empty())
+ Result += ":" + ValName;
if (Args.size()) {
Result += " " + Args[0]->getAsString();
if (!ArgNames[0].empty()) Result += ":$" + ArgNames[0];
Modified: llvm/branches/Apple/Dib/utils/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/utils/TableGen/Record.h?rev=67330&r1=67329&r2=67330&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/utils/TableGen/Record.h (original)
+++ llvm/branches/Apple/Dib/utils/TableGen/Record.h Thu Mar 19 14:59:04 2009
@@ -857,11 +857,13 @@
///
class DagInit : public Init {
Init *Val;
+ std::string ValName;
std::vector<Init*> Args;
std::vector<std::string> ArgNames;
public:
- DagInit(Init *V, const std::vector<std::pair<Init*, std::string> > &args)
- : Val(V) {
+ DagInit(Init *V, std::string VN,
+ const std::vector<std::pair<Init*, std::string> > &args)
+ : Val(V), ValName(VN) {
Args.reserve(args.size());
ArgNames.reserve(args.size());
for (unsigned i = 0, e = args.size(); i != e; ++i) {
@@ -869,9 +871,9 @@
ArgNames.push_back(args[i].second);
}
}
- DagInit(Init *V, const std::vector<Init*> &args,
+ DagInit(Init *V, std::string VN, const std::vector<Init*> &args,
const std::vector<std::string> &argNames)
- : Val(V), Args(args), ArgNames(argNames) {
+ : Val(V), ValName(VN), Args(args), ArgNames(argNames) {
}
virtual Init *convertInitializerTo(RecTy *Ty) {
@@ -880,6 +882,8 @@
Init *getOperator() const { return Val; }
+ const std::string &getName() const { return ValName; }
+
unsigned getNumArgs() const { return Args.size(); }
Init *getArg(unsigned Num) const {
assert(Num < Args.size() && "Arg number out of range!");
Modified: llvm/branches/Apple/Dib/utils/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/utils/TableGen/TGParser.cpp?rev=67330&r1=67329&r2=67330&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/utils/TableGen/TGParser.cpp (original)
+++ llvm/branches/Apple/Dib/utils/TableGen/TGParser.cpp Thu Mar 19 14:59:04 2009
@@ -636,6 +636,18 @@
Init *Operator = ParseIDValue(CurRec);
if (Operator == 0) return 0;
+ // If the operator name is present, parse it.
+ std::string OperatorName;
+ if (Lex.getCode() == tgtok::colon) {
+ if (Lex.Lex() != tgtok::VarName) { // eat the ':'
+ TokError("expected variable name in dag operator");
+ return 0;
+ }
+ OperatorName = Lex.getCurStrVal();
+ Lex.Lex(); // eat the VarName.
+ }
+
+
std::vector<std::pair<llvm::Init*, std::string> > DagArgs;
if (Lex.getCode() != tgtok::r_paren) {
DagArgs = ParseDagArgList(CurRec);
@@ -648,7 +660,7 @@
}
Lex.Lex(); // eat the ')'
- return new DagInit(Operator, DagArgs);
+ return new DagInit(Operator, OperatorName, DagArgs);
}
case tgtok::XConcat:
case tgtok::XSRA:
More information about the llvm-commits
mailing list