TableGen/DAGPatterns: Allow bit constants in addition to int constants

Summary:
Implicit casting is a simple quality of life improvement.

Change-Id: I3d2b31b8b8f12cbb1e84f691e359fa713a9c4b42

Reviewers: tra, simon_tatham, craig.topper, MartinO, arsenm

Subscribers: wdng, llvm-commits

Differential Revision: https://reviews.llvm.org/D47432

llvm-svn: 333904
This commit is contained in:
Nicolai Haehnle 2018-06-04 14:45:12 +00:00
parent 8cd2ee1f24
commit ab390f0c41
1 changed files with 5 additions and 3 deletions

View File

@ -2566,10 +2566,12 @@ TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit,
return Res;
}
if (IntInit *II = dyn_cast<IntInit>(TheInit)) {
if (isa<IntInit>(TheInit) || isa<BitInit>(TheInit)) {
if (!OpName.empty())
error("Constant int argument should not have a name!");
return std::make_shared<TreePatternNode>(II, 1);
error("Constant int or bit argument should not have a name!");
if (isa<BitInit>(TheInit))
TheInit = TheInit->convertInitializerTo(IntRecTy::get());
return std::make_shared<TreePatternNode>(TheInit, 1);
}
if (BitsInit *BI = dyn_cast<BitsInit>(TheInit)) {