Allow bits init values to be used in patterns, turn them into ints.

llvm-svn: 27286
This commit is contained in:
Chris Lattner 2006-03-31 05:25:56 +00:00
parent e330741a6c
commit ef86937943

View File

@ -830,6 +830,15 @@ TreePatternNode *TreePattern::ParseTreePattern(DagInit *Dag) {
New = new TreePatternNode(II);
if (!Dag->getArgName(0).empty())
error("Constant int argument should not have a name!");
} else if (BitsInit *BI = dynamic_cast<BitsInit*>(Arg)) {
// Turn this into an IntInit.
Init *II = BI->convertInitializerTo(new IntRecTy());
if (II == 0 || !dynamic_cast<IntInit*>(II))
error("Bits value must be constants!");
New = new TreePatternNode(dynamic_cast<IntInit*>(II));
if (!Dag->getArgName(0).empty())
error("Constant int argument should not have a name!");
} else {
Arg->dump();
error("Unknown leaf value for tree pattern!");
@ -888,6 +897,16 @@ TreePatternNode *TreePattern::ParseTreePattern(DagInit *Dag) {
if (!Dag->getArgName(i).empty())
error("Constant int argument should not have a name!");
Children.push_back(Node);
} else if (BitsInit *BI = dynamic_cast<BitsInit*>(Arg)) {
// Turn this into an IntInit.
Init *II = BI->convertInitializerTo(new IntRecTy());
if (II == 0 || !dynamic_cast<IntInit*>(II))
error("Bits value must be constants!");
TreePatternNode *Node = new TreePatternNode(dynamic_cast<IntInit*>(II));
if (!Dag->getArgName(i).empty())
error("Constant int argument should not have a name!");
Children.push_back(Node);
} else {
std::cerr << '"';
Arg->dump();