From ab390f0c419dcf05a158f19eba7fac4282042e4e Mon Sep 17 00:00:00 2001 From: Nicolai Haehnle Date: Mon, 4 Jun 2018 14:45:12 +0000 Subject: 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 --- llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'llvm/utils/TableGen/CodeGenDAGPatterns.cpp') diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 730d336ce94..3394afca6e2 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -2566,10 +2566,12 @@ TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit, return Res; } - if (IntInit *II = dyn_cast(TheInit)) { + if (isa(TheInit) || isa(TheInit)) { if (!OpName.empty()) - error("Constant int argument should not have a name!"); - return std::make_shared(II, 1); + error("Constant int or bit argument should not have a name!"); + if (isa(TheInit)) + TheInit = TheInit->convertInitializerTo(IntRecTy::get()); + return std::make_shared(TheInit, 1); } if (BitsInit *BI = dyn_cast(TheInit)) { -- cgit v1.2.3