mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-23 03:59:12 +00:00
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. llvm-svn: 67286
This commit is contained in:
parent
3402d4260c
commit
0eed59a7df
@ -337,7 +337,7 @@ def SEXTW : OForm2<0x1C, 0x01, "sextw $RB,$RC",
|
||||
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))>;
|
||||
|
||||
|
||||
|
@ -1132,7 +1132,7 @@ TreePatternNode *TreePattern::ParseTreePattern(DagInit *Dag) {
|
||||
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 @@ TreePatternNode *TreePattern::ParseTreePattern(DagInit *Dag) {
|
||||
|
||||
// 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 @@ TreePatternNode *TreePattern::ParseTreePattern(DagInit *Dag) {
|
||||
// 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 @@ TreePatternNode *TreePattern::ParseTreePattern(DagInit *Dag) {
|
||||
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 @@ void CodeGenDAGPatterns::ParseDefaultOperands() {
|
||||
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 @@ static bool HandleUse(TreePattern *I, TreePatternNode *Pat,
|
||||
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 @@ static bool HandleUse(TreePattern *I, TreePatternNode *Pat,
|
||||
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 @@ FindPatternInputsAndOutputs(TreePattern *I, TreePatternNode *Pat,
|
||||
|
||||
// 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!");
|
||||
|
@ -426,7 +426,7 @@ Init *BinOpInit::Fold() {
|
||||
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 *DagInit::resolveReferences(Record &R, const RecordVal *RV) {
|
||||
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 @@ Init *DagInit::resolveReferences(Record &R, const RecordVal *RV) {
|
||||
|
||||
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];
|
||||
|
@ -857,11 +857,13 @@ public:
|
||||
///
|
||||
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 @@ public:
|
||||
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 @@ public:
|
||||
|
||||
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!");
|
||||
|
@ -636,6 +636,18 @@ Init *TGParser::ParseSimpleValue(Record *CurRec) {
|
||||
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 @@ Init *TGParser::ParseSimpleValue(Record *CurRec) {
|
||||
}
|
||||
Lex.Lex(); // eat the ')'
|
||||
|
||||
return new DagInit(Operator, DagArgs);
|
||||
return new DagInit(Operator, OperatorName, DagArgs);
|
||||
}
|
||||
case tgtok::XConcat:
|
||||
case tgtok::XSRA:
|
||||
|
Loading…
Reference in New Issue
Block a user