From ffa4fdcd17779d6262f66633ecfb35050344fce9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 31 Mar 2006 05:25:56 +0000 Subject: [PATCH] Allow bits init values to be used in patterns, turn them into ints. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27286 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelEmitter.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index 06e0d5b7135..5d1689c3fdd 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -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(Arg)) { + // Turn this into an IntInit. + Init *II = BI->convertInitializerTo(new IntRecTy()); + if (II == 0 || !dynamic_cast(II)) + error("Bits value must be constants!"); + + New = new TreePatternNode(dynamic_cast(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(Arg)) { + // Turn this into an IntInit. + Init *II = BI->convertInitializerTo(new IntRecTy()); + if (II == 0 || !dynamic_cast(II)) + error("Bits value must be constants!"); + + TreePatternNode *Node = new TreePatternNode(dynamic_cast(II)); + if (!Dag->getArgName(i).empty()) + error("Constant int argument should not have a name!"); + Children.push_back(Node); } else { std::cerr << '"'; Arg->dump();